Project

Week 2 Air standard Cycle

AIM : To write a program in MATLAB to solve an Otto cycle and make plots for it.

OBJECTIVE :

  • To solve and find out different state variables in Otto cycle and plot it's p-v diagram.
  • To calculate the thermal efficiency of the given Otto cycle.

THEORY : The Otto cycle is the ideal cycle for spark-ignition reciprocating engines. In most spark-ignition engines, the piston executes four complete strokes (two mechanical cycles) within the cylinder, and the crankshaft completes two revolutions for each thermodynamic cycle. These engines are called four-stroke internal combustion engines.

Initially, both the intake and the exhaust valves are closed, and the piston is at its lowest position (BDC). During the compression stroke, the piston moves upward, compressing the air-fuel mixture. Shortly before the piston reaches its highest position (TDC), the spark plug fires and the mixture
ignites, increasing the pressure and temperature of the system. The highpressure gases force the piston down, which in turn forces the crankshaft to rotate, producing a useful work output during the expansion or power stroke. At the end of this stroke, the piston is at its lowest position (the completion
of the first mechanical cycle), and the cylinder is filled with combustion products. Now the piston moves upward one more time, purging the exhaust gases through the exhaust valve (the exhaust stroke), and down a second time, drawing in fresh air-fuel mixture through the intake valve (the intake
stroke). Notice that the pressure in the cylinder is slightly above the atmospheric value during the exhaust stroke and slightly below during the intake stroke.

Fig.1 -Actual and ideal cycles in spark-ignition engines and their p-v diagrams.

The four processes in an Otto cycle are:

  1. Isentropic compression process or Reversible adiabatic compression of air (Process 1-2),
  2. Constant volume heat addition process (Process 2-3),
  3. Isentropic expansion process or Reversible adiabatic expansion of air (Process 3-4),
  4. Constant volume heat rejection process (Process 4-1).

GOVERNING EQUATIONS :

Various equations of Otto cycle are involved in this project. These are :

  • Compression ratio (`r_c`) , `r_c = (V_1/V_2)` or `1 + V_s/V_c`,
  • Swept volume (`V_s`) = `pi/4 *d^2*l`, where d is bore diameter and l is stroke length,
  • `V/V_c` = 1 + `1/2(r_c - 1)[ R+1-costheta-(R^2 -sin^2theta)^(1/2)]`,

where R = length of connecting rod/crank radius ,

  • Adiabatic process equation = `p*v^gamma` = constant,
  • Ideal Gas equation = `p*v = m*R*T`,
  • Thermal efficiency of Otto cycle(`eta`)= `1-1/(r_c^(gamma-1))`,
  • From the figure, `v_1` = `v_s + v_c` , `v_2 = v_c`.

BODY OF THE CONTENT :

EXPLANATION OF MATLAB CODES :

  • Since Otto cycle is an air-standard cycle, the specific heat (`gamma`) of air is taken as 1.4.
  • Initial conditions, such as temperature (`T_1`)and pressure (`p_1`) of surrounding is assumed to be 313K and 101.325 kPa respectively.
  • The geometrical design of engine cylinder which consists of bore diameter, stroke length and length of connecting rod is also known and accordingly `v_s` and `v_c` are calculated.
  • The maximumum temperature (`T_3`) occuring inside the cylinder is also known .
  • Other state variables are calculated using Adiabatic processes equations and ideal gas equations.
  • Similarly the thermal efficiency is also calculated accordingly using the formula given.
  • For plotting the calculated state variables on a p-v diagram with just using plot command will yield into incorrect p-v diagram.
  • So to rectify this, a different funtion is created for storing different value of crank angle rotation as compression and expansion occurs in different stroke or cycle. This function is then called to main program and accordingly plot is drawn from various points obtained.

MATLAB CODE FOR SOLVING AND PLOTTING CURVE :

% A program to calculate different state variables in an Otto Cycle and to
%  calculate its thermal efficiency and plot it on p-v diagram

clear all
close all
clc

% Inputs varibale

gamma = 1.4;                                  % for air gamma= 1.4
T3 = 1873;                                    % max temp inside engine cyr

% State variable
 
 p1 = 101325;                                 % ambient atmospheric
 T1 = 313;                                    % conditions assumed
 
