Project

Matlab code to plot PV diagram for Ideal Otto cycle, and to calculate its thermal efficiency.

AIM:

To write a code that can create PV diagram for Otto cycle and calculate thermal efficiency.

Theory:

The Otto cycle is a set of process used by spark ignition internal combustion engines (2-stroke or 4 -stroke cycles). These engines a)ingest a mixture of fuel and air ,b)compress it, c)cause it to react, thus effectively adding heat through converting chemical energy into thermal energy ,d)expand the fuel and air.

The different processes are show in the figure:

  1. Intake stroke ,gasoline vapour and air drawn into engine(0-1).
  2. Compression stroke,(isentropic compression pressure and temperature increases (1-2)).
  3. Combustion (spark),short time, essentially constant volume (2-3),pressure and temperature increases.(constant volume heat addition)
  4. Power stroke : expansion (3-4).(isentropic expansion)
  5. Valve exhaust :valve opens ,gas escapes. Rejection of heat (4-1).(constant volume heat rejection)
  6. Exhaust stroke, piston pushes remaining combustion products out of chamber (1-0).

Engine geometric parameters:

1.bore (B)

2.stroke(S)

3.connecting rod length(r)

4.cr(compression ratio)

Governing equation

Volume swept=`(π÷4)×(bb"bore")^2×stroke`

Volume clearance=(volume swept÷(cr-1))

Representation

p=pressure

v=volume

T=temperatue

`gamma`= specific heat ratio

Compression stroke:

`p2v2^gamma = p1v1^gamma`

cr=v1/v2

T2=`((p2×v2×T1)/(p1×v1))`

Combustion stroke:

p3=p2*(T3/T2) ,v3=v2

Power stroke:

v4=v1

`p4v4^gamma = p3v3^gamma`

Thermal efficiency:

`eta=((bb"work done")/(bb"heat absorbed"))`

`eta=1-(1/(cr^(gamma-1) ))`

Piston kinematics:

The variation of volume is not linear during the motion of piston. The equation can tells us variation of volume with respective to crank angle.

`v=vc×(1+0.5×(cr-1)(R+1-costheta-√(R^2-sin^2⁡theta ) ).`

Objectives:

  1. To write the Mat lab program to plot state points of Otto cycle on Pressure volume graphs.
  2. Identify the mistake ,over the mistakes.
  3. Plot correct PV diagram of Otto cycle.
  4. Calculation of thermal efficiency.

Body of the content:

The below code will calculate pressure volume at state point 1 2 3 4 of otto cycle and plot them on PV diagram and

will calculate efficiency of otto cycle.

%state variables

p1=101325 pascal

T1=500K

the units of volume is `m^3`

%inputs

gamma=1.4

T3=2300K

%Engine geometric parameters

bore=0.1

con-rod=0.15

stroke=0.1

cr=7

Code:

clear all
close all
clc
%state variables
p1=1013250;
 T1=500;
 %input
 T3=2300;
 gamma=1.4;
 %engine geometric parameters
 bore=0.1;
 s=0.1;
 crod=0.15;
 cr=7;
 %calculating swept volume and the clearance volume
 v_swept=(pi/4)*bore^2*s;
 v_clearance=v_swept/(cr-1);
 v1=v_swept+v_clearance;
 v2=v_clearance;
 g=1.4;
 %calculation of state variables at state point 2
 %p2*v2^g=p1*v1^g
 p2=p1*cr^g;
%(p1*v1/T1)=(p2*v2/T2)|T2=(p2*v2*T2)/(p1*v1) 
 T2=( p2*v2*T1/(p1*v1));
 %calculation of state varibles at point 3 
 %(p2/T2)=(p3/T3)|v3=v2
 p3=(p2*T3/T2);
 v3=v2;
 %calculation of state varibes at point 4
 %p3*v3^gamma=p4*v4^gammma
 v4=v1;
 p4=p3*(v3/v4)^g;
 figure(1)
 hold on
 plot(v1,p1,'*','color','r')
  plot(v2,p2,'*','color','r')
   plot(v3,p3,'*','color','r')
    plot(v4,p4,'*','color','r')
   xlabel('volume ')
   ylabel('pressure')
   title({'PV Diagram'; 'state point of Otto cyle'})
   figure(2)
   plot([v1 v2 v3 v4 v1],[p1 p2 p3 p4 p1],'color','b')
     xlabel('volume ')
   ylabel('pressure')
   title({'PV Diagram';  'Otto cyle'})
   thermalefficiency=(1-1/cr^(g-1))

