Challenge

Week 2 Air standard Cycle

"""
	OTTO CYCLE SIMULATOR
"""

import math
import matplotlib.pyplot as plt

#inputs
p1 = 2500
t1 = 200
gamma = 1.4
t3 = 3050

#geometric parameters
bore = 0.5
stroke = 0.3
con_rod = 1.5
cr = 15

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

#state point 2
v2 = v_c

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

#p2v2 / t2 = p1v1 / t1 
#rhs = p1v1 / t1
#p2v2 / t2 = rhs
#t2 = p2v2 / rhs

rhs = p1*v1/t1
t2 = p2*v2 / rhs

#state point 3
v3 = v2

#p2v3 / t3 = p2v2 / t2
#rhs = p2v2 / t2
# p3 = rhs * t3 / v3

rhs = p2 * v2 / t2
p3 = rhs * t3 / v3

#state point 4
v4 = v1

#p4v4^gamma = p3v3^gamma

p4 = p3*pow( v3,gamma )/pow( v4,gamma )

#p4v4 / t4 = p3v3 / t3

t4 = p4 * v4 / rhs

plt.plot([v1 , v2, v3, v4, v1], [p1, p2, p3, p4, p1])
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.