Project

Air Standard Cycle - Otto Cycle (PV - Diagram)

AIR STANDARD CYCLE – OTTO CYCLE (PV DIAGRAM)

OBJECTIVE :-

To create a program to plot the PV diagram of Otto Cycle and calculate the thermal efficiency of the IC (Internal Combustion) Engine.

PLATFORM USED :-

  1. Software – MATLAB R2019a
  2. Programming Language – Python

SYSTEM SPECIFICATIONS :-

  1. Manufacturer - DELL
  2. Operating System - Windows 10
  3. Processor - Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz 1.80GHz
  4. RAM – 8 GB

GOVERNING EQUATIONS :-

a) Volume change inside the combustion chamber,

`V/V_c = 1 + 1/2 (r_c -1) [R + 1 – cosθ – (R^2 - (sin)^2 θ)]^( 1/2`

Where,

V - Volume [`mm^3`]

`V_c` - Clearance Volume [cc]

`r_c` - Compression Ratio [No Unit]

R - Connecting Rod Length [mm]

b) Ideal Gas Equation,

PV = nRT

Where,

P - Pressure [Pa - Pascal]

V - Volume [`mm^3`]

n - No of Moles

R - Gas Constant [8.314 `J mol^(-1) k^(-1)` ]

T - Temperature [k - Kelvin]

c) During Adiabatic Process,

`PV^γ` = constant

Where,

P - Pressure [P – Pascal]

V - Volume

𝛾 - `C_p/C_v` [`C_p` – Constant Pressure & `C_v` – Constant Volume]

d) Thermal Efficiency,

`η = 1 - 1/((r_c)^(γ-1) )`

Where,

`η` - Otto Cycle Efficiency

`r_c` - Compression Ratio

𝛾 - `C_p/C_v` [`C_p` – Constant Pressure & `C_v` – Constant Volume]

e) Swept Volume,

`V_s = π/4 d^2 l`

Where,

d - Bore (Cylinder diameter) [mm]

l - Stroke (Length of Connecting Rod) [mm]

f) Clearance Volume,

`V_c = V_s/((r_c-1))`

Where,

`V_s` - Swept Volume [cc]

`r_c` - Compression Ratio [No Unit]

DESCRIPTION :-

INTRODUCTION :-

Initially we need to calculate P (Pressure), V (Volume), T (Temperature) for all the four various state points and plot them in graph. Then using the geometric parameters associated with engine kinematics (Bore, Stroke, Clearance Volume & Swept Volume) need to manipulate the volume from one state to another state. Then plot the graph between pressure and volume to get PV – Diagram for Otto Cycle, simultaneously calculating the thermal efficiency of the engine.

OTTO CYCLE – PV DIAGRAM :-

Various Stages in Otto Cycle (PV Diagram) :-

  1. Stage 1 - Process 1 – 2 : Adiabatic Compression
  2. Stage 2 - Process 2 – 3 : Constant Volume Heat Addition
  3. Stage 3 - Process 3 – 4 : Adiabatic Expansion
  4. Stage 4 - Process 4 – 1 : Constant Volume Heat Rejection

ENGINE KINEMATICS :-

The motion of crank mechanism and its associated parameters are considered as follows,

  1. Bore
  2. Stroke
  3. Connecting Rod Length
  4. Compression Ratio

PISTON KINEMATICS IN IC ENGINE (OTTO CYCLE) :-

The piston moves from TDC (Top Dead Center) to BDC (Bottom Dead Center) or vice-versa during the funtion on IC engine. The motion associated is linear reciprocating motion for piston and rotational motion for crank and connecting rod.

INPUT AND OUTPUT PARAMETERS :-

INPUT PARAMETERS :-

  1. Pressure (P1 = 101325 Pa ) and Temperature (T1 = 500 k) at State 1
  2. Temperature (T3 = 2300 k) at state 3
  3. Gamma (𝛾) = 1.4
  4. Bore = 0.1
  5. Stroke = 0.1
  6. Connecting Rod Length (con_rod) = 0.15
  7. Compression Ratio (cr) = 12
  8. Starting Crank Angle (start_crank) and Ending Crank Angle (end_crank)

OUTPUT PARAMETERS :-

  1. Volume (V1) at State 1
  2. Pressure (P2), Volume (V2) and Temperature (T2) at State 2
  3. Pressure (P3) and Volume (T3) at State 3
  4. Pressure (P4) and Volume (V4) at State 4
  5. Clearance Volume (v_clearance)
  6. Swept Volume (v_swept)
  7. Total volume at compression (V_compression) and total pressure at compression (P_compression)
  8. Total Volume at expansion (V_ expansion) and total pressure at expansion (P_ expansion)

