Project

Air Standard Cycle using MATLAB

AIM : To visualize P-V Diagram of Otto Cycle and to calculate thermal efficiency using Matlab.

OBJECTIVE :

  • To study the Otto Cycle and write a program to calculate the state variables of Otto Cycle.
  • To write a program to plot a P-V diagram of the Otto Cycle.
  • To calculate Thermal Efficiency of Otto Cycle using Matlab.

THEORY :

Air Standard Cycle –

To carry out the analysis of the heat engines, the concept of air standard cycles was conceived. In these cycles certain mass of air is considered to be working in the thermodynamic cycle. The addition and rejection of heat is considered to take place with the external reservoir and ideally all the processes are reversible. The internal combustion engines are considered to be working on the principle of air standard cycles. The two most commonly used air standard cycles are Otto cycle and Diesel cycle. The Otto cycle corresponds to four stroke gasoline or petrol engines also called Spark Ignition (SI) engines. The Diesel cycle corresponds to four stroke Diesel engines also called as Compression Ignition (CI) engines.

Assumptions made in Air Standard Cycles -

  • The combustion process is idealized by a constant-volume process (SI cycle), a constant-pressure process (CI cycle), or a combination of both (CI Dual cycle).
  • Exhaust blow down is approximated by a constant-volume process.
  • All processes are considered reversible.

Otto Cycle –

The Otto cycle is an air standard cycle which approximates the processes in petrol or diesel engines. It is based on constant volume heat addition (combustion) and heat rejection processes, and isentropic compression and expansion. The air-standard Otto cycle is the idealized cycle for spark-ignition internal combustion engines. This cycle is shown above on P–V and T-S diagrams. The spark-ignition engine is modelled with this Otto cycle. The actual P-V diagram for an engine has rounded corners because of the processes of combustion take place at a finite rate. The Ideal Otto cycle has sharp corners because the ‘combustion’ is switched on and off instantaneously.

The Otto cycle 1 → 2 → 3 → 4 consists of following four processes:

Process 1 → 2: Reversible adiabatic compression of air;

Process 2 → 3: Heat addition at constant volume;

Process 3 → 4: Reversible adiabatic expansion of air;

Process 4 → 1: Heat rejection at constant volume.

A typical engine cycle of four-stroke petrol engine is defined in the above figure. It consists of a compression stroke(a), followed by a period of combustion close to top dead centre(b) and then by expansion(c). These two strokes form the power producing processes, but afterwards the products of combustion have to be replaced by fresh air. So the exhaust valve is open at the beginning of the exhaust stroke and the burnt gases is expelled away by the upward motion of the piston(d). In a four-stroke engine the piston executes two complete revolutions of the crankshaft, and uses two strokes while the gas is pushed out by the piston on the up stroke, and then the intake valve is opened to enable air to be induced.

Detailed Processes –

  1. Process 1 → 2: Reversible adiabatic compression of air : During this phase the piston will be drawn up, so it can compress the fuel-air mixture that entered the chamber. The compression causes the mixture to increase slightly in pressure and temperature. However, no heat is exchanged. In terms of thermodynamics, this is referred to as an adiabatic process. When the cycle reaches point 2, that is when the fuel is met by the spark plug to be ignited.
  1. Process 2 → 3: Heat addition at constant volume : This is where combustion occurs due to the ignition of fuel by the spark plug. The combustion of the gas is complete at point 3, which results in a highly pressurized chamber that has a lot of heat (thermal energy). In terms of thermodynamics, this is referred to as an isochoric process.
  1. Process 3 → 4: Reversible adiabatic expansion of air : The thermal energy in the chamber as a result of combustion is used to do work on the piston which pushes the piston down increasing the volume of the chamber. This is also known as the power stroke because it is when the thermal energy is turned into motion to power the machine or vehicle.
  1. Process 4 → 1: Heat rejection at constant volume : From process 4 to 1, all waste heat is expelled from the engine chamber. As the heat leaves the gas, the molecules lose kinetic energy causing the decrease in pressure. Then the exhaust phase occurs when the remaining mixture in the chamber is compressed by the piston to be exhausted out, without changing the pressure.
  • FORMULAS :
  1. Swept Volume (Vs) – The volume swept by the piston during its motion is called as swept volume. It is given as,

`V_s= π/4×d^2×l`

where,

d = diameter or bore of the piston;

`l` = height of the piston.

  1. Clearance Volume (Vc) – The space or volume which is left between the piston and top dead center of the cylinder during the combustion or exhaust stroke is called as clearance volume.

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

where,

rc = Compression Ratio of the cylinder.

  1. Total Volume (VT) – The Total Volume of the cylinder is the summation of Swept Volume of the piston and the Clearance Volume.

`V_T=V_s+ V_c`

  1. Adiabatic Process - The process which occurs without transferring heat or mass between a thermodynamic system and its surroundings is called as adiabatic process. This process obeys Boyle’s law which is given as,

