Week 6 - Data analysis
- AIM:
The main aim of the project is to extract the data from the output file and to plot the user defined parameters as output plots and to calculate the power output and specific fuel consumption from the given data.
- OBJECTIVE:
- To read the data from a given data file.
- To perform the compatability check.
- To plot a grap between 2 parameter given by the user as an input.
- To do the basic performance calculation by calculating area under P-V diagram,power output of the engine and specific fuel consumption.
Thermodynamic data collected from the simulation of a port fuel injected engine is extracted and analyzed in python.The data file consisting of different thermodynamic data.
FORMULAE:
Power output = `A*n*10^6`......W
where A = Area under P-V curve=workdone per cycle
n = Number of cycles per sec
n = `N/(2*60)` for 4-stroke engine
n = `N/(60)` for 2-stroke engine
N = Rotation per min
SFC(Specific fuel consumption) = (Fuel consumed in kg/hr)/(Power output in kW)
- CODING:
#Importing the required modules
import math
import matplotlib.pyplot as plt
import numpy as np
#Compatability check
filename = input('Enter file name :')
if filename == 'engine_data.out':
print('File found sucessfully!!')
else:
print('File not recognized,please provide a valid CONVERGE output file')
exit()
print('----------------------------------------------------------')
#Printing the data for the user reference
print('1-crank,2-pressure.3-max pressure,4-min pressure,5-mean temp,6-max_temp,7-min_temp,8-volume,9-mass,10-density,11-integrated_HR,12-HR rate,13-C_p,14-C_v,15-Gamma,16-Kin_visc,17-Dyn_visc')
name = ['Crank','Pressure','Max_pressure','Min_pressure','Mean_Temp','Max_Temp','Min_Temp','Volume','Mass','Density','Intergrated_HR','HR_rate','C_p','C_v','Gamma','Kin_Visco','Dyn_visco']
print('-------------------------------------------------------')
#Creating the variables for user defined parameter
x = input('enter the first parameter :')
y = input('enter the second parameter :')
print('----------------------------------------------------------')
#Declaring input as integer
x=int(x)
y=int(y)
#Empty array for storing the data
column_1 =[]
column_2=[]
for line in open('engine_data.out'):
if '#' not in line:
column_1.append(float(line.split()[x-1]))
column_2.append(float(line.split()[y-1]))
#Plotting
plt.figure(1)
plt.plot(column_1,column_2,linewidth=3)
plt.title(name[y-1]+ 'vs' +name[x-1],fontsize=20,color='red')
plt.xlabel(name[x-1],fontsize=10)
plt.ylabel(name[y-1],fontsize=10)
plt.show()
#Performance calculation
pressure=[]
volume=[]
for line in open('engine_data.out'):
if '#' not in line:
pressure.append(float(line.split()[1]))
volume.append(float(line.split()[7]))
P = 1000000*np.array(pressure)
V = np.array(volume)
#Calculating area under P-V
Area = np.trapz(P,V)
print('Workdone (area under P-V diagram)=',Area,'Joules')
print('----------------------------------------------------------')
#Calculating Power output
Power = (Area*2*math.pi*(1500/60))/1000
print('Power output=',Power,'kW')
print('----------------------------------------------------------')
#Calculating the specific fuel consumption
sfc = 20*pow(10,-6)*3600/Power
print('Specific fuel consumption=',sfc,'g/kW.h')
- EXPLANATION:
- Initially required modules for the code has been imported.
- Perform the compatability check giving the name of the file as input and if user gives the correct filename then only program will execute otherwise it will terminate.
- Creating the variables x and y for which user has to enter the values.
- Using for loop read the column by neglating '#' symbol in the data and append the data and store the values in the variables.
- The values which extracted by the user will be plot.
- For the basic performance calculation use pressure and volume column from the data by intializing for loop.
- Calculate the area under P-V curve which is equal to the workdone.
- Calculate the power output by assuming 1500rpm as a engine speed.
- Calculate the specific fuel consumption using the formula.
- OUTPUT:
When user enter correct file name:

PRESSURE VS VOLUME:

PRESSURE VS CRANK:

When user enter invalid file name:

- CONCLUSION:
- The given data has been extracted sucefully and plots required by the user can be obtained by the code.
- The basic performance calculation has been done
Workdone = 500.586 joules
Power_output = 78.632kW
SFC = 0.00091565 g/kW.h