Vous êtes sur la page 1sur 8

INDIAN INSTITUTE OF SPACE SCIENCE AND TECHNOLOGY

THIRUVANANTHAPURAM

Modeling & Analysis Lab


AE-343
LAB REPORT-II

SUBMITTED BY:

SIDDHARTHA LAKKARAJU (SC10B028)


WASEEM MOHAMMED (SC10B022)

Problem : 1
1. The first simulation was done using the 2 differential equations derived
using the pendulum properties, following codes were executed for the same:
function xdot=f(t, x);
xdot(1)=x(4);
xdot(2)=x(5);
xdot(3)=x(6);
A = [1 0 0 -1 0;0 1 0 0 -1;0 0 1 -sin(x(3)) cos(x(3));1 0 sin(x(3)) 0 0;0 1 -cos(x(3)) 0 0];
B = [0 -10 0 -x(6)*x(6)*cos(x(3)) -x(6)*x(6)*sin(x(3))]';
S = inv(A)*B;
xdot(4)=S(1);
xdot(5)=S(2);
xdot(6)=S(3);
endfunction
x0 = [cos(1),sin(1),1,1*sin(1),1*cos(1),1]'; t0 = 0;
t = [0:0.01:10]; x
= ode(x0,t0,t,f);
plot(t,x(3,:))
plot(t,x(6,:))

2. The simulation was done using the newtons method for the compound
pendulum, following codes were executed to simulate the compound
pendulum:
function xdot=f(t, x);
xdot(1) = x(2);
A = [1 0 0 -1 0;0 1 0 0 -1;0 0 1 -sin(x(1)) cos(x(1));1 0 sin(x(1)) 0 0;0 1 -cos(x(1)) 0 0];
B = [0 -10 0 -x(2)*x(2)*cos(x(1)) -x(2)*x(2)*sin(x(1))]';
S = inv(A)*B;
xdot(2) = S(3);
endfunction
x0 = [1,1]';
t0 = 0;
t = [0:0.01:10]; x
= ode(x0,t0,t,f);
plot(t,x)

3. The simulation was done for ploting the x-dot, x-double dot, y-dot, y-double
dot, theta-dot & theta-double dot:
function xdot=f(t, x);
xdot(1)=x(4);
xdot(2)=x(5);
xdot(3)=x(6);
A = [1 0 0 -1 0;0 1 0 0 -1;0 0 1 -sin(x(3)) cos(x(3));1 0 sin(x(3)) 0 0;0 1 -cos(x(3)) 0 0];
B = [0 -10 0 -x(6)*x(6)*cos(x(3)) -x(6)*x(6)*sin(x(3))]';
S = inv(A)*B;

xdot(4)=S(1);
xdot(5)=S(2);
xdot(6)=S(3);
endfunction
x0 = [cos(1),sin(1),1,1*sin(1),1*cos(1),1]'; t0 = 0;
t = [0:0.01:10]; x
= ode(x0,t0,t,f);
plot(t,x(3,:))
plot(t,x(6,:))

Problem : 2
1. A compound pendulum with spring and viscous damping was simulated
using the newtons method for the above model, following codes were
executed to observe the angular position and velocity of the damped
compound pendulum.
The plot shows the angular position vs time(the above one) and angular
velocity vs time(the lower one) as can be seen from the graph as time
increases the velocity keeps on decreasing and finally becomes zero, the
angular position as obvious attains a constant value, that can be seen in
the graph itself.

function zd=sv(t, z)
zd(1)=z(2);
xb=cos(z(1));
yb=sin(z(1));
l=sqrt(((4-xb)^2)+((6yb)^2)); Fs=l-2;
Fs1=Fs*((4-xb)/l);
Fs2=Fs*((6-yb)/l);
A=[1 0 0 -1 0; 0 1 0 0 -1;0 0 6 0 0;1 0 2*sin(z(1)) 0 0;0 1 2*cos(z(1)) 0 0];
B=[Fs1;Fs2-9.8;-2*z(2)+(Fs2*cos(z(1)))-(Fs1*sin(z(1)))-19.6*cos(z(1));2*cos(z(1))*z(2)*z(2);2*sin(z(1))*z(2)*z(2)]; S=inv(A)*B;
zd(2)=S(3);
endfunction
z0=[0 0]';
t0=0;
t=0:0.01:30;
z=ode(z0,t0,t,sv);
xb=cos(z(1));
yb=sin(z(1));
l=sqrt(((4-xb)^2)+((6-yb)^2));
plot(t,z);
E=(2*z(2)*z(2))+19.6*(1+sin(z(1)))+0.5*(l-2)*(l-2)+2*z(2)*(1);
plot(t,E)

