otto cycle and its plots
clear all
close all
clc
%defining the input variables
gamma= 1.4
p1= 101325
t1= 500
t3= 2300
bore= 0.1;
stroke= 0.1;
cm_rod= 0.15;
cr= 12;
%definig formulas for calculation
v_swept= (pi/4)*bore^2*stroke;
v_clearance= v_swept/(cr-1);
v1= v_swept + v_clearance;
v2= v_clearance;
%defining v n p compression for every instant between points 1 n 2
p2= p1*(cr^gamma);
t2= p2*v2*t1/(p1*v1);
constant_c= p1*v1^gamma;
v_compression= engine_kinematocs(bore,stroke,cm_rod,cr,180,0);
p_compression= constant_c./v_compression.^gamma;
%defining v n p expansion for every instant between points 3 n 4
v3= v2;
p3= p2*t3/t2;
constant_d= p3*v3^gamma;
v_expansion= engine_kinematocs(bore,stroke,cm_rod,cr,0,180);
p_expansion= constant_d./v_expansion.^gamma;
v4= v1;
p4= p3*(v3/v4)^gamma;
%thermal efficiency formula
efficiency = (1-(1/cr^(gamma-1)));
%plotting graph
figure(1);
hold on
plot(v1,p1,'*','color','r')
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(v4,p4,'*','color','r')
plot(v_compression,p_compression,'linewidth',2)
plot(v_expansion,p_expansion,'linewidth',2)
plot([v2 v3],[p2 p3],'linewidth',2)
plot([v4 v1],[p4 p1],'linewidth',2)
%engine kinematic function
function [v]= engine_kinematocs(bore,stroke,cm_rod,cr,start_crank,end_crank)
a= stroke/2;
R= cm_rod/a;
v_s= pi/4*bore^2*stroke;
v_c= v_s/(cr-1);
theta= linspace(start_crank,end_crank,100);
term1= 0.5*(cr-1);
term2= R+1-cosd(theta);
term3= (R^2-sind(theta)).^0.5;
v= (1+term1*(term2-term3)).*v_c;
From the given data we will derive the values of volume and pressure at 1, 2, 3 n 4.
Since processes between 1 n 2 and 3 n 4 are exponential we need to derive values for volume and pressure at every intermediate position.
in order to calculate intermediate positions, we will define one function that will derive volume from BDC to TDC and vice versa.
By plotting points at 1 2 3 n 4 we can now join 2 n 3 and 4 n 1 by a straight line (as they are isochoric process) and for isentropic process i.e. process 1-2 and 3-4, we will plot all values between them.
the thermal efficiency is calculated by the efficiency formula written in the code above.