`PV^γ=Constant`

where,

P = Pressure of the system;

V = Volume of the system;

g = Value of ratio of specific heats for the fluid.

  1. Combined Gas Law – This law is stated as the volume of a given amount of gas is proportional to the ratio of its temperature and pressure.

`(PV)/T=Constant`

  1. Change of volume inside the engine combustion chamber is given by,

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

where,

V = Volume inside cylinder when piston is at an angle `theta`.

R = Ratio of length of connecting rod to crank pin radius (a).

Also crank pin radius (a) = stroke length `l`/2

  1. Thermal Efficiency of Otto Cycle (h) – It is given as,

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

MATLAB Program :

%Program to plot otto cycle PV diagram
clear all
close all
clc

%Inputs
gamma = 1.4;
t3 = 3500;             %in Kelvin

%State variables
p1 = 150500;           %in Pa
t1 = 700;              %in Kelvin

%Engine Geometric Parametres 
bore = 0.3;            %in metres
stroke = 0.3;          %in metres
con_rod = 0.15;        %in metres
cr = 14;

%Calculating swept volume and clearance volume
v_s = (pi/4)*bore^2*stroke;
v_c = v_s/(cr-1);

v1 = v_s + v_c;
v2 = v_c;

%State variables at state point 2
%Using equation p2v2^gamma = p1v1^gamma
%p2 = p1*(v1/v2)^gamma = p1*cr^gamma
p2 = p1*cr^gamma;

%p1v1/t1 = p2v2/t2 | t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);

constant_c = p1*v1^gamma;
V_compression = Otto_cycle_formula(bore,stroke,con_rod,cr,180,360);

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_formula(bore,stroke,con_rod,cr,0,180);

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;

t4 = p4*v4*t3/(p3*v3);

%THERMAL EFFICIENCY
Thermal_Efficiency = 1-((cr)^(1-gamma))

%Plotting
figure(2)
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','b')
plot([v4 v1],[p4 p1],'color','b')

Step-wise Explanation of the Code :

  1. The code starts with clear all, close all and clc where,
  • ‘clear all’ command is used to clear the data stored in the workspace.
  • ‘close all’ command is used to close all plots and figures.
  • ‘clc’ command is used to clear the command window.
  1. Then the given inputs or known values of `gamma`, t3, p1, t1, are entered. Here pn represents pressure at state point ‘n’, tn represents temperature at point ‘n’ and vn represents volume at point ‘n’ where ‘n’ can be 1, 2, 3 or 4.
  2. Then the Engine Geometric parameters are entered which include bore diameter, stroke length, connecting rod length and the compression ratio of the engine.
  3. The swept volume and clearance volume is calculated using some relations and formulas.
  4. The state variables v1, v2, p2, t2, v3, p3, v4 and p4 are calculated using the formulas mentioned above.
  5. Now to achieve a set of solution for every value of crank angle , a separate code is written in new script.
    function [V] = Otto_cycle_formula(bore,stroke,con_rod,cr,start_crank,end_crank)
    
    a = stroke/2;
    R = con_rod/a;
    
    v_s = (pi/4)*bore^2*stroke;
    v_c = v_s/(cr-1);
    
    theta = linspace(start_crank,end_crank,200);
    
    t1 = 0.5*(cr-1);
    t2 = R + 1 - cosd(theta);
    t3 = (R^2 - sind(theta).^2).^0.5;
    
    V = (1 + t1*(t2 - t3)).*v_c;
    
    
    end​
  6. Here in this script, ‘function’ syntax is used which declares a function named “Otto_cycle_Formula” that acceps inputs “bore, stroke, con_rod, cr, start_crank, end_crank” and returns outputs in the “V” array.
  7. To compute this array the formulas for a, R, `V_s` and `V_c` are entered.
  8. The value of crank angle ‘theta’ is calculated for 200 values between initial angle and final angle.
  9. Then to obtain a curve, the equation of V i.e Volume inside cylinder when piston is at an angle `theta`, is formulated.
  10. This function is called in the code and V_compression, P_compression, V_expansion, P_expansion is calculated with respect to the values of crank angle ‘theta’.
  11. The Thermal Efficiency is calculated by using the formula mentioned above.
  12. Finally all state variable points are plotted along with the curves and the PV cycle is thus obtained.

Plot for P-V diagram :

Values from Workspace :

ERRORS :

  • Invalid expression or missing logical operators -Solution – The missing multiplication operator ‘*’ is corrected.

RESULTS :

  • The P-V diagram for all the four process have been plotted. It is been noted that the actual P-V diagram has round corners compared to ideal P-V diagram.
  • The thermal efficiency of the Otto Cycle is 65.20%. As noted, the thermal efficiency mainly depends on compression ratio of the engine and the type of fluid. So it can be concluded that engines with higher compression ratio will have high thermal efficiency.
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.