Project

Air standard cycle (otto cycle) using matlab

  • Aim: code that can solve an otto cycle and make plots for it.
  • Objective: Plotting PV diagram and calculating the thermal efficiency of an Otto cycle.
  • THEORY: The otto cycle is a cycle of engine operation which requires four strokes of the piston for induction, compression, ignition, and exhaust. The fuel and air mixture is compressed before combustion is started by an electrical spark or other means. Dig of Otto cycle

PV daigram:

Process 1 to 2 = isentropic compression. Here enters the cycle at point 1 when compression starts and it ends at point 2. The air is compressed in an isentropic process through a volume ratio called compression ratio

Process 2 to 3 = Constant volume heat addition. Here heat addition starts at point 2 and ends at point 3. A quantity of heat is added at constant volume and the working fluid temperature rises

Process 3 to 4 = Isentropic expansion Here the isentropic expansion starts at point 3 and it ends at point 4 to the original volume

Process 4 to 1 = Constant volume heat rejection Here completes the cycle by a constant volume process in which heat is rejected

Engine Geometric Parameters - 1. BORE 2. STROKE 3. CONNECTION ROD 4. COMPRESSION RATIO

Piston Terminologies:

With Engine Geometric Parameters, we can solve kinematic equation of piston and will be able to compute volume trace From the computed volume trace, will be able to trace swept volume and clearance volume.

PISTON KINEMATICS - Piston Kinematics enhances the position of the piston from top dead centre to bottom dead center and the change is volume inside combustion chamber.

  • Governing equation : To define the isentropic compression process,

PVγ=constant">PVγ=constantPVγ=constant

Swept volume =

(Vs)=(π4)⋅bore2⋅stroke.">(Vs)=(π4)⋅bore2⋅stroke.(Vs)=(π4)⋅bore2⋅stroke.

Clearance volume = SweptVolumeCompressionRatio−1"> SweptVolumeCompressionRatio−1 SweptVolumeCompressionRatio−1

The volume of the cylinder as a function of a crank angle:

(VVc) =1+0.5(Cr-1)(R+1-cos(θ)-(R2sin2(θ))0.5).">(VVc) =1+0.5(Cr−1)(R+1−cos(θ)−(R2sin2(θ))0.5).(VVc) =1+0.5(Cr-1)(R+1-cos(θ)-(R2sin2(θ))0.5).

where:

R - con_rod/stroke

Efficiency of Otto cycle = (1-(1cr)γ-1)">(1−(1cr)γ−1)(1-(1cr)γ-1)

η - thermal efficiency

Cr – compression ratio

ϒ – 1.4

  • function code :
function[v] = piston_kinematics ( bore, stroke, con_rod, c_r, start_crank_angle, end_crank_angle)
%Inputs   
a = stroke/2;
R = con_rod/a;
v_swept = pi/4*bore.^2*stroke;
v_clearance = v_swept./(c_r-1);

theta = linspace(start_crank_angle, end_crank_angle, 180);

term1 = 0.5*(c_r-1);
term2 = R+1-cosd(theta);
term3 = (R^2 -sind(theta).^2).^0.5;
v = v_clearance.*(1+term1*(term2-term3));
end

First of all creating function that returns the volume at every point of the process function name being piston_kinematics (function name should be save same name as function program) and input variable will be bore,stroke,connecting rod,starting crank angle and ending crank angle like this .in the body of the function calculate crank pin radius , swept volume clearance volume and the angles of the crank rotation with the help of the geometric derive equation we can calculate different values of crank angles at different stages of otto cycle.then function is closed using end command

clear all
close all
clc
%Inputs
gamma = 1.4
%state variablesc
p1 = 101325
t1 = 500
t3 = 2000

%engine geometric parameters 
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
c_r = 12;
%calculating the swept  volume and clearance volume
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(c_r-1);
% state variables at state point 1
v1 = v_swept + v_clearance
%isentropic constant for path 1 and path 2
constant_c = p1*v1^gamma;
%state variables at state point 2
v2 = v_clearance 
p2 = p1*(c_r^gamma);
t2 = t1*c_r^(gamma-1);
v_compression = piston_kinematics (bore,stroke,con_rod,c_r,0,180);
%variation of volume from state1 to state 2 w.r.t crank angle theta
p_compression = constant_c./v_compression.^gamma;
%state variables at state point 3
v3 = v2;
p3 = p2*t3/t2;
%isentropic constant for path 3 and path 4
constant_c1 = p3*v3^gamma;
%state variables at state point 4
v4 = v1
p4 = p3/(c_r^gamma-1 );
t4 = t3/(c_r^(gamma-1));
v_expansion = piston_kinematics(bore,stroke,con_rod,c_r,0,180);
p_expansion = constant_c1./v_expansion.^gamma;
%thermal efficiency 
thermal_efficiency = 1 - (1/(c_r^(gamma-1)))
%plotting the point on p-v diagram 
figure(1)
hold on
plot(v1,p1,'*','color','r');
plot(v2,p2,'*','color','g');
plot(v3,p3,'*','color','k');
plot(v4,p4,'*','color','b');
plot(v_compression,p_compression,'linewidth',2,'color','g');
plot([v2 v3],[p2 p3],'linewidth',2,'color','y');
plot(v_expansion,p_expansion,'linewidth',2,'color','b');
plot([v4 v1],[p4 p1],'linewidth',2,'color','k');
title('P-V DIAGRAM OF AIR STANDARD OTTO CYCLE')
legend('Compression','Heat addition','Expansion','Heat rejection');

xlabel('Volume');
ylabel('Pressure');


figure(2)
plot([v1 v2 v3 v4 v1],[p1 p2 p3 p4 p1],'color','b')

to create the main program we will take some input parameters geometric parameters such as bore, stroke connecting rod and cr also initialized ,swept and clearance volume are calculated from geometric parameters and the remaining state variables are calculated using gaslaw, adiabatic equation , and isobaric condition . After got all the variables values then we can calculate thermal efficiency using the temperature .then using plot function ,the state point are plot by a '*'and then the process joining these state are represented by respective curve.the syntax of the plot function is plot (xy)

  • 0utput plot :

This is an incorrect PV diagram because the compression and expansion processes are represented by straight lines. This is not the actual case as the volume decreases/increases in a non-linear manner. The correct graph is represented in the program output section.

THERMAL EFFICIENCY:

Te efficiency of a heat engine measured by the ratio of the work done by otto cycle to the heat supply to it.

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.