Challenge

Air standard Cycle

Air standard Cycle

Aim:

To write a code for otto cycle and create PV plot and also to find out thermal efficiency of the engine.

Objectives:

  1. To create a PV diagram
  2. To find out thermal efficiency of the engine

Assumption:

Gamma=1.4

P1=101325Pa

T1=400K

T3=2500K

Bore diameter=0.1m

Stroke=0.1m

Compression ratio(cr)=5

Connecting rod length=0.15m

Formulas used:

Solution procedure:

  1. To assume all input parameters such as pressure, temperature, stroke and bore diameter etc
  2. Calculate pressure and temperature at different stages
  3. Plot the PV diagram
  4. Find out Thermal efficiency

code:

# otto cycle simulator
# by Abhishek Savakar
from math import *
from matplotlib.pyplot import *


def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
    # geometric parameters

    a = stroke / 2
    R = con_rod / a

    # volume parameters
    v_s = (pi / 4) * pow(bore, 2) * stroke
    v_c = v_s / (cr - 1)

    theta = radians(180)
    sc = radians(start_crank)
    ec = 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 - cos(theta)
        term3 = pow(R, 2) - pow(sin(theta), 2)
        term3 = pow(term3, 0.5)
        v.append((1 + term1 * (term2 - term3)) * v_c)

    return v


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

# geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 5

# volume computation
v_s = (pi / 4) * pow(bore, 2) * stroke
v_c = v_s / (cr - 1)
v1 = v_c + v_s

# state point 2
v2 = v_c

# p2v2^gama=p1v1^gama
p2 = p1 * pow(v1, gama) / pow(v2, gama)

# p2v2/t2 = p1v1/t1  | rhs=p1v1/t2  | t2= p2v2/rhs
rhs = p1 * v1 / t1
t2 = p2 * v2 / rhs
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))

# print(p_compression)

# state point 3
v3 = v2

# p3v3/t3=p2v2/t2   |rhs = p2v2/t2   | p3= rhs*t3/v3

rhs = p2 * v2 / t2
p3 = rhs * 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

# p4v4^gama=p3v3^gama
p4 = p3 * pow(v3, gama) / pow(v4, gama)

# p4v4/t4=rhs
t4 = p4 * v4 / rhs

# thermal efficiency
thermal_eff = 1 - 1 / pow(cr, (gama - 1))
print('\nThermal Efficiency:', thermal_eff * 100, "%")

# plotting pv diagram
plot([v2, v3], [p2, p3])
plot(v_compression, p_compression)
plot(v_expansion, p_expansion)
xlabel("volume")
ylabel("Pressure")
plot([v4, v1], [p4, p1])
show()

Output screen:

Code explanation:

  1. Importing math module and matplotlib.pyplot module.
  2. Assume input parameters.
  3. Volume i.e vc and vs computation.
  4. Calculating pressure and temperature at various stages.
  5. Call the engine kinematics function for compression and expansion which will return v.
  6. Plot PV diagram using all volumes and pressures calculated.
  7. Find out thermal efficiency.

PV Diagram:

Results:

We have successfully plotted the PV diagram.

The thermal of engine was calculated to be= 47.46944391192465 %

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.