Project

Plot p-v Diagram and Calculate thermal efficiency of Otto cycle using Octave

AIM: TO WRITE PROGRAM TO PLOT P-V DIAGRAM OF OTTO CYCLE AND CALCULATE THERMAL EFFICIENCY OF CYCLE USING OCTAVE

GOVERNING EQUATIONS:

1] Combined gas law: we derive this law by combining law of Charles, Boyle and Gay-Lussac law this equation will help to find property at point 2 and point 3 .

`Pv/T=C`

where

p = pressure in pascal

V = volume in m3

T = temperature in kelvin

C = constant

2] The mathematical equation for an ideal gas undergoing a reversible (i.e., no entropy generation) adiabatic process can be represented by the polytropic process equation. This equation will help in finding property related to isentropic compression and isentropic expansion.

`PV^Y=C`

where

p =pressure in pascal

V =volume in m3

Y= (Cp/Cv) =ratio of specific heat

C = constant

3] thermal efficiency of Otto cycle is given by: from analyzing equation it is evident that thermal efficiency depends directly upon compression ratio r. Since y for air is 1.4, an increase in r produce increase in ƞ.

`n=1-1/r^((Y-1) )`

where

Ƞ=thermal efficiency

r = compression ratio

y= ratio of specific heat

4) Swept volume : is the measure of the cylinder volume displaced by all of the pistons of a piston engine.

Swept volume = (π/4) *(bore^2) *stroke length

Where

Bore = diameter of each cylinder in piston engine

Stroke length = distance travelled by the piston in each cycle.

5) Clearance volume: This is the volume of the space in the cylinder left at the end of the compression stroke.

Clearance volume = (swept volume) / (compression ratio -1)

Where

Compression ratio = the ratio of the volume of the cylinder and the combustion chamber when the piston is at the bottom, and the volume of the combustion chamber when the piston is at the top

6) this equation tells about how combustion chamber volume changes as function of crank angle.

`v/v_c =1+1/2 (r_c-1)[1+R-cos⁡θ-(R^2-〖sin〗^2⁡θ )^(1/2) ]`

Where

ϴ = crank angle

rc = compression ratio

OBJECTIVES OF PROJECT:

1] To write program to plot air standard Otto cycle.

2] To understand difference between theoretical and actual Otto cycle

3] To calculate thermal efficiency

THEORETICAL BACKGROUND:

An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines.

Processes:

The processes are described by

  • Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
  • Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from bottom dead centre (BDC) to top dead Centre (TDC).
  • Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead Centre. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
  • Process 3–4 is an adiabatic (isentropic) expansion (power stroke).
  • Process 4–1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead Centre.
  • Process 1–0 the mass of air is released to the atmosphere in a constant pressure process.

MAIN PROGRAM:

Programming language used: High level Programming Language using Octave software

clear all
close all
clc
% inputs
pi=3.14;
gamma=1.4;
t3=2300;

% state variable
p1=101325
t1=500

% engine geometric parameter
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;

% calculating swept volume and clerance volume
v_swept= (pi/4)*bore^2*stroke;
v_clearance= v_swept/(cr-1);

v1= v_swept + v_clearance ;
v2= v_clearance ;

