Week 2 Air standard Cycle
AIM: To write a Python code that plots an otto cycle and calculates the thermal efficiency.
BASICS OF THERMODYNAMIC PROCESSES AND THEIR EQUATIONS:
- Isentropic Process: An adiabatic and reversible process is termed as isentropic process. The equation describing an Isentropic process is `p*v^gamma=constant` ---- Eq. 1
- Ideal gas relation is `(p*v)/T=constant` ---- Eq. 2
- Efficiency of otto cycle: `eta_(th)= 1-1/(r^gamma-a)`
INPUTS REQUIRED:
- Engine geometry
- Bore
- Stroke Length
- Length of connecting rod
- Initial Pressure and Temperature
- Temperature immediately after combustion
- Compression Ratio
- Value of Gamma (ratio of specific heats)
OTTO CYCLE: It is an idealized thermodynamic cycle that describes the functioning of a typical Spark Ignition (SI) engine.
REQUIRED FORMULAE:
- Swept volume (`v_s`)= `pi/4 * d^2 * l`
- Clearance volume (`v_c`)= `v_s/(r-1`
- Variation of volume inside the cylinder with crank angle
`v/v_s= 1+1/2 (r-1)[R+1-cos theta-(R^2-sin^2theta)^(1/2)]`
The Otto cycle comprises of four processes:
- Isentropic compression (1-2)
- Constant volume heat addition (2-3)
- Isentropic expansion (3-4)
- Constant volume heat rejection (4-1)
Fig. 1 Ideal otto cycle
The thermodynamic changes occurring throughout the cycle are:
- Isentropic compression process (1-2)
The charge is compressed in an adiabatic and reversible process (isentropic).
The state properties undergo change according to the equation 1.
Hence pressure at state to is calculated as `p_2= p_1* (v_2/v_1)^gamma` The temperature is calculated using the equation `T_2= T_1*(p_2/p_1).(v_2/v_1)` - Constant volume heat addition process (2-3)
Compressed charge is heated at constant volume. Temperature at the state point 3 is known to us. Hence the equation 1 is made used to determine the pressure at state point 3 as `T_3= T_2*(p_3/p_2)`. - Isentropic expansion process (3-4)
The heated charge is allowed to expand isentropically and the properties state point 4 are found using the equations 1 and 2 by substituting respective values. - Constant volume heat rejection process (4-1)
The charge is cooled at constant volume which results in a pressure drop.
Using the above equations we determine the properties at all the state points.
CODE:
import math
import matplotlib.pyplot as plt
#Function to incorporate engine kinematics and calculate the pressure corresponding to the volume
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
#Calculating volume
V_s=math.pi*(1/4)*pow(bore,2)*stroke
V_c=V_s/(cr-1)
start_angle=math.radians(start_crank)
end_angle=math.radians(end_crank)
#Connecting rod geometry
a=stroke/2
R=con_rod/a
num_values=100 #Number of divisions
dtheta=(end_angle-start_angle)/(num_values-1)
V=[]
for i in range(0,num_values):
theta=start_angle+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
#Kmown primitives
p1=101325
t1=500
gamma=1.4
t3=2300
#Engine geometry
bore=0.1
stroke=0.1
con_rod=0.15
cr=8
#Calculating the volume
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
v1=v_c+v_s
#state point 2
v2=v_c
p2=p1*pow(v1,gamma)/pow(v2,gamma)
t2=(p2*v2)/(p1*v1/t1)
V_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant=p1*pow(v1,gamma)
P_compression=[]
for v in V_compression:
P_compression.append(constant/pow(v,gamma))
#state point 3
v3=v2
#p3v3/t3=p2v2/t2|rhs=p2v2/t2|p3=rhs*t3/v3
p3=(p2*v2/t2)*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:
P_expansion.append(constant/pow(v,gamma))
#state point 4
v4=v1
p4=p3*pow(v3,gamma)/pow(v4,gamma)
t4=(p4*v4/(p3*v3))*t3
#Plotting the results
plt.plot([v2,v3],[p2,p3],color='blue')
plt.plot(V_compression,P_compression,color='blue')
plt.plot(V_expansion,P_expansion,color='blue')
plt.plot([v4,v1],[p4,p1])
plt.xlabel('Volume (m^3)')
plt.ylabel('Pressure (Pa)')
plt.title('P-V diagram of otto cycle')
#Thermal efficiency
Thermal_efficiency=(1-(1/(pow(cr,gamma-1))))*100
print('Thermal efficiency of this cycle is:',Thermal_efficiency,'%')
EXPLAINATION OF CODE:
- All known variables (Pressure(s), Temperature(s), adiabatic index, engine geometry) have to be defined and assigned
- The swept and clearance volumes have to be calculated
- The properties at all state points have to be calculated using respective formulae
- The corrected volume has to be calculated based on the formulae decsribed. This has been written as a function named engine_kinematics. This function is called an an array of volumes for different crank angles at 1 degree. This volume vector is used to calculate the corresponding pressure.
- The plot commands have to be used in order to visualize the graph
- The equation to calculate the thermal efficiency has to be calculated and the same has to be displayed.
OUTPUT:
- Plot of the otto cycle
RESULTS:
- The otto cycle was plotted
- The thermal efficiency of the otto cycle was calculated to be 56.472471835193794 %
NOMENCLATURE:
p- pressure
v- volume
T- Temperature
`eta_(th)`- Thermal efficiency
r- Compression Ratio
R- Ratio of length of connecting rod to crank pin radius
`theta`- Crank angle