CODING :-

CODE FOR PLOTTING FOUR STATE POINTS

% Clearing all the stored values in Workspace
clear all
% Terminating all the plotted graphs
close all
% Clearing all the outputs in Command Window
clc

% Input parameters for state 1
% Pressure (P1)
p1 = 101325;
% Temperature (T1)
t1 = 500;


% Input parameters for state 3
% Temperature (T1)
t3 = 2300;

% Input parameters for Ideal Gas Equation
gamma = 1.4;

% Engine Geometric Parameters
% Cylinder Diameter
bore = 0.1;
% Stroke Length
stroke = 0.1;
% Length of Connecting Rod
con_rod = 0.15;
% Compression Ratio
cr = 12;
% Swept Volume
v_swept = (pi/4)*bore^2*stroke;
% Clearance Volume
v_clearance = v_swept/(cr-1);

% Formula for determining volume at state 1 & 2 (V1 & V2)
v1 = v_swept + v_clearance;
v2 = v_clearance;

% Determining variables at state 2
% Pressure (P2)
% Adiabatic Process - (p1*v1)^gamma = (p2*v2)^gamma
p2 = p1*cr^gamma;

% Temperature (T2)
% From Ideal Gas Equation - (p1*v1)/t1 = (p2*v2)/t2
t2 = p2*v2*t1/(p1*v1);

% Defining variables at state 3
% Volume is constant during heat addition process
% Volume (V3)
v3 = v2;

% From Ideal Gas Equation - (p3*v3)/t3 = (p2*v2)/t2
p3 = p2*(t3/t2);
% Defining variables at state 4
% Volume is constant during heat rejection process
% Volume (V4)
v4 = v1;

% Pressure (P4)
% Adiabatic Process - (p13*v3)^gamma = (p4*v4)^gamma
p4 = p3*(v3/v4)^gamma;

% Plotting the different state points in graph
% Retaining the plots that are newly generated in the current plot
hold on;
% Plotting the state 1 (Pressure & Volume) points
plot(v1,p1,'*','color','r')
% Plotting the state 2 (Pressure & Volume) points 
plot(v2,p2,'*','color','r')
% Plotting the state 3 (Pressure & Volume) points 
plot(v3,p3,'*','color','r')
% Plotting the state 4 (Pressure & Volume) points 
plot(v4,p4,'*','color','r')
% Assigning the name for X-axis
xlabel('Volume')
% Assigning the name for Y-axis
ylabel('Pressure')
% Assigning title for the graph that is being plotted
title('Four State Points (P&V) in Otto Cycle')

PROGRAM PROCESS :-

  1. The compiler starts the program.
  2. At first it will clear all the old data from the workspace window, next the old plots will be terminated and the outputs in command window will be cleared.
  3. Then the compiler will check the input parameters and its assigned values.
  4. The swept and clearance volume will be calculated.
  5. Then v1 is calculated and the clearance volume value is stored in variable v2.
  6. Next p2 and t2 are calculated and values are stored respectively.
  7. The value of v2 is assigned to v3 variable.
  8. Then p3 is calculated and values are stored respectively.
  9. Now the value of v1 is assigned to v4 variable.
  10. Then p4 is calculated and values are stored respectively.
  11. The ‘hold on’ command is executed to update all the plots that are newly generated to the primary plot.
  12. Then the graphical representation is don by plotting all the pressure (p1,p2,p3,p4) and volume (v1,v2,v3,v4) variables respectively.
  13. Then the name for X-axis and Y-axis are assigned.
  14. Finally title for the plot is assigned.
  15. The compiler terminates the program.

ERROR ENCOUNTERED :-

  1. ERROR 1 – Plotted the pressure and volume for all four states in a straight line which is wrong because only constant volume heat addition and heat rejection should be connected in straight lines.
  2. ERROR 2 – Forgot to include brackets for the equation so that the state 1 and state 2 points were plotted along the X-axis. [t2 = p2*v2*t1/p1*v1 corrected to t2 = p2*v2*t1/(p1*v1)].

ERROR 1

ERROR 2

OUTPUT :-

  1. The four state points were plotted in the graph with Pressure and Volume as Y and X axes respectively.

CODE FOR OBTAINING THE VOLUME TRACE DURING COMBUSTION USING ENGINE GEOMETRIC PARAMETERS

CODING :-

% Program to calculate the total volume from one state to another using engine geometric parameters

