Challenge

Week 2 Air standard Cycle

AIM -

Creating a PV diagram and finding output the thermal efficiency of the engine.

code -

import math
import matplotlib.pyplot as plt

# defining bore, stroke,connecting rode length (con_rod), compression ratio (cr), starting (start_crank) & ending (end_crank) of crank
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):

    a = stroke/2                                                  # a = crank pin radius
    R = con_rod/a                                                 # R = constant

    v_s = math.pi* (1/4) * pow(bore,2) * stroke                  # v_s = swept volume
    v_c = v_s/(cr-1)                                            # v_c = clearance volume

    sc = math.radians(start_crank)                             # sc = start crank angle in radians
    ec = math.radians(end_crank)                                # ec = end crank angle in radians

    num_values = 50

    dtheta = (ec - sc)/(num_values-1)                                    # calculating equal 50  intervals between sc & ec 

    V = []

    for i in range(0,num_values):
        theta = sc + i * dtheta                                           # to find volume trace equation sliptted to 3 terms
        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)                      # equation to find volume trace to finish otto cycle graph

    return V

p1 = 101325
t1 = 500
g = 1.4
t3 = 2300

# engine geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.5                                                                # con_rod = connecting rod length
cr = 12                                                                      # cr = compression ratio

v_s = (math.pi/4) * pow(bore,2) * stroke
v_c = v_s/(cr-1)
v1 = v_c + v_s

v2 = v_c                                                                     # state point 2

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

# p1v1/t1 = p2v2/t2   
rhs = p1 * v1/t1
t2 = p2 * v2/rhs
V_comp = engine_kinematics(bore, stroke, con_rod, cr, 180, 0)

constant = p1 * pow(v1,g)

P_comp = []


for V in V_comp:
    P_comp.append(constant/pow(V,g))

v3 = v2                                                                      # state point 3

# p3v3/t3 = p2v2/t2
rhs = p2 * v2/t2
p3 = rhs * t3/v3

V_exp = engine_kinematics(bore, stroke, con_rod, cr, 0, 180)

constant = p3 * pow(v3,g)
    
P_exp = []

    
for V in V_exp:
    P_exp.append(constant/pow(V,g))

v4 = v1                                                 # state point 4

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

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

t_eff = 1 -(1/pow(cr,(g-1)))                            # themal efficiency
print(t_eff)

plt.plot([v2,v3],[p2,p3])
plt.plot(V_comp, P_comp)
plt.plot(V_exp, P_exp)
plt.plot([v4,v1],[p4,p1])
plt.show()

answer -

thermal effeciency obtained = 0.6298

conclusion - an otto cycle consists of 0 - 1 = constant pressure (air sucked)

1 - 2 = adiabatic compression (TDC to BDC)

2 - 3 = constant volume heat transfer ( at TDC before combustion)

3 - 4 = adiabatic expansion ( power stroke )

4 - 1 = constant volume heat rejection ( at BDC)

1 - 0 = constant pressure process (air released)

imported math & matplotlib.pyplot modules into the program.

then defined bore, stroke,connecting rode length (con_rod), compression ratio (cr), starting (start_crank) & ending (end_crank) of crank. then assingned the values of crank pin radius (a) & R.
then assigned the values of swept volume (v_s) & clearance volume (v_c)
where v_s = pi * (1/4) * bore^2 * stroke & v_c = v_s / (cr-1)
converting start and end crank angles into radians sc & ec respectively. then providing number of interval (num_values) 50 to be taken between sc & ec . to take intervals equally seperated (ec - sc)/(num_values-1)
an empty array for volume (v) is created.
for loop is created to find the value of v at different angles
equation to find the trace volume v = v_c * (1 + (1/2)(cr-1)[R + 1 - cos (theeta) - (R^2 - sin^2 (theeta)^0.5]
this equation is divided into term1, term2, term3 for easyness in calculation & programming.
then using append function every values of v calculated for different theeta angle is created and using return function it is returned to empty array of v .
then inputs like p1, t1, t3, g, bore, stroke, con_rod, cr ae given
volume at state point 1 will be v_s + v_c
at state point 2 volume (v2) = v_c &
pressur (p2) can be obtained using p2v2^g = p1v1^g
temperature (t2) can be obtained from p1v1/t1 = p2v2/t2
then finding compression volume (V_comp) by defining the variables also providing start_crank = 180 & end_crank = 0
then calculating a constant with p1 * v1^g
then creating an empty array for pressure in compression P_comp
and a for loop is created to find P_comp for differnt values of V in V_comp
then using append function the values stored one after another to the empty array of P_comp.
at state point 3 volume (v3) = v2
pressure (p3) can be obtained using p3v3/t3 = p2v2/t2
then finding expansion volume (V_exp) by defining the variables also providing start_crank = 0 & end_crank = 180
then calculating a constant with p3 * v3^g
then creating an empty array for pressure in compression P_exp
and a for loop is created to find P_exp for differnt values of V in V_exp
then using append function the values stored one after another to the empty array of P_exp.
at state point 4 volume (v4) = v1
pressure (p4) can be obtained using p4v4^g = p3v3^g
temperature (t4) using p4v4/t4 = p1v1/t1
to find thermal efficiency (t_eff) = 1 -(1/(cr^(g-1))) is used.
since it is a otto cycle plot the graph it requires 4 sets of variables
first is cycle graph is plotted betwen [v2,v3],[p2,p3]
for second cycle V_comp, P_comp
3rd V_exp, P_exp
4th [v4,v1],[p4,p1]
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.