All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Take a look at the data analysis video before you attempt this challenge. Your task is to write a script that does the following. Data visualizer (100 points) Your script should take column numbers as the input and plot the respective columns as separate images Each file should be saved by the name of the column The plot…
Saravanan S
updated on 19 Sep 2021
Take a look at the data analysis video before you attempt this challenge.
Your task is to write a script that does the following.
Data visualizer (100 points)
Compatability check (30 points)
Basic performance calculation (50 points)
Program:
import math
import numpy as np
import matplotlib.pyplot as plt
file_name =input(' Enter File Name ==> ')
if file_name == ('engine_data.OUT'):
crank_angle =[]
pressure = []
max_pres = []
min_pres = []
mean_temp = []
max_temp = []
min_temp = []
volume =[]
mass=[]
density = []
integrated_hr = []
hr_rate=[]
cp = []
cv = []
gamma = []
kin_vis = []
dyn_vis = []
parameter =[]
unit =[]
lines = 1
ct =1
counter = 1
for line in open('engine_data.OUT'):
if '#' in line:
if ct == 3:
parameter.append(line.split())
ct=ct+1
if counter ==4:
unit.append(line.split())
counter=counter+1
if '#' not in line:
crank_angle.append(float(line.split()[0]))
pressure.append(float(line.split()[1]))
max_pres.append(float(line.split()[2]))
min_pres.append(float(line.split()[3]))
mean_temp.append(float(line.split()[4]))
max_temp.append(float(line.split()[5]))
min_temp.append(float(line.split()[6]))
volume.append(float(line.split()[7]))
mass.append(float(line.split()[8]))
density.append(float(line.split()[9]))
integrated_hr.append(float(line.split()[10]))
hr_rate.append(float(line.split()[11]))
cp.append(float(line.split()[12]))
cv.append(float(line.split()[13]))
gamma.append(float(line.split()[14]))
kin_vis.append(float(line.split()[15]))
dyn_vis.append(float(line.split()[16]))
lines = lines+1
select_parameter = [0, crank_angle, pressure, max_pres,min_pres,mean_temp,max_temp,min_temp,volume,mass,density,integrated_hr,hr_rate,cp,cv,gamma,kin_vis,dyn_vis]
print('\nAnalysing an IC Engines results Parameter and ploting the data')
print('\n1.crank_angle \n2.pressure \n3.max_pres \n4.min_pres \n5.mean_temp \n6.max_temp \n7.min_temp \n8.volume \n9.mass\n10.density\n11.integrated_hr\n12.hr_rate\n13.cp\n14.cv\n15.gamma\n16.kin_vis\n17.dyn_vis')
print('\nSelect different x and y inputparameters, only from te list given above. \nDo not enter 0 or any other number beyound list given above')
x = int(input('\nEnter the x_axis paramter to plot the data - '))
y = int(input('\nEnter the y_axis paramter to plot the data - '))
for i in range (0, len(parameter)):
for j in range (0, len(unit)):
fig = plt.figure(linewidth = 5, edgecolor = "k")
plt.plot(select_parameter[x], select_parameter[y])
plt.xlabel(parameter[0][x]+unit[0][x], size = '10')
plt.ylabel(parameter[0][y]+unit[0][y], size = '10')
plt.title(parameter[0][y] + 'Vs' + parameter[0][x], size = 15)
plt.savefig(parameter[0][y] + 'Vs' + parameter[0][x]+'.png')
print('\nEngine performance calculation')
fuel_consumption = 20
RPM = 1500
print('\nFuel consumption is ',fuel_consumption,'mg')
print('\nEngine RPM is ',RPM)
workdone = np.trapz(select_parameter[2], select_parameter[8])
workdone = (workdone*pow(10,6))
print('\n1. Work done by engine =%.5f' %(workdone),'J')
power = (workdone*(RPM/60))/1000
print('\n2. Power output =%.5f' %(power),'KW')
RPS =RPM/60
Total_strokes = 4*RPS
fuel_consumption = fuel_consumption*Total_strokes
specifice_fuel_consumption =(fuel_consumption*0.0036)
print('\n3. The Fuel consumption/ Second at given engine speed =%.5f' %(fuel_consumption),'Mg/s')
print('\n4. Specific fuel_consumption =%.5f' %(specifice_fuel_consumption),'g/KW.hr')
else:
print('File not recognized. Please provide a valid CONVERGE output file')
Result:
Plot Between column 11 &15:
Different file name:
PV plot:
The area under the P-V diagram:
The area under PV diagram = Work done ==> 500.58663 J
The power output of the engine ==> 12.51467 KW
The specific fuel consumption of the engine ==> 7.20000 g/KW.hr
Inference:
Thus the program to read the Output file of an engine simulation and calculate the required is done.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 2 - Rankine cycle Simulator
Understand the concept of Rankine cycle by referring to standard thermal engineering text book. Create a Rankine Cycle Simulator using OCTAVE/MATLAB. Your code should calculate the state points of the Rankine Cycle (any type of your choice) based on user inputs. Then, plot the corresponding T-s and h-s plots for…
26 Sep 2021 04:41 PM IST
Week 6 - Data analysis
Take a look at the data analysis video before you attempt this challenge. Your task is to write a script that does the following. Data visualizer (100 points) Your script should take column numbers as the input and plot the respective columns as separate images Each file should be saved by the name of the column The plot…
19 Sep 2021 09:36 AM IST
Week 5 - Curve fitting
Curve fitting: Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to constraints. Curve fitting can involve either interpolation, where an exact fit to the data is required, or smoothing, in which a…
13 Sep 2021 03:20 PM IST
Week 3 - Solving second order ODEs
Equation: n the above equation, g = gravity in m/s2, L = length of the pendulum in m, m = mass of the ball in kg, b=damping coefficient. Write a program in Python that will simulate the pendulum motion, just like the one shown in the start of this challenge. use, L=1 metre, m=1 kg, b=0.05. g=9.81 m/s2. Simulate the motion…
29 Aug 2021 11:39 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.