All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
# IMPORTING IMP MODULE import math import numpy as np import matplotlib.pyplot as plt #Taking inputs from user file_name=input("Enter file name :") print('------------------------------------------------------------------') #checking for valid file if file_name == 'engine_data.out': print('File found succesfully!! you…
Sachin Barse
updated on 11 Oct 2022
# IMPORTING IMP MODULE
import math
import numpy as np
import matplotlib.pyplot as plt
#Taking inputs from user
file_name=input("Enter file name :")
print('------------------------------------------------------------------')
#checking for valid file
if file_name == 'engine_data.out':
print('File found succesfully!! you may continue...n')
else:
print('File not recognized. Please provide a valid CONVERGE output file')
exit()
print('------------------------------------------------------------------')
#parameters given below for plot
print('The plot paramters given below in the series n')
print('1-crank,2-Pressure, 3-Max_Pressure, 4-Min_Pressure, 5-Mean_Temp, 6-Max_Temp, 7-Min_Temp, 8-Volume, 9-Mass, 10-density, 11-integrated_HR, 12-HR_Rate, 13-C_p, 14-C_v, 15-Gamma, 16-kin-Vics, 17-Dyn_Visc')
print('---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------')
name=['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']
# take inputs from users
x = input('Enter the first parameter you need to plot : ')
y = input('Enter the second parameter you need to plot : ')
print('------------------------------------------------------------')
# declare inputs as integer
x = int(x)
y = int(y)
# uesd to store the value
column_1 = []
column_2 = []
# look for taking required data and opening the data file
for line in open(file_name):
if '#' not in line:
column_1.append(float(line.split()[x-1]))
column_2.append(float(line.split()[y-1]))
# plot
plt.figure(1)
plt.plot(column_1, column_2, linewidth=3)
plt.title(name[y-1]+' & '+name[x-1]+' Plot',fontsize=20,color='red')
plt.xlabel(name[x-1],fontsize=12)
plt.ylabel(name[y-1],fontsize=12)
plt.savefig(name[x-1] + ' vs ' + name[y-1] + '.png')
plt.grid()
plt.show()
#basic performance calculation
pressure = []
volume = []
for line in open('engine_data.out'):
if '#' not in line:
pressure.append(float(line.split()[1]))
volume.append(float(line.split()[7]))
P = 1000000*np.array(pressure) # converting to pascal
V = np.array(volume)
#calculating area PV diagram
AREA = np.trapz(P, V)
print('nWorkdone (area under P-V diagram)= ',AREA ,'Joules')
# Calculating power
power = (AREA * 2* math.pi * (1500/60))/1000
print('Power out of the equation = ',power,'KW')
#calculating specific fuel consumption
sfc = 20 * pow(10, -6)* 3600 / power
print('Specific fuel consumption= ',sfc, 'g/kw.h')
#plotting P-V Diagram
plt.figure(2)
plt.plot(volume, pressure, linewidth = 3)
plt.title('P-V diagram',fontsize=20,color='red')
plt.xlabel('Volume',fontsize=12)
plt.ylabel('Pressure',fontsize=12)
plt.grid()
plt.show()
Explanation-
1.Initially, the required modules are imported.
2.File name is taken as an input from user and, to verify the user file with engine_data.out file, if command is used.
3.The Using a for loop every line of file is read line by line and the lines with '#'not include to read data and are appended to an array named 'column_1 & column_2’.
4.Using a for loop the extracted column no and names are displayed for user and asked to make a plot.
5.Then the values of the column selected by user are extracted and stored in an array and further plotted on a graph.
6.For basic performance calculation the values of pressure andvolume column are extracted and using the 'np.trapz(P,V)'
command, area under the PV diagram is calculated which also is the Workdone.
7.Converting the given speed of 1500rpm into rps the power output of the engine is calculated and further the specific fuel
consumption of engine is calculated.
8.All the values calculated are displayed on the screen for the user.
Result -
Output screen and plot-
If the user enters a valid file name & for parameter 1 , 2-
plot obtained-
If the user enters a valid file name & for parameter 1 , 5-
plot obtained-
If the user enters a valid file name & for parameter 1 , 8-
plot obtained-
If the user enters a valid file name & for parameter 1 , 12-
plot obtained-
If the user enters a valid file name & for parameter 2, 5-
plot obtained-
If the user enters a valid file name & for parameter 1, 15-
plot obtained-
If the user enters a valid file name & for parameter 1, 14-
plot obtained-
Along with these program second figure of plot in common is PV diagram:
If the user enters an invalid file name-
Output -
Workdone (area under P-V diagram)= 500.5866274680076 Joules
Power out of the equation = 78.63196356693916 KW
Specific fuel consumption= 0.0009156581717396209 g/kw.h
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...
FINAL INDEPENDENT PROJECT
Project : Design & Animate the drone camera for project model. Attached Link For Model Review : https://drive.google.com/file/d/1f6sjaJc6Od2AEnmh-JYFFoLMmUveWk61/view?usp=drive_link
15 May 2024 05:42 PM IST
Week - 4
AIM: Implement control logic of a “washing machine” using Stateflow as per given sequence: If the power supply is available, the system gets activated. If the Water supply is not available, stop the process & indicate through LED Soaking time should be 200s followed by Washing…
13 Mar 2024 10:27 AM IST
Week -2
1.Door Bell Simulink Model: Simulink Model Explanation: The pulse generator is used to create square wave pulses at regular intervals.The block waveform parameters Amplitude,pulse width,period and phase delay,determine the shape of the output waveform. …
12 Mar 2024 12:23 PM IST
Project 1
Attached Model for Project :- Attached link for grading :- https://drive.google.com/file/d/13bjiEKi2h1sYtm9LzZMouMksFAZYnVIQ/view?usp=drive_link
29 Oct 2023 11:00 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.