Challenge

MATLAB - Comparing the Diesel cycle and Otto cycle (air standard cycles)

AIM:

To compare the Diesel cycle and Otto cycle with same compression ratio, in terms of PV diagram, TS diagram, Efficiency using MATLAB.

INTRODUCTION:

The working fluid remains a gas throughout the entire cycle. It is called as ‘Air standard cycle’, because, the working fluid closely resembles air at all times (air is utilized for the combustion of the fuel).The cycle is called to be ‘Ideal’, because it contains the processes which are taken place are considered to be the reversible processes.In practice, no cyclic processes are possible without having the irreversibility and hence, all the processes in a cycle are the irreversible one.

ASSUMPTIONS MADE:

  1. The working fluid is perfect gas.
  2. There is no change in mass of the working medium.
  3. All the process that constitutes the cycle is reversible.
  4. Heat is assumed to be supplied from a constant high temperature source and not from chemical reaction during the cycle.
  5. There are no heat losses.
  6. The working medium has constant specific heats throughout the cycle.

GOVERNING EQUATIONS:

  1. `(PxxV)/T`= Constant
  2. `PxxV^(gamma)`= Constant (for Isentropic process)
  3. ΔS = R x ln`(V_i/V_(i-1))`
  4. Compression ratio =`(V_1/V_2)`
  5. Otto cycle thermal efficiency = 1-`(1/(CR))^(gamma-1)`
  6. Diesel cycle thermal efficiency = 1-`1/(CR)^(gamma-1)[(r_c^gamma-1)/(gamma(r_c-1))]`

Where

P-Pressure

T-Temperature

S-Entropy

V-Volume

CR-Compression ratio

rc=Cut off ratio

=Specific heat ratio

OBJECTIVE OF THE PROJECT:

The main objective is to compare the idealized cycles in terms of efficiencies and PV,TS diagrams.

BODY OF THE CONTENT:

  1. MATLAB software is used in this project.
  2. Algorithm:
    1. Display project name.
    2. Ask user whether default values can be used using inputcommand and store result in ch variable.
    3. If values are need to be user defined using ifcommand check ch variable and inside it, using input command store the values in respective variables.
    4. Display the inputs (default/user defined) with values
    5. Begin diesel cycle calculation
    6. In state point 1, we know v1,p1,t1. s1 can be found using the reference entropy(eq(3)).
    7. In state point 2, we know s1=s2, v2=clearance volume. Using the eq (2) and eq(1) find p2 and t2 respectively.
    8. In state point 3, we know p2=p3 and t3. using eq(1) find v3. Also find s3 using s2 as shown(eq(3)).
    9. In state point 4, we know v4=v1, s3=s4. using eq(2) and eq(1) find p4 and t4 respectively.
    10. To find intermediate points between (1 and 2) and (3 and 4) in PV diagram, use eq(2).
    11. To find intermediate points between (2 and 3) and (4 and 1) in TS diagram, use eq(3).
    12. Find thermal efficiency of diesel cycle using eq(6).
    13. Plot PV and TS diagram with title, axes title, grid, legends.
    14. Begin diesel cycle calculation
    15. In state point 1, we know v1,p1,t1. s1 can be found using the reference entropy(eq(3)).
    16. In state point 2, we know s1=s2, v2=clearance volume. Using the eq (2) and eq(1) find p2 and t2 respectively.
    17. In state point 3, we know v2=v3 and t3. using eq(1) find p3. Also find s3 using s2 as shown(eq(3)).
    18. In state point 4, we know v4=v1, s3=s4. using eq(2) and eq(1) find p4 and t4 respectively.
    19. To find intermediate points between (1 and 2) and (3 and 4) in PV diagram, use eq(2).
    20. To find intermediate points between (2 and 3) and (4 and 1) in TS diagram, use eq(3).
    21. Find thermal efficiency of otto cycle using eq(5).
    22. Plot PV and TS diagram with title, axes title, grid, legends.
    23. Compare efficiencies of otto and diesel cycle and return conclusion.
  3. CODE
