All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
1. AIM: - To write code that can solve an Otto cycle and make plots for it. 2. OBJECTIVE: - To write code in MATLAB program that can solve an Otto cycle and Plot PV Diagram. The code should create a PV diagram. Finding the thermal efficiency of the engine. 3. GOVERNING EQUATION: - Volume change in the combustion…
Gaurav Hole
updated on 18 Jan 2022
1. AIM: -
To write code that can solve an Otto cycle and make plots for it.
2. OBJECTIVE: -
To write code in MATLAB program that can solve an Otto cycle and Plot PV Diagram.
3. GOVERNING EQUATION: -
VVc=[1+12⋅(cr-1)]⋅[R+1-cos(θ)]-[R2-(sin)2(θ)]12
In an IC engine volume of the combustion chamber changes when the piston moves from TDC to BDC. To get an accurate graph for the PV diagram we have to use the above equation for continuous volume change in the chamber.
Were,
V = volume change
Vc = Clearance volume
Cr = compression ratio
R = (con_rod/a) Length of connecting rod/Crankpin radius
a = stroke/2
η=1-1(Cr)γ-1
Were,
Cr= compression ratio
γ = gamma
The thermal efficiency of the Otto cycle is a function of compression ratio (r) and the ratio of specific heat (γ). as (γ) is assumed to be a constant for any working fluid, the efficiency is increased by increasing the compression ratio. Further, the efficiency is independent of heat supplied and pressure ratio. The use of gases with hither (γ) value would increase the efficiency of the Otto cycle.
4. DESCRIPTION: -
4.1 Otto Cycle: -
*Valve Timing Diagram*
*PV Diagram*
Air fuel mixture (working fluid) is drawn into the cylinder, at atmospheric pressure (constant pressure) through the open intake valve before 15 degrees, while the exhaust valve is closed during this process.
The piston moves from the crank end (BDC, bottom dead center) to the cylinder head end (TDC, top dead center) as the working gas with initial state 1 is compressed Isentropically to state point 2, through compression ratio (V1/V2). Mechanically this is the isentropic compression of the air/fuel mixture in the cylinder, also known as the compression stroke. This isentropic process assumes that no mechanical energy is lost due to friction and no heat is transferred to or from the gas, hence the process is reversible. The compression process requires that mechanical work be added to the working gas. Generally, the compression ratio is around 9–10:1 (V1:V2) for a typical engine. The intake valve closes at 45 degrees after BDC.
Ignition starts at 30 degrees before TDC. The piston is momentarily at rest at TDC. The air/fuel mixture remains in a small volume at the top of the compression stroke. Heat is added to the working fluid by the combustion of the injected fuel, with the volume essentially being held constant. The pressure rises simultaneously and the ratio is called the "explosion ratio" (P3/P2).
The increased high pressure exerts a force on the piston and pushes it towards the BDC. Expansion of working fluid takes place Isentropically and work is done by the system on the piston. The volume ratio (V4/V3) is called the "isentropic expansion ratio". (For the Otto cycle is the same as the compression ratio(V1/V2). Mechanically this is the expansion of the hot gaseous mixture in the cylinder known as expansion (power) stroke.
The piston is momentarily at rest at BDC. The working gas pressure drops instantaneously from point 4 to point 1 during a constant volume process as heat is removed to an idealized external sink that is brought into contact with the cylinder head. In modern internal combustion engines, the heat-sink may be surrounding air (for low-powered engines), or a circulating fluid, such as coolant. The gas has returned to state 1.
The exhaust valve opens at 45 degrees before BDC. As the piston moves from "BDC" to "TDC" with the exhaust valve opened, the gaseous mixture is vented to the atmosphere. After that exhaust valve close at 10 degrees after TDC. Here valve overlapping has occurred.
Valve overlap is the period during engine operation when both intake and exhaust valves are open at the same time. Valve overlap occurs when the piston nears TDC between the exhaust and the intake. Duration of valve overlap is between 10° - 20° of crankshaft rotation, depending on the engine design. The intake valve is opened during the exhaust event just before TDC, initiating the flow of the new charge into the combustion chamber.
As the exhaust gases are evacuated from the combustion chamber, a small but distinct low-pressure area is created on the surface of the piston head. By opening the intake valve earlier than TDC, the charge begins to fill this low-pressure area while exhaust gases exit. The low-pressure area on the head of the piston assists the fresh charge in filling the combustion chamber to its maximum capacity.
Valve overlap is designed into the engine and is most useful at higher speeds. At higher speeds, the extra amount of intake charge brought into the combustion chamber provides a substantial increase in available power. The amount of time that both valves are open directly related to engine rpm. The higher the engine rpm, the shorter the amount of time that both valves are open. The angle of crankshaft rotation when both valves are open does so change, only the amount of time both valves are open varies. Thus, at idle, the amount of time both valves are open is relatively long compared to that at top no-load speed.
4.2 Ideal Otto cycle
Air standard Otto cycle is used for the SI Engines (Spark Ignition Engine). The cycle Contains Mainly four Processes. In the overall cycle, suction and Exhaust are neglected, also power consumption is not considered.
The Ideal Otto cycle consists of the four processes which are as follows.
1-2 Reversible Adiabatic compression (or) Isentropic Compression.
2-3 Constant Volume Heat Addition.
3-4 Reversible Adiabatic Expansion (or) Isentropic Expansion.
4-1 Constant Volume Heat Rejection.
S.no |
Process |
Operation |
Position of piston |
Change in parameter |
1. |
1-2: Isentropic Compression |
Compression of air. |
BDC to TDC |
V: Decreases from V1 To V2 T: Increases from T1 to T2 P: Increases from P1 to P2 S: Entropy remains constant (S1=S2) |
2. |
2-3: Constant Volume Heat Addition |
Heat is added in the form of spark and combustion occurs. |
At TDC for a moment |
V: Remains constant (V2 = V3) T: Increases from T2 to T3 P: Increases from P2 to P3 S: Increases from S2 to S3 |
3. |
3-4: Isentropic Expansion |
Expansion of air takes place due to heat addition. |
TDC to BDC |
V: Increases from V3 to V4 T: Decreases from T3 to T4 P: Decreases from P3 to P4 S: Entropy remains constant (S3=S4) |
4. |
4-1: Constant Volume Heat Rejection |
Heat is rejected to a sink. |
At BDC for a moment |
V: Volume remains constant (V4 = V1) T: Decreases from T4 to T1 P: Decreases from P4 to P1 S: Decreases from S4 to S1 |
When the piston in the cylinder of the Internal Combustion Engine (SI Engine) moves from BDC (i.e. Bottom Dead Centre) to TDC (i.e. Top Dead Centre) the Pressure and volume Relatively change, which is represented on the Diagram known as PV-Diagram. The ideal PV-Diagram can be seen below.
4.3 Terms in the Otto cycle:
Compression ratio (Cr)= (volume before compression) / (Volume after compression) i.e. (V1/V2)
V1 = (Vs+Vc)
V2 = Vc
Compression ratio (Cr)= (Vs+Vc) / Vc
Where: -
Vs = Swept Volume
Vc = Clearance Volume
Similarly, as the compression ratio,
Therefore, Expansion ratio (Er) = V4/V3
Note: - for Otto cycle compression Ratio = Expansion ratio i.e. (Cr = Er).
η=1-1Crγ-1
It's clear from the above expression that efficiency increase with the increase in value of (r), which means we can have maximum efficiency by increasing (r) to a considerable extent but due to practical difficulties its value is limited to about 9. In some higher cc bikes, it’s become 12.
5State Variable: -
5.1 State variable at Point - 1: -
1. Initial Pressure & Temperature:
2. Engine Geometry parameters:
3. Swept volume and Clearance volume:
Where: -
Cr = compression ratio,
D = Bore
L = Stroke
5.2 State Variable at point - 2: -
1. Calculating Pressure at point 2 (P2):
Due to isentropic compression, we can apply the PV Relation here.
P1V1γ=P2V2γ
Where, P2 is Unknown to us which can be calculated with the help of the relation between the volume, pressure, and compression ratio
Also, we can calculate the P2 as follow
Cr=V1V2=[P2P1]γ
Therefore, P2=P1⋅(Cr)γ
2. Calculating temp at point 2 (T2):
To get the value of temp T2 we are using the ideal gas equation = mRT1,
m⋅R=P1⋅V1T1
P2⋅V2=m⋅R⋅T2
m⋅R=P2⋅V2T2
Therefore, P1⋅V1T1=P2⋅V2T2
Hence, T2=P2⋅V2⋅T1P1⋅V1
5.2 State Variable at point-3: -
1. Calculating Volume at point 3 (V3):
V3=V2
2. Calculating Pressure at point 3 (P3):
By using the ideal gas equation
P3=P2⋅T3T2
5.4 State Variable at point-4:
1. Calculating Volume at point 4 (V4):
V1=V4
2. Calculating Pressure at point 4 (P4):
Also, from P3V3γ=P4V4γ
P4=P3⋅(V3V4)γ
6. Programming Explanations: -
Clearvars: - Command used to clear variables from the workspace.
close all: - Command used to close all the plot windows.
Clc: - Command is used to Clear Command Window
6.1 Giving input
As discussed above,
% Otto cycle
% Input
gamma = 1.4;
t3 = 2300;
% Engine geometry parameter
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;
% State variables at state point 1
p1 = 101325;
t1 = 500;
% Calculating the swept volume and clearance 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
p2 = p1*cr^gamma;
% p1v1/t2 = p2v2/t2 t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);
% State variables at state point 3
v3 = v2;
% p3v3/t3 = p2v2/t2 p3 = p2*t3/t2
p3 = p2*t3/t2;
% State variables at state point 4
v4 = v1;
%p3v3^gamma = p4v4^gamma p4 = p3*(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma;
% p4v4/t4 = p3v3/t3 t4 = p4*v4*t3/(p3*v3)
t4 = p4*v4*t3/(p3*v3);
% Thermal efficiency
Thermal_Efficiency = (1-(cr^(gamma-1))^-1)*100;
% Plotting
hold on
plot(v1,p1,'*','color','r')
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(v4,p4,'*','color','r')
xlabel('Volume (m^3)')
ylabel ('Pressure (KPa)')
For plotting, we are using the plot command and we get a PV diagram having four-point in it which Represents State points. after Executing the Program, we get our output as follow,
We cannot join them from the line because isentropic processes do not have a constant slope. If we try, we get the result as follows by using the following command, which is an Error.
6.2 Error Elimination.
To eliminate error, we need the following two things.
Program to get Piston kinematics Relation is as follows
function [V] = Otto_cycle_kinematics(bore,stroke,con_rod,cr,start_crank, end_cranck)
a = stroke/2;
R = con_rod/a;
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);
theta = linspace(start_crank,end_cranck,100);
% Geometric relationship formula
% V/Vc = {1 + 0.5*(cr-1)[R + 1 - cosd(theta) - (R^2 - sind(theta)^2)^0.5]}
term1 = 0.5*(cr-1);
term2 = R + 1 - cosd(theta);
term3 = (R^2 - sind(theta).^2).^0.5;
V = (1 + term1*(term2-term3)).*v_clearance;
end
Here, we are taking all the parameters the same as above but we need a different formula for the calculation of the volume change inside the combustion chamber. The required relationship we can get by the following formula.
VVc=[1+12⋅(cr-1)]⋅[(R+1-cos(θ)]-[R2-(sin)2(θ)]12
To simplify the formula, we divided the formula into three sub formulas as follows
term1 = 12⋅(cr-1)
term2 = R+1-cosd(θ)
term3 =(R2-sind2(θ))12
At last, we get our final formula as
V=(1+term1⋅(term2-term3))⋅Vc
here, we are using cosd and sind because we get theta in degree.
Were,
R = (con_rod/a) Length of connecting rod/Crankpin radius
a = stroke/2
Now, we are going to use this Program in our first program for getting PV Diagram correctly, but using the total program to our first program is not the correct way, therefore, we are creating a function command here. To use this command in maim program, we have to use the same name for the function.
If not, we get an error as follow,
Now, in our main program, we are using this function for the Pressure and volume changes in the compression and Expansion
stroke, for the volume we can define the function as follows.
V_compression = piston_kinematics(bore,stroke,con_rod,cr,180,0);
But for the pressure, we know that P*V^gamma = constant
Hence, we are defining this relation and using it as,
constant_c = P1*V1^gamma;
P_compression = constant_c./V_compression.^gamma;
similarly, for Expansion, we are using the above relation as,
constant_c = P3*V3^gamma;
V_expansion = piston_kinematics(bore,stroke,con_rod,cr,180,360);
P_expansion = constant_c./V_expansion.^gamma;
6.3 Thermal Efficiency: -
Formula for thermal efficiency of Otto cycle as follow,
ThermalEfficiency=(1-(crγ-1)-1)⋅100
7. Final program
clearvars
close all
clc
% Otto cycle
%input
gamma = 1.4;
t3 = 2300;
%State variables at state point 1
p1 = 101325;
t1 = 500;
% Engine geometry parameter
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;
% calculating the swept volume and clearance 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
p2 = p1*cr^gamma;
% p1v1/t2 = p2v2/t2 t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);
constant_c = p1*v1^gamma;
V_compression = Otto_cycle_kinematics(bore,stroke,con_rod,cr,180,0);
P_compression = constant_c./V_compression.^gamma;
% State variables at state point 3
v3 = v2;
% p3v3/t3 = p2v2/t2 p3 = p2*t3/t2
p3 = p2*t3/t2;
constant_c = p3*v3^gamma;
V_expansion = Otto_cycle_kinematics(bore,stroke,con_rod,cr,180,360);
P_expansion = constant_c./V_expansion.^gamma;
% state variables at state point 4
v4 = v1;
%p3v3^gamma = p4v4^gamma p4 = p3*(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma;
% thermal efficiency
Thermal_Efficiency = (1-(cr^(gamma-1))^-1)*100;
figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(V_compression,P_compression,'linewidth',1,'color','r')
plot(v2,p2,'*','color','r')
plot(V_expansion,P_expansion,'linewidth',1,'color','r')
plot(v3,p3,'*','color','r')
plot([v2 v3],[p2 p3],'linewidth',1,'color','c')
plot(v4,p4,'*','color','r')
plot([v4 v1],[p4 p1],'linewidth',1,'color','c')
xlabel('Volume (m^3)')
ylabel('Pressure (KPa)')
title('Otto Cycle P/V Diagram')
8. Function command
function [V] = Otto_cycle_kinematics(bore,stroke,con_rod,cr,start_crank, end_cranck)
a = stroke/2;
R = con_rod/a;
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);
theta = linspace(start_crank,end_cranck,100);
% Geometric relationship formula
% V/Vc = {1 + 0.5*(cr-1)[R + 1 - cosd(theta) - (R^2 - sind(theta)^2)^0.5]}
term1 = 0.5*(cr-1);
term2 = R + 1 - cosd(theta);
term3 = (R^2 - sind(theta).^2).^0.5;
V = (1 + term1*(term2-term3)).*v_clearance;
end
9. Output
Compression ratio: - 12
Thermal efficiency: - 62.9893
Plot Command is used to get the final plot but we need to plot the two graphs in the same figure. Hence, we are using a hold on command to do it.
xlable() and ylabel() commands are used to define the labels in the plots. title() command is used to define the plot title.
10. Conclusion: -
Hence, we are able to program the code to solve an Otto cycle and Plot PV Diagram. Also found is the thermal efficiency of the Otto cycle. with the help of this program, by small adjustments in the program, we can use it in multiple applications.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Project 2-Highway Assistant-Lane Changing Assistant
AIM: - Develop model as per given requirement and generate AUTOsar software compile code. OBJECTIVE: - This model must be developed in MATLAB Simulink per MBD guidelines. Code Generation Profile must be Autosar Coder. Simulink Data Dictionary must be created for the model & must be linked to the model. All the input…
30 Apr 2022 02:11 PM IST
Project 1- Traffic Jam Assistant Feature
Aim: - To Build a Simulink model for Traffic Jam Assistant as per the requirement document and create requirements tagging. To check a model under standard guidelines with help of a model adviser. (MABB guidelines) To build an embedded code for the model. Objective: - Development of MATLAB Simulink model as per requirement.…
12 Apr 2022 07:35 AM IST
Project 2 Adaptive Cruise Control
Aim: - To Build a Simulink model as per the requirement document and create requirements tagging. To check a model under standard guidelines with help of a model adviser. (MABB guidelines) To build an embedded code for the model. Objective: - Developing Adaptive Cruise Control feature as per the Requirement Document using…
04 Apr 2022 08:35 AM IST
Project 1 (Mini Project on Vehicle Direction Detection
Aim: - To Build a Simulink model as per requirement document and create requirements tagging. To check a model under standard guidelines with help of model adviser. (MABB guidelines) To build an embedded code for model. Objective: - Development of MATLAB Simulink model as per requirement. Tag the requirements to the simulink…
01 Apr 2022 11:49 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.