Project

Air Standard cycle

Aim:

To write a program in Python to plot an otto cycle and calculate its thermal efficiency.

Objective:

  • To solve the different state variables of otto cycle.
  • To plot a P-V diagram.
  • To calculate the thermal efficiency of an otto cycle.

Theory:

An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines.

The processes are described as:

  • Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
  • Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from bottom dead centre (BDC) to top dead centre (TDC).
  • Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead centre. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
  • Process 3–4 is an adiabatic (isentropic) expansion (power stroke).
  • Process 4–1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead centre.
  • Process 1–0 the mass of air is released to the atmosphere in a constant pressure process.

Governing equations:

  • Compression ratio : Vs+Vc/Vc

Where Vs=swept volume=(pi/4)*d^2*L

Where d=bore

L=stroke

Vc=clearance volume

  • Volume change inside the cylinder due to various processes :
  • For isoentropic process, P*V^gamma=constant.
  • Thermal efficiency of otto cycle=1-(1/cr^(gamma-1))

where cr=compression ratio=12 (assumed)

gamma=specific heat of air=1.4

Assumptions:

  • The initial pressure P1 and temperature T1 is assumed to be 101325 pascal and 500 kelvin.
  • The maximum temperature inside the engine cylinder. T3 is assumed to be 2300 kelvin.

Code:

# Otto cycle simulator
# By : Anubrat Padhee

# Importing math library
import math

# Importing mathplotlib library
import matplotlib.pyplot as plt

#inputs

# Pressure at state point 1 unit-pascal
p1=101325
# Tempearture at state point unit-Kelvin
t1=500
# Specific heat for air
gamma=1.4
# Temperature at state point 3 unit-Kelvin
t3=2300

# Engine geometric parameters
bore=0.1 # unit-metre
stroke=0.1 # unit-metre
con_rod=0.15 # unit-metre
c_r=12 # Compression ratio

# Volume computation

# Swept volume
v_s=(math.pi)/4*pow(bore,2)*stroke
# Clearance volume
v_c=v_s/(c_r-1)

def engine_kinematics(bore,stroke,con_rod,start_crank,end_crank):
		# Crank pin radius
		a=stroke/2

		# Crank radius
		R=con_rod/a

		# Swept volume
		v_s=(math.pi)/4*pow(bore,2)*stroke
		# Clearance volume
		v_c=v_s/(c_r-1)

		# Starting crank angle
		sc=math.radians(start_crank)
		# Ending crank angle
		ec=math.radians(end_crank)

		num_values=50

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

		v=[]

		for i in range(num_values):
			theta=(sc+i*dtheta)
			# Function for how volume changes inside a engine cylinder
			term_1=0.5*(c_r-1)
			term_2=R+1-math.cos(theta)
			term_3=pow(R,2)-pow(math.sin(theta),2)
			term_3=pow(term_3,0.5)

			v.append((1+term_1*(term_2-term_3))*v_c)
		return v

# Volume at state point 1
v1=v_s+v_c

# State point 2

v2=v_c

# Pressure at state point 2
#p2*v2^gamma=p1*v1^gamma
p2=(p1*pow(v1,gamma))/pow(v2,gamma)

# Temperature at state point 2
#p1*v1/t1=p2*v2/t2
rhs=(p1*v1)/t1
t2=(p2*v2)/rhs
v_compression=engine_kinematics(bore,stroke,con_rod,180,0)
const=p1*pow(v1,gamma)
p_compression=[]
for V in v_compression:
	p_compression.append(const/pow(V,gamma))

# State point 3

v3=v2

# Pressure at point 3
p3=(p2*v2*t3)/(v3*t2)

v_expansion=engine_kinematics(bore,stroke,con_rod,0,180)
const=p3*pow(v3,gamma)
p_expansion=[]
for V in v_expansion:
	p_expansion.append(const/pow(V,gamma))

# State point 4

v4=v1

# Pressure at state point 4
# p4*v4^gamma=p3*v3^gamma
p4=(p3*pow(v3,gamma))/pow(v4,gamma)

# Temperature at state point 4
t4=(p4*v4)/rhs

#Calculating thermal efficiency of otto cycle
therm_eff=(1-1/pow(c_r,(gamma-1)))*100
print("The thermal efficiency of the given otto cycle is ",therm_eff)

#plotting 
plt.figure()
plt.xlabel("V")
plt.ylabel("P")
plt.title("P-V diagram for otto cycle")
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.show()

Procedure:

  1. Importing libraries
  2. Defining thermodyanamic properties.
  3. Defining engine geometroc parameters.
  4. Pressure & Temperature at state 1.
  5. Calculating swept volume and clearance volume.
  6. Calculating themodynamic propert at state 1.
  7. Calling the function to determine various points between state1 & 2
  8. Calculating properties at state 2.
  9. Properties at third state 3.
  10. Calling the function to determine various points between state3 & 4.
  11. Properties at state 4.
  12. Plotting the points and lines.
  13. Calculating thermal efficiency.
  14. Then writing a fuction as shown below fuction and then using it in main program and calcute and plot the pv diagram.

Output:

P-V Diagram of otto cycle:

Thermal efficiency of otto cycle:

Conclusion:

Thus we plotted the P-V diagram from the given assumed information and the thermal efficiency was found to be 62.989 %

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.