Week 2 Air standard Cycle
%main program
close all
clear all
clc
%Inputsbore=100;stroke=200;con_rod=250;cr=22;n=1.4;Vs= pi/4*bore^2*stroke;Vc=Vs/(cr-1);function [V]= otto_cycle(bore,stroke,con_rod,cr,start_crank,end_crank);Vs= pi/4*bore^2*stroke;Vc=Vs/(cr-1);r=stroke/2;R= con_rod/r;theta= linspace(start_crank,end_crank,120);term1=0.5*(cr-1);term2=R+1-cosd(theta);term3=(R^2-sind(theta).*sind(theta)).^0.5;%Relation defining change of volume inside the cylinder with resoecvt to the crank angleV= (1+term1*(term2-term3)).*Vc;end%state variables 1p1= 101350;v1=Vs+Vc;t1=300;V_compression= otto_cycle(bore,stroke,con_rod,cr,180,0);P_compression= (p1*v1^n)./V_compression.^n;%state variables 2p2=p1*cr^n;v2=Vc;t2=t1*cr^(n-1);%state variables 3t3=3000;v3=v2;p3=(t3/t2)*p2;%state variables 4v4=v1;p4=p3/cr^n;V_expansion= otto_cycle(bore,stroke,con_rod,cr,180,0);P_expansion= (p4*v4^n)./V_compression.^n;%efficiencyeff= (1-(1/cr^n))*100;figure(1)hold onplot(v1,p1,'*','color','b')plot(V_compression,P_compression)plot(v2,p2,'*','color','b')plot(v3,p3,'*','color','b')plot(V_expansion,P_expansion)plot(v4,p4,'*','color','b')line([v2 v3],[p2 p3])line([v4 v1],[p4 p1])figure(2)plot([v1 v2 v3 v4],[p1 p2 p3 p4],'*','color','r')grid on;