% Engine Geometric Parameters
% Template to input no of parameters and call the function when required
% Inputting the engine geometric parameters as a function of engine_kinematics
% Assigning the output to variable ‘[V]’
function [V] = engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)

% Calculating crank pin radius and connecting rod length
% Crank Pin Radius
a = stroke/2;
% Connecting Rod Length
R = con_rod/a;
 
% Calculating swept and clearance volume
% Swept Volume
v_swept = (pi/4)*bore^2*stroke;
% Clearance Volume
v_clearance = v_swept/(cr-1);
 
% Determining Crank Angle using input values and ‘linspace’ command
% Linspace command generates 200 values between start_crank and end_crank
theta = linspace(start_crank,end_crank,200);

% The equation for determining the volume trace from one state to another using engine geometric parameters
% The equation is divided into three different terms for easier calculation
term1 = 0.5*(cr-1);
term2 = R+1-cosd(theta);
term3 = (R^2-sind(theta).^2).^0.5;
 % The divided terms are combined into a single equation for calculating volume
V = (1+term1*(term2-term3)).*v_clearance;
 
% For a function in programming should have a end line to determine the limits
end

PROGRAM PROCESS :-

  1. The compiler starts the program.
  2. Then it checks for the input parameters in the function template is correct.
  3. Then for further execution of the command lines the compiler searches for the values of input parameters which is to be provided by us.
  4. Then the crank pin radius is calculated and stored in variable ‘a’.
  5. Then connecting rod length is calculated and stored in variable ‘R’.
  6. Then swept volume and clearance volume are calculated.
  7. Then for plotting the volume trace the crank angle to be generated for solving the equation which is done by ‘linspace’ command and the angle limits are manually entered including the number of values to be generated.
  8. The equation for calculating volume between two states are divided into three terms (term1, term2 & term3) for easy calculation.
  9. Then term1, term2 and term3 are calculated followed by storing the values respectively.
  10. Then the complete equation is solved by combining all the three terms using required arithmetic operations.
  11. Then the function ends.
  12. The compiler terminates the program.

ERROR ENCOUNTERED :-

  1. ERROR 3 – Forgot to enter the values for the input parameters.

ERROR CORRECTED :-

OUTPUT :-

  1. The volume trace is calculated and to check the calculation I plotted the volume trace for compression process.

CODE FOR TESTING THE FUNCTION TEMPLATE :-

% Entering the values for the input parameters and storing the value of calculated volume in V_compression variable
V_compression = engine_kinematics(0.1,0.1,0.15,12,0,180)
% Plotting the volume for compression process
plot(V_compression)
% Enabling title for the plotted graph
title('Volume Trace for Compression Stroke')

CODE FOR OTTO CYCLE (PV – DIAGRAM) AND CALCULATING THE THERMAL EFFICIENCY

INTRODUCTION :-

For generating the plot of Otto Cycle’s PV diagram, we need to combine both the above program i.e., merging the code of volume trace and code of plotting (calling the ‘engine_kinematics’ function template whenever required) the four state points in PV diagram.

CODING :-

% Clearing all the stored values in Workspace
clear all
% Terminating all the plotted graphs
close all
% Clearing all the outputs in Command Window
clc

% Input parameters for state 1
% Pressure (P1)
p1 = 101325;
% Temperature (T1)
t1 = 500;

% Input parameters for state 3
% Temperature (T1)
t3 = 2300;

% Input parameters for Ideal Gas Equation
gamma = 1.4;

% Engine Geometric Parameters
% Cylinder Diameter
bore = 0.1;
% Stroke Length
stroke = 0.1;
% Length of Connecting Rod
con_rod = 0.15;
% Compression Ratio
cr = 12;
% Swept Volume
v_swept = (pi/4)*bore^2*stroke;
% Clearance Volume
v_clearance = v_swept/(cr-1);

% Formula for determining volume at state 1 & 2 (V1 & V2)
v1 = v_swept + v_clearance;
v2 = v_clearance;

% Determining variables at state 2
% Pressure (P2)
% Adiabatic Process - (p1*v1)^gamma = (p2*v2)^gamma
p2 = p1*cr^gamma;

% Temperature (T2)
% From Ideal Gas Equation - (p1*v1)/t1 = (p2*v2)/t2
t2 = p2*v2*t1/(p1*v1);

% Determining the total pressure during compression process
% Adibatic Process – (P*V)^gamma = C (constant)
constant_c = p1*v1^gamma;
% Calling the function template from volume trace code
% During compression the piston moves from TDC γ€–(180γ€—^o) to BDC γ€–(0γ€—^o)
V_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0);
% Total pressure during compression process – P = (c/V)^gamma
P_compression = constant_c./V_compression.^gamma;

