Week 2 Air standard Cycle
AIM:
To code a pyton program to plot a otto cycle according to the given parameter values.
PROBLEM STATEMENT:
Otto cycle represents the processes that occur in a spark ignition engine. It is a cycle that primarily consists of four main state points and repeats the cycle by repeating through those four points. It runs on the following processes:
1-2: follows an isentropic combustion process
2-3: follows a isochoric heat addition process
3-4: follows an isentropic expansion (power stroke).
Process 4–1 completes the cycle by a constant-volume process in which heat is rejected
The thermodynamic relations followed during the processes are:
isentropic:
P1V1^gamma = P2^gamma
isochoric:
P1/T1 = P2/T2
By following these relations, we calculate the state variables at the different state points.
# program to create an otto cycle simulator
import math
import matplotlib.pyplot as plt
# defining a function to calculate the intermediate volume during compression and expansion
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
#geomatric paramters
a = stroke/2
R = con_rod/a
#volumetric parameters
V_s = math.pi*(1/4)*pow(bore,2)*stroke
V_c = V_s/(cr-1)
sc = math.radians(start_crank)
ec = math.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 -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
# general inputs
gamma = 1.4
t3 =2300
# inputs for state 1
p1 = 101325
t1 = 500
# inputs on engine parameters
bore = 0.1
stroke = 0.1
conn_rod = 0.15
cr = 12
# calculating clearance volume and swept volume
vs = stroke*(math.pi*pow(bore,2))/4
vc = vs/(cr-1)
v1 = vs+vc
# state variables at state point 2
v2 = vc
# p1v1/t1 = p2v2/t2 | t2 = p2*v2*t1/(p1v1)
t2 = t1*pow(cr,gamma-1)
# p2v2^gamma = p1v1^gamma
# p2 = p1*(v1/v2)^gamma = p1*cr^gamma
p2 = p1*pow(cr,gamma)
# creating the pressure and volume cordinates during compression
v_comp = engine_kinematics(bore, stroke, conn_rod, cr, 180, 0)
# p_comp*v_comp^gamma = constant
constant = p1*pow(v1,gamma)
p_comp = []
for v in v_comp:
p_comp.append(constant/pow(v,gamma))
# state variables at state point 3
v3 = v2
# p3v3/t3 = p2v2/t2 | p3 = p2*t3/t2
p3 = p2*t3/t2
# creating the pressure and volume cordinates during expansion
v_exp = engine_kinematics(bore, stroke, conn_rod, cr, 0, 180)
# p_comp*v_comp^gamma = constant
constant = p3*pow(v3,gamma)
p_exp = []
for v in v_exp:
p_exp.append(constant/pow(v,gamma))
# state variables at state point 4
v4 = v1
# p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)
# t4/t3 = (v3/v4)^(gamma-1)
p4 = p3*pow((v3/v4),gamma)
t4 = t3*pow((1/cr),(gamma-1))
# thermal efficiency
Thermalefficiency = 1-(1/pow((cr-1),(gamma-1)))
# plotting
plt.plot([v2,v3],[p2,p3])
plt.plot(v_comp,p_comp)
plt.plot([v4,v1],[p4,p1])
plt.plot(v_exp,p_exp)
plt.xlabel("volume")
plt.ylabel("pressure")
plt.title("P-V diagram")
plt.show()
print("theremal effieciency = %d",Thermalefficiency)
PROCEDURE AND EXPLANATION:
- First, we import the neccesary modules required for our code.Then, we define the values of all the input values required for our calculation.
- Then, we calculate the values of v1(volume at state point 1) and v2(volume at state point 2) by calculating swept volume and clearance volume. Then, we find the values of all the required state variables at the required four points, using the different thermodynamic relations that are suitable for the process.
- After finding the cordinates for the points, we now join them. For joining of state point 2-3 and 4-1, a simple straight line will do the job, as they are isochoric processes. But to join the the other two points, we have to find the pressure and volume cordinates throught the corresponding process.
- To plot an otto cycle, we first have to locate all the four state points of the cycle. We can find all cordinates of all the four state points with the help of the given data and using them according to the mathematic relations of the thermodynamic processes followed in each step.
- the variation of volume and crank angle is not a linear relationship. it actually varies with respect to the following equation:
V = 1 + 0.5*(cr-1)*(R + 1 - cosd(theta)-(R^2 - sind(theta).^2).^0.5))*v_c
- We define a function such that it returns an array containing the values of the instantenous volumes at the specified angle of crank.
- Then, we call the function to get the volume values from crank angle of 180 degrees to 0 degrees during process 1-2 as compression and 0 degrees to 180 degress during process 3-4, as expansion.
- To get the corresponding values of pressure, we divide each element of the volume array by the constant value(P*V^gamma).
- Finally, after getting the values of both pressure and volume, we plot the curve with the two obtained arrays.
RESULTS:
plot:
efficiency: