Air standard cycle
AIR STANDARD CYCLE
AIM:-
Write code that can solve an otto cycle and make plots for it.
OBJECTIVE:-
⦁ The code should create a PV diagram .
⦁ find the thermal efficiency of the engine
THEORY:-
Otto cycle :
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines. The Otto cycle is a description of what happens to a mass of gas as it is subjected to changes of pressure, temperature, volume, addition of heat, and removal of heat.

Process 1-2: isentropic compression of the working fluid occurs as the piston moves from bottom dead center (BDC) to top dead center (TDC).
Process 2-3: here, with the SI, a rapid burning occurs inside the piston; therefore, the heat addition takes place at the constant volume.
Process 3-4: in this process, the working fluid expands isentropically and produces the useful work for the cycle.
Process 4-1: heat removal at constant volume. In practical applications, the heat is removed by expelling the exhaust gas to the atmosphere.
Compression ratio (cr): it is the ratio between the volume of the cylinder and combustion chamber in an internal combustion engine at their maximum and minimum values.


GOVERNING EQIATIONS :-
Cylinder volume and crank angle equation

a= stroke/2
Compression ratio
`cr = (VC + VS)/(VC)`
Where cr = compression ratio
VS = swept volume = `(pi)/4*b^2*stroke`
where b = bore
VC = clearance volume
Thermal efficiency

where , CR = compresion ratio
k = cp/cv =1.4
CODE:-
1. Function to find cylinder volume
% FUNCTION FOR CYLINDER VOLUME
function[v] = engine_kinematics(bore, stroke,l,cr,start_crank,end_crank)
% l = connecting rod length in meters
% cr = compression ratio
% engine geometric parameters ( in m)
% a = crank radius .
a=stroke/2;
R = l/a;
% calculating swept volume and clearance volume
swept_vol = (pi/4)*bore^2*stroke;
clearance_vol = swept_vol/(cr-1);
theta=linspace(start_crank,end_crank,100);
term1 = 0.5*(cr-1);
term2 = R+1-cosd(theta);
term3 = (R^2-(sind(theta)).^2).^0.5;
% v = cylinder volume
% calculating cylinder volume
v = (1+ term1 *(term2-term3))*clearance_vol;
end
2. Program to plot pv diagram of otto cycle and to find thermal efficiency
% program for plotting pv diagram of otto cycle and to find thermal
% efficiency
clear all
close all
clc
% inputs
gamma =1.4;
% state variable at state 1
p1 = 101325; % in pascal
t1 = 500 ; %in kelvin
% engine geometric parameters ( in m)
bore = 0.1;
stroke = 0.1;
conn_rod = 0.15;
cr = 12;
% calculating swept volume and clearance volume
swept_vol = (pi/4)*bore^2*stroke;
clearance_vol = swept_vol/(cr-1);
v1=swept_vol+ clearance_vol;
v2= clearance_vol;
% state variables at state 2
% p1*v1^gamma = p2*v2^gamma
% p2 = p1*(v1/v2)^gamma = p1*cr*gamma
p2 = p1*cr^gamma;
% ideal gas formula
% p1v1/t1 = p2v2/t2
% t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);
constant_c=p1*v1^gamma;
% function calling
v_compression=engine_kinematics(bore,stroke,conn_rod,cr,180,0);
p_compression = constant_c./v_compression.^gamma;
% state variable at state 3
t3=2300 ;% in kelvin
v3=v2;
% p3v3/t3 = p2v2/t2
% p3 = p2v2t3/t2v3
% p3 = p2t3/t2
p3=(p2*t3)/t2;
constant_c=p3*v3^gamma;
% function calling
v_expansion = engine_kinematics(bore,stroke,conn_rod,cr,0,180);
p_expansion = constant_c./v_expansion.^gamma;
% state variables at state 4
v4 = v1;
% p3v3^gamma = p4v4^gamma
% p4 = p3*(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma;
t4 = p4*v4*t3/(p3*v3);
% finding thermal efficiency
TE = 1-((t4-t1)/(t3-t2));
%plotting
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(v_compression,p_compression , 'linewidth',3)
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
line([v2,v3],[p2,p3],'linewidth',3)
plot(v_expansion,p_expansion,'linewidth',3)
plot(v4,p4,'*','color','r')
line([v1,v4],[p1,p4],'linewidth',3)
xlabel('volume')
ylabel('pressure')
title('otto cycle')
STEPS :
1. we coded a function to find cylinder volume . function name is engine_kinematics
2. we then calculated various state points using the formulas given in equation section .
3. by calling the function engine_kinematics we calculated path values for expansion and compression
4. then we calculated thermal efficiency of the engine.
5. after that we plotted pv diagram .
RESULT :-

thermal efficiency = 0.6299 = 62.99%
CONCLUSION:-
We have successfully coded matlab program to plot PV diagram and also to find thermal efficiency of the engine .