Challenge

Week 2 Air standard Cycle

Q.1)
import math
import matplotlib.pyplot as plt 
""" Engine Kinematics_otto cycle
"""
def engine_kinematics_otto(bore,con_rod,stroke,cr,start_crank,end_crank):

	#geometric parameters(meters)
	#crank pin radius=cp_rad
	cp_rad=stroke/2
	R=con_rod/cp_rad
	#swept volume=v_s
	v_s=(math.pi/4)*pow(bore,2)*stroke
	#cerance volume
	v_c=v_s/(cr-1)

	#sca=start crank angle,eca=end crank angle

	sca=math.radians(start_crank)
	eca=math.radians(end_crank)

	#num_values determines the point function of the path during compression and expansion path
	num_values=30
	dtheta=(eca-sca)/(num_values-1)

	v=[]

	for i in range(0,num_values):
		theta=sca+i*(dtheta)
		term1=0.5*(cr-1)
		term2=pow(R,2)-pow(math.sin(theta),2)
		term3 =R+1-math.cos(theta)
		term4=pow(term2,0.5)

		v.append((1+term1*(term3-term4))*v_c)
#while calculating v in set of v_expansion loop, asked the calculate value of v for each point out of 30 in compressing path
#So giving instruction that return the calculated values for (v/v_c) formula. So the append can be happened 
#with each new calculated value of v.
		return(v)

#inputs(pascal,kelvin,)
p1=101325
import math
import matplotlib.pyplot as plt 
""" Engine Kinematics_otto cycle
"""
def engine_kinematics_otto(bore,con_rod,stroke,cr,start_crank,end_crank):

	#geometric parameters(meters)
	#crank pin radius=cp_rad
	cp_rad=stroke/2
	R=con_rod/cp_rad
	#swept volume=v_s
	v_s=(math.pi/4)*pow(bore,2)*stroke
	#cerance volume
	v_c=v_s/(cr-1)

	#sca=start crank angle,eca=end crank angle

	sca=math.radians(start_crank)
	eca=math.radians(end_crank)

	#num_values determines the point function of the path during compression and expansion path
	num_values=30
	dtheta=(eca-sca)/(num_values-1)

	v=[]

	for i in range(0,num_values):
		theta=sca+i*(dtheta)
		term1=0.5*(cr-1)
		term2=pow(R,2)-pow(math.sin(theta),2)
		term3 =R+1-math.cos(theta)
		term4=pow(term2,0.5)

		v.append((1+term1*(term3-term4))*v_c)
	return(v)

#inputs(pascal,kelvin,)
p1=101325
t1=500
gamma=1.4

#after the combustion the temperature at constant volume heat addition
t3=2300
#geometric parameters(meters)
bore=0.1
stroke=0.1
#connecting rod
con_rod=0.15
#compression ratio
cr=8.6

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

#At state point 1-2 piston moves BDC to TDC,isentropic compression process takes place
v1=v_s+v_c

#At state point 2 as after compression, volume in compression chamber =v_c
v2=v_c
#p2v2^gamma =p1v1^gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)

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

constant=p1*pow(v1,gamma)

#p_compression*v_compression^gamma=constant

p_compression=[]

#for different value  within the set of v_compression instead of putting values manually making an array which is a list
#which gives also an array of p_compression which is nothing but empty array, p_compression=[],in the loop of v_compression
for v in v_compression:
	p_compression.append(constant/pow(v,gamma))

	

#At state point 2-3 ignition phase ,constant volume heat addition and expansion process takes place
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_otto(bore,con_rod,stroke,cr,0,180)

constant=p3*pow(v3,gamma)
#p_expansion*v_expansion^gamma=constant

#for different value  within the set of v_expansion instead of  manually calculation time taking so an array which is a list
#which gives also an array of p_expansion which is nothing but empty array, p_expansion=[], for loop of v_expansion

p_expansion=[]

for v in v_expansion:
	p_expansion.append(constant/pow(v,gamma))
	print(p_expansion)


#At state point 4,constant volume heat rejection process takes place
v4=v1
#p4v4^gamma=p3v3^gamma
p4=p3*pow(v3,gamma)/pow(v4,gamma)
#p4v4/t4=rhs
t4=p4*v4/rhs

#v2,v3 at x-axis heat addition point connector w.r.t the pressure at those point at y-axis
plt.plot([v2,v3,],[p2,p3,])
plt.plot(v_compression,p_compression)
#v4,v1 at x-axis heat rejection point connector w.r.t the pressure  at those point at y-axis
plt.plot([v4,v1,],[p4,p1,])
plt.plot(v_expansion,p_expansion)
plt.show()



t1=500
gamma=1.4

#after the combustion the temperature at constant volume heat addition
t3=2300
#geometric parameters(meters)
bore=0.1
stroke=0.1
#connecting rod
con_rod=0.15
#compression ratio
cr=8.6

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

#At state point 1-2 piston moves BDC to TDC,isentropic compression process takes place
v1=v_s+v_c

#At state point 2 as after compression, volume in compression chamber =v_c
v2=v_c
#p2v2^gamma =p1v1^gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)

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

constant=p1*pow(v1,gamma)

#p_compression*v_compression^gamma=constant

p_compression=[]

#for different value  within the set of v_compression instead of putting values manually making an array which is a list
#which gives also an array of p_compression which is nothing but empty array, p_compression=[],in the loop of v_compression
for v in v_compression:
	p_compression.append(constant/pow(v,gamma))

	

#At state point 2-3 ignition phase ,constant volume heat addition and expansion process takes place
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_otto(bore,con_rod,stroke,cr,0,180)

constant=p3*pow(v3,gamma)
#p_expansion*v_expansion^gamma=constant

#for different value  within the set of v_expansion instead of  manually calculation time taking so an array which is a list
#which gives also an array of p_expansion which is nothing but empty array, p_expansion=[], for loop of v_expansion

p_expansion=[]

for v in v_expansion:
	p_expansion.append(constant/pow(v,gamma))
	print(p_expansion)


#At state point 4,constant volume heat rejection process takes place
v4=v1
#p4v4^gamma=p3v3^gamma
p4=p3*pow(v3,gamma)/pow(v4,gamma)
#p4v4/t4=rhs
t4=p4*v4/rhs

#v2,v3 at x-axis heat addition point connector w.r.t the pressure at those point at y-axis
#plt.plot([v2,v3,],[p2,p3,])
#plt.plot(v_compression,p_compression)
#v4,v1 at x-axis heat rejection point connector w.r.t the pressure  at those point at y-axis
#plt.plot([v4,v1,],[p4,p1,])
#plt.plot(v_expansion,p_expansion)
#plt.show()


Q.2)
#Efficiency of the cycle
import math
import matplotlib.pyplot as plt 
#i_p=P*A*L*N*2*pi/60 =indicated power(kw)
#Here p is max mean value taken as 30bar of engine
#pressure
P=3000
#Area of cylinder head
A=0.1
#L=stroke length
L=0.1
#N=rotational speed pf engine in rpm
N=3000
i_p=P*A*L*N*2*(math.pi/60)

#thermal efficiency(ef)=i_p/fuel energy(Kj/s)
#for 1 litre gasoline have 10kwh=36000Kj energy or i_p/((mass of fuel/s)*calorific value)
ef=(i_p/360000)
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.