Upload
others
View
15
Download
6
Embed Size (px)
Citation preview
Lagrange-dumbbell.wxm 1 / 9
Spinning top - represented by
dumbbell
(%i1) kill(all);
(%o0) done
1 Coordinates
(%i1) depends([x,y,z,X,Y,Z,theta,phi,theta_1,phi_1,r,T,U,L],t);
(%o1) [x( )t ,y( )t ,z( )t ,X( )t ,Y( )t ,Z( )t ,�( )t ,'( )t ,�1( )t ,'1( )t ,r( )t ,
T( )t ,U( )t ,L( )t ]
(%i2) h_1: h*[sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta)];
(%o2) [h cos( )' sin( )� ,h sin( )' sin( )� ,h cos( )� ]
(%i3) h_2: h*[sin(%pi-theta)*cos(phi+%pi), sin(%pi-theta)*sin(phi+%pi), cos
(%o3) [−h cos( )' sin( )� ,−h sin( )' sin( )� ,−h cos( )� ]
(%i4) R: r*[sin(theta_1)*cos(phi_1), sin(theta_1)*sin(phi_1), cos(theta_1)]
(%o4) [cos( )'1 r sin( )�1 ,sin( )'1 r sin( )�1 ,r cos( )�1 ]
(%i5) r_1: R+h_1;
(%o5) [cos( )'1 r sin( )�1 +h cos( )' sin( )� ,sin( )'1 r sin( )�1 +h sin( )'
sin( )� ,r cos( )�1 +h cos( )� ]
(%i6) r_2: R+h_2;
(%o6) [cos( )'1 r sin( )�1 −h cos( )' sin( )� ,sin( )'1 r sin( )�1 −h sin( )' sin( )�
,r cos( )�1 −h cos( )� ]
2 Kinetic energy
Lagrange-dumbbell.wxm 2 / 9
(%i7) T[1]: m/2*(diff(r_1[1],t)^2+diff(r_1[2],t)^2+diff(r_1[3],t)^2);
(%o7) (m (
� �
−r sin( )�1
� �
d
d t�1 +
� �
d
d tr cos( )�1 −h sin( )�
� �
d
d t�
2
+(
sin( )'1 r cos( )�1
� �
d
d t�1 +sin( )'1
� �
d
d tr sin( )�1 +cos( )'1
� �
d
d t'1 r sin( )�1
+h sin( )' cos( )�� �
d
d t� +h cos( )'
� �
d
d t' sin( )� )^ 2 +(cos( )'1 r cos( )�1
� �
d
d t�1 +cos( )'1
� �
d
d tr sin( )�1 −sin( )'1
� �
d
d t'1 r sin( )�1 +h cos( )' cos( )�
� �
d
d t� −h sin( )'
� �
d
d t' sin( )� )^ 2 ))/ 2
(%i8) T[2]: m/2*(diff(r_2[1],t)^2+diff(r_2[2],t)^2+diff(r_2[3],t)^2);
(%o8) (m (
� �
−r sin( )�1
� �
d
d t�1 +
� �
d
d tr cos( )�1 +h sin( )�
� �
d
d t�
2
+(
sin( )'1 r cos( )�1
� �
d
d t�1 +sin( )'1
� �
d
d tr sin( )�1 +cos( )'1
� �
d
d t'1 r sin( )�1
−h sin( )' cos( )�� �
d
d t� −h cos( )'
� �
d
d t' sin( )� )^ 2 +(cos( )'1 r cos( )�1
� �
d
d t�1 +cos( )'1
� �
d
d tr sin( )�1 −sin( )'1
� �
d
d t'1 r sin( )�1 −h cos( )' cos( )�
� �
d
d t� +h sin( )'
� �
d
d t' sin( )� )^ 2 ))/ 2
(%i9) T: factor(trigsimp(ratsimp(T[1]+T[2])));
(%o9) m (r2
� �
d
d t�1
2
+
� �
d
d t'1
2
r2 sin( )�12+h2
� �
d
d t�
2
+h2
� �
d
d t'
2
sin( )� 2+
� �
d
d tr
2
)
3 Potential energy
➔ /*U[1]: trigsimp(-M*m*G/(r_1[1]^2+r_1[2]^2+r_1[3]));
U[2]: trigsimp(-M*m*G/(r_1[1]^2+r_1[2]^2+r_1[3]));*/;
(%i11) U[1]: trigsimp(-M*m*G/r);
U[2]: trigsimp(-M*m*G/r);
(%o10) −G M m
r
(%o11) −G M m
r
Lagrange-dumbbell.wxm 3 / 9
(%i12) U: gfactor(trigsimp(U[1] + U[2]));
(%o12) −2 G M m
r
4 Lagrange function
(%i13) T;
(%o13) m (r2
� �
d
d t�1
2
+
� �
d
d t'1
2
r2 sin( )�12+h2
� �
d
d t�
2
+h2
� �
d
d t'
2
sin( )� 2+
� �
d
d tr
2
)
(%i14) U;
(%o14) −2 G M m
r
(%i15) L: T - U;
(%o15) m (r2
� �
d
d t�1
2
+
� �
d
d t'1
2
r2 sin( )�12+h2
� �
d
d t�
2
+h2
� �
d
d t'
2
sin( )� 2+
� �
d
d tr
2
)+2 G M m
r
5 Lagrange equations II
5.1 theta equation
(%i16) D1: diff(L, diff(theta,t));
(%o16) 2 h2 m
� �
d
d t�
(%i17) E1: expand(ratsimp(diff(D1,t) - diff(L,theta) = 0));
(%o17) 2 h2 m
� �
d2
d t2� −2 h2 m
� �
d
d t'
2
cos( )� sin( )� =0
(%i18) E11: trigsimp(solve(E1, diff(theta,t,2)));
(%o18) [d2
d t2�=
� �
d
d t'
2
cos( )� sin( )� ]
5.2 phi equation
(%i19) D2: diff(L, diff(phi,t));
(%o19) 2 h2 m
� �
d
d t' sin( )� 2
Lagrange-dumbbell.wxm 4 / 9
(%i20) E2: trigsimp(ratsimp(diff(D2,t) - diff(L,phi) = 0));
(%o20) 4 h2 m
� �
d
d t' cos( )� sin( )�
� �
d
d t� +2 h2 m
� �
d2
d t2' sin( )� 2=0
(%i21) E21: trigsimp(solve(E2, diff(phi,t,2)));
(%o21) [d2
d t2'=−
2
� �
d
d t' cos( )�
� �
d
d t�
sin( )�]
5.3 theta_1 equation
(%i22) D3: diff(L, diff(theta_1,t));
(%o22) 2 m r2
� �
d
d t�1
(%i23) E3: expand(ratsimp(diff(D3,t) - diff(L,theta_1) = 0));
(%o23) 2 m r2
� �
d2
d t2�1 +4 m r
� �
d
d tr
� �
d
d t�1 −2 m
� �
d
d t'1
2
r2 cos( )�1
sin( )�1 =0
(%i24) E31: trigsimp(solve(E3, diff(theta_1,t,2)));
(%o24) [d2
d t2�1=−
2
� �
d
d tr
� �
d
d t�1 −
� �
d
d t'1
2
r cos( )�1 sin( )�1
r]
5.4 phi_1 equation
(%i25) D4: diff(L, diff(phi_1,t));
(%o25) 2 m
� �
d
d t'1 r2 sin( )�1
2
(%i26) E4: expand(ratsimp(diff(D4,t) - diff(L,phi_1) = 0));
(%o26) 4 m
� �
d
d t'1 r2 cos( )�1 sin( )�1
� �
d
d t�1 +4 m
� �
d
d t'1 r
� �
d
d tr
sin( )�12+2 m
� �
d2
d t2'1 r2 sin( )�1
2=0
(%i27) E41: trigsimp(solve(E4, diff(phi_1,t,2)));
(%o27) [d2
d t2'1=−
2
� �
d
d t'1 r cos( )�1
� �
d
d t�1 +2
� �
d
d t'1
� �
d
d tr sin( )�1
r sin( )�1]
5.5 r equation
Lagrange-dumbbell.wxm 5 / 9
(%i28) D5: diff(L, diff(r,t));
(%o28) 2 m
� �
d
d tr
(%i29) E5: expand(ratsimp(diff(D5,t) - diff(L,r) = 0));
(%o29) −2 m r
� �
d
d t�1
2
−2 m
� �
d
d t'1
2
r sin( )�12+2 m
� �
d2
d t2r +
2 G M m
r2=0
(%i30) E51: trigsimp(solve(E5, diff(r,t,2)));
(%o30) [d2
d t2r=
r3
� �
d
d t�1
2
+
� �
d
d t'1
2
r3 sin( )�12−G M
r2]
(%i31) expand(%);
(%o31) [d2
d t2r=r
� �
d
d t�1
2
+
� �
d
d t'1
2
r sin( )�12−
G M
r2]
6 Prepare solution
(%i39) GC: trigsimp(first(solve([first(E11),first(E21),first(E31),first(E41
[diff(theta,t,2), diff(phi,t,2), diff(theta_1,t,2), diff(phi_1,t
(%o39) [d2
d t2�=
� �
d
d t'
2
cos( )� sin( )� ,d2
d t2'=−
2
� �
d
d t' cos( )�
� �
d
d t�
sin( )�,
d2
d t2�1
=−
2
� �
d
d tr
� �
d
d t�1 −
� �
d
d t'1
2
r cos( )�1 sin( )�1
r,
d2
d t2'1=−
2
� �
d
d t'1 r cos( )�1
� �
d
d t�1 +2
� �
d
d t'1
� �
d
d tr sin( )�1
r sin( )�1,
d2
d t2r=
r3
� �
d
d t�1
2
+
� �
d
d t'1
2
r3 sin( )�12−G M
r2]
(%i41) transform(Eq) := (A: ratsubst(phi_d, diff(phi,t), Eq),
A: ratsubst(phi_dd, diff(phi,t,2), A),
A: ratsubst(theta_d, diff(theta,t), A),
A: ratsubst(theta_dd, diff(theta,t,2), A),
A: ratsubst(phi_1d, diff(phi_1,t), A),
A: ratsubst(phi_1dd, diff(phi_1,t,2), A),
A: ratsubst(theta_1d, diff(theta_1,t), A),
A: ratsubst(theta_1dd, diff(theta_1,t,2), A),
A: ratsubst(r_d, diff(r,t), A),
ratsubst(r_dd, diff(r,t,2), A)
)$
Lagrange-dumbbell.wxm 6 / 9
(%i46) G1: transform(GC[1])$
G2: transform(GC[2])$
G3: transform(GC[3])$
G4: transform(GC[4])$
G5: transform(GC[5])$
7 Solution
(%i231) str: [h=0.25, m=1, G=1, M=10];
(%o231) [h=0.25,m=1,G=1,M=10]
(%i241) Eq1: gfactor(ev(rhs(G1), str, eval))$
Eq2: gfactor(ev(rhs(G2), str, eval))$
Eq3: gfactor(ev(rhs(G3), str, eval))$
Eq4: gfactor(ev(rhs(G4), str, eval))$
Eq5: gfactor(ev(rhs(G5), str, eval))$
Eq6: theta_d;
Eq7: phi_d;
Eq8: theta_1d;
Eq9: phi_1d;
Eq10: r_d;
(%o237) �d(%o238) 'd
(%o239) theta_1d
(%o240) phi_1d
(%o241) rd
➔ /*kill(theta, phi, theta_d, phi_d);*/;
(%i338) s: rk([Eq1, Eq2, Eq3, Eq4, Eq5, Eq6, Eq7, Eq8, Eq9, Eq10],
[theta_d, phi_d, theta_1d, phi_1d, r_d, theta, phi, theta_1, phi_1
[.03, .02, 0.0, 0.02, 0., %pi/2, %pi/2, %pi/2, 0, 12], [t,0,92
➔ /*theta: phi: theta_d: phi_d: 0.;*/;
/*ev(Eq3);ev(Eq4);ev(Eq5);*/;
/*s: rk([ev(Eq3), ev(Eq4), ev(Eq5), ev(Eq8), ev(Eq9), ev(Eq10)],
[theta_1d, phi_1d, r_d, theta_1, phi_1, r],
[.0, 0.18, 0., 0.01, 0., 10], [t,0,240.,1])$*/;
7.1 Graphics
Lagrange-dumbbell.wxm 7 / 9
(%i348) c1: makelist([p[1],p[2]],p,s)$
c2: makelist([p[1],p[3]],p,s)$
c3: makelist([p[1],p[4]],p,s)$
c4: makelist([p[1],p[5]],p,s)$
c5: makelist([p[1],p[6]],p,s)$
c6: makelist([p[1],p[7]],p,s)$
c7: makelist([p[1],p[8]],p,s)$
c8: makelist([p[1],p[9]],p,s)$
c9: makelist([p[1],p[10]],p,s)$
c10:makelist([p[1],p[11]],p,s)$
7.2 Plot theta, phi, psi
➔ /*c1;c2;c3;c4;c5;c6;*/;
(%i349) wxplot2d([[discrete, c1], [discrete, c2]], [y,-0.1, 0.1],
[xlabel, "time"],
[legend, "theta^{dot}", "phi^{dot}"])$
(%t349)
Lagrange-dumbbell.wxm 8 / 9
(%i350) wxplot2d([[discrete, c3], [discrete, c4]],
[xlabel, "time"],
[legend, "theta_1^{dot}", "phi_1^{dot}"])$
(%t350)
(%i351) wxplot2d([[discrete, c5], [discrete, c6]],
[xlabel, "time"],
[legend, "r^{dot}", "theta"])$
(%t351)
Lagrange-dumbbell.wxm 9 / 9
(%i352) wxplot2d([[discrete, c7], [discrete, c8]],
[xlabel, "time"],
[legend, "phi", "theta_1"])$
(%t352)
(%i353) wxplot2d([[discrete, c9], [discrete, c10]],
[xlabel, "time"],
[legend, "phi_1", "r"])$
(%t353)