Project

otto cycle simulation by using python

Aim: To write a program for otto cycle and state points of pressure and volume change.

Introduction: an otto cycle is basic cycle of thermerodunamic cycle which tells spark ignition piston engine, the cycle tells what undergo in combustion chamber such as pressure, tempeature, volume, heat addition and heat rejection for mass of gas(air fule mixture).

the following equation gives the relationship between the crank angle and volume in combustion chamber.

where

Vc= clerence volume.

rc= compression ratio.

R= constant

for creating the exact plot we define a function called engine kinematics, which calculates the exact plot of pressure and volumae with respect to crank rotation in compression and expansion stroke.

Program

following input values were taken

bore=0.1m

storke=0.1m

connecting rod=con_rod=0.15m

compression ratio=cr=8

gamma=1.4

crank pin=a=storke/2

# curve graph for otto cycle
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore, storke, con_rod, cr, start_crank, end_crank):
	a= storke/2
	R= con_rod/a
	v_s=(math.pi/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

p1=101325
t1=500
stroke=0.1
bore=0.1
con_rod=0.15
cr=8
gamma=1.4
t3=2300
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
# at point1
v1=v_s+v_c

# at point2
v2=v_c
p2=p1*pow(v1,gamma)/pow(v2,gamma)
rhs2=p1*v1/t1
t2=p2*v2/rhs2
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))

# at point3
v3=v2
rhs3=p2*v2/t2
p3=rhs3*t3/v3
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))
# at point4
v4=v1
p4=p3*pow(v3,gamma)/pow(v4,gamma)
t4=p4*v4/rhs2
thermal_efficency=1-(1/(pow(cr,gamma)-1))
print(thermal_efficency)

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('voulme')
plt.ylabel('pressure')
plt.show()

Expalination

1] intially the function command is defined(def) so the defined values can used at any time in the program.

2] to get cure at compression and expansion process, above shown volume eqution is used.

3] for loop is created to define the number of values between compression and expansion process.

4] after calculating the volume at each crank angle to get output graph return command is used.

5] finally the thermal effieciency of otto cycle is found using equation for given input values.

output

thermal efficency= 0.94=94%

conculsion:

the program to extract pv diagram for otto cycle and thermal efficency is done sucessfully.

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.