Java Applets 1 1 2 Applets Runge-Kutta 3 Applet 3, Web Visual Simulation of Classical Mechanics in terms of Java Applets Toshiaki Izumoto 1 and Yuki Irokawa 1 In this paper, some Java applets are made of the visual simulation of the classical mechanics. The orbit of the Kepler motion is first visualized by numerically integrating the differential equation of the 2-body central force problem. The magnitudes of numerical errors are evaluated of the Euler, the Runge-Kutta and the Symplectic integration methods by comparing the numerical results of the orbit and the constants of motion with the eact solution. A visual 3-body simulation is then performed of the earth and the moon in the solar system by making use of the Symplectic 6th integration method, where the constants of motion are carefully observed. The virtual problems are discussed, for eample, of the moon spiraling away. The visual simulation may facilitate learning in a virtual class. 1. Java Graphics 1) 2) 6) Java Applets Kepler 4),5) 7) 10) Newton Euler Runge-Kutta (RK) Symplectic 4 (SI) 10) 12) Kepler Velocity-Verlet 5) RK 13). 3 Symplectic 10),11), 14),15) 1 Department of Physics, Rikkyo University 1 c 2011 Information Processing Society of Japan
Applets 2. 2.1 1 Hamiltonian m 1 U(q) H = K + U(q) = p 2 /2m + U(q), U(q) = k/ q (1) { dp/dt = {p, H} = H/ q, (2) dq/dt = {q, H} = H/ p K, U, E Newton 4 p md 2 q/dt 2 = kq/ q 3 (9) m 1 ( m 2 ) 2 m µ = m 1 m 2 /(m 1 + m 2 ), k = Gm 1 m 2 (1) 9 G (r, θ), (p r, p θ ) 16) r = C/{1 + ɛ cos(θ + θ 0 )}. (10) C ɛ C = l 2 /mk, ɛ = 1 + 2El 2 /mk 2. (11) {p, H}, {q, H} Poisson {p, K} = 0, {p, U} = U/ q = f(q), {q, K} = p/m, {q, U} = 0 { dp/dt = f(q) = kq/ q 3, dq/dt = p/m (3) (4) E l R = 1 m m 2 = 1 T = 1 ( 1 3). t = 0 (r, θ) = (1, 0) dr/dt = 0, r(dθ/dt) = RΩ = v 0 (Ω ) C = v0/(2π) 2 2, ɛ = 1 v0/(2π) 2 2 (12) r = v0/ [ 2 (2π) 2 + {v0 2 (2π) 2 } cos θ ] (13) E M E = p 2 /2m k/ q, M = [q p]. (5) 4 de/dt = 0, dm/dt = 0 (6) the virial theorem K = Ū/2. (7) K, Ū K, U Ē = Ū/2 (8) v 0 v 0 < 2 2π, E = v0/2 2 (2π) 2 < 0, v 0 = 2π, v 0 = 2 2π, E = v0/2 2 (2π) 2 = 0, v 0 > 2 2π, E = v0/2 2 (2π) 2 > 0. a, b a = C/(1 ɛ 2 ) = k/2e = 1/{2 v0/(2π) 2 2 } (14) b = a 1 ɛ 2 = l 2 /2µE = 1/ 2(2π) 2 /v0 2 1 (15) l/2m πab 1 T 2 c 2011 Information Processing Society of Japan
T = 2πab/(l/m) = 4π 2 a 3 /GM = 1/{2 v 2 0/(2π) 2 } 3/2 (16) 2.2 3 Hamiltonian m i, q i, p i (i = 1, 2, 3) H = K + U = p 2 i /2m i Gm i m j / q i q j, (17) i i<j M = [q i p i ] (18) i { dp i /dt = H/ q i, dq i/dt = H/ p i, (i = 1, 2, 3) 1 q 1 q 2 q 3 {q 1, q 2, q 3 } {p 1, p 2, p 3 } {R G, R, r} {P G, P, p} q 1 = R G (m 2 + m 3 )R/M G, q 2 = R G + m 1R/M G m 3r/(m 2 + m 3), q 3 = R G + m 1 R/M G + m 2 r/(m 2 + m 3 ), p 1 = m 1 P G /M G P, p 2 = m 2P G/M G + m 2P/(m 2 + m 3) p, p 3 = m 3 P G /M G + m 3 P/(m 2 + m 3 ) + p. Hamiltonian H = P 2 G/2M G + P 2 /2m + p 2 /2µ { Gm 1 m 2 / R m 3 r/(m 2 + m 3 ) (19) (20) +Gm 1 m 3 / R m 2 r/(m 2 + m 3 ) + Gm 2 m 3 / r }, (21) M = [R G P G] + [R P] + [r p] (22) M G = m 1 + m 2 + m 3, m = m 1 (m 2 + m 3 )/M G, µ = m 2 m 3 /(m 2 + m 3 ) (23) Ẽ M Ẽ = E P 2 /2M G, M = M [R G P G] (24) r R m 2, m 3 m 1 21 Newton r M Gd 2 R G /dt 2 = 0, m d 2 R/dt 2 Gm 1(m 2 + m 3)R/ R 3, µ d 2 r/dt 2 Gm 2 m 3 r/ r 3 +Gm 1 m 2 m 3 /(m 2 + m 3 ){3(R r)r/ R 2 r}/ R 3 r, R Java Applets. R G = (0, 0, 0), R = (R, 0, 0), r = (r cos θ, 0, r sin θ), (26) P G = (0, 0, 0), P = (0, mrω, 0), p = (µrω cos θ, 0, µrω sin θ). (27) M G, m, µ R, r Ω, ω 20, {q 1, q 2, q 3 } {p 1, p 2, p 3 }, θ = 5.15. 2.3 2.3.1 Euler Runge-Kutta p, q z = {q, p} 4 t dz/dt ż ż = g(t, z) (28) (25) 3 c 2011 Information Processing Society of Japan
1 Table 1 Masses and mass ratios of stars 3 T Table 3 Angular velocities of bounded motion m 1 1.9891 10 30 kg 333,400 m 2 5.974 10 24 kg 1. m 3 7.34767 10 22 kg 0.0123000 Ω 2π[T 1 ] 1. ω 2π/(27.32/365.24)[T 1 ] 13.369 Table 2 2 Average distances of two stars - R 1.496 10 8 km 1. - r 3.844 10 5 km 0.0025696 Euler t n = n t Taylor z n+1 z n + tg(t n, z n) (29) Euler t 1. Runge-Kutta t z n+1 = z n + k 2, (30) k 1 = t g(t n, z n), k 2 = t g(t n + t/2, z n + k 1/2) 2 1 Kepler. t z n+1 = z n + (k 1 + 2k 2 + 2k 3 + k 4 )/6, (31) k 1 = t g(t n, z n ), k 2 = t g(t n + t/2, z n + k 1 /2), k 3 = t g(t n + t/2, z n + k 2/2), k 4 = t g(t n + t, z n + k 3) 2.3.2 Symplectic z = (q, p), ż = {z, H} (32) {z, H} Poisson H = K(p) + U(q) D H D H = {z, H} (33) z( t) = exp[ td H]z(0) (34) D H = {z, K} + {z, U} = D K + D U (35) z( t) = exp[ t(d K + D U )]z(0) (36) Symplectic 10),11) Symplectic O( t 2 ) exp[ t(d K + D U )] exp[ td K] exp[ td U ] + O( t 2 ) (37) Symplectic O( t 3 ) exp[ t(d K + D U )] exp[( t/2)d K ] exp[ td U ] exp[( t/2)d K ] (38) Symplectic O( t 4 ) exp[ t(d K + D U )] L 2 [s 1 (D K + D U )] L 2 [s 2 (D K + D U )] L 2 [s 1 (D K + D U )] (39) L 2[A + B] = exp[(1/2)a] exp[b] exp[(1/2)a] s 1 = 1/(2 2 1/3 ), s 2 = 1 2s 1 Symplectic O( t 6 ) exp[ t(d K + D U )] L 4 [s 3 (D K + D U )] L 4 [s 4 (D K + D U )] L 4 [s 3 (D K + D U )] (40) L 4[A + B] = L 2[s 1(A + B)]L 2[s 2(A + B)]L 2[s 1(A + B)] s 3 = 1/(2 2 1/5 ), s 4 = 1 2s 3 5) Velocity Verlet 4 c 2011 Information Processing Society of Japan
1., r 0 = 1, v 0 = 2π, ɛ = 0 Euler 1 Fig. 1 Orbits of the Earth, calculated by using numerical integration methods for the initial values of r 0 = 1 and v 0 = 2π. A circle is the exact solution in this case. 1 Symplectic 2. 3. Java Applets 3.1 Java Applet Kepler Applet r m 2.1 9 k (2π) 2 2. r 0 = 1, v 0 = 2π 0.70 ɛ = 0.51 0.538 Euler Runge-Kutta Fig. 2 Orbits of the Earth, calculated by using numerical integration methods for the case of the initial values of r 0 = 1 and v 0 = (2π) 0.70. An ellipse with the eccentricity ɛ = 0.51 is the exact solution in this case. Applet Euler Runge-Kutta (RK) Symplectic SI ) t Newton i r 0 v 0 ii t t 1 2 (13) 3 4 Kepler 6 5 c 2011 Information Processing Society of Japan
3 Runge-Kutta (RK2nd) Simplectic (SI2nd) r 0 = 1, v 0 = 2π 0.70 RK2nd Fig. 3 Time variation of the energy and the angular momentum, which are calculated with the 2nd-order RK (RK2nd) and the SI2nd methods for the initial values of r 0 = 1 and v 0 = (2π) 0.70. Note that the numerical deviation in the case of the RK2nd method grows monotonically as time elapses. r 0 = 1, v 0 = 2π 2π 0.70, ɛ = 0.0 0.51 t = T/200, (T ) Euler. Euler 29 Runge-Kutta RK2nd 30 Symplectic SI2nd 38 Euler RK2nd SI2nd ɛ = 0.51 r 0 = 1, v 0 = 2π 0.70 4 Runge-Kutta 4 (RK4th) Simplectic 4 (SI4th) r 0 = 1, v 0 = 2π 0.70 RK4th. 3 100 Fig. 4 Time variation of numerical deviations from the constants of motion, which are predicted with the 4th-order Runge-Kutta(RK) and the Symplectic Integrator(SI) methods for the initial values of r 0 = 1 and v 0 = (2π) 0.70. In the case of the RK4th method, the numerical deviation grows monotonically as time elapses. Note that the scale of the vertical axis is magnified by a factor of 100. ɛ = 0.51 RK2nd SI2nd. RK4th SI4th RK2nd 4 RK4th SI4th RK4th SI4th 6 c 2011 Information Processing Society of Japan
5.. R r α 4α. Fig. 5 The binary system of the earth and the moon moving around the sun. Note that the relative distance between the earth and the moon is apparently multiplied by α (, and 4α within an inset) after the numerical integration. 3.2 Java Applet 3 3 Applet Symplectic 6 2.2 17) RK 2 13) 2.3 Symplectic 2 Velocity Verlet 5) Kepler 3 6. r α 4α. Fig. 6 The binary system of the earth and the moon which is set to circle in the opposite direction, is traveling around the sun. Note that relative the distance between the earth and the moon is apparently multiplied byα (, and 4α within an inset) in the drawing. Symplectic 6 t. 3 Ẽ M 24 5 R r α =10 ( 4α =40 ). 13),15). Applet α 1 12 13 7 c 2011 Information Processing Society of Japan
7 r 1.50 v 1/ 1.5. r α 4α. Fig. 7 The binary system of the earth and the moon moving around the sun. Note that the relative distance between the earth and the moon is apparently multiplied by α (, and 4α within an inset) after the numerical integration. 8 r 2.0 v 1/ 2.0 r α 4α. Fig. 8 The binary system of the earth and the moon is moving around the sun. Note that the relative distance between the earth and the moon is apparently multiplied by α (, and 4α within an inset) after the numerical integration. 3 6 19 80 1 18) 1 80 ±1 14),15) 1 3.8cm 7 8 0 < (1 + β) r (1 + β) r, v v / 1 + β (41) - 1 + β 15) 1/(1 + β) (1 + β) 3/2 50 r 1.5 1.8 2 8 8 c 2011 Information Processing Society of Japan
25 4. 1 2 Runge-Kutta Euler Runge-Kutta t Symplectic. 3 Java Applet 3 1.8 2, Java Applets Applets / 19) Web page 1) Oracle Corporation, Java T M Platform, Standard Edition 6 JDK. 2),,,,, JAVA 2009 28pYE-3. 3),, Java Graphics Vol.2009-CE-99,No.2,1-8,2009. 4) W. Fendt, http://www.walter-fendt.de/ph14e/ 5) PhET, Interactive Simulations, univ. of Colorado at Boulder, http://phet.colorado.edu/ 6) PheET, 16 2010 34-37 7) 3 2010, 8) (2007, ), http://www.a-phys.eng.osaka-cu.ac.jp/terai/comp phys/comp.pdf 9) 2008), http://www-solid.eps.s.u-tokyo.ac.jp/ataru/edu/ensyu08.pdf 10) :Symplectic http://cms.phys.s.u-tokyo.ac.jp/ naoki/cipintro/symp/symp1.html 11) H. Yoshida, Construction of higher order symplectic integrators, Physics Letters A150 (1990) pp.262-268. 12) : 2008, Kyoto-University Open Courseware http://ocw.kyoto-u.ac.jp/faculty-of-integrated-human-studies-jp/introductionto-simulation 13), 3 Fortran Pascal 1991,. 14) Wikipedia Lunar distance(astronomy), http://en.wikipedia.org/wiki/lunar distance (astronomy) 15) Newton (2009, ) 16) H. Goldstein, Classical Mechanics, (1964, Addison-Wesley Pub. Company). 17) Java 2003,. 18) /. 19), http://www2.rikkyo.ac.jp/web/izumoto/multimediaworks.html 9 c 2011 Information Processing Society of Japan