Project

Engine data Analysis using PYTHON

Engine Data Analysis

Now, for this challenge there are different objectives that I had to solve that are:

1.Compatibility Chek

2.Data Visualizer

3.Basic Performance Calculation

Before starting out, I wrote down the required import files. Here, I also required the trapz import of numpy to use the transpose function

Compatibility Check:-

For the compatibility check I used a simple try block . To make the code user responsible, as given in the challenge I asked for the file name to be parse as an input from the user . Then, it goes to the try block , where the file is opened in the \'read\' mode. If the file name is not correct, the code goes to the exception block and it throws an error.

Data Visualizer:-

Now, to read the file, I had to go through it properly once. The file contains few comments that start with an \'#\' . So, they had to be skipped which is what I first did by writing an if condition inside a loop. The rest of the lines contained 17 columns representing different engine parameters and 8664 rows of data. These were appended in an array \'val\', This array was then transposed usig the transpose function in an array named \'column\' .

Now, as the column data has been obtained , another user interactive code was wriiten where I asked for two column values out of 17 columns between which the graph had to be plotted. Both the numbers were stored in two variables \'x\' and \'y\' . All the parameter names were saved inside a variable \'parameters\' and was printed for the user to choose from.

Now, simply a graph was plotted between the two columns with the labels and title and was saved with title name using the savefig command.

Basic Performance Calculation:-

now there were three values that were to be calculated between the pressure and volume columns, that are :- area under the curve, power and specific fuel consumption.

Starting with the area, first the pressure and volume colums were taken and stored as an np array \'volume\' and \'pressure\'. The area was then simply calculated by using the transpose finction of the trapz import andwas then printed.

For power the following formula was used , P= area(W) * RPM/ 9950

This was simply used to calculate the power and was printed.

For the fuel consumption the following formulae was used,

BSFC = Fuel per second / power where, Fuel per second=Fuel per stroke*RPM*60

This was simply coded and the specific fuel consumption was calculated and printed.

Below I have attached the code snippet:-

\'\'\'
Engine data Analysis
\'\'\'

#Imports Required
import matplotlib.pyplot as plt 
import math
import numpy as np 
from numpy import trapz as tp

#input file name from user
file=input(\"Enter the file name with extension: \")

#Compatibility Check
try:	
	data=open(file,\'r\')
except FileNotFoundError:
	print(\"File not recognized, Please provide a valid file name\")

#Excluding the comments
val=[]
for i in data:
	if \'#\' not in i:
		val.append(i.split())

#Saving all the data in an array
column=np.transpose(val)
column=column.astype(float)

#Printing all the parameter names for user convenience
parameters=[\'Crank Angle\',\'Pressure\',\'Maximum Pressure\',\'Minimum Pressure\',\'Mean Temp\',\'Maximum Temp\',\'Minimum Temp\',\'Volume\',\'Mass\',\'Density\',\'Heat Rejection\',\'Heat Rejection Rate\',\'CP\',\'CV\',\'gamma\',\'Kinematic Viscosity\',\'Dynamic Viscosity\']
print(parameters)
print(\'These are the parameters provided in the file\')
x=int(input(\'Now provide the corresponding no. for the first input Value(0-16): \'))
y=int(input(\'Now provide the corresponding no. for the second input Value(0-16): \'))

#plotting
plt.plot(column[x,:],column[y,:],color=\'green\')
plt.xlabel(parameters[x])
plt.ylabel(parameters[y])
plt.title(parameters[x]+\' vs \'+parameters[y])
plt.savefig(parameters[y]+\' VS \'+parameters[x]+\'.png\')
plt.show()


#basic performance calculations
Volume=np.array(column[7,:])
pressure = np.array(column[1,:])
#Area Calculation
area=tp(y=pressure.transpose(),x=Volume.transpose())
print(\'Area under the curve in MJ: \',area)

#Power Calculation
RPM=1500
power=area*(RPM/9550)*pow(10,6)
print(\'Power in  KW :\',power)

#Fuel Consumption Calculation
fuel_per_stroke = 20*1e-06
fps=fuel_per_stroke*RPM*60
bsfc=fps/(power*1e+03)
print(\'Specific fuel consumption in g/j: \',bsfc)

Outputs and Graphs:-

1. Basic performance values=

\"\"

2. error thrown when wrong fileame given =

\"\"

3. PV Diagram =

\"\"

Few more graphs :-

\"\"

\"\"

\"\"

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.