% state variable at point 2
% according to p1v1^gamma=p2v2^gamma
%p2=p1*(v1/v2)^gamma=p1*(cr)^gamma
 p2=p1*(cr)^gamma ;
 % according to ideal gas law p1*v1/t1 = p2*v2/t2 
 % t2= p2*v2/p1*v1
 t2= p2*v2*t1/(p1*v1) ;
 c_constant=p1*v1^gamma;
  v_compression= engine_kinematicts_fun(bore,stroke,con_rod,cr,180,0);
  
  p_compression = c_constant./v_compression.^gamma ;
 
 % state variables at point 3
 % according to constant volume heat addition process
 v3=v2;
 % as constant volume process p3/t3=p2/t2
 % p3=p2*t3/t2;
  p3=p2*t3/t2;
  c_constant=p3*v3^gamma;
  v_expansion = engine_kinematicts_fun(bore,stroke,con_rod,cr,0,180);
  
  p_expansion = c_constant./v_expansion.^gamma ;
  
  % state variable at point 4
   v4=v1;
  % according to p3v3^gamma=p4v4^gamma
  %p4=p3*(v3/v4)^gamma
  p4=p3*(v3/v4)^gamma ;
   figure(1)
   hold on
   
   plot(v_compression,p_compression,'linewidth',2,'color','g')
   line([v2,v3],[p2,p3],'linewidth',2,'color','y')
    plot(v_expansion,p_expansion,'linewidth',2,'color','r')
      line([v4,v1],[p1,p4],'linewidth',2,'color','b')
xlabel('Volume')
ylabel('Pressure')
title ('P-V DIAGRAM OF OTTO CYCLE')
legend('Isentropic compression','Heat addition','Isentropic expansion','Heat rejection')
  % figure(2) or incorrect way of plotting
   %plot ([v1,v2,v3,v4],[p1,p2,p3,p4],'color','b')
   
   % thermal efficiency of otto cycle
   %thermal efficiency = 1-1/cr^(gamma-1) 
   thermal_efficiency = (1-1/cr^(gamma-1))*100 

EXPLANATION:

  • First, I have defined inputs that I will required throughout the program and inputs are Pi=3.14, gamma for air =1.4, maximum temperature of cycle=2300 kelvin.
  • We have known two input parameters for state variable 1 that we defined as P1=101325 pascal and temperature at point 1=500 kelvin.
  • We have not known volume at point 1 and point 2 but we know geometric parameter of engine, so we need to define those parameters first and then used those parameters for volume calculation so Bore=0.1m, stroke=0.1m, connecting rod length = 0.15m, compression ratio =12.
  • By using those parameters, we have calculated swept volume and clearance volume.
  • So, we calculated v1 and v2, and we will calculate p2 by using polytropic process equation because process 1-2 is isentropic compression.
  • We will find temperature at point2 by using combined gas law or ideal gas law .
  • Process 2-3 is constant volume heat addition so v3=v2 and p3 is calculated using ideal gas law taking volume constant.
  • Now we will find property at point 4 by using polytropic process equation because process 3-4 is isentropic expansion and v4=v1 because constant volume heat rejection process.
  • Now we will plot coordinate point by using plot command.
  • To join point in each process we need to understand those process as we know constant volume heat rejection and heat addition are plotted by line command because variation is linear.
  • As we know isentropic compression process and isentropic expansion process are not linear so we need to use function to plot those process.

SUPPLEMENTARY PROGRAM:

Programming language used: High level Programming Language using Octave software

function[v] = engine_kinematicts_fun(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,100);

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
 
 
 

EXPLANATION:

  • This program uses function which we define in this program and call that function in main program.
  • Bore, stroke, con_rod, cr, start_crank, end_crank is argument of function engine_kinematicts_fun that we have done in first line of code.
  • We want crank mean radius for calculating ‘r’ which is ratio of con_rod and crank mean radius and after that we calculate swept and clearance volume.
  • We have to see how combustion chamber volume changes as function crank angle.That we can do with piston kinematic equation.
  • We have divided that equation into term, term2 and term3 which we have calculated separately and then combined those term.
  • We have done this for different values of crank angle.
  • At last we have closed the function by using end keyword.

PRECAUTIONS:

1] Script file name of supplementary code and function name should be same.

2] Input argument to function should be in same order as you have defined in function.

3] Don’t use close all and clear all and clc in supplementary code.

4] Don’t plot p-v diagram in wrong way.

OUTPUT:

1] P-V Diagram

2] Thermal efficiency= 62.983%

3] Actual variation of volume is different than theoretical variation of volume in isentropic compression and isentropic expansion.

Result: We have successfully written program to plot P-V diagram and calculated thermal efficiency of 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.