state points of otto cycle

thermal efficiecy:

error:

The above plot does not represent Otto cycle. To draw the actual plot of Otto cycle we have to consider the concept of piston dynamic.In actual volume does not vary linearly between top dead centre and botton centre . The variation of the volume is show below:

The below code will plot actual PV diagram for Otto cycle :

clear all
close all
clc
%state variables
p1=1013250;
 T1=500;
 %input
 T3=2300;
 gamma=1.4;
 %engine geometric parameters
 bore=0.1;
 s=0.1;
 crod=0.15;
 cr=7;
 %calculating swept volume and the clearance volume
 v_swept=(pi/4)*bore^2*s;
 v_clearance=v_swept/(cr-1);
 v1=v_swept+v_clearance;
 v2=v_clearance;
 g=1.4;
 %calculation of state variables at state point 2
 %p2*v2^g=p1*v1^g
 p2=p1*cr^g;
  c=p1*v1^g;
 v_compression=engine_kinematics(0.1,0.1,cr,0.15,180,0);
 p_compression=(c./v_compression.^g);
%(p1*v1/T1)=(p2*v2/T2)|T2=(p2*v2*T2)/(p1*v1) 
 T2=( p2*v2*T1/(p1*v1));
 %calculation of state varibles at point 3 
 %(p2/T2)=(p3/T3)|v3=v2
 p3=(p2*T3/T2);
 v3=v2;
 %calculation of state varibes at point 4
 %p3*v3^gamma=p4*v4^gammma
 v4=v1;
 p4=p3*(v3/v4)^g;
 c2=p3*(v3)^g;
 v_expansion=engine_kinematics(0.1,0.1,cr,0.15,0,180);
 p_expansion=c2./(v_expansion.^g);
 figure(1)
 hold on
  plot(v1,p1,'*','color','r')
  plot(v2,p2,'*','color','r')
  plot(v3,p3,'*','color','r')
  plot(v4,p4,'*','color','r')
  P1=plot(v_compression,p_compression,'color','m')%isentropic compression
  P2=plot([v2 v3],[p2 p3],'color','b')%constant volume heat addition
  P3=plot(v_expansion,p_expansion,'color','y')%isentropic expansion
  P4=plot([v4 v1],[p4,p1],'color','g')%constant volume heat rejection
  xlabel('volume ')
  ylabel('pressure')
  title({'PV Diagram';'Otto cycle'})
  legend([P1 P2 P3 P4],{'isentropic compression','constant volume heat addition','isentropic expansion','constant volume heat rejection'})
  thermalefficiency=(1-1/cr^(g-1))     

the code will plot the actual Otto cycle

Workspace of the code:

To plot the above graph engine_kinematics function was used. The below one is code for engine_kinematics:

function v = engine_kinematics(bore,stroke,cr,con_rod,start_crank,end_crank)
a=stroke/2;
R=con_rod/a;
theta=linspace(start_crank,end_crank,abs(end_crank-start_crank));
v_s = (pi/4)*bore^2*stroke;
v_c=v_s/(cr-1);
term1=0.5*(cr-1);
term2=R+1-cosd(theta);
term3=(R^2-sind(theta).^2).^0.5;
 v=(1+term1*(term2-term3)).*v_c;
end

Conclusion:

1.The code has calculated the pressure and volume at various state point ( i.e 1,2,3,4).

2.Has plotted the state point (1,2,3,4) on PV diagram.

3.Ideal otto cycle was plotted.

4.The actual otto cycle is different from the ideal otto cycle.

5.Thermal efficiency was calculated, so thermal efficiency is 54.08%.

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.