Week 2 Air standard Cycle
OBJECTIVE :- To write a python program for air standerd cycle and create a PV diagram & calculate otto cycle thermal efficiency.
PROBLEM STATEMENT :-
In this challenge I need to do-
- Write a code for air standerd cycle I.e. Otto cycle and create a PV diagram
- Also calculate thermal efficiency of the engine which is a output.
- Attach all relevant snapshots.
SOLUTION PROCEDURES :-
For creating PV diagram I adopted following procedures-
- First off all I import math and plot function at the top.
- Define all terminology which we have to required while creating PV diagram and finding thermal efficiency.
- Define stroke volume and clearance volume- Vs = pi/4*(bore)^2*stroke
- Crank start and crank end angle are defined in degree
- Define total number of values and dtheta
- Create empty matrix for volume
- Define total volume by compression volume equation and appended it in total volume by using for loop and return it each time after running the for loop.

- These all the function for engine kinematics.
- Then define pressure, temperature and gamma also bore, stroke, connecting rod length, compression ratio, initial and final temperatre.
- Engine kinematics function put in volume compression by using for loop.
- Do the same process for volume expansion.
- Plot some PV diagram by changing compression ratio (I.e. cr).
PYTHON CODE :-
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
# geometric parameters
a = stroke/2 #crank pin radius
R = con_rod/a # piston radius
# V_s = pi/4*B^2*L
V_s = math.pi*(1/4)*pow(bore,2)*stroke
V_c = V_s/(cr-1)
sc = math.radians(start_crank) #crank start in degree
ec = math.radians(end_crank) # crank end in degree
num_values = 50 # number of values in curve
dtheta = (ec-sc)/(num_values-1)
V = [] # volume
# V/Vc = 1 + 0.5(cr-1)[R + 1 - cos(theta) - (R^2 - sin^2(theta))^0.5]
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)
return V
#inputs
p1 = 101325 #pressure
t1 = 500 #temperature
gamma = 1.4
t3 = 2300
# geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15 #connecting rod
cr = 8 #compression ratio
#volume computation
v_s = (math.pi/4)*pow(bore,2)*stroke #swept volume
v_c = v_s/(cr-1) #clearance volume
v1 = v_c + v_s #total volume
#state point-2
v2 = v_c
p2 = p1*pow(v1,gamma)/pow(v2,gamma)
rhs = p1*v1/t1
t2 = p2*v2/rhs
V_compression = engine_kinematics(bore, stroke, con_rod, cr, 180, 0) #compression volume
constant = p1*pow(v1, gamma)
p_compression = [] #compression pressure
for v in V_compression: #compression volume
p_compression.append(constant/pow(v, gamma))
v3 = v2
rhs = p2*v2/t2
p3 = rhs*t3/v3
V_expansion = engine_kinematics(bore, stroke, con_rod, cr, 0, 180)
constant = p3*pow(v3, gamma)
p_expansion = []
for v in V_expansion: #expansion volume
p_expansion.append(constant/pow(v, gamma))
v4 = v1
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
t4 = p4*v4/rhs
# Otto cycle thermal efficiency
a = 1/pow(cr,(gamma-1))
thermal_efficiency = (1 - a)*100
print(thermal_efficiency)
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.savefig("PV diagram")
plt.show()
RESULTS :-
PV diagram for different compression ratio are as follows-
- PV diagram of straight line :-

This is the simple otto cycle without using the formula, P*V^gamma = constant.
- PV diagram for CR = 6 :-

- PV diagram for CR = 8 :-

- PV diagram for CR = 12 :-

- PV diagram for CR = 15 :-

DISCUSSION :-
From above PV diagram we can say that, otto cycle intercepted area is depends on compression ratio. As compression ratio increases intercepted area also decreases and vice-versa.
Straight line PV diagram at compression and expansion shows that P*V^gamma = constant not applied.
Curve line PV diagram is a theorotical cycle at constant pressure.
THERMAL EFFICIENCY :-
Formula for thermal efficiency-
Thermal efficiency = (1 - ((1/((compression ratio)^(gamma-1))))*100.
It is depends on compression ratio. For different compression ratio different efficiency are as follows-
- For compression ratio =6 :-
Thermal efficiency = 51.16%
- For compression ratio =8 :-
Thermal efficiency = 56.47%
- For compression ratio =12 :-
Thermal efficiency = 63%
- For compression ratio =15 :-
Thermal efficiency = 66.15%
CONCLUSIONS :-
From above python code and PV diagram we can conclude that-
- Compression stroke start at BDC and end at TDC at 180 degree and similerly expansion start at TDC and end at BDC at 180 degree.
- As much more number of values on compression and expansion curve, we get the soft curve.
- Inscribed area of PV diagram is totally depends on compression ratio (cr). as compression ratio increases inscribed area of PV diagram decreases and vice-versa.
- Thermal efficiency also depends on compression ratio. As compression ratio changes thermal efficiency also changes.
- For normal compression ratio=12, thermal efficiency is nearly equal to 63%.
In this way, I write a python code for otto cycle efficiency and calculate thermal efficiency for different compression ratio. I analyse everything and write final conclusions, also write all python code procedures.