% Defining variables at state 3
% Volume is constant during heat addition process
% Volume (V3)
v3 = v2;

% From Ideal Gas Equation - (p3*v3)/t3 = (p2*v2)/t2
p3 = p2*(t3/t2);

% Determining the total pressure during expansion process
% Adibatic Process – (P*V)^gamma = C (constant)
constant_c = p3*v3^gamma;
% Calling the function template from volume trace code
% During compression the piston moves from TDC γ€–(0γ€—^o) to BDC γ€–(180γ€—^o)
V_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180);
% Total pressure during expansion process – P = (c/V)^gamma
P_expansion = constant_c./V_expansion.^gamma;

% Defining variables at state 4
% Volume is constant during heat rejection process
% Volume (V4)
v4 = v1;

% Pressure (P4)
% Adiabatic Process - (p13*v3)^gamma = (p4*v4)^gamma
p4 = p3*(v3/v4)^gamma;

% Plotting the different state points in graph
% Retaining the plots that are newly generated in the current plot
hold on;

% Plotting Pressure and Volume during Compression Stroke
plot(V_expansion,P_expansion,'linewidth',1.5,'color','b')
% Plotting the state 2 and state 3 (Pressure & Volume) points
plot([v2 v3],[p2 p3],'linewidth',1.5,'color','r')
% Plotting Pressure and Volume during Expansion Stroke
plot(V_compression,P_compression,'linewidth',1.5,'color','g')
% Plotting the state 4 and state 1 (Pressure & Volume) points
plot([v4 v1],[p4 p1],'linewidth',1.5,'color','black')

% Assigning title to the plot
title('Otto Cycle - PV Diagram')

% Assigning the name for X-axis
xlabel('Volume')
% Assigning the name for Y-axis
ylabel('Pressure')

% Enabling the legend to the plot for easy understanding
legend('Isentropic Compression','Constant Volume Heat Addition','Isentropic Expansion','Constant Volume Heat Rejection')

% Assigning title for the graph that is being plotted
title('Otto Cycle – PV Diagram')

%Thermal Efficiency of Otto Cycle
therm_efficiency = (1-(1/cr^(gamma-1)))*100;

PROGRAM PROCESS :-

  1. The compiler starts the program.
  2. At first it will clear all the old data from the workspace window, next the old plots will be terminated and the outputs in command window will be cleared.
  3. Then the compiler will check the input parameters and its assigned values.
  4. The swept and clearance volume will be calculated.
  5. Then v1 is calculated and the clearance volume value is stored in variable v2.
  6. Next p2 and t2 are calculated and values are stored respectively.
  7. Then constant (c) is calculated for compression process (p1 & v1) using adiabatic process condition.
  8. Next the function template (engine_kinematics) is called from the volume tracing program.
  9. The compiler verifies the input and output parameters match in the function template and then calculates the total pressure during compression process and stores in (P_compression) variable.
  10. Then constant (c) is calculated for expansion process (p3 & v3) using adiabatic process condition.
  11. Next the function template (engine_kinematics) is called from the volume tracing program.
  12. The compiler verifies the input and output parameters match in the function template and then calculates the total pressure during expansion process and stores in (P_expansion) variable.
  13. The value of v2 is assigned to v3 variable.
  14. Then p3 is calculated and values are stored respectively.
  15. Now the value of v1 is assigned to v4 variable.
  16. Then p4 is calculated and values are stored respectively.
  17. The ‘hold on’ command is executed to update all the plots that are newly generated to the primary plot.
  18. Then the graphical presentation is plotted for compression process pressure (P_compression) and volume (V_compression).
  19. Then the graphical representation is plotted for state 2 and state 3 pressure (p2,p3) and volume (v2,v3,) variables respectively.
  20. Then the graphical presentation is plotted for expansion process pressure (P_ expansion) and volume (V_ expansion).
  21. Then the graphical representation is plotted for state 4 and state 1 pressure (p1,p4) and volume (v1,v4,) variables respectively.
  22. The name for the plot is assigned.
  23. Then the name for X-axis and Y-axis are assigned.
  24. The legends for the plot is enabled.
  25. Thermal efficiency of Otto Cycle is calculated.
  26. The compiler terminates the program.

OUTPUT :-

  1. The PV diagram from Otto Cycle is plotted.
  2. Thermal Efficiency is calculated for Otto Cycle.
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.