%IC engine air std cycle comparison
clc
clear all
close all

%Introduction
fprintf("COMPARISON OF DIESEL AND OTTO CYCLE\n\n")

%DEFAULT INPUTS
%bore diameter
b=0.1;
%stroke length
s=0.1;
%compression ratio
cr=20;
%specific heat ratio
gama=1.4;
%swept volume = displacement volume
swept=(pi*b^2*s)/4;
%clearance volume(cr=(swept volume+clearance volume)/clearance volume)
clearance=swept/(cr-1);
%Temperature at intake begining
t_1=500;
%Pressure at intake begining
p_1=101326;
%Temperature at Power stroke end
t_3=2000;
%Reference State
Pref=100000;        % 0.1 (MPa)
Tref=298.15;        % 25 Deg C
Sref=6.86305;       % (kJ/kgK)
%Universal gas constant
R=0.287;             
%specific heat values    
cv=0.821;               
cp=R+cv;


ch=input("\n\nDo you want to continue with default values (PRESS any button) or need to assign values(PRESS 1): ");
if(ch==1)
b=input('\nEnter Bore(in m):')
s=input('\nEnter Stroke(in m):')
cr=input('\nEnter Compression Ratio:')
t_1=input('\nEnter Temperature at intake begining(in deg Celcius):')
p_1=input('\nEnter Pressure at intake begining(in N/m^2):')
t_3=input('\nEnter Temperature at Power stroke end(in deg Celcius):')
end

%Inputs
fprintf("\n\nINPUTS\nBore: %.2f m \n",b);
fprintf("Stroke: %.2f m \n",s);
fprintf("Compression ratio: %.2f \n",cr);
fprintf("Temperature at intake begining: %.2f deg Celcius \n",t_1);
fprintf("Pressure at intake begining: %.2f N/m^2 \n",p_1);
fprintf("Temperature at Power stroke end: %.2f deg Celcius \n",t_3);

%Introduction
fprintf('\n\nAIR STANDARD DIESEL CYCLE');
fprintf('\n\nPROCESSES:\n1-2:Isentropic compression\n2-3:Constant pressure heat addition\n3-4:Isentropic expansion\n4-1:Constant volume heat extraction');

%STATE 1 isentropic compression = compression stroke
p1=p_1;                                        %input
t1=t_1;                                        %input
v1=swept+clearance;
s1=Sref+(cp*log((t1+273.15)/Tref));      

%STATE 2 constant pressure heat addition = power stroke
v2=clearance;
p2=p1*cr^gama;                                    %p2 from (p1*v1^gama=p2*v2^gama) and (cr=v1/v2)
t2=p2*v2*t1/(p1*v1);                              %t2 from ((p1v1/t1)=(p2v2/t2))  
s2=s1;

%Isentropic compression
cons1=p1*v1^gama;
v_comp=linspace(v1,v2,50);       
p_comp=cons1./v_comp.^gama;

%STATE 3 isentropic expansion = expansion stroke
p3=p2;
t3=t_3;                                          %input
v3=v2*t3/t2;
s3=s2+(cp*log(t3/t2));                           %p3 from ((p3v3/t3)=(p2v2/t2)) and (v3=v2) 

%constant pressure heat addition
t23=linspace(t2,t3,50);
s23=s2+(cp*log(t23/t2));

%STATE 4 constant volume heat extraction=exhaust stroke
v4=v1;
p4=p3*(v3/v4)^gama;                               %p4 from (p4*v4^gama=p3*v3^gama)
%t4= (p4*cr*t3/p3);                               %t4 from ((p3v3/t3)=(p4v4/t4)) and v3=v2 and v1=v4 and (cr=v1/v2)
t4=t3*((v3/v4)^(gama-1));
s4=s3;

%Isentropic expansion
cons2=p3*v3^gama;
v_exp=linspace(v3,v4,50);       
p_exp=cons2./v_exp.^gama;

