Challenge

Week 6 - Data analysis

Aim: -

Our main aim to visualize the data,compatability test, calculate the Area under the curve I.e. Work one and to plot the graphs.

It is important for mechanical engineer to analyze and visualize the data.

Formule: -

Power:

P = W*N

Where N = speed in rpm

W = Work done = Area under curve in KJ

Brake specific fuel consumption :

BSFC:

M_F*3600/P

Where M_F = mass of fuel

Python program to check compatability test, data visulisation,plotting the graphs:

'''
Data anaalysis of a Engine by Rahematulla Kaladagi
'''


#Import modules
import matplotlib.pyplot as plt
import numpy as np
import math
from numpy import trapz


#Compatability test 

try:
	file = open('Engine_data.out')
except Filenotrecognised:
	print('File not recognised')
	sys.exit()

#Data anylisis
file = open('Engine_data.out')
data = []
for line in file:
	if '#' not in line:
		data.append(line.split())

clm = np.transpose(data) # row to column transformation
clm = clm.astype(float)

#Parameters
prmts = ['Crank','Pressure','Max_Pres','Min_Pres','Mean_Temp','Max_Temp','Min_Temp','Volume', 'Mass','Density','Integrated_HR', 'HR_Rate','C_p', 'C_v', 'Gamma','Kin_Visc','Dyn_Visc'] 
print(prmts)
print('Followings are the codes for corresponding parameters')
num_prmts = ['Crank=0', 'Pressure=1', 'Max_Pres=2', 'Min_Pres=3', 'Mean_Temp=4', 'Max_Temp=5', 'Min_Temp=6', 'Volume=7', 'Mass=8', 'Density=9', 'Integrated_HR=10', 'HR_Rate=11', 'C_p=12', 'C_v=13', 'Gamma=14', 'Kin_Visc=15', 'Dyn_Visc=16']
print(num_prmts)
print("Enter the code for respective prmts")
y = int(input('for y axis:')) #input no for parameters
x = int(input('for x axis:')) #input no for parameters
#plotting graphs
plt.plot(clm[x],clm[y],linewidth=3,color='r')
plt.title(prmts[y]+ ' vs ' +prmts[x])
plt.xlabel(prmts[x],color='green',fontsize=10)
plt.ylabel(prmts[y],color='green',fontsize=10)
plt.savefig(prmts[y]+' vs '+prmts[x]+'.pdf')
plt.show()

#Calculation
Pressure =clm[1]*1e6 # pressure in pascal
Volume = clm[7]
#Area under the P-V curve
A = np.trapz(Pressure,Volume)  #Area
A= A/(1000)
print(str(A) +' KJ')
#Area under the curve = workdone (W)
W = A #workdone #Area

#to find power
N= 1500/60 #speed in rev per sec
P =W*N
Power  = str(P) + ' KW'
print('Power developed: '+ Power)


#Brake specific fuel consumption 
m_f  = 20 #microgram
bsfc = m_f*3600/P
bsfc = bsfc/1e6 #gm/KWhr
bsfc = bsfc/1000
print('Brake Specific fuel consumption: ',bsfc,'Kg/KW-hr')

Explanation:

Algorithms: -

  • import the required modules
  • Comtaibility test to check the file opening

Data analysis part

  • open the file and load it a variable called ‘data’ and remove the lines which includs "#"
  • use transpose command to interchange row into column and store it in variable called clm in float type
  • make a array for parameters named prmts and num of array
  • give input for y and x for plotting
  • use matplotlib for plotting y vs x

Caluculation part

  • make arrays for pressure and volume
  • use trapz command to find area under the curve == workdone
  • and finally find the Power and bsfc using the formulue
  • bsfc = (m_f*3600)/P
  • P =W*n

Solution:

plot:

Result: -

Area under the P-V curve: 0.5005866274680075 KJ

Power developed: 12.514665686700187 KW

Brake Specific fuel consumption: 5.753249971073309e-06 Kg/KW-hr

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.