Week 2 Air standard Cycle
AIM: To write code that can solve an otto cycle and make plots for it.
OBJECTIVE:
- To write a program to plot PV- diagram of an Otto cycle.
- To calculate the thermal efficiency of the otto cycle.
INTRODUCTION:
Otto cycle is a gas power cycle that is used in spark-ignition internal combustion engines (modern petrol engines).
An Otto cycle consists of four processes:
Two isentropic (reversible adiabatic) processes
Two isochoric (constant volume) processes
In the above diagrams,
p - Pressure
V - Volume
T - Temperature
s - Entropy
Vc - Clearance Volume
Vs - Swept Volume
Processes in Otto Cycle:
- Process 1-2: Isentropic compression
- Process 2-3: Constant Volume Heat Addition
- Process 3-4: Isentropic expansion
- Process 4-1: Constant Volume Heat Rejection
Some of the engine geometric parameters that are needed to start with the calculations are:
- Bore=0.1
- Stroke=0.1
- Connecting rod length=0.15
- Compression ratio(cr)=8
GOVERNING EQUATIONS:
- Swept volume(Vs)=(pi/4)*bore^2*stroke
- Clearance volume(Vc) = Vs /(cr-1)
- v=(1+0.5(cr-1)*[R+1-cos(theta)-(R^2-sin(theta)^2)^0.5])* Vc.
Here R=connecting rod length/2
- For an isentropic process,
`(p*v)^γ =c`
Here, p=pressure at a particular point.
V=volume at a particular point.
- Idea gas equation
`(p*v)/t=c`
Here t= temperature at a particular point.
- Thermal efficiency of otto cycle:
`η=1-1/(cr)^(γ-1)`
BODY OF THE CONTENT:
Code for otto cycle:
# Air standard cycle(Otto cycle)
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore,stroke,con_rod,cr,start_angle,end_angle):
a=stroke/2
R=con_rod/a
s_a=math.radians(start_angle)
e_a=math.radians(end_angle)
num_values=50
dtheta=(e_a-s_a)/(num_values-1)
V=[]
for i in range(0,num_values):
theta=s_a+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_temp=(1+term1*(term2-term3))*v_c
V.append(V_temp)
return V
#inputs
P1=101325
T1=500
gamma=1.4
T3=2300
#geometric parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr=8
#Volume computation , here swept volume(v_s) and clearence volume(v_c)
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
#state variable at state 1
V1=v_s+v_c
#state variable at state 2
V2=v_c
P2=P1*pow(cr,gamma)
T2=P2*V2*T1/(P1*V1)
constant_c=P1*pow(V1,gamma)
v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0)
p_compression=[]
for v in v_compression:
p=constant_c/pow(v,gamma)
p_compression.append(p)
#state variable at state 3
V3=V2 #constant volume
P3=P2*T3/T2 #P2*V2/T2=P3*V3/T3(ideal gas equation)
constant_c=P3*pow(V3,gamma)
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180)
p_expansion=[]
for v in v_expansion:
p=constant_c/pow(v,gamma)
p_expansion.append(p)
#state variable at state 4
V4=V1
P4=P3/pow(cr,gamma) #as P3*(V3^gamma)=P4*(V4^gamma)
#Efficiency of otto cycle
efficiency=(1-(1/pow(cr,(gamma-1))))*100
print('Thermal efficiency=',efficiency)
plt.plot(V1,P1,'bo')
plt.plot(V2,P2,'bo')
plt.plot(V3,P3,'bo')
plt.plot(V4,P4,'bo')
plt.plot(v_compression,p_compression,'g')
plt.plot([V2,V3],[P2,P3],'g')
plt.plot(v_expansion,p_expansion,'g')
plt.plot([V4,V1],[P4,P1],'g')
plt.xlabel('Volume(V)')
plt.ylabel('Pressure(P)')
plt.title('P-V Diagram')
plt.savefig('P_V Diagram')
plt.show
EXPLANATION:
- The first thing we do is to import the math module and the matplotlib library.
- Further we define a function which takes the values of bore,stroke,con_rod,cr,start_angle,end_angle and calculates 'V' and returns its value whenever we call it.
- Further we assume the inlet pressure(P1),temperature(T1),gamma and tempertaure at point 3 (T3) as these are not stated.
- Further we define the geometric parameters bore,stroke,con_rod,cr.
- Using the geometric parameters we calculate v_s and using v_s we calculate v_c.
- Using v_s and v_c we calculate V1.
- As we know that 1-2 is isentropic compression process,P2 can be calculated and V2 is the clearence volume.T2 can be calculated by applying gas law on state 1 and state2.
- Now for finding the volume in between state1 and state 2,the function is used so when we call the function we get the different values of V_compresssion and as the for loop functions each time it takes the value of v_compression and stores it in v , this v helps us to calculate p and stores the value in p_compression.
- During this process storke angle changes from 180 to 0 degrees.
- These values of v_compression and p_compresssion are used while joining the state point1 and state point 2.
- In process 2-3 volume remains constant .Therefore V2=V3.
- Also by applying gas law at state point 2 and 3 ,P3 can be calculated.
- In process 3-4, as it is isentropoic expansion process P4 can be calculated from the relation and V4=V1.
- The values of pressure for expansion between state point 3 and state point 4 can be calculated in the similar manner as we calculated for the p_compression.But this time the stroke angle changes from 0 to 180 degrees.
- The process 4-1 is constant volume heat rejection, so here V4=V1.
- Now we know all the properties at state points 1,2,3,4 and also in between the states.So the plots can now be created by using the plot command.
- The efficiency can be calculated using the relation between gamma and compression ratio.
OUTPUT:
1) P-V Diagram
2)Thermal Efficiency
Conclusion:
Therefore the PV diagram is plotted using the program and the efficiency is calculated as well.