WRITE A CODE TO SOLVE A OTTO CYCLE AND TO CALCULATE THE THERMAL EFFICIENCY.
AIM:
Matlab program to plot the p-v diagram and to calculate the thermal efficiancy of the otto cycle.
OBJECTIVE:
- To plot the pressure volume characteristics of an otto cycle.
- To calculate the thermal efficiancy.
- Understanding the ideal gas laws
- Understanding the nature of the curve during the isentropic process.
- Analyze the change in volume coresponding to the crank angle.
THEORY:
otto cycle is used in spark ignition engines.
the cycle contains the four reversible process.
- isentropic compression
- constant- volume heat addition process.
- isentropic expansion.
- constant volume heat rejection process.
CODE:
%PROGRAM TO PLOT TTHE P-V DIAGRAM OF THE OTTO CYCLE
%TO CALCULATE THE THERMAL EFFICIANCY OF THE CYCLE
clear all
close all
clc
%inputs
gamma = 1.4 %adiabatic index is given
t3 = 2300 % the temperature of combustion
% state variables
p1 = 101325 % the atmospheric pressure
t1 = 500 %initial temperature
%inputs
bore = 0.1 %nomial diameter of the inside cylinder
stroke = 0.1 %stroke length of the cylinder
cond_rod = 0.15 %connecting rod length
cr = 12 %compression ratio (max cylinder volume to minimum cylinder volume)
%swept volume and clerance volume calculation
v_swept = pi/4*bore^2*stroke; %volume in the cylinder from bdc to tdc
v_clearance = v_swept/(cr - 1); %volume in the cylinder gap above tdc
v1 = v_swept + v_clearance
v2 = v_clearance
% state variables at state point 2
% p1v1^gammma = p2v2^gamma
%p2= p1*(v1/v2)^gamma
p2 = p1*cr^gamma;
% p1v1/t1 = p2v2/t2 | t2 = p2*v2*t1/p1v1
t2 = p2*v2*t1/(p1*v1);
constant_c = p1*v1^gamma;
V_compression = piston_kinematics(bore,stroke,cond_rod,cr,180,0) % calling the function
P_compression = constant_c./V_compression.^gamma
%state variables at state point 3
v3 = v2
% p3v3/t3 =p2v2/t2 | p3 = p2*t3/t2 from ideal gas law
p3 = p2*t3/t2;
constant_c = p3*v3^gamma;
V_expansion = piston_kinematics(bore,stroke,cond_rod,cr,0,180)
P_expansion = constant_c./V_expansion.^gamma
% state variables at state point 4
v4 = v1
% p3v3^gamma = p4v4^gamma| p4 = p3(v3/v4)^gamma
p4 = p3*(v3/v4)^gamma
figure(1)
hold on
plot(v1,p1,'*','color','b')
plot(V_compression,P_compression)
plot(v2,p2,'*','color','b')
plot([v2,v3],[p2,p3])
plot(v3,p3,'*','color','b')
plot(V_expansion,P_expansion)
plot(v4,p4,'*','color','b')
plot([v4,v1],[p4,p1])
grid on
xlabel('volume in m^3')
ylabel('pressure in pascal')
title('otto cycle P-V diagram')
% to calculate the thermal efficiancy
%eff(otto) = work(net)/heat(input)
eff = 1 - 1/(cr^(gamma-1));
fprintf('the thermal efficiancy of otto cycle is %f',eff) % to display the output
the program function:
% code to calculate the volume of the cycle.(called function)
function [V] = piston_kinematics(bore,stroke,cond_rod,cr,start_crank,end_crank)
a = stroke/2
R = cond_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
end
output:


CONCLUSION:
Hence the pv diagram of the otto cycle and the thermal efficiency is calculated.