Project

Python Program To Calculate Air Standard Cycle

AIM: Python program code to solve the ottp cycle and create PV diagram and plot the graph for thermal efficiency output of the engine.

CODE:

"""
 Otto Cycle
"""

import math
import matplotlib.pyplot as plt

#engine kinematics

def engine_kinematics(bore,stroke,con_rod,cr,start_a,end_a):
	#geometric parameters
	a=stroke/2
	r=con_rod/a

	#volume calculations
	s_v = math.pi*(1/4)*pow(bore,2)*stroke
	c_v = s_v/(cr-1)

	sc=math.radians(start_a)
	ec=math.radians(end_a)

	tot_values=50

	dtheta=(ec-sc)/(tot_values-1)

	v=[]
	
	for i in range(0,tot_values):
		theta=sc+i*dtheta
		term1=0.5*(cr-1)
		term2=r+1-math.cos(theta)
		term3=pow((pow(r,2)-pow(math.sin(theta),2)),0.5)
		v.append((1+term1*(term2-term3))*c_v)

	return v	


#inputs
p1=101325
t1=500
gama=1.4
t3=2300

#geometric parameters
bore = 0.2
stroke = 0.15
con_rod = 0.15
cr = 8

#volume calculations
s_v = (math.pi/4)*pow(bore,2)*stroke
c_v = s_v/(cr-1)
v1 = s_v+c_v

#calculations of state points
#state point 2
v2=c_v
p2=p1*pow(v1,gama)/pow(v2,gama)   #p2v2^gama=p1v1^gama
const=p1*v1/t1    #p2v2/t2=p1v1/t1
t2=p2*v2/const

v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant=p1*pow(v1,gama)
p_compression=[]
for v in v_compression:
	p_compression.append(constant/pow(v,gama))


#state point 3
v3=v2
const=p2*v2/t2  #p3v3/t3=p2v2/t2
p3=const*t3/v3

v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant=p3*pow(v3,gama)
p_expansion=[]
for v in v_expansion:
	p_expansion.append(constant/pow(v,gama))


#state point 4
v4=v1
p4=p3*pow(v3,gama)/pow(v4,gama)  #p4v4^gama=p3v3^gama
t4=p4*v4/const   #p4v4/t4=const

#plotting of p-v diagram
plt.plot(v_compression,p_compression)
plt.plot([v2,v3],[p2,p3])
plt.plot(v_expansion,p_expansion)
plt.plot([v4,v1],[p4,p1])
plt.xlabel('Volume')
plt.ylabel('Pressure')
plt.show()

#Thermal efficiency calculation
ct=gama-1
thermal_eff=1-pow(1/cr,ct)
print(thermal_eff)

OUTPUT GRAPH of AIR STANDARD CYCLE

Thermal Efficiency of Engine = 0.564

REPORT:

Initially get the values of engine geometric parameters and state variables. Calculation of Swept volume and clearance volume.

Find state Variables at each point.

Plot the state variables and values of volume and pressure changing during compression and expansion.

Calculate the thermal efficiency.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.