Project

PV diagram visualizer for Otto cycle using Matlab.

Objective:

  • To write code which creates a PV diagram.
  • To find the thermal efficiency of the engine.

Introduction:

The Otto cycle was given by Dr. Nikolaus August Otto. It is a gas power cycle that is used in a Spark Ignition(i.e. petrol engine) for its working. The entire modern petrol engine works on the Otto cycle.

It has four processes:

1. Isentropic (reversible adiabatic) compression
2. Constant volume (Isochoric) heat addition
3. Isentropic (reversible adiabatic) Expansion
4. Constant volume heat rejection.

1. Process 1-2: Isentropic Compression

This process involves the motion of piston from TDC to BDC. The air that is sucked into cylinder during suction stroke undergoes reversible adiabatic (isentropic) compression. Since the air is compressed, the pressure increases from P1 to P2, the volume decreases from V1 to V2, temperature rises from T1 to T2, and entropy remains constant.

2. Process 2-3: Constant Volume Heat Addition

This process is an isochoric process i.e. the heat is added to the air at constant volume. The piston in this process rest for a moment at TDC and during this time heat is added to the air through external source. Due to the heat addition, the pressure increases from P2 to P3, pressure, volume remains constant(i.e. V2=V3), temperature increases from T2 to T3 and entropy increases from S2 to S3.

3. Process 3-4: Isentropic Expansion

In this process, the isentropic (reversible adiabatic) expansion of air takes place. The piston moves from TDC to BDC. Power is obtained in this process which is used to do some work. Since this process involves expansion of air, so the pressure decreases from P3 to P4, volume increases from V3 to V4, temperature falls from T3 to T4 and entropy remains unchanged (i.e. S3=S4).

4. Constant Volume Heat Rejection

In this process, the piston rest for a moment at BDC and rejection of heat takes place at constant volume. The pressure decreases from P4 to P1, Volume remains constant (i.e. V4=V1), temperature falls from T4 to T1.

When this cycle is used in four stroke petrol engine than two process increases. one is suction of air fuel mixture inside the cylinder which takes place at constant atmospheric pressure and other one is exhaust of gases out of the engine cylinder at constant atmospheric pressure. These two process are not shown in ideal otto cycle that we have discussed above.

Code:

% otto cycle simulation 
clear all
close all
clc
% geometric parameter
bore = 0.3;
stroke = 0.3;
conn_rod = 0.35;
cr = 14;

s_v = (pi/4)*bore^2*stroke; % suction volume
c_v = s_v/(cr-1)  % clearance volume

% input paramaters.....(given)
p1 = 105000 % in pascal
t1 = 500  % in kelvin
v1 = s_v + c_v;
v2 = c_v;
gamma = 1.4;

% point 2 parameters
p2 = p1*(v1/v2)^gamma;  % since p2/p1 = (v1/v2)^gamma
t2 = t1*((p2*v2)/(p1*v1)); % since t2/t1 = (p2*v2)/(p1*v1)
C = p1*v1^gamma;

% calling function
V_compression = piston_kinematics(bore,stroke,conn_rod,s_v,c_v,cr,180,0);
P_compression = C./V_compression.^gamma;

% point 3 parameters
v3 = v2;
t3 = 2800;
p3 = p2*(t3/t2);
C = p3*v3^gamma;
% calling function
V_expansion = piston_kinematics(bore,stroke,conn_rod,s_v,c_v,cr,0,180);
P_expansion = C./V_expansion.^gamma;

% point 4 parameters
v4 = v1;
p4 = p3*(v3/v4)^gamma;
t4 = t3*((p4*v4)/(p3*v3));

% plotting
figure(1)
hold on
plot(v1,p1,'o','color','r')
plot(v2,p2,'o','color','r')
plot(V_compression,P_compression,'color','b')
plot([v2 v3],[p2 p3],'color','b')
plot(v3,p3,'o','color','r')
plot(v4,p4,'o','color','r')
plot(V_expansion,P_expansion,'color','b')
plot([v1 v4],[p1 p4],'color','b')
xlabel('Volume')
ylabel('Pressure')
legend('P-V diagram for Otto cycle')

% calculating thermal efficiency
Thermal_efficiency = (1-(1/(cr)^(gamma-1)))*100

Explanation of code:

1. The inputs are given to the geometric parameter such as bore,connecting rod,stroke,gamma etc.

2. The stroke volume and clearance volume is found by the formula.

3. The inputs are given for point no. 1 and also inputs are found out for all 4 points with the help of relations and formula.

4. The movement of piston due to compression and expansion can be traced by the following formula: ''V = (1+(0.5*(cr-1).*(R+1-cosd(theta)-(R^2-sind(theta).^2).^0.5)))*c_v".

5. And the pressure at that movement can be traced by the following formula: P_ = C./V_expansion.^gamma;

6. Graph is plotted for all the points of volume and pressure.It is to be noted that the graph for isentropic compression and expansion are curved in nature. Labeling for x-axis and y-axis is done with the help of command "label" and the command legend is used for giving the legend.

7. The "function" command :

function [V] = piston_kinematics(bore,stroke,conn_rod,s_v,c_v,cr,start_crank,end_crank)
a = stroke/2;
R = conn_rod/a;

theta = linspace(start_crank,end_crank,100);
V = (1+(0.5*(cr-1).*(R+1-cosd(theta)-(R^2-sind(theta).^2).^0.5)))*c_v;
end


The function command is created using a different script and it is saved with the same name as of the name of our function, this step is very important or else it will not work.

In the function command we have found the value of volumetric compression and expansion which shows the movement of piston while it moves during compression and expansion.

Plots:

Thermal Efficiency :

Thermal Efficiency of otto cycle is obtained by the formula :

Thermal_efficiency = (1-(1/(cr)^(gamma-1)))*100

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.

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.