sec5.2.mws

Classical Mechanics with Maple

Section 5.2: Worked Examples of the Synthetic and Analytic Methods

Dr. Harald Kammerer
maple@jademountain.de

Initialisation

> restart;

> libname:="C:/mylib/m6dynlib","C:/mylib/m6dynfig",libname:

> with(linalg):with(plots):with(plottools):with(dynamics);with(figures_chapter_5);

Warning, the protected names norm and trace have been redefined and unprotected

Warning, the name changecoords has been redefined

Warning, the name arrow has been redefined

[LAGRANGE, MI, gravitational_energy, impact, kineti...

[Fig_5_1, Fig_5_10, Fig_5_11, Fig_5_2, Fig_5_3, Fig...

5.2 Worked Examples of the Synthetic and Analytic Methods

5.2.1 Example 1

Consider a single mass, hanging by two springs from the ceiling and guided at both sides in the vertical direction without friction (Fig. 3). No outer forces are active. Here the displacement in the vertical direction is denoted by x , the velocity by xd and the acceleration by xdd . The displacement, the velocity and the acceleration are downward positve. For x=0 the springs should be free of stress. The exercise is to find the equation of motion for the system.

> display([Fig_5_3()],scaling=constrained,axes=none,title="Figure 3");

[Maple Plot]

Synthetic Method

Consider the equilibrium of the free body (Fig. 4). Forces in the horizontal directions at the vertical guide rails have no influence on the motion. On the mass the two spring forces

> Fs1(t) := k1*x(t)

and

> Fs2(t) := k2*x(t)

as well as the inertial force

> Fi(t) := m*xdd(t)

act where

> xdd(t) := diff(x(t),`$`(t,2))

At last the weight force acts on the body

> Fg := m*g

Fig. 4 shows all acting forces on the free body .

> display([Fig_5_4()],scaling=constrained,axes=none,title="Figure 4");

[Maple Plot]

The equilibrium of all forces in x -direction yields the equation of motion (eom) for the system

> eom_s:=Fi(t)+Fs1(t)+Fs2(t)-Fg=0;

eom_s := m*xdd(t)+k1*x(t)+k2*x(t)-m*g = 0

Or after collecting derivatives of x

> eom_s:=collect(eom_s,x);

eom_s := (k1+k2)*x(t)+m*diff(x(t),`$`(t,2))-m*g = 0...

Analytic Method

Here as the first step the kinetic and the potential energy have to be written down. Non-potential forces are not active. It is not necessary to cut the supports for this method.

Potential Energy

The potential energy of the first spring is (see spring_energy )

> V1:=spring_energy(k1,x(t));

V1 := 1/2*k1*x(t)^2

and for the second spring accordingly

> V2:=spring_energy(k2,x(t));

V2 := 1/2*k2*x(t)^2

The potential energy caused by the position of the body is (see gravitational_energy )

(notice the positive direction of x downwards!)

> Vg:=gravitational_energy(m,g,-x(t));

Vg := -m*g*x(t)

The total potential energy is

> V:=V1+V2+Vg;

V := 1/2*k1*x(t)^2+1/2*k2*x(t)^2-m*g*x(t)

Or after collecting all the same powers of x

> V:=collect(V,x);

V := (1/2*k1+1/2*k2)*x(t)^2-m*g*x(t)

Kinetic Energy

There is only one mass which can only translate in one direction. Rotations are imposible. The velocity is given by

> xd(t) := diff(x(t),t)

So the kinetic energy is simply (see kinetic_energy )

> T:=kinetic_energy(m,xd(t));

T := 1/2*m*diff(x(t),t)^2

Necessary derivatives

According to the Lagrangian equation several derivatives have to be calculated. To do this with Maple it is useful to make some substitutions:

> subs1 := {x(t) = s, diff(x(t),t) = v}

With this we get for the kinetic energy

> T:=subs(subs1,T);

T := 1/2*m*v^2

and for the potential of the system

> V:=subs(subs1,V);

V := (1/2*k1+1/2*k2)*s^2-m*g*s

Now the kinetic energy T has to be differentiated with respect to the velocity v

> L1:=diff(T,v);

L1 := m*v

Next the kinetic energy T has to be differentiated with respect to the displacement s

> L2:=diff(T,s);

L2 := 0

At last the potential energy has to be differentiated with respect to the displacement s

> L3:=simplify(diff(V,s));

L3 := s*k1+s*k2-m*g

Now the substitutions are made backwards

> subs2 := {v = diff(x(t),t), s = x(t)}

> L1:=subs(subs2,L1);

L1 := m*diff(x(t),t)

> L2:=subs(subs2,L2);

L2 := 0

> L3:=subs(subs2,L3);

L3 := k1*x(t)+k2*x(t)-m*g

The equation of motion is now given by

> eom_a:=diff(L1,t)-L2+L3=0;

eom_a := m*diff(x(t),`$`(t,2))+k1*x(t)+k2*x(t)-m*g ...

Or after collecting all the same derivatives of x

> eom_a:=collect(eom_a,x);

eom_a := (k1+k2)*x(t)+m*diff(x(t),`$`(t,2))-m*g = 0...

Conclusion of Example 2

In this example it seems to be much easier to use the synthetic method, because all active and all passive forces are very clear and simple to describe. To formulate the equilibrium is not very time-consuming. To solve the problem by use of the analytic method, the solution is more formal but needs more effort. But this is a very simple system, so this result cannot be generalized.

In the next example we use the function LAGRANGE from the dynamics package to get the Lagrangian equations

5.2.2 Example 2

Consider a system of two bodies as given in Fig. 5. The first body is a cylinder with radius r and mass M . The second body is a cube with the mass m . The cube hangs by an inextensible rope that is fixed on the ground and lies over the cylinder. The cylinder hangs by a spring with stiffness k from the ceiling.

The displacement of the cylinder in the vertical direction is denoted by y , the velocity by yd and the acceleration by ydd . The vertical displacement of the cylinder is denoted by x , the velocity by xd and the acceleration by xdd . At last the rotation of the cylinder with respect to its center is denoted by f , the rotational speed by f _d and the rotational acceleration by f _dd . The displacements, the velocities and the accelerations are downward positve, the rotation is positive counterclockwise. For x=0 , y=0 and f =0 the spring should be free of stress. There should be no horizontal motion.

The exercise is again to find the equation of motion for the system.

> display([Fig_5_5()],scaling=constrained,axes=none,title="Figure 5");

[Maple Plot]

Synthetic Method

Before we consider the equilibrium of the free bodies, we first consider the moment of inertia of the cylinder. The cylinder rotates around the connection point between cylinder and rope, because this point is fixed by the rope (called point A). The rotation of the cylinder can be split for small displacements into a rotation around the center C of the cylinder and a translation in the vertical direction. This is pictured in the animations in fig. 6 and fig. 7. (Click the picture and press "play" in the menu bar.)

> display(Fig_5_6(),insequence=true,scaling=constrained,axes=none,title="Figure 6");

[Maple Plot]

> display(Fig_5_7(),insequence=true,scaling=constrained,axes=none,title="Figure 7");

[Maple Plot]

In this example we consider the motion of the cylinder as a rotation around point C and a translation in the vertical direction, as fig. 8 shows. Then we need the moment of inertia of the cylinder for the rotation around point C. From the dynamics package we get by use of the MI function

> J := MI('solidcylinder',M,r);

J := 1/2*M*r^2

Now we consider the equilibrium of the two free bodies as shown in Fig. 8.

> display([Fig_5_8()],scaling=constrained,axes=none,title="Figure 8");

[Maple Plot]

At first we write down the equilibrium of all forces in the vertical direction for the cube.

> F_cube := m*g-S2-m*xdd(t) = 0

F_cube := m*g-S2-m*diff(x(t),`$`(t,2)) = 0

The equilibrium of the forces in the vertical direction at the cylinder yields

> F_cylinder := M*g+S1+S2-k*y(t)-M*ydd(t) = 0

F_cylinder := M*g+S1+S2-k*y(t)-M*ydd(t) = 0

And the equilibrium of the moments at the cylinder with respect to the center C yields

> M_cylinder_C := S1*r-S2*r-J*phi_dd(t) = 0

M_cylinder_C := S1*r-S2*r-1/2*M*r^2*phi_dd(t) = 0

Here the condition for the moment of inertia J is respected.

Additionally there are some geometrical relations between the displacements x(t) and y(t) and the rotation phi(t). In this example only small displacements are considered, so that sin( a ) = a , tan( a ) = a and cos( a ) = 1 . To derive the relations between x , y and f we look to Fig. 9.

> display([Fig_5_9()],scaling=constrained,axes=none,title="Figure 9");

[Maple Plot]

The relations are

> x(t) := 2*y(t)

> phi(t) := -x(t)/(2*r)

Notice especially the minus sign in the condition between f and x .

For the displacements and the rotation we write for their derivatives

> xd(t) := diff(x(t),t)

> yd(t) := diff(y(t),t)

> phi_d(t) := diff(phi(t),t)

> xdd(t) := diff(x(t),t,t)

> ydd(t) := diff(y(t),t,t)

> phi_dd(t) := diff(phi(t),t,t)

From the equilibrium of the forces at the cube we isolate S2

> Sol1:=isolate(F_cube,S2);

Sol1 := S2 = m*g-2*m*diff(y(t),`$`(t,2))

We insert this result into the equilibrium of the forces at the cylinder

> Sol2:=subs(Sol1,F_cylinder);

Sol2 := M*g+S1+m*g-2*m*diff(y(t),`$`(t,2))-k*y(t)-M...

Here we isolate S1

> Sol3:=isolate(Sol2,S1);

Sol3 := S1 = -M*g-m*g+2*m*diff(y(t),`$`(t,2))+k*y(t...

and substitute this and Sol1 into the equilibrium of moments at the cylinder. This yields the equation of motion

> eom_s:=subs({Sol3,Sol1},M_cylinder_C);

eom_s := (-M*g-m*g+2*m*diff(y(t),`$`(t,2))+k*y(t)+M...

Some rewriting yields

> eom_s:=collect(simplify(eom_s/r),{y(t),diff(y(t),t,t),g});

eom_s := (-2*m-M)*g+(4*m+3/2*M)*diff(y(t),`$`(t,2))...

Analytic Method

In this system are no non-conservative forces active. We consider first the potential energy of the system.

Potential Energy

The potential energy of the spring is (see spring_energy )

> V_spring:=spring_energy(k,y(t));

V_spring := 1/2*k*y(t)^2

The potential energy caused by the position of the cylinder is (see gravitational_energy )

(notice the positive direction of x and y downwards!)

> Vg_cylinder:=gravitational_energy(M,g,-y(t));

Vg_cylinder := -M*g*y(t)

And for the cube the potential energy is

> Vg_cube:=gravitational_energy(m,g,-x(t));

Vg_cube := -2*m*g*y(t)

Here and in the further calculation the conditions between x , y and f are taken over from the synthetic method (see fig. 5).This effort is the same in both methods.

The total potential energy is

> V:=V_spring+Vg_cylinder+Vg_cube;

V := 1/2*k*y(t)^2-M*g*y(t)-2*m*g*y(t)

Kinetic Energy

Now there are two masses. The cube makes only a translation in the vertical direction. The motion of the cylinder here should be considered as a rotation arround point A. The moment of inertia for this rotation is (see section 4.2.2)

> J_A := J+M*r^2

J_A := 3/2*M*r^2

The velocities are

> xd(t) := diff(x(t),t)

xd(t) := 2*diff(y(t),t)

> yd(t) := diff(y(t),t)

yd(t) := diff(y(t),t)

> phi_d(t) := diff(phi(t),t)

phi_d(t) := -diff(y(t),t)/r

So the kinetic energy of the cube is (see kinetic_energy )

> T_cube:=kinetic_energy(m,xd(t));

T_cube := 2*m*diff(y(t),t)^2

For the rotation of the cylinder the kinetic energy can be written by

> T_cylinder:=kinetic_energy(J_A,phi_d(t));

T_cylinder := 3/4*M*diff(y(t),t)^2

with the conditions for the moment of inertia J _A and the relation between y and phi and their derivatives.

The total kinetic energy is

> T:=T_cube+T_cylinder;

T := 2*m*diff(y(t),t)^2+3/4*M*diff(y(t),t)^2

Use The Function LAGRANGE

There are no non-conservative forces, so we have

> F := 0

The equation of motion we get by use of the function LAGRANGE :

> eom_a:=LAGRANGE(T,V,[F],[y],t);

eom_a := -M*g-2*m*g+4*m*diff(y(t),`$`(t,2))+k*y(t)+...

(Notice: For use of the function LAGRANGE F and y have to be written as sets.)

Some rewriting yields

> eom_s:=collect(simplify(eom_s),{y(t),diff(y(t),t,t),g});

eom_s := (-2*m-M)*g+(4*m+3/2*M)*diff(y(t),`$`(t,2))...

Conclusion of Example 3

In this example it is more efficient to use the analytic method, because all actions which have to be done are very schematic. This is especially seen by the use of the prepared function LAGRANGE . It is not necessary to write down the equilibrium for the free bodies, and the complicated cutting of the connections is avoided. Together with the conclusion of example one we can see that it depends on the particular problem to decide which method is more useful.

As the last example of this course we want to consider an example with two degrees of freedom

Example 3

> unassign('x','y','t','g','F','m'):

We consider the same system as in example 2 but now with an additional mass me connected by the spring ke and driven by the time-dependent force F(t) , as shown in Fig. 10.

> display([Fig_5_10()],scaling=constrained,axes=none,title="Figure 10");

[Maple Plot]

We leave out here the vertical guidances but we assume that there exists only vertical motions. In addition to the well known system we have now the mass me . Now we have the two independent Lagrangian coordinates x and y . So we get two coupeld equations of motion for the system. We calculate the equations of motion by use of the LAGRANGE function. Therefore we have at first to calculate the kinetic energy and the potential of the system. The active force F(t) will be considered as a non-conservative force. Here we don't consider the systhetic method.

Kinetic Energy

We define the state when all springs are stressless as the initial state of the system. So we have the kinetic energy of the upper cuboid (see example 2) with use of the definition of the velocity of the cuboid

> xd(t) := diff(x(t),t)

given by

> T_cuboid:=kinetic_energy(m,xd(t));

T_cuboid := 1/2*m*diff(x(t),t)^2

Tho motion of the mass me has the velocity

> yd(t) := diff(y(t),t)

So we get for the kinetic energy of the mass me

> T_me:=kinetic_energy(me,yd(t));

T_me := 1/2*me*diff(y(t),t)^2

The total kinetic energy is then

> T:=T_cuboid+T_me;

T := 1/2*m*diff(x(t),t)^2+1/2*me*diff(y(t),t)^2

Potential Energy

The potential energy of the upper springs are (see example 2)

> V1:=spring_energy(k1,x(t));

V1 := 1/2*k1*x(t)^2

and

> V2:=spring_energy(k2,x(t));

V2 := 1/2*k2*x(t)^2

The potential energy caused by the position of the upper cuboid is

(notice the positive direction of x downwards!)

> Vg_cuboid:=gravitational_energy(m,g,-x(t));

Vg_cuboid := -m*g*x(t)

The elongation of the spring ke is defined by the difference between the displacement of the both cuboids, which means

> Delta := y(t)-x(t)

For the potential of the spring ke we get

> Ve:=spring_energy(ke,Delta);

Ve := 1/2*ke*(y(t)-x(t))^2

For the mass particle me we have the gravitational energy

> Vg_me:=gravitational_energy(me,g,-y(t));

Vg_me := -me*g*y(t)

(Notice: For use of the Lagrangian equation only the changing of the potential is of interest. So it doesn't matter that we choose two different horizontals to formulate the potential of gravity for the bodies.)

The total potential energy is

> V:=collect(V1+V2+Vg_cuboid+Ve+Vg_me,{x(t),y(t)});

V := (1/2*k2+1/2*k1+1/2*ke)*x(t)^2+(-ke*y(t)-m*g)*x...

Use The Function LAGRANGE

There only non-conservative force is the force F(t) acting on the upper cuboid. To calculate the non-conservative forces with respect to the Lagrangian coordinates we need in general to define a global coordinate system. Here this is not necessary, but we will do it to show the method.

We define the global X-Y-Z- coordinate system with the X -axis in the horizontal direction, the Y -axis orthogonal to the drawing and the Z -axis in the opposite direction of the lagrangian coordinates x and y . So we get the equations of transformation

> r1:=vector(3,[0,0,-x(t)]);

r1 := vector([0, 0, -x(t)])

> r2:=vector(3,[0,0,-y(t)]);

r2 := vector([0, 0, -y(t)])

For the following calculation we need the derivative of these vectors with respect to the lagrangian coordinates. To get these we make some temporary substitutions

> sv := {x(t) = lx, y(t) = ly}

> sr := {lx = x(t), ly = y(t)}

Now we calculate the necessary derivatives

> for i from 1 by 1 to 3 do

> rdiff11[i]:=subs(sr,diff(subs(sv,r1[i]),lx));

> rdiff12[i]:=subs(sr,diff(subs(sv,r2[i]),lx));

> rdiff21[i]:=subs(sr,diff(subs(sv,r1[i]),ly));

> rdiff22[i]:=subs(sr,diff(subs(sv,r2[i]),ly));

> od:

The result of these derivatives should be evident, so we needn't to talk about it in detail. We write the result as vectors

> rd11:=vector(3,[rdiff11[1],rdiff11[2],rdiff11[3]]);

rd11 := vector([0, 0, -1])

> rd12:=vector(3,[rdiff12[1],rdiff12[2],rdiff12[3]]);

rd12 := vector([0, 0, 0])

> rd21:=vector(3,[rdiff21[1],rdiff21[2],rdiff21[3]]);

rd21 := vector([0, 0, 0])

> rd22:=vector(3,[rdiff22[1],rdiff22[2],rdiff22[3]]);

rd22 := vector([0, 0, -1])

The vectors of the resultant of the nonconservative forces acting on both bodies with respect to the global X-Y-Z- coordinate system are

> F1:=vector(3,[0,0,F(t)]);

F1 := vector([0, 0, F(t)])

> F2:=vector(3,[0,0,0]);

F2 := vector([0, 0, 0])

Finaly we calculate the dotproduct and the sum of the equation Q[k] = sum(F[i]*diff(r[i],q[k]),i = 1 .. n)

> Q[1]:=dotprod(F1,rd11)+dotprod(F2,rd12);

Q[1] := -F(t)

> Q[2]:=dotprod(F1,rd21)+dotprod(F2,rd22);

Q[2] := 0

So we get at last the vector of the nonconservative forces as

> Q := [Q[1], Q[2]]

Q := [-F(t), 0]

It can easily be seen that we can write tis forces direct without this detailed calculation.

The set of the Lagrangian coordinates is

> xy := [x, y]

The equation of motion we get by use of the function LAGRANGE :

> eom:=LAGRANGE(T,V,Q,xy,t);

eom := m*diff(x(t),`$`(t,2))+2*(1/2*k2+1/2*k1+1/2*k...

So we get the two coupled differential equations

> EOM1:=eom[1];

EOM1 := m*diff(x(t),`$`(t,2))+2*(1/2*k2+1/2*k1+1/2*...

> EOM2:=eom[2];

EOM2 := me*diff(y(t),`$`(t,2))-ke*x(t)-me*g+ke*y(t)...

We rearange the result and get

> DGL1:=collect(EOM1,{x(t),diff(x(t),t$2),y(t),diff(y(t),t$2)});

DGL1 := m*diff(x(t),`$`(t,2))+(k2+k1+ke)*x(t)-ke*y(...

> DGL2:=collect(EOM2,{x(t),diff(x(t),t$2),y(t),diff(y(t),t$2)});

DGL2 := me*diff(y(t),`$`(t,2))-ke*x(t)-me*g+ke*y(t)...

For completeness we calculate the solution of this equations. Before doing this we make some assumptions for the initial state of the motion. We define that at t = 0 the system starts in it's initial state without motion, that means

> IC1 := x(0) = 0

> IC2 := y(0) = 0

> IC3 := D(x)(0) = 0

> IC4 := D(y)(0) = 0

Finally we assume that the excitation is harmonic

> F(t) := F0*sin(Omega*t)

and we use some concrete values for the system constants

> g:=9.81:

> k1:=5.0:

> k2:=5.0:

> ke:=2.0:

> m:=1.0:

> me:=0.2:

> F0:=0.01:

> Omega:=5.0:

The system of the differential equations is now

> eval(DGL1);eval(DGL2);

1.0*diff(x(t),`$`(t,2))+12.0*x(t)-2.0*y(t)-9.810 = ...

.2*diff(y(t),`$`(t,2))-2.0*x(t)-1.962+2.0*y(t) = 0

To get the solution of this system of differential equations we use the adequate MAPLE funktion

> LSG:=value(dsolve({eval(DGL1),eval(DGL2),IC1,IC2,IC3,IC4},{x(t),y(t)})):

The result is first very extensive, so we use some rearrangement by use of different MAPLE funktions

> xs(t):=simplify(evalf(combine(simplify(rhs(LSG[1])),trig)));

xs(t) := -.5714285714e-3*sin(5.*t)-2.599009427*cos(...
xs(t) := -.5714285714e-3*sin(5.*t)-2.599009427*cos(...

> ys(t):=simplify(evalf(combine(simplify(rhs(LSG[2])),trig)));

ys(t) := -.8192439086e-3*sin(3.947477129*t)+.857142...
ys(t) := -.8192439086e-3*sin(3.947477129*t)+.857142...

Finally we see the time history of the motion of both bodies in Fig. 11 (green: upper mass, blue: lower mass)

> Tend:=10:

> P1:=plot(xs(t),t=0..Tend,color=green,thickness=3):

> P2:=plot(ys(t),t=0..Tend,color=blue,thickness=3):

> display({P1,P2}, title="Figure 11");

[Maple Plot]

We see that the motion is a vibration around the static equilibium.

Fig. 12 shows the motion of the system.

> display(Fig_5_11(xs(t),ys(t),eval(F(t)*50),Tend,t),insequence=true,scaling=constrained,axes=none, title="Figure 12");

[Maple Plot]

This is the end of this course. Once you have understood these principles and examples, you have enough knowledge to solve simple dynamic problems. The dynamics package should give you some helpful functions for your own calculations. I wish you much fun in your future endeavors in classical mechanics.