2. The simulation was also done for the total energy of the system vs time ,
the following graphs were obtained by the same:

function zd=sv(t, z)
zd(1)=z(2);
xb=cos(z(1));
yb=sin(z(1));
l=sqrt(((4-xb)^2)+((6yb)^2)); Fs=l-2;
Fs1=Fs*((4-xb)/l);
Fs2=Fs*((6-yb)/l);
A=[1 0 0 -1 0; 0 1 0 0 -1;0 0 6 0 0;1 0 2*sin(z(1)) 0 0;0 1 2*cos(z(1)) 0 0];
B=[Fs1;Fs2-9.8;-2*z(2)+(Fs2*cos(z(1)))-(Fs1*sin(z(1)))-19.6*cos(z(1));2*cos(z(1))*z(2)*z(2);2*sin(z(1))*z(2)*z(2)]; S=inv(A)*B;
zd(2)=S(3);
endfunction
z0=[0 0]';
t0=0;
t=0:0.01:30;
z=ode(z0,t0,t,sv);
xb=cos(z(1));
yb=sin(z(1));
l=sqrt(((4-xb)^2)+((6-yb)^2));
//plot(t,z)
E=(3*(z(2,:)^2))+19.6*(1+sin(z(1,:)))+0.5*(sqrt(((4-cos(z(1,:)))^2)+((6-sin(z(1,:)))^2))2)^2;
plot(t,E)
z

The graph obtained is as following

Problem : 3
Integrating all nine equations of motion with some initial conditions we
have tried to simulate the same as following:
function zd=deriv(t, z);
m2=1;m3=2;m4=3;l2=4;r2=1.8;l3=8;r3=4.3;a=3;I2=10;I3=24;g=9.81;
zd(1)=z(4);
zd(2)=z(5);
zd(3)=z(6);
A =[m2 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0 0; 0 m2 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0; 0 0 I2 0 0 0 0 0 0 r2*sin(z(1)) r2*cos(z(1)) (l2-r2)*sin(z(1)) -(l2-r2)*cos(z(1)) 0 0 0 0; 0 0 0 m3 0 0 0 0 0 0 0 1 0 -1 0 0 0; 0
0 0 0 m3 0 0 0 0 0 0 0 1 0 -1 0 0; 0 0 0 0 0 I3 0 0 0 0 0 -r3*sin(z(2)) -r3*cos(z(2)) -(l3-r3)*sin(z(2)) -(l3r3)*cos(z(2)) 0 0; 0 0 0 0 0 0 m4 0 0 0 0 0 0 1 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0; 0 0 0 0 0 0 0 0 0 0
0 0 0 0 a 0 -1; 1 0 r2*sin(z(1)) 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 1 -r2*cos(z(1)) 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0
l2*sin(z(1)) 1 0 r3*sin(z(2)) 0 0 0 0 0 0 0 0 0 0 0; 0 0 -l2*cos(z(1)) 0 1 -r3*cos(z(2)) 0 0 0 0 0 0 0 0 0 0 0;
0 0 l2*sin(z(1)) 0 0 l3*sin(z(2)) 1 0 0 0 0 0 0 0 0 0 0; 0 0 -l2*cos(z(1)) 0 0 -l3*cos(z(2)) 0 1 0 0 0 0 0 0 0
0 0; 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0];
B =[0; -m2*g; 0;0; -m3*g; 0; 0; m4*g ;0; -(z(4))^2*r2*cos(z(1)); -(z(4))^2*r2*sin(z(1)); (z(4))^2*l2*cos(z(1))-(z(5))^2*r3*cos(z(2)); -(z(4))^2*l2*sin(z(1))-(z(5))^2*r3*sin(z(2)); (z(4))^2*l2*cos(z(1))-(z(5))^2*l3*cos(z(2)); -(z(4))^2*l2*sin(z(1))-(z(5))^2*l3*sin(z(2)); 0 ;0];
S=inv(A)*B;
zd(4)=S(3);
zd(5)=S(6);
zd(6)=S(9);

endfunction
z0=[2 4 3 0 0 0]';
t0=0;
t=[0:0.001:15];
z= ode(z0,t0,t,deriv);
plot(t,z)

Conclusion:
Scilab has been a very effective tool in simulating different mechanisms with less
effort. The pendulum, with and without damping and the slider crank mechanism
have been seen extensively.

Vous aimerez peut-être aussi