clear all
close all
clc
%Gas Propeties
Gamma = 1.4;
%state variables
P1 = 101325;
T1 = 300;
T3 = 2000;
%Engine parameters
d_bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 12;
%Swept and clearance Volume computation
v_swept = (pi/4)*((d_bore)^2)*stroke;
v_clerance = v_swept/(cr-1);
%trace of P-V Cycle.
v1 = v_swept + v_clerance;
v2 = v_clerance;
Const_1= P1*v1^Gamma;
V_compression = engine_kinematics(d_bore, stroke,con_rod,cr,180,0);
P_compression = Const_1./V_compression.^Gamma;
P2 = P1*((cr)^Gamma);
T2 = T1*((cr)^(Gamma - 1));
v3 = v2;
P3 = P2*(T3/T2);
Const_2= P3*v3^Gamma;
V_expansion = engine_kinematics(d_bore, stroke,con_rod,cr,0,180);
P_expansion = Const_2./V_expansion.^Gamma;
v4= v1;
P4 = P3/(cr^Gamma);
T4 = P3*v3*T3/(P4*v4);
figure(1)
hold on
plot(v1,P1,\'*\',\'color\',\'r\')
plot(v2,P2,\'*\',\'color\',\'r\')
plot(V_compression,P_compression);
plot(v3,P3,\'*\',\'color\',\'r\')
plot(V_expansion,P_expansion);
plot(v4,P4,\'*\',\'color\',\'r\')
plot([v2 v3],[P2 P3],\'color\',\'b\')
plot([v4 v1],[P4 P1],\'color\',\'b\')
ylabel(\'Pressure in Pascals\')
xlabel(\'Volume in metrics\')
%Efficiency
Efficiency = (1-(1/cr)^(Gamma-1))*100
% Funtion for Engine Kinematics
function [V] = engine_kinematics(d_bore, stroke,con_rod,cr,crank1,crank2)
%d_bore = 0.1; stroke = 0.1; con_rod = 0.15; cr =V = linspace(V1,V2,10)v 12;
theta = linspace(crank1,crank2,100);
a = stroke/2;
R = con_rod/a;
%Swept and clearance Volume computation
v_swept = (pi/4)*((d_bore)^2)*stroke;
v_clerance = v_swept/(cr-1);
%computation of Crank angle.
Term1 = 0.5*(cr-1);
Term2 = R+1-cosd(theta);
Term3 = (R^2 -(sind(theta).^2)).^0.5;
V = (1 + Term1*(Term2-Term3))*v_clerance;
end