Challenge

Week 2 Air standard Cycle

import math
import matplotlib.pyplot as plt
import numpy as np

# Engine_Kinematics 

# engine perameters 
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12



def engine_kinematics(bore,stroke,con_rod,start_v,end_v,cr):
	a = stroke/2
	R = con_rod/a
	
	v_s = (math.pi/4)*pow(bore,2)*stroke
	v_c = v_s/(cr-1)

	st_c = math.radians(start_v)
	ed_c = math.radians(end_v)

	nm_value = 50
	v = []

	dtheta = (ed_c-st_c)/(nm_value-1)
	for i in range(0,nm_value):
		theta = st_c+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.append((1+term1*(term2-term3))*v_c)
	return v	
	

# inputs

pressure_1 = 101325
temp_1  = 500
gamma = 1.4
temp_3 = 2000 # in kelvins

swept_volume = math.pi/4*pow (bore,2)*stroke
clearence_volume = swept_volume/(cr-1)

volume_1 = swept_volume+clearence_volume
volume_2 = clearence_volume

# process 1-2, compression 
#p2v2^gamma = p1v1^gamma;

pressure_2 = pressure_1*pow(cr,gamma)

# p1v1/t1 = p2v2/t2
temp_2 = pressure_2*volume_2*temp_1/(pressure_1*volume_1)

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

# (p_compression*v_compression)^gamma = constant
constant = pressure_1*pow(volume_1,gamma)
p_compression = []
for v in v_compression:
	p_compression.append(constant/pow(v,gamma))



volume_4 = volume_1
volume_3 = volume_2

# 2-3  process expanssion process

# p2v2/t2 = p3v3/t3

pressure_3 =pressure_2*temp_3/temp_2

# process 3-4 
pressure_4 = pressure_3*pow((volume_3/volume_4),gamma)

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

# (p_expansion*v_expansion)^gamma = constant
constant = pressure_3*pow(volume_3,gamma)
p_expansion = []
for v in v_expansion:
	p_expansion.append(constant/pow(v,gamma))


thermal_efficiency = (1-(1/(pow(cr,(gamma-1)))))*100
print(thermal_efficiency)

plt.plot([volume_2,volume_3],[pressure_2,pressure_3])
plt.plot(v_compression,p_compression)
plt.plot(v_expansion,p_expansion)
plt.plot([volume_4,volume_1],[pressure_4,pressure_1])
plt.show()
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.