All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
import matplotlib.pyplot as plt import numpy as np from numpy import trapz fname = input("Enter the filename: ") if fname == 'engine_data.out': print('file is valid') else: print('file is invalid') exit() def compatibility_check(a): if 'CONVERGE' not in a: print('please provide converge output file to process') exit()…
Rajiv Ranjan
updated on 30 Jun 2021
import matplotlib.pyplot as plt
import numpy as np
from numpy import trapz
fname = input("Enter the filename: ")
if fname == 'engine_data.out':
print('file is valid')
else:
print('file is invalid')
exit()
def compatibility_check(a):
if 'CONVERGE' not in a:
print('please provide converge output file to process')
exit()
else:
print('compatibility check is successful')
pass
FILE = []
for line in open(fname):
if '#' in line:
FILE.append(line.split())
compatibility_check(FILE[0])
noc = len(FILE[1])
head = len(FILE[2])
col_no = []
col_val = []
col_units = []
z = FILE[1].index('column')
for i in range(z,noc-1):
col_no.append(i)
for j in FILE[2]:
if j is not '#':
col_val.append(j)
for k in FILE[3]:
if k is not '#':
col_units.append(k)
print('data available are:')
for a in range(0,len(col_no)):
print(col_no[a],col_val[a],col_units[a])
xaxis = int(input('Enter xaxis column no:'))-1
yaxis = int(input('Enter yaxis column no:'))-1
x = []
y = []
for line in open(fname):
if '#' not in line:
x.append(float(line.split()[xaxis]))
y.append(float(line.split()[yaxis]))
plt.plot(x,y,linewidth=1.5)
plt.xlabel(col_val[xaxis])
plt.ylabel(col_val[yaxis])
plt.show()
pressure = []
vol = []
for line in open(fname):
if '#' not in line:
pressure.append(float(line.split()[1]))
vol.append(float(line.split()[7]))
Pressure = 1e6*np.array(pressure)
Volume = np.array(vol)
area = np.trapz(Pressure,Volume)
print('workdone =',area, 'joules')
cyclepersec = 750/60
power = area*(cyclepersec/1000)
print('power=',power,'kw')
mass_flow = 20e-6
sfc = mass_flow*3600/power
print('specific fuel consumption =',sfc,'g/kwh')
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...
Week 3 - Solving second order ODEs
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt import math # function that returns dz/dt def model(theta,t,b,g,l,m): theta1 = theta [0] theta2 = theta [1] dtheta1_dt = theta2 dtheta2_dt = -(b/m)*theta2 - (g/l)* math.sin(theta1) dtheta_dt = [dtheta1_dt,dtheta2_dt] return dtheta_dt…
01 Jul 2021 03:33 AM IST
Week 6 - Data analysis
import matplotlib.pyplot as plt import numpy as np from numpy import trapz fname = input("Enter the filename: ") if fname == 'engine_data.out': print('file is valid') else: print('file is invalid') exit() def compatibility_check(a): if 'CONVERGE' not in a: print('please provide converge output file to process') exit()…
30 Jun 2021 12:37 PM IST
Week 5 - Curve fitting
1. What does popt and pcov mean? The curve_fit function returns two items, which we call popt and pcov.The popt argument are the best fit for 'a' and 'b'. The pcov variable contains the covariance matrix which indicates the uncertainties and corelation between parameters. This is mostly useful when the data has uncertainties.…
30 Jun 2021 12:31 PM IST
Week 2 Air standard Cycle
INTRODUCTION: - The Otto cycle is the theoretical cycle of interest when one is considering reciprocating SI engines. The four-stroke Otto cycle is made up of the following four internally reversible processes: 1–2, isentropic compression; 2–3, constant-volume heat addition; 3–4, isentropic…
19 May 2021 10:07 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.