AIR STANDARD CYCLE SIMULATOR P-V DIAGRAM VISUALIZER
AIR STANDARD CYCLE SIMULATOR (P-V DIAGRAM VISUALIZER)
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical Petrol engine. It is the thermodynamic cycle most commonly found in automobile engines.
Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from (BDC) to top dead centre (TDC).
Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead centre. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
Process 3–4 is an adiabatic (isentropic) expansion (power stroke).
Process 4–1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead centre.
Process 1–0 the mass of air is released to the atmosphere in a constant pressure process.
CODE EXPLANATION:-
In otto cycle simulator program/code ,first we defined the basic function oe parameters, importing of math module and plotlib module,by the code illustrated above.
Here we code two programs and then depending upon the convinience , we convert our second program to a (def) function so that it can be recall again and again.
In the first coding we defined some input parameters as (bore, stroke, v_c, v_s, maximum cycle temperature,gama, compression ratio)
And depending upon those parameters and combining with thermodynamics relation ,we had calculated stae points for otto cycle.
State point 1 --------------input parameters (already defined)
p1=101325 mpa | v1=v_c+v_s
State point2
here (v2=v_c) & p2v2^gama=p1v1^gama------------------------using this relation t2 was calculated .
State point3
v3=v2 | by using ideal gas relation p3 had to be evaluated. peak pressure on the cycle.
State point 4
v4=v1 | p4v4^gama=p3v3^gama
value to computed is t4 .
After calculating all the stae points , we had plotted those results on a graph ,but the graph seems to be ideal and the points are only 4 .
1-2 =isentropic compression
3-4= isentropic expansion
within this (1-2) &(3-4) process there is a straight line but the process is not straight it should be parabola. To define a plot of parabola we need to calculate multiple pressure and volume within that region.
So, we had written a program for intermidiate calculation of pressure & volume and that is being used in our first otto cycle simulator ,code with \'FOR LOOP\" condition.
The functional program can calculate any \"n\" multiple values for the pressure & volume between (1-2)&(3-4) process.
Also we extended the program to calculate thermal efficiency of cycle. And the equation used to calculate thermal efficiency is based on compression ratio.
# otto cycle simulator
import math
import matplotlib.pyplot as plt
# defining a function, so that it can be recall again and again.
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
#engine kinematics
import math
#geometric parameters
a=stroke/2
R=con_rod/a
#volume parameters
v_s=math.pi*(1/4)*pow(bore,2)*stroke
v_c= v_s/(cr-1)
sc=math.radians(start_crank)
ec=math.radians(end_crank)
num_values=50
dtheta=(ec-sc)/(num_values-1)
V=[]
for i in range(0,num_values):
theta=sc+i*dtheta
term1 = 0.5*(cr-1)
term2 = R+1-math.cos(theta)
term3 = pow(R,2) - pow(math.sin(theta),2)
term3 = pow(term3,0.5)
V.append ((1+term1*(term2-term3))*v_c)
#After calculation of V values it need to store in the V array even if the code is running out of the defined function
return V
#inputs
p1=101325
t1=500
gama=1.4
t3=2300
#geometric parameter
bore= 0.1
stroke=0.1
con_rod=0.15 #connecting rod length
cr=12 #compression ratio
#volume calculation
v_s=(math.pi/4)*pow(bore,2)*stroke #swept volume
v_c=v_s/(cr-1) #clereance volume
v1=v_c+v_s
#state point 2
v2=v_c
#p2v2^gama=p1v1^gama
p2=p1*pow(v1,gama)/pow(v2,gama)
#p2v2/t2=p1v1/t1 | x=p1v1/t1 | p2v2/t2=x | t2=p2v2/x
x=p1*v1/t1
t2=p2*v2/x
V_compression=engine_kinematics(bore, stroke, con_rod, cr, 180, 0)
constant = p1*pow(v1,gama)
p_compression = []
for v in V_compression:
p_compression.append(constant/pow(v,gama))
#state point 3
v3=v2
# p3v3/t3 = p2v2/t2 | x=p2v2/t2 | p3 = x*t3/v3
x=p2*v2/t2
p3= x*t3/v3
V_expansion=engine_kinematics(bore, stroke, con_rod, cr, 0, 180)
constant = p3*pow(v3,gama)
p_expansion = []
for v in V_expansion:
p_expansion.append(constant/pow(v,gama))
#state point4
v4=v1
#p4v4^gama=p3v3^gama
p4=p3*pow(v3,gama)/pow(v4,gama)
#p4v4/t4=p3v3/t3
t4=p4*v4/x
plt.plot([v2,v3],[p2,p3])
plt.plot(V_compression,p_compression)
plt.plot(V_expansion,p_expansion)
plt.plot([v4,v1],[p4,p1])
plt.xlabel(\'volume\')
plt.ylabel(\'pressure\')
plt.show()
# Thermal efficiency | 1-(1/(c_r)^gama-1) |
y= pow(cr,(gama-1))
thermal_efficiency= (1-(1/y))*100
print(thermal_efficiency)
1) p-v DIAGRAM FOR compression ratio=12
2) Thermal efficiency
the thermal efficiency calculation is based on compression ratio is 62.98 % (small code is written for that.)