%constant volume heat extraction
t41=linspace(t4,t1,50);
s41=s4+(cv*log(t41/t4));

%cut off ratio
rc=v3/v2;

%thermal efficiency
effd=1-(cr^(1-gama)*((rc^gama-1)/(gama*(rc-1))));
fprintf("\n\nOUTPUT\nThermal Efficiency of this diesel cycle= %.2f percentage\n",effd*100);

%plotting begins

%PV DIAGRAM

%Naming the figure
figure(1)
%keep the plots on screen
hold on
plot(v_comp,p_comp);
plot([v2,v3],[p2,p3]);
plot(v_exp,p_exp);
plot([v1,v4],[p1,p4]);
%labelling
xlabel('Volume in m^3');
ylabel('Pressure in N/m^2');
%grid visiblity
grid on;
legend({'Isentropic compression','Constant pressure heat addition','Isentropic expansion','Constant volume heat extraction'},'FontSize',12,'Location','northeast');
title({'Diesel Cycle PV diagram'},'FontSize',20);
text(v1,p1,' 1','FontSize',10)
text(v2,p2,'2','FontSize',10)
text(v3,p3,'  3','FontSize',10)
text(v4,p4,'  4','FontSize',10)

%TS DIAGRAM

%Naming the figure
figure(2)
%keep the plots on screen
hold on
plot([s1,s2],[t1,t2]);
plot(s23,t23);
plot([s3,s4],[t3,t4]);
plot(s41,t41);
%labelling
xlabel('Entropy (kJ/kg)');
ylabel('Temprature (K)');
%grid visiblity
grid on;
legend({'Isentropic compression','Constant pressure heat addition','Isentropic expansion','Constant volume heat extraction'},'FontSize',12,'Location','southeast');
title({'Diesel Cycle TS diagram'},'FontSize',20);
text(s1,t1,' 1','FontSize',10)
text(s2,t2,' 2','FontSize',10)
text(s3,t3,' 3','FontSize',10)
text(s4,t4,' 4','FontSize',10)


%-------------------------------------------------------------------------------------------------------------


%Introduction
fprintf('\n\nAIR STANDARD OTTO CYCLE');
fprintf('\n\nPROCESSES:\n1-2:Isentropic compression\n2-3:Constant volume heat addition\n3-4:Isentropic expansion\n4-1:Constant volume heat extraction');

%'o' in variable(po,so..) represent otto

%STATE 1 isentropic compression = compression stroke
po1=101326;                                        %input
to1=500;                                           %input
vo1=swept+clearance;
so1=Sref+(cp*log((to1+273.15)/Tref));      

%STATE 2 constant pressure heat addition = power stroke
vo2=clearance;
po2=po1*cr^gama;                                    %po2 from (po1*vo1^gama=po2*vo2^gama) and (cr=vo1/vo2)
to2=po2*vo2*to1/(po1*vo1);                          %to2 from ((po1*vo1/to1)=(po2*vo2/to2))  
so2=so1;

%Isentropic compression
conso1=po1*vo1^gama;
vo_comp=linspace(vo1,vo2,50);       
po_comp=conso1./vo_comp.^gama;

%STATE 3 isentropic expansion = expansion stroke
vo3=vo2;
to3=2000;                                          %input
po3=po2*to3/to2;                                   %p3 from ((po3*vo3/t3)=(po2*vo2/to2)) and (vo3=vo2) 
so3=so2+(cp*log(to3/to2));                        

%constant pressure heat addition
to23=linspace(to2,to3,50);
so23=so2+(cp*log(to23/to2));

%STATE 4 constant volume heat extraction=exhaust stroke
vo4=vo1;
po4=po3*(vo3/vo4)^gama;                               %po4 from (po4*vo4^gama=po3*vo3^gama)
%to4= (po4*cr*to3/po3);                               %to4 from ((po3vo3/to3)=(po4vo4/to4)) and vo3=vo2 and vo1=vo4 and (cr=vo1/vo2)
to4=to3*((vo3/vo4)^(gama-1));
so4=so3;

