**Aim :** To plot the PV-Diagram for an otto cycle and to calculate the thermal efficiency of the cycle.

**Intro :** Otto cycle is a thermodynamic cycle, which is predominantly used in gasoline(petrol) engines. It consists of 4 processes in it,starting from 'Isentropic compression, Constant volume heat addition, Isentropic expansion and Constant volume heat rejection'.

** **

** Figure (a)**

Figure (a) explains about the 4 strokes in an engine, i.e suction stroke, Compression stroke, Power Stroke(Expansion) and the Exhaust stroke.

**Graph (a) Volume vs Pressure:**

** **

The piston cyclinder arrangement becomes a closed system during compression and expansion process ,so when the piston moves, the volume and pressure of the medium inside it varies accordingly, which is clearly explained in Graph (a).

**Process 0-1:** Suction,

**Process 1-2: **Compression**,**

**Process 2-3: **Ignition Phase,

**Process 3-4: **Expansion stroke,

**Process 4-1: **Idealized heat rejection,

**Process 1-0: **Exhaust stroke.

**Graph(b) Volume vs temperature: The Variation of temperature w.r.t. Volume is shown in this graph**

** **

**Formula used:**

v/v_c = 1 +(1/2(cr -1))[R + 1-cos(theta)-(R^2-sin(theta)^2)^(1/2)]`

Where,

v = Volume of the cylinder,

v_c = clearance volume,

cr = compression ratio,

R = con_rod_length/ crank pin radius,

theta = Crank angle.

Thermal efficiency :(1 - 1/(cr)^(gamma-1))

cr = compression ratio.

**program for the function :**

```
% function to calculate the piston kinematics
function [v] = engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)
%inputs
a = stroke/2;
R = con_rod/a;
theta = linspace(start_crank,end_crank,180);
% swept volume and clearance volume
v_s = (pi/4)*bore^2*stroke;
v_c = v_s/(cr-1);
%to the fine the changing volume during otto cycle
term1 = 0.5*(cr-1);
term2 = R + 1 -cosd(theta);
term3 = (R^2 - sind(theta).^2).^0.5;
v = (01+ term1*(term2 - term3)).*v_c;
end
```

**Program for the otto cycle :**

```
% Plotting of PV diagram of an otto cycle and to calculate the thermal efficiency of the cycle.
clear all
close all
clc
%inputs
gamma = 1.4
t3 = 2300
% state variables at state point 1
% Temperature is in Kelvin(K), Pressure in N/m^2
p1 = 101325
t1 = 270
%Engine Geometric Parametrics
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;
% calculating the total volume(v1), clearance volume and swept volume
v_swept = (pi/4)*(bore)^2*stroke;
v_clearance = (v_swept)/(cr-1);
v1= v_swept + v_clearance
v2 = v_clearance
% state variables at state point 2
% p2v2^gamma = p1v1^gamma(Iso-entropic process)
% p2 = p1*(v1/v2)^gamma = p1*(cr)^gamma
p2 = p1*(cr)^gamma
% t2/t1 = (v1/v2)^(gamma-1)
t2 = t1*(v1/v2)^(gamma-1)
constant_c = p1*v1^gamma
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
p_compression = constant_c./(v_compression.^gamma)
% state variables at state point 3
v3 = v2
% p2v2/t2 =p3v3/t3
p3 = (t3/t2)*p2
constant_c = p3*v3^gamma
v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
p_expansion = constant_c./(v_expansion.^gamma)
%state variabels at state point 4
v4= v1
p4 = p3*(v3/v4)^gamma
%plotting of the state points
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(v_compression,p_compression)
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(v_expansion,p_expansion)
plot(v4,p4,'*','color','r')
plot([v2 v3],[p2 p3],'color','r')
plot([v4 v1],[p4 p1],'color','b')
% thermal efficieny of otto cycle :
thermal_efficiency = (1 - 1/(cr^(gamma-1)))*100
```

**Explanation of the program:**

The input variables and the state variables at state point 1 is defined.

After which the geometric parametrics of the engine is defined.

Using thermodynamics relations based on their respective processes, equations are used to determine the unknown variables at various points.

A separate function is created to calculate the varying volume of the engine, based on the crank angle. This function is called in the main program.This function helps in plotting the compression and expansion curves, which is not a straight line.

By obtaining the values at all state points,the PV- Graph is plotted.

The thermal efficiency of the otto cycle is calculated using its standard formula.

**Output graph : **

** **

**Thermal Efficiency obtained :**

** **

** **

**Result & conclusion:**

The physical parameters of each state points is determined and the PV-Graph is plotted.

This Program is usefull to detemine the relation of P-V at varying input conditions.

This can also be used to find the volume of the engine based on the crank angle or vice-versa.