Week 2 Air standard Cycle
Objective:
Problem Statement:
1. Your code should create a PV diagram
2. You should output the thermal efficiency of the engine.
Once you have done this, create a project in projects.skill-lync.com.
Solution Procedure: write a code.
the code is attached as follows: (since there is no support for tickets and my doubt to use insert code sample is not solved, in the interest of time I am copy pasting my code. I will file a ticket once I get the access to raise tickets and attend live classes to solve all the doubts)
import matplotlib.pyplot as plt
import math
# this is a Python program to to simulate otto cycle
#factors involved are as follows:
'''
p is pressure in pascals (p1, p2, p3, p4)
t is temperature in kelvin (t1, t2, t3, t4)
v_s is swept volume
v is volume at different states (v2, v2, v3, v4)
bore length, stroke length, connecting rod (con_rod) length is in meters
'''
#engine Kinematics is used to calculate the Volume applicable for various theta values
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
a = stroke/2
R = con_rod/a
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 = []
#to calculate swept volume
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(v_c * (1 + term1 * (term2 - term3)))
return V
#define inputs now at state1
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2300
#define geometric params now
bore = 0.1
stroke = 0.1
con_rod = 0.15
#cr is the ratio of total cyclindrical volume and clearance volume Vc
cr = 12
#swept volume is Vs, which is the difference between total cylindrical volume and the clearance volume
Vs = (math.pi/4) * pow(bore, 2) * stroke
Vc = Vs/(cr - 1)
v1 = Vs + Vc
v2 = Vc
p2 = p1 * (pow(v1, gamma) / (pow(v2, gamma)))
rhs = p1 * (v1 / t1)
t2 = p2 * (v2 / rhs)
#all the values of compression volume will be obtained as a def result defined earlier
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))
#ideal gas law is used to caculate the pressure at state 3
v3 = v2
rhs = p2 * (v2 / t2)
p3 = rhs * (t3 / v3)
#all the values of expansion volume will be obtained as a def result defined earlier
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))
v4 = v1
p4 = p3 * (pow(v3, gamma) / pow(v4, gamma))
t4 = t3 * pow((v3 / v4), (gamma - 1))
#to calculate the thermal efficiency of the Engine
#Thermal Efficiency = ratio of work done during the cycle to the heat supplied
Teff = 1 - ((t4 - t1) / (t3 - t2))
print("the efficiency of the otto cycle is %.2f" % (Teff*100) + "%")
#now plot the graphs
plt.plot([v2, v3], [p2, p3])
plt.plot(V_Compression, P_Compression)
plt.plot(V_Expansion, P_Expansion)
plt.plot([v4, v1], [p4, p1])
plt.xlabel("Volume im m^3--->")
plt.ylabel("Pressure in Pa---->")
plt.show()
process 1 to 2 is isentropic compression.
process 2 to 3 is constant volume heat addition.
process 3 to 4 is isentropic expansion.
process 4 to 1 is constant volume heat rejection.
Results and Discussion:
diagram is attached as below:

otto cycle efficiency is a s below:

the efficiency of the engine is 0.6298928275128468. that is 62.99% as calculated by the code formula.
the graph of the cycle is attached. the code is also attached.
'the description is given. the code is also explained.
the .py file is also attached.
the project is also created.