%Isentropic expansion
conso2=po3*vo3^gama;
vo_exp=linspace(vo3,vo4,50);       
po_exp=conso2./vo_exp.^gama;

%constant volume heat extraction
to41=linspace(to4,to1,50);
so41=so4+(cv*log(to41/to4));

%thermal efficiency
effo=1-(1/cr)^(gama-1);
fprintf("\n\nOUTPUT\nThermal Efficiency of this otto cycle= %.2f percentage\n",effo*100);
if (cr>12) 
fprintf('\nWARNING: Compression ratio, in otto cycle, should be lesser than 12(maximum for suoercars) otherwise KNOCK will occur, which reduces efficiency and damages engine')
end
%plotting begins

%PV DIAGRAM

%Naming the figure
figure(3)
%keep the plots on screen
hold on
plot(vo_comp,po_comp);
plot([vo2,vo3],[po2,po3]);
plot(vo_exp,po_exp);
plot([vo1,vo4],[po1,po4]);
%labelling
xlabel('Volume in m^3');
ylabel('Pressure in N/m^2');
%grid visiblity
grid on;
legend({'Isentropic compression','Constant volume heat addition','Isentropic expansion','Constant volume heat extraction'},'FontSize',12,'Location','northeast');
title({'Otto Cycle PV diagram'},'FontSize',20);
text(vo1,po1,' 1','FontSize',10)
text(vo2,po2,'2','FontSize',10)
text(vo3,po3,'  3','FontSize',10)
text(vo4,po4,'  4','FontSize',10)

%TS DIAGRAM

%Naming the figure
figure(4)
%keep the plots on screen
hold on
plot([so1,so2],[to1,to2]);
plot(so23,to23);
plot([so3,so4],[to3,to4]);
plot(so41,to41);
%labelling
xlabel('Entropy (kJ/kg)');
ylabel('Temprature (K)');
%grid visiblity
grid on;
legend({'Isentropic compression','Constant volume heat addition','Isentropic expansion','Constant volume heat extraction'},'FontSize',12,'Location','southeast');
title({'Otto Cycle TS diagram'},'FontSize',20);
text(so1,to1,' 1','FontSize',10)
text(so2,to2,' 2','FontSize',10)
text(so3,to3,' 3','FontSize',10)
text(so4,to4,' 4','FontSize',10)

%conclusion 
fprintf('\n\nCONCLUSION')
if (effd>effo)
fprintf("\n\nAt same Compression ratio, Thermal efficiency of diesel cycle (%.2f) is greater than that of Otto cycle (%.2f).\n\n",effd*100,effo*100)
else
fprintf("\nAt same Compression ratio, Thermal efficiency of Otto cycle (%.2f) is greater than that of Diesel cycle (%.2f).\n\n",effo*100,effd*100)
end
fprintf('\nSince these cycles are idealized cycle, Real efficiency varies and mostly diesel engine has more efficiency than petrol engines irrespective of idealised cycle efficiencies. Further, these idealised cycles does not include friction losses and throttling losses.')

RESULTS:

Diesel cycle

Otto cycle

CONCLUSION

  • Idealized cycles does not account throttling losses and frictional losses which reduces efficiency dramatically.
  • They don’t account knock at higher compression ratio for otto cycle. Knock results because of collision of thermal shock waves, (one from spark plug’s spark flame, another from self ignited flame) which increases pressure and damages engine cylinder and/or piston and also increases vibrations and noise.
  • So with same compression ratio, following idealized cycle, otto cycle has more efficiency.
  • In real life, diesel cycle has more efficiency than that of petrol engines following otto cycle due to possibility of designing for higher compression ratio for diesel cycle.
  • PV diagrams represent that power stroke occurs at constant pressure in diesel cycle whereas in otto cycle, power stroke occurs at constant volume.
  • TS diagrams represent temperature at the end of power stroke is higher in diesel cycle compared to 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.