Week 2 Air standard Cycle
PROBLEM STATEMENT: Plot an air standard otto cycle P-V plot representing the various processes involved using python and estimate the thermal efficiency for the assumed parameters.
OBJECTIVE: To use python programming language to create an effective code which can plot the otto cycle for the given input parameters, mechanical parameters and state points and also calculate the thermal efficiency for the same.
PROCEDURE AND CODE:
The purpose of the code is to first calculate the parameters at the state points of the otto cycle. The next important purpose is to plot a perfect otto cycle for the given and ssumed parameters.Also it needs to calculate otto thermal efficiency.
mechanical parameters like bore,stroke,connecting rod length , compression ratio are taken as constant inputs.
The code is as follows. (for the entirety of problem)
import math
import matplotlib.pyplot as plt
#alloting values for various parameters of the otto cycle
bore = 0.1 #meter
stroke = 0.1 #meter
con_rod = 0.15 #meter
cr = 8 #compression ratio
a = stroke/2 #crank radius
R = con_rod/a
gamma = 1.4
v_s = (math.pi/4)*bore*bore*stroke
v_c = v_s/(cr - 1)
#entry conditions (state point 1) starting of compression
p1 = 101325 #pa
t1 = 500 #kelvin
#calculating all the state point pressure and volumes
v1 = v_s + v_c
rhs = (p1 * v1/t1)
#state point 2
p2 = p1 * (pow(cr,gamma))
v2 = v_c
#state point 3
v3=v2
t3 = 2300 #assuming max temperature of cycle is 2300 k
p3 = rhs*t3/v3
#state point 4
v4 = cr * v3
p4 = p3 * (pow(1/cr , gamma))
#executing the formula for absolute volume during compression and expansion
def parameters_calc(v_c , v_s , cr ,R , theta_start , theta_end):
num_of_angles = 100
theta = []
for i in range(0,num_of_angles):
theta.append(theta_start - i*((theta_start - theta_end)/(num_of_angles - 1)))
#calculating various volumes for the values of theta
volumes=[]
for i in theta:
term1 = 0.5 * (cr-1)
term2 = R+1 - (math.cos(math.radians(i)))
term3 = pow(((pow(R,2)) - (pow(math.sin(math.radians(i)) , 2))) , 0.5)
temp_v = (1 + (term1)*(term2 - term3))*v_c
volumes.append(temp_v)
return volumes
#creating arrays of volume for expansion and compression
exp_volumes= parameters_calc(v_c , v_s , cr ,R , 180, 0)
comp_volumes= parameters_calc(v_c , v_s , cr ,R , 0 , 180)
#creating arrays of pressure for expansion
exp_pressures = []
for vol in exp_volumes:
exp_pressures.append(p1 * pow(v1/vol , gamma))
#creating arrays of pressure for compression
comp_pressures = []
for vol in comp_volumes:
comp_pressures.append(p3 * pow(v3/vol , gamma))
#calculating thermal efficiency
thermal_effi = (1 - (1/(pow(cr,gamma-1)))) * 100
print(thermal_effi)
plt.plot(exp_volumes , exp_pressures)
plt.plot(comp_volumes , comp_pressures)
plt.plot([v1,v4],[p1,p4])
plt.plot([v2,v3],[p2,p3])
plt.show()
The various state points are calculated using the isentropic law equations and ideal gas equations. Here it is to be noted that the maximum temperature (T3) is assumed to be 2300k.
after calculating the state points, the code for calculating the points on the processes of expansion and compression is done. For this pupose we create a function which can return a list of 100 values of volumes for the process(isentropic expansion or compression) points which is later stroed in an array. The derived formula for volume at a process point is predetermined and is utilised here for the calculation.
Now array of various pressure values corresponding to the various volumes found above are calculated using 'for loop' and suitable isentropic law equations.
finally the various processes of otto cycle are plotted using 'matplotlib.pyplot' module of python.
Also thermal efficiency of the otto cycle is found using the air standard otto efficiency formula.
RESULT AND OBSERVATION:
The final plot of the otto cycle is as shown.
We can observe a smooth isentropic expansion and isentropic compression curves have been plot along with constant heat addition and heat rejection lines.Thus otto cycle has been successfully plot for the given conditions using python.
Thermal efficiency is 56.472% .