Challenge

Week 2 Air standard Cycle

import math
import matplotlib.pyplot as plt
def engine_kinematices(bore,stroke,con_rod,cr,start_crank,end_crank):

    a=stroke/2
    R=con_rod/a
    #volume parameter
    vs=math.pi*(1/4)*pow(bore,2)*stroke
    vc=vs/(cr-1)
    #volume parameter
    vs=math.pi*(1/4)*pow(bore,2)*stroke
    vc=vs/(cr-1)
    sc=math.radians(start_crank)
    ec=math.radians(end_crank)
    num_values=180
    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=(1+term1*(term2-term3))*vc
        v.append(V)
    return (v)
    
# input aparameters       
bore=0.1
stroke=0.1
con_rod=0.15
cr=8
gama= 1.4
    #inputes
t1= 500
t3=2300
    #point 1
p1=101325
vs=(math.pi/4)*pow(bore,2)*stroke
vc= vs/(cr-1)
    #point 1

v1=vc+vs

    #point 2
v2=vc
    #p2v2^gama= p1v16gama
p2=p1*pow(v1,gama)/pow(v2,gama)
    # p2v2/t2= p1v1/t1 | p1v1/t1=rhs  |
rhs=p1*v1/t1
t2=p2*v2/rhs
V_compression=engine_kinematices(bore,stroke,con_rod,cr,180,0)
constant=p1*pow(v1,gama)
p_compression=[]
for v in V_compression:
    p_comp=(constant/pow(v,gama))
    p_compression.append(p_comp)

    # point 3
v3=v2
    # p3v3/t3 =p2v2/t2 | rhs =p2v2/t2
rhs =p2*v2/t2
p3=rhs*t3/v3
V_expansion=engine_kinematices(bore,stroke,con_rod,cr,0,180)
constant=p3*pow(v3,gama)
p_expansion=[]
for v in V_expansion:
    p_exp=(constant/pow(v,gama))
    p_expansion.append(p_exp)
    # point 4
v4=v1
    #p4v4^gama=p3v3^gama 
p4=p3*pow(v3,gama)/pow(v4,gama)
    #p4v4/t4= p3v3/t3 | rhs= p3v3/t3
rhs=p3*v3/t3
t4= p4*v4/rhs

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('Volume')
plt.ylabel('Pressure')
plt.show()






Engine_Kinematices


import math 
import matplotlib.pyplot as plt

# input parameters
# 
bore=0.1
stroke=0.1
con_rod=0.15
cr=12
gama= 1.4
start_crank=0
end_crank=180
#inputes
t1= 500
t3=2300

a=stroke/2
R=con_rod/a
 
#volume parameter
vs=math.pi*(1/4)*pow(bore,2)*stroke
vc=vs/(cr-1)
theta=math.radians(180)


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=(1+term1*(term2-term3))*vc
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.