Project

CALCULATING THERMAL EFFICIENCY AND PLOT P-V DIAGRAM FOR OTTO CYCLE

% OTTO CYCLE
clear all 
close all
clc

% INPUTS
t1 = 290;
p1 = 100;
t3 = 1575.1;
% Engine geometric parameters
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 8;
% Calculating the swept volume and the clearance volume 
v_swept=(pi/4)*bore^2*stroke;
v_clearance=v_swept/(cr-1);

v1=v_clearance+v_swept;
v2=v_clearance;
% The variation of specific heats with temperature is to be accounted for.
% Using data from Thermodynamics An Engineering Approach 8th Ed(table A 17)
% State variables at state point 1 
t1=290;
u1=206.91;
vr1 = 676.1;
% Process 1-2(isentropic compression of an ideal gas)
vr2 = vr1/cr;
t2 = 652.4 ;
u2 = 475.11;
p2 = p1*(t2/t1)*cr;
%p2v2^k1=p1v1^k1
k1=log(p2/p1)/log(cr);
V_compression = engine_kinematics_1(bore, stroke, con_rod, cr, 180, 0);
constant_c = p1*v1^k1;
P_compression = constant_c ./(V_compression).^k1;

% Process 2-3 (constant-volume heat addition)
T3 = 1575.1;
u3 = 1275.11;
vr3 = 6.108;
v3 = v2;
qin = u3-u2;
p3 = p2*(t3/t2);
% Process 3-4 (isentropic expansion of an ideal gas):
 vr4 = cr*vr3;
 t4 = 795.6;
 v4 = v1;
 p4 = p1*(t4/t1);
 u4 = 588.74 ;
 %p3v3^k2=p4v4^k2
k2=log(p3/p4)/log(cr);
V_expansion = engine_kinematics_1(bore, stroke, con_rod, cr, 0, 180);
constant_c = p3*v3^k2;
P_expansion = constant_c ./(V_expansion).^k2;
qout = u4-u1;
Win = qin-qout;
% Calculating thermal efficiency
thermal_efficiency = Win/qin
figure(1)
title('otto cycle')
hold on 
plot(v1,p1,'*','color','r')
plot(V_compression,P_compression)
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(V_expansion,P_expansion)
plot(v4,p4,'*','color','r')
plot([v2 v3],[p2 p3])
plot([v4 v1],[p4 p1])
function [V] = engine_kinematics_1(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, 181);
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

First i started the code by writing the inputs ( temperature, pressure at state 1 and temperature at state 3)

then the engine geometric parameters and calculate the total volume and clearance volume.

I have calculated the properties for each state, volume variation at expansion and compression by using geometric equation, i have calculated also the thermal efficiency for the whole cycle.

the thermal efficiency is 52.3%

At the end i have used the plotting commands to plot the pv diagram.

ERRORS:

I forgot to calculate the value of v3, i overcame this error by writing v2=v3 because it is constant volume process.

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.