Challenge

Week 6 - Data analysis

Aim: To do Data analysis using Python Programming.

Introduction:Data analysis is a process of inspecting, cleansing,transforming and modelling data with the goal of discovering useful information, informing conclusions and supporting decision-making. Data analysis has multiple facets and approaches, encompassing diverse techniques under a variety of names, and is used in different business, science, and social science domains. In today's business world, data analysis plays a role in making decisions more scientific and helping businesses operate more effectively.

Analysis refers to breaking a whole into its separate components for individual examination. Data analysis is a process for obtaining raw data and converting it into information useful for decision-making by users. Data is collected and analyzed to answer questions, test hypotheses or disprove theories.

Problem Statement:1.Calculate the area under the P-V diagram.

2.Calculate the power output of this engine. Assume that RPM is 1500.

3.Calculate its specific fuel consumption.

Python Program:

"""
     Demonstrating File Parsing in Python
"""
import math
import matplotlib.pyplot  as plt
import numpy as np

#filename=input("nEnter the name with the extension(.out):")
try:
	open('engine_data.out','r')

except FileNotFoundError:
	print('nThis is not a valid file.n')
	exit()


line_count=1
crank=[]                       # in Degree
pressure=[]                    # in MPa
max_pressure=[]                # in MPa
min_pressure=[]                # in MPa
mean_temperature=[]            # in K
max_temperature=[]             # in K
min_temperature=[]             # in K
volume=[]                      # in m^3
mass=[]                        # in Kg
density=[]                     # in Kg/m^3
Integrated_HR=[]               # in J
HR_Rate=[]                     # in J/time
C_p=[]                         # in J/Kg-K
C_v=[]                         # in J/Kg-k
Gamma=[]    
kin_Visc=[]                    # in m^2/s
dyn_visc=[]                    # in N*s/m^2

for line in open('engine_data.out'):
	if '#' not in line:
		crank.append(float(line.split()[0]))
		pressure.append(float(line.split()[1]))
		max_pressure.append(float(line.split()[2]))
		min_pressure.append(float(line.split()[3]))
		mean_temperature.append(float(line.split()[4]))
		max_temperature.append(float(line.split()[5]))
		min_temperature.append(float(line.split()[6]))
		volume.append(float(line.split()[7]))
		mass.append(float(line.split()[8]))
		density.append(float(line.split()[9]))
		Integrated_HR.append(float(line.split()[10]))
		HR_Rate.append(float(line.split()[11]))
		C_p.append(float(line.split()[12]))
		C_v.append(float(line.split()[13]))
		Gamma.append(float(line.split()[14]))
		kin_Visc.append(float(line.split()[15]))
		dyn_visc.append(float(line.split()[16]))

		line_count = line_count + 1


Parameters=np.array([[0],crank,pressure,max_pressure,min_pressure,mean_temperature,max_temperature,min_temperature,volume,mass,density,Integrated_HR,HR_Rate,C_p,C_v,Gamma,kin_Visc,dyn_visc])
Variables=['crank','pressure','max_pressure','min_pressure','mean_temperature','max_temperature','min_temperature','volume','mass','density','Integrated_HR','HR_Rate','C_p','C_v','Gamma','kin_Visc','dyn_visc']
print('crank=1','pressure=2','max_pressure=3','min_pressure=4','mean_temperature=5','max_temperature=6','min_temperature=7','volume=8','density=9','Integrated_HR=10','HR_Rate=11','C_p=12','C_v=13','Gamma=14','kin_Visc=15','dyn_visc=16')


x=input('Enter x element:')
x=int(x)
y=input('Enter y element:')
y=int(y)

#Plotting
plt.plot(Parameters[x],Parameters[y], color ='blue',linewidth=3)
plt.xlabel(Variables[x-1])
plt.ylabel(Variables[y-1])
plt.show()

#Calculating Work done
work_done=np.trapz(Parameters[2],Parameters[8])
print('Area under the p-v diagram:',work_done,'J')

#Calculating Power
speed=2*math.pi*1500/60
power=work_done*speed
print('Power is \t',power)

#Calculating Specific Fuel Consumption
Fuel=20*pow(10,-6)*3600*100000
S_F_C=Fuel/power
print('Specific_fuel_consumption',S_F_C,'gm/whr')

Procedure:First of all the data in the file engine data out is being splitted with the comma and a specific number is assigned to all of them.The file contains the various thermodynamic elements like pressure, temperature,volume etc.

1.First the compatibilty is checked by try and except command.

2.After that file parsing and all the datas were splitted and assigned a no.

3.The assignment of different parameters is done so that it can be called with that specific no.

4.After that with the help of formulas area under the curve i.e.Work done,power and specific fuel consumption is calculated.

Results:

Plot of P-V Diagram:

Other Values:

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.