MATLAB ICE Assign
MATLAB ICE Assign
ICE LAB
Section – D
Assignment # 01
No . Name Registration No .
Submitted to:
Sir.Rasikh Tariq
Spark ignition is occurred a specific position of the piston which can be
represented as a function of the crank angles.
Q.no.1: Identify the joints and links in a piston cylinder engine and find out its
Degree of Freedom.
Q.no.2: Derive a relationship between a piston position and the crank angles.
Q.no.3: Each piston position corresponds to a specific remaining/displaced
cylinder volume. Derive a relationship between the crank angles and
remaining/displaced cylinder volume. (Solve it by hand)
Q.no.4: Now take suitable lengths of the linkage mechanism such that the
Grashoff Condition is satisfied and plot the graph between: (Solve it on Matlab
and attach code) a. Piston Position (y-axis) and Crank Angles (x-axis) b.
Displaced/Remaining Cylinder (y-axis) and Crank Angles (x-axis)
CODE#1(Graph)
clc;clear;close all
r=input('Enter Crank Radius=');
l=input('Enter Connecting Rod Length=');
d=input('Enter Dore Dia=');
if l>r
Crankangle=linspace(0,4*pi,100);
for i=1:1:100
p(i)=r*cos(Crankangle(i))+sqrt(l.^2-(r.^2*(sin(Crankangle(i))).^2))+(r-
l);
vd(i)=(pi*p(i)*d.^2)/4;
vr(i)=((pi*2*r*d.^2)/4)-vd(i);
end
subplot(3,1,1),plot(Crankangle,p)
title('Piston Position vs Crank Angle')
xlabel('Crank Angle')
ylabel('Piston Position')
legend('Piston Position vs Crank Angle')
grid
subplot(3,1,2),plot(Crankangle,vd)
title('Displaced Volume vs Crank Angle')
xlabel('Crank Angle')
ylabel('Displaced Volume')
legend('Displaced Volume vs Crank Angle')
grid
subplot(3,1,3),plot(Crankangle,vr)
title('Remaining Volume vs Crank Angle')
xlabel('Crank Angle')
ylabel('Remaining Volume')
legend('Remaining Volume vs Crank Angle')
grid
else
disp('Invalid lengths or dia or Non Grashoff Condition');
end
Output
CODE#2(Animation)
%This m-script shows a simple simulation for the crank-slider mechanism for
% the crank shaft-piston mechanism
% l = rod length (distance between piston pin and crank pin)
% r = crank radius (distance between crank pin and crank center, i.e. half
stroke)
% A = crank angle (from cylinder bore centerline at TDC)
% x = piston pin position (upward from crank center along cylinder bore
centerline)
%Written by: Umar Farooq 15-me-092 (Section B G1)
%The crank-slider mechanism scetch
% P
% o
% o
% o
% o N
% *
% *
% *
% O
l=30;
r=15;
X=[0 0 0];
Y=[0 r r+l];
X_Piston=[-7 7 7 -7 -7];
Y_Piston=[l-5 l-5 l+5 l+5 l-5];
h = plot(X,Y,'LineWidth',4,'XDataSource','X','YDataSource','Y');
axis([-1.1*r 1.1*r -1.5*r 1.5*r+l]);
set(gca,'DataAspectRatio',[1 1 1])
grid on
hold('all')
g =
plot(X_Piston,Y_Piston,'r','LineWidth',4,'XDataSource','X_Piston','YDataSource
','Y_Piston');
angle=0:0.01:2*pi;
x_circle=r.*cos(angle);
y_circle=r.*sin(angle);
i = plot(x_circle,y_circle,'LineWidth',4)
for A=0:0.08:4*pi
x=r*cos(A)+sqrt(l^2-r^2*sin(A)^2);
N=[r*sin(A) r*cos(A)];
P=[0 x];
X=[0 r*sin(A) 0];
Y=[0 r*cos(A) x];
Y_Piston=[x-5 x-5 x+5 x+5 x-5];
refreshdata(h,'caller')
refreshdata(g,'caller')
refreshdata(i,'caller')
drawnow
pause(.1)
end
Output