Week 2 Air standard Cycle
1.AIM: Solvig an otto cycle and making plots for it.
2.GOVERNING EQUATIONS:
Adiabatic compression/expansion process: `P_1 V_1^γ= P_2 V_2^γ`
Ideal gas law: `(P_1 V_1)/T_1 = (P_2 V_2)/T_2`
Efficiency of the cycle: `η=1- 1/〖(rc)〗^(γ-1)`
`η=1- (T_4-T_1)/(T_3-T_2 )`
3.OBJECTIVE OF THE PROGRAME: This programe plots a PV diagram of Otto cycle. Also it calculates the thermal efficiency of the cycle.
4.EXPLANATION OF OTTO CYCLE: The Otto cycle is the ideal cycle for spark-ignition engines. Nikolaus Otto invented it in 1867. In ideal Otto cycles, air-standard assumption is used. The ideal Otto cycle consists of four internal reversible processes:
Process 1-2 Isentropic/Adiabatic compression
Process 2-3 Constant volume heat addition
Process 3-4 Isentropic/Adiabatic expansion
Process 4-1 Constant volume heat rejection
5.BODY OF THE CONTENT:
MAIN CODE:
#This programe is written in python
#Otto cycle simulator
import math
import matplotlib.pyplot as plt
#Engine kinematics
def engine(bore,stroke,con_rod,cr,start_crank,end_crank):
import math
import matplotlib.pyplot as plt
#Geomtric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 6
a = stroke/2
R = con_rod/a
#Volume computation
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_c+v_s
ec = math.radians(end_crank)
sc = math.radians(start_crank)
#No of divisions in the range of angle
n = 50
dtheta = (ec - sc)/(n-1)
V = []
for i in range(0,n):
theta = sc + (i*dtheta)
term1 = 0.5*(cr-1)
term2 = R+1-(math.cos(theta))
term3 = pow((pow(R,2))-(pow(math.sin(theta),2)),0.5)
V.append(v_c*(1+term1*(term2-term3)))
return V
#Inputs
gamma = 1.4
#Geomtric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 6
#Volume computation
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_c+v_s
#State 1 | inputs
p1 = 101325
t1 = 500
t3 = 2300
#State 2
v2 = v_c
#P2*v2^gamma = p1*v1^gamma
p2 = (p1*pow(v1,gamma))/(pow(v2,gamma))
#p2*v2/t2 = p1*v1/t1
t2 = (p2*v2*t1)/(p1*v1)
#Calling engine function
V_compresssion = engine(bore,stroke,con_rod,cr,180,0)
#P*v^gamma = constant
constant = p1*pow(v1,gamma)
P_compression = []
for v in V_compresssion:
P_compression.append(constant/pow(v,gamma))
#State 3
v3 = v2
#p3*v3*/t3 = p2*v2/t2
p3 = (p2*v2*t3)/(t2*v3)
#Calling engine function
V_expansion = engine(bore,stroke,con_rod,cr,0,180)
#P*v^gamma = constant
constant = p3*pow(v3,gamma)
P_expansion = []
for v in V_expansion:
P_expansion.append(constant/pow(v,gamma))
#State 4
v4 = v1
#p4*v4^gamma = p3*v3^gamma
p4 = (p3*pow(v3,gamma))/(pow(v4,gamma))
#p4*v4/t4 = p3*v3/t3
t4 = (p4*v4*t3)/(p3*v3)
#Plotting
plt.plot([v2,v3],[p2,p3])
plt.plot(V_compresssion,P_compression)
plt.plot(V_expansion,P_expansion)
plt.plot([v4,v1],[p4,p1])
#Title for the plot
plt.title('cycle')
#Labelling of X axis
plt.xlabel('Volume')
#Labelling of Y axis
plt.ylabel('Temperature')
#Marking the 4 points
plt.text(v1,p1,'1')
plt.text(v2,p2,'2')
plt.text(v3,p3,'3')
plt.text(v4,p4,'4')
#Plot is saved in the current folder
plt.savefig('Otto cycle')
plt.show()
#Efficiency of the cycle
eff = 1-((t4-t1)/(t3-t2))
print(eff)
EXPLANATION:
- I have imported the math library and plot library for necessary plotting and calculations.
- Then I have defined a function as engine in which the inputs will be bore, stroke, connecting rod, compression ratio, start crank angle, end crank angle.
- Then i have given the geometric parameters of the piston.
- Then according to the formula i have calculated the swept volume and clearance volume.
- I have given two variables as sc and ec which are start crank angle and end crank angle in degree respectively.
- Then I have defined the dtheta also created an empty array as V.
- Then I have used a for loop according to the formula for the calculation of Volume.
- This is the end of the function engine which returns the value of V.
- Now for the main code by using gas laws and other equations i have calculated the pressure temperature and volume at state 1, state 2, state 3, state 4.
- By using plot command i have joined the 4 state point and saved the PV plot.
6.OUTPUT:
PLOT:
Efficiency:
7.ERRORS AND DEBUGGING: I got a different plot when I made mistakes in formula.
8.CONCLUSION: From these program i got the PV diagram as output also the efficiency of the cycle. When I put different values of pressure, temperature, compression ratio , I get different PV diagram and different efficiency.