Air standard Cycle
Air standard Cycle
Aim:
To write a code for otto cycle and create PV plot and also to find out thermal efficiency of the engine.
Objectives:
- To create a PV diagram
- To find out thermal efficiency of the engine
Assumption:
Gamma=1.4
P1=101325Pa
T1=400K
T3=2500K
Bore diameter=0.1m
Stroke=0.1m
Compression ratio(cr)=5
Connecting rod length=0.15m
Formulas used:
Solution procedure:
- To assume all input parameters such as pressure, temperature, stroke and bore diameter etc
- Calculate pressure and temperature at different stages
- Plot the PV diagram
- Find out Thermal efficiency
code:
# otto cycle simulator
# by Abhishek Savakar
from math import *
from matplotlib.pyplot import *
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
# geometric parameters
a = stroke / 2
R = con_rod / a
# volume parameters
v_s = (pi / 4) * pow(bore, 2) * stroke
v_c = v_s / (cr - 1)
theta = radians(180)
sc = radians(start_crank)
ec = 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 - cos(theta)
term3 = pow(R, 2) - pow(sin(theta), 2)
term3 = pow(term3, 0.5)
v.append((1 + term1 * (term2 - term3)) * v_c)
return v
# inputs
p1 = 101325
t1 = 500
gama = 1.4
t3 = 2300
# geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 5
# volume computation
v_s = (pi / 4) * pow(bore, 2) * stroke
v_c = v_s / (cr - 1)
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 | rhs=p1v1/t2 | t2= p2v2/rhs
rhs = p1 * v1 / t1
t2 = p2 * v2 / rhs
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))
# print(p_compression)
# state point 3
v3 = v2
# p3v3/t3=p2v2/t2 |rhs = p2v2/t2 | p3= rhs*t3/v3
rhs = p2 * v2 / t2
p3 = rhs * 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 point 4
v4 = v1
# p4v4^gama=p3v3^gama
p4 = p3 * pow(v3, gama) / pow(v4, gama)
# p4v4/t4=rhs
t4 = p4 * v4 / rhs
# thermal efficiency
thermal_eff = 1 - 1 / pow(cr, (gama - 1))
print('\nThermal Efficiency:', thermal_eff * 100, "%")
# plotting pv diagram
plot([v2, v3], [p2, p3])
plot(v_compression, p_compression)
plot(v_expansion, p_expansion)
xlabel("volume")
ylabel("Pressure")
plot([v4, v1], [p4, p1])
show()
Output screen:
Code explanation:
- Importing math module and matplotlib.pyplot module.
- Assume input parameters.
- Volume i.e vc and vs computation.
- Calculating pressure and temperature at various stages.
- Call the engine kinematics function for compression and expansion which will return v.
- Plot PV diagram using all volumes and pressures calculated.
- Find out thermal efficiency.
PV Diagram:
Results:
We have successfully plotted the PV diagram.
The thermal of engine was calculated to be= 47.46944391192465 %