Project

Air Standard Cylce

Objective

To solve an otto cycle and make plots for it.

To create a code for PV diagram

To calculate the thermal efficiency of the mal Engine

\"PV

\"\"\"
	otto cycle simulator
\"\"\"

import math
import matplotlib.pyplot as plt

def Engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
	\"\"\"
	Engine Kinematics

	\"\"\"

	import math

	# Geometric parameters

	a=stroke/2
	R=con_rod/a

	# voolume 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 = 100

	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


# inputs
pressure_1=101325
temperaure_1=500
gamma=1.4

# Geometric parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr=8
temperaure_3=2300

# Volume Computation
swept_vol=(math.pi/4)*pow(bore,2)*stroke
clearence_vol=swept_vol/(cr-1)
vol_1=swept_vol+clearence_vol

# state point 2
vol_2=clearence_vol

# p2v2*gamma=p1v1^gamma
pressure_2=pressure_1*pow(vol_1,gamma)/pow(vol_2,gamma)

#p2v2/t2=p1v1/t1 | rhs=p1v1/t1

rhs=pressure_1*vol_1/temperaure_1
temperaure_2=pressure_2*vol_2/rhs
V_compression = Engine_kinematics(bore, stroke, con_rod, cr, 180,0)
constant = pressure_1*pow(vol_1,gamma)

P_compression =[]

for v in V_compression:
	P_compression.append(constant/pow(v,gamma))


# state point 3
vol_3=vol_2

#p3v3/t3=p2v2/t2 ||

rhs=pressure_2*vol_2/temperaure_2
pressure_3=rhs*temperaure_3/vol_3

# Expansion Proces
V_expansion = Engine_kinematics(bore, stroke, con_rod, cr, 0,180)
constant = pressure_3*pow(vol_3,gamma)

P_expansion =[]

for v in V_expansion:
	P_expansion.append(constant/pow(v,gamma))

# state point 4
vol_4=vol_1

#p4v4
pressure_4=pressure_3*pow(vol_3,gamma)/pow(vol_4,gamma)

# p4v4
temperaure_4=pressure_4*vol_4/rhs

k=(gamma-1)
Thermal_efficiency=1-(1/pow(cr,k))
print(Thermal_efficiency)

plt.plot([vol_2,vol_3],[pressure_2,pressure_3])
plt.plot(V_compression, P_compression)
plt.plot(V_expansion, P_expansion )
plt.plot([vol_4,vol_1],[pressure_4,pressure_1])
plt.show()


*** Solution****
0.5647247183519379



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.