Challenge

Week 2 Air standard Cycle

Problem statement:

vBased on the concepts you have learnt during the forward kinematics routine, go ahead and write code that can solve an otto cycle and make plots for it.

Here are the requirements

1. Your code should create a PV diagram

2. You should output the thermal efficiency of the engine.

CODE:


# -*- coding: utf-8 -*-
"""
Created on Sat Jul  1 15:26:15 2023

@author: TSARUN
"""
import math
import matplotlib.pyplot as plt 
"""
p1=101325     #Sample data
t1 = 500
bore =0.1
stroke=0.1
con_r=0.15
cr =12
gama=1.4
t3=2300

"""
p1 = float(input('Initial pressure?\n'))    #Taking values from the user
t1 = float(input('Initial temp?\n'))
bore = float(input('Bore radius?\n'))
stroke =float( input('Stroke?\n'))
con_r = float(input('Connecting rod?\n'))
cr = float(input('Compression ratio?\n'))
gama =float( input('gama?\n'))
t3= float(input('state 3 temp?\n'))


s_v = (math.pi/4)*math.pow(bore,2)*stroke  #calculating volume
c_v = s_v/(cr-1)
v1 = c_v + s_v

#finding 2nd state values
v2=c_v                                
p2 = p1*pow(v1,gama)/pow(v2,gama)  #finding pressure with formula pv^gama =Constant
#print(p2)
rhs =p1*v1/t1    #finding temperature with formula pv/t = constant
t2 =p2*v2/rhs

#finding 3nd state values

v3 =v2
rhs= p2*v2/t2   #finding pressure with formula pv/t = constant
p3 =rhs*t3/v3

#finding 4th state values
v4 =v1
p4 =p3*pow(v3,gama)/pow(v4,gama)  #finding pressure with formula pv^gama = constant
t4 =p4*v4/rhs #finding temperature with formula pv/t = constant

eff = (1- (pow((v2/v1),(gama-1))))  #finding efficiency of engine

print('efficiency of ottocycle is ={} ',format(eff))

plt.plot([v1,v2,v3,v4,v1],[p1,p2,p3,p4,p1])    #ploating graph
plt.show()
plt.savefig('ottocycle.png')   #saving image

Result:

Obtained ottocycle graph and efficinecy
according to the data from user, graph attached as attachement
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.