Challenge

Week 6 - Data analysis

Aim:

Write a Python code to analyse the data by parsing the output file of engine simulation.

Objective:

  • Write a code to check the compatibility of the file.
  • Write a code to parse the data and extract user defined data types.
  • Plot the graphs according to user requirement.
  • Calculate the area under PV diagram, power output of the engine and specific fuel consumption.
import math
import matplotlib.pyplot as plt
importnumpyasnp

"""
Data engine in python
"""
# using the exception 'compatability check'
try:
data = open('engine_data.out','r')
print('file found')
except FileNotFoundError:
print('fiel not recoginized,please provide a valid output file')


# Input variables
spring_no_11 =11 # assume the 'spring no 11' bar/m
L=0.15 # assuem stroke in 'm'
d =0.10 # assume bore diameter in 'm'
A=(math.pi/4)*d**2 # area of cylinder 'm^2'
n=1500/2 # RPM , four stroke engine (N/2)
m=20*pow(10,-6) # fuel consumptuion g/s


line_count = 1
#Crank = []
Volume = []
Pressure = []

for line in open ('engine_data.out'):
if '#' not in line:
Pressure.append(float(line.split()[1]))
Volume.append(float(line.split()[7]))

area_of_indication = np.linspace(Pressure,Volume)
length_of_indicator =(0.00057-5.6e-5) # measure from the p-v diagra
P_m =((area_of_indication/length_of_indicator)*spring_no_11) # meanf effficetve pressure
P_i=(P_m*L*A*n)/(60*1000) # Indicate power
P_f=0.3*P_i # Frictional power
P_b=P_i-P_f # Brake power
Mech_eff=(P_b/P_i)*100 # Mechannical Efficency
sfc= (m*3600)/P_b # specific furel condspution - g/Kw-h



# Plot figuare
print('mean effective presure(kw):',+P_m)
# ind
print('Indicate power:',+P_i)
# fp
print('frictional power:',+P_f)
# brp
print('Break Power:',+P_b)
# mech
print('Mechanical:',+P_m)
# sfc
print('specific furel condspution:',+sfc)
plt.plot(Volume,Pressure,linewidth=3)
plt.xlabel ('Volume')
plt.ylabel ('Pressue')
plt.title('Volume vs Pressure')

plt.show()
print (sfc)
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.