% Engine geometry properties
 
 bore = 0.15;
 stroke = 0.2;
 connecting_rod = 0.8;
 c_r = 10.5;
 
 % Calculating swept volume and clearance volume
 
 v_swept = (pi/4)*bore^2*stroke;
 v_clearance = v_swept/(c_r -1) ;
 v1 = v_swept + v_clearance;
 v2 = v_clearance;
  
 % state variables at state point 2          
 % p2*v2^gamma = p1*v1^gamma                  % Isentropic compression
 
 p2 = p1* c_r^gamma;
 
 % (p1*v1)/T1 = (p2*v2)/T2 | T2 = p2*v2*T1/(p1*v1)
 
 T2 = p2*v2*T1/(p1*v1);
 
 C_const = p1*(v1^gamma);
 V_comp = engine_kinematics(bore,stroke,connecting_rod,c_r,180,0);
 P_comp = C_const./V_comp.^gamma;
 
 % State variables at state point 3
 
 v3 = v2;                                     % Isochoric process
  
 % (p3*v3)/T3 = (p4*v4)/T4 | p3 = p2*T3/(T2)
 
 p3 = p2*T3/(T2);
 
 C_const = p3*(v3^gamma);
 V_exp = engine_kinematics(bore,stroke,connecting_rod,c_r,0,180);
 P_exp = C_const./V_exp.^gamma;
   
   
 % state variables at state point 4
 v4 = v1;                                    % Isochoric process  
 
 % p3*v3^gamma = p4*v4^gamma                 % Isentropic expansion process
 p4 = p3* (v3/v4)^gamma;
 
 % Calculating thermal efficiency
 
 thermal_efficincy = 1- (1/((c_r)^(gamma-1)));
 Ques_2 = strcat('The thermal efficiency of the given Otto cycle is =',num2str( thermal_efficincy))
 % Plotting the state variables data on p-v diagram
 
 figure(1)
 hold on
 
 plot(v1, p1, '*', 'color', 'r')
 plot(V_comp, P_comp,'linewidth',2)
 
 plot(v2, p2, '*', 'color', 'r')
 
 plot(v3, p3, '*', 'color', 'r')
 line([v2 v3],[p2 p3],'color','b','linewidth',2)
 plot(V_exp, P_exp,'linewidth',2)
  
 plot(v4, p4, '*', 'color', 'r')
 line([v4 v1],[p4 p1],'color','b','linewidth',2)
 
 xlabel('Volume (m^3)')
 ylabel('Pressure (Pa)')
 grid on 

MATLAB CODE FOR CREATING FUNCTION USED IN MAIN PROGRAM :

% Function for Engine kinematics
function [V] = engine_kinematics(bore, stroke, con_rod, c_r, start_crank, end_crank)

r = (stroke/2);
n = con_rod/r;
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(c_r -1) ;

theta = linspace(start_crank, end_crank, 100);    % creating a linearly spaced vector of crank angle

term_1 = 0.5*(c_r - 1);                           % disintegrating the formula into smaller parts
term_2 = n + 1 - cosd(theta);
term_3 = (n^2 - sind(theta).^2).^0.5;

% finding volume trace

V = (1 + term_1* (term_2 -term_3)).*v_clearance;

end

ERRORS AND REMEDIES :

  • Element wise operator was missing while using arithmatic operations on arrays.
  • It was rectified by putting "." at required places.
  • The above plot for p-v curve was obtained initially. On finding the cause of error it was observed that there was an unnecessary line in the function program as
  • This line was removed and program works as desired.

RESULTS :

  • The following plot for p-v curve was observed:
  • The themal efficiency and different state variables calculated are as follows:

CONCLUSION : The desired and correct p-v diagram of Otto cycle was obtained using an array of volume inside the engine cylinder at different crank angle.

REFERENCES : The theory and fig 1 is derived from Thermodynamics- An engineering approach by Y.A Cengel.

  • `p` = pressure,
  • `v` = volume of engine cylinder,
  • `T` = temperature,
  • `v_c` = clearance volume, (Clearance volume is a volume between the cylinder head and the piston top when the piston is at top dead center (TDC).),
  • `v_s` = swept volume,(Swept volume is the displacement of one cylinder. It is the volume between top dead center (TDC) and bottom dead center (BDC).),
  • `gamma`= specific heat,
  • `d` = bore diameter (diameter of each cylinder)
  • `l`= stroke length (The stroke length is how far the piston travels in the cylinder, which is determined by the cranks on the crankshaft.)
  • `eta`= 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.