Project

MATLAB/ OCTAVE PROGRAM FOR OTTO - CYCLE

AIM: To write a code using Matlab/ Octane to find the Thermal Efficiency and Plot a P-V diagram of Otto Cycle.

PRE-REQUISITE KNOWLEDGE: The Otto-Cycle is one of the most common thermodynamic cycles that can be found in the automobile engines and describes the functioning of a typical spark ignition piston engine.

OTTO-CYCLE PROCESS:

PROCESS 1 - 2 (Isentropic Compression): This process is also known as compression stroke. The gas i.e., air - fuel mixture is compressed adiabatically form state 1 to state 2 as the piston moves from BDC (Bottom Dead Center) to TDC (Top Dead Center)

PROCESS 2 - 3 (Isochoric compression): This process is also known as ignition phase. In this phase, there's an increase in pressure at constant volume which means the piston is at the TDC i.e., the piston is at rest.

PROCESS 3 - 4 (Isentropic expansion): This process is also known as power stroke. The gas expands adiabatically from state 3 to state 4. The piston moves from TDC to BDC.

PROCESS 4 - 1 (Isochoric decompression): This process is also known as exhaust stroke. In this phase, the cycle completes by a constant volume process in which heat is rejected from the air while the piston is at BDC.

INPUTS:

  • gamma = 1.4
  • t3 = 2300K
  • p1 = 101325 N/m^2
  • t1 = 500K
  • bore = 0.1m
  • stroke = 0.1m
  • connecting rod length = 0.15m
  • compression ratio = 12

MAIN PROGRAM:

%%code for Otto Cycle to plot P-V Diagram and to find Thermal Efficiency

clear all
close all
clc

%inputs
gamma = 1.4

%temptrature in kelvin (K)
t3 = 2300

%state variables
%pressure in nm^-2

p1 = 101325
t1 = 500

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

%calculating swept 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 point 2
% p2v2^gamma = p1v1^gamma
% p2 = p1(v1/v2)^gamma = p1*cr^gamma
p2 = p1*cr^gamma;

%to find the tempraure at state point 2, the formula goes as follow
% p1v1/t1 = p2v2/t2 || therefore, t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1);

% to obtain a curve from state point 1 to state point 2 we are calling a function called Engine Kinematics for which a seperate code is written and saved as engine_kinematics.m

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 point 3
% p3v3/t3 = p2v2/t2 || p3 = p2*t3/t2
v3 = v2;
p3 = p2*t3/t2;

% to obtain a curve from state point 3 to state point 4 we are calling a function called Engine Kinematics for which a seperate code is written and saved as engine_kinematics.m

constant_c = p1*v1^gamma;
V_expansion = engine_kinematics(bore, stroke, con_rod, cr, 0, 180);
P_expansion = constant_c./V_expansion.^gamma;

% state variable at point 4
% p3v3^gamma = p4v4^gamma || p4 = p3(v3/v4)^gamma
v4 = v1;
p4 = p3*(v3/v4)^gamma;

% thermal efficiency
% thermal_efficiency = 1-1/cr^(gamma-1) or 1-(t1/t2)

thermal_efficiency = (1-(t1/t2)*100);

% plotting all the state variables i.e., P-V Diagram

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

FUNCTION PROGRAM:

%% code for Engine Kinematics

function [V] = engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank)

a = stroke/2
R = con_rod/a
%% swept volume
v_s = pi/4*bore^2*stroke;
%% clearance volume
v_c = v_s/(cr-1);

theta = linspace(start_crank, end_crank,100)

%%this formula is purely obtained by geometric terms. The formula goes as follows

%% (V/v_c) = 1 + (1/2)(cr-1){R + 1 cos(@)-[R^2-(sin(@))^2]}

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: The code was written and executed. The P-V Diagram was obtained as per the inputs and the Thermal Efficiency was found to be 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.