Project

Engine data analysis using python

Thermodynamic data collected from simulation of a Port Fuel Injected engine is extracted and analysed from a data file using a Python program.

This data file consists of 17 columns of different thermodynamic parameters for which more than 8000 values have been recorded. The objective is to open the file in the directory, read and extract desired data from the file. The program takes the input from the user and plots the graph for the respective parameter and also calculates the Work done per cycle, Power output for specified rpm and Specific Fuel Consumption.

Below is the program for the engine data analysis.

"""
   Engine fata analysis using python
"""

import matplotlib.pyplot as plt
import math
import numpy as np

#input file from user
filename = input("\nEnter the name of CONVERGE output filename with the extension(.out): ")

#compatibility check
try:
 	data=open(filename,'r') #reading the input file
except FileNotFoundError:
	print("File not recognized. Please provide a valid CONVERGE output file")

#skipping the comments
value=[]
for line in data:
	if '#' not in line:
		value.append(line.split())
		
column=np.transpose(value)
column=column.astype(float)

#parameters from the filename
parameter=['Crank Angle','Pressure','Maximum Pressure','Minimum Pressure','Mean Temperature','Maximum Temperature','Minimum Temperature','Volume','Mass','Density','Heat Rejection','Heat Rejection Rate','C_p','C_v','gamma','Kinematic Viscosity','Dynamic Viscosity']
print(parameter)
print('Each parameter from the file is provided with the code as below')
corresponding_num=['crank_angle=0','pressure=1','max_pres=2','min_pres=3','mean_temp=4','max_temp=5','min_temp=6','volume=7','mass=8','density=9','Heat Rejection=10','Heat Rejection Rate=11','C_p=12','C_v=13','gamma=14','Kin Vis=15','Dyn Vis=16']

#taking input for x and y parameter
print(corresponding_num)
print("please enter the code for independent variable then press enter: \n")
x=int(input())
print("please enter the code for dependent variable then press enter: \n")
y=int(input())

#plotting
plt.plot(column[x,:],column[y,:],linewidth=3,color='blue')
plt.xlabel(parameter[x],fontsize=10)
plt.ylabel(parameter[y],fontsize=10)
plt.title(parameter[y]+'    VS    '+parameter[x],fontsize=10)
plt.savefig(parameter[y]+'VS'+parameter[x]+'.png')
plt.show()

vol=column[7,:]
press=column[1,:]*pow(10,6)  #converting the pressure into Pascal

#area under the curve
work=[]
for i in range(0,8664):
	work.append((vol[i+1]-vol[i])*(press[i+1]+press[i])*0.5)

work_done=0
for j in range(0,len(work)):
	work_done=work_done+work[j]

print('Area under the p-v diagram i.e, Work Done :',work_done,'J')

#Power calculations
speed=1500/60 
power=work_done*speed
print('Power:',power/1000,'KW')

#specific fuel consumption
m_f=20*pow(10,-6)  
bsfc=(m_f*3600)/power
print('Specific Fuel Consumption:',bsfc,'gm/KWhr')

Output plots some parameters entered by me.

Like this we can give various inputs to obtain the required plots.

Area under the p-v diagram i.e, Work Done : 500.58662746800763 J

Power: 12.51466568670019 KW

Specific Fuel Consumption: 5.753249971073308e-06 gm/KWhr

These are the outputs for the input of Pressure and Volume.

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.