In: Mechanical Engineering
MATLAB based problem: Create a motoring model for the engine with the following specifications, and plot the in-cylinder pressure against (i) cylinder volume and (ii) crank angle degrees (20 points)  Bore = 107mm, stroke = 124mm, compression ratio = 17.3, Length of connecting rod = 192mm. Assume the ratio of specific heats is 1.4 (constant), atmospheric pressure is 1 bar and ambient temperature is 298 K.
clc;
clear all;
format long;
%-------Defining Engine Geometry (All dimensions are in meter (m)------%
B = 0.107; %---Engine bore
L = 0.124; %---Engine stroke
r = 17.3; %---Engine compression ratio
l = 0.192; %---Engine connecting rod length
R = 0.058; %---Crank pin radius (Assumption, not given in the question)
Vs=(pi/4)*(B^2)*L; %---Stroke volume
Vc=Vs/(r-1); %---Clearance volume
Vt=Vs+Vc; %---Total volume
Ap=(pi/4)*(B^2); %---Piston Area
Smin=Vc/Ap; %---Clearance length
D=l/R; %---Ratio of connecting rod length to crank radius
Theta=[1:1:720]; % Crank angle in degree
Po= 100; %initial pressure in kPa
To=298; %initial tempereature in K
gamma=1.4; %Ratio of specific heat
for i=1:1:720
V(i)=Vc*(1+0.5*(r-1)*(D+1-cos(pi*i/180)-(D^2-(sin(pi*i/180))^2)^0.5));
V(i+1)=Vc*(1+0.5*(r-1)*(D+1-cos(pi*(i+1)/180)-(D^2-(sin(pi*(i+1)/180))^2)^0.5));
for i=1:1:215
P(i)=100;
T(i)=298;
for i=216:1:504
P(216)=100;
T(216)=289;
P(i+1)=P(i)*(V(i)/V(i+1))^gamma;
T(i+1)=T(i)*(V(i+1)/V(i))^(1-gamma);
for i=505:1:720
P(i)=P(504);
T(i)=T(504);
P(i+1)=P(i)*(T(i+1)/T(i));
end
end
end
end
i=1:1:720;
plot(i,P(i+1))