Project

To write a program in MATLAB/OCTAVE that can solve an Otto cycle and make plots for it

AIM:

To write a program in MATLAB/OCTAVE that can solve an Otto cycle and make plots for it.

EQUATION/FORMULA USED:

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

OBJECTIVE:

  • To plot a PV diagram
  • To find out the thermal efficiency of the engine.

THEORY:

An Otto cycle is an ideal thermodynamic cycle that describes the function of a spark ignition piston engine. The idea of the Otto cycle was first proposed by Nicolas Otto back then in 1876. It is the thermodynamic cycle most commonly found in automobile engines. It describes what happens to a mass of gas as it is subjected to changes of pressure, temperature, volume, the addition of heat and removal of heat.

  • Otto cycle uses the spark plugs to light the charge, which is a mixture of air and fuel.
  • Petrol engines work on the principle of the Otto cycle whereby to supply the fuel into the combustion chamber Carburator is used.
  • Otto cycle works on four processes, which are intake stroke, compression stroke, expansion stroke and then exhaust stroke.
  • In the Otto cycle, the heat addition takes place at constant volume.
  • The overall efficiency is way less than that of the diesel cycle.
  • The charge is drawn in by the cylinders during the intake stroke.
  • Adiabatic expansion takes place during the backward stroke of the
  • It has a compression ratio from 7:1 to 10:1 which is lesser than that of a diesel cycle.
  • It has a high thermal efficiency when compared to the Diesel cycle.
  • In the Otto cycle, at the time of heat addition, the piston is at Top Dead Center (TDC).

Process 1 to 2: 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.

Process 2 to 3: 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. In terms of thermodynamics, this is referred to as an isochoric process.

Process 3 to 4: 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.

Process 4 to 1: In 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 a decrease in pressure.

BODY:

  1. CODE:

Function Code:

function [V] = engine_kinematics(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;
  

endfunction

Main Code:

clear all
close all
clc

%input
gamma = 1.4
t3 = 2000

%state varialbles
p1 = 101325
t1 = 500

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

%calculate the swept volume and clearance volume
v_swept = (pi/4)*bore^2*stroke
v_clearance = v_swept/(cr-1)

v1 = v_swept + v_clearance
v2 = v_clearance

%state variables at state point 2 
%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 = engine_kinematics(bore, stroke, con_rod, cr, 180, 0);

P_compression = constant_c./V_compression.^gamma;

 
% state variable at state pont 3
v3 = v2

%p3v3/t3 = p2v2/t2 | p3 = p2*t3/t2
p3 = p2*t3/t2

constant_c = p3*v3^gamma;
V_expansion = engine_kinematics(bore, stroke, con_rod, cr, 0, 180);

P_expansion = constant_c./V_expansion.^gamma;

% state variable at state pont 4
v4 = v1

%p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma

%plotting
figure(1)
hold on
plot(v1,p1,'*', 'color', 'r')
plot(V_compression, P_compression)
plot(v2,p2,'*', 'color', 'r')
plot([v2 v3],[p2 p3], 'color','g')
plot(v3,p3,'*', 'color', 'r')
plot(V_expansion, P_expansion)
plot(v4,p4,'*', 'color', 'r')
plot([v4 v1],[p4 p1],'color','g');
xlabel('Volume');
ylabel('Pressure');
grid on


%Thermal Efficiency
eta = 1 - (1/cr^(gamma-1))
printf('thermal efficiency : ')
disp(eta*100)
  1. STEP-WISE EXPLANATION OF THE CODE:
  • This program is written and executed using octave.
  • Starting with all the general command e. clear all, close all & clc.
  • Inputting all the code comment at all the required location starting with %
  • Inputting the values of all the constant variable, state variables, engine geometric parameters.
  • Then calculate the swept volume and clearance volume.
  • Calculate state variables at state point 2.
  • Calculate state variables at state point 3.
  • Calculate state variables at state point 4.
  • Then the code is written to plot the graph.
  • Colour and width of the line in the plot is set according to the
  • All the component of the plot is labelled accordingly.
  • Then we create a new file to write the function code.
  • Inputting all the variables followed by the formulae.
  • Then implementing the function code in the main code for compression followed by the expansion at the desired location accordingly.
  • Finally, we get the desired output and hence the desired plot.
  • Also, calculating the thermal efficiency.

2. ERROR FACED WHILE PROGRAMMING:

Written the wrong command for dot product.

3. STEP TAKEN TO OVERCOME THOSE ERROR:

I have rectified the error later by replacing the position of dot to a correct position.

4. SCREENSHOT OF ERROR:

OUTPUT:

  1. PV PLOT:

  1. THERMAL EFFICIENCY:

  1. RESULT:

Hence we got the desired plot and thermal efficiency as 62.989%

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.