Document not found! Please try again

Computation in Classical Mechanics - Open Source Physics

25 downloads 82 Views 384KB Size Report
Computation in Classical Mechanics. J. E. Hasbun. Department of Physics. University of West Georgia. Scientific advances create the need to become ...
Computation in Classical Mechanics

J. E. Hasbun Department of Physics University of West Georgia

Scientific advances create the need to become computationally adept to tackling problems of increasing complexity. The use of computers in attaining solutions to many of science’s difficult problems is inevitable. Therefore, educators face the challenge to infuse the undergraduate curriculum with computational approaches that will enhance students’ abilities and prepare them to meet the world’s newer generation of problems. Computational physics courses are becoming part of the undergraduate physics landscape and learned skills need to be honed and practiced. A reasonable ground to do so is the standard traditional upper level physics courses. I have thus developed a classical mechanics textbook1 that employs computational techniques. The idea is to make use of numerical approaches to enhance understanding and, in several cases, allow the exploration and incorporation of the “what if environment” that is possible through computer algorithms. The textbook uses Matlab because of its simplicity, popularity, and the swiftness with which students become proficient in it. The example code, in the form of Matlab scripts, is provided not to detract students from learning the underlying physics. Students are expected to be able to modify the code as needed. Efforts are under way to build OSP2 Java programs that will perform the same tasks as the scripts. Selected examples that employ computational methods will be presented. 1 To be published, Jones and Bartlett Publishers. 2 Open Source Physics: http://www.opensourcephysics.org/.

Table of Contents Chapter 1

Review of Newton's Laws Euler’s method (computation)

Chapter 2

Application of Newton's 2nd Law of Motion in One Dimension

Chapter 3

Harmonic Motion in One Dimension

Chapter 4

Examples of Harmonic Motion Interacting Spring-Mass System (Computation)

Chapter 5

Vectors and Differential Calculus

Chapter 6

Motion Beyond One Dimension Charged particle in 3d under both E\&M fields (computation)

Chapter 7

Systems of Coordinates Foucault pendulum (computation)

Chapter 8

Central Forces

Chapter 9

Gravitation Binary System (simulation)

Chapter 10

Rutherford Scattering Rutherford Scattering (simulation)

Chapter 11

Systems of Particles

Chapter 12

Motion of Rigid Bodies Symmetric Top (simulation)

Chapter 13

Lagrangian Dynamics Double Pendulum (simulation) Principle of Least Action (simulation)

Chapter 1 Highlights Why we need computational physics? We can go beyond solvable problems. We can get more insight. We can explore situations beyond classroom examples. Start with the iterative Euler method.

Chapter 1 Highlights Why we need computational physics? We can go beyond solvable problems. We can get more insight. We can explore situations beyond classroom examples. If we know the acceleration of an object,



dv = ∫ a dt

If the acceleration is constant, an object’s velocity is

∫ dx = ∫ v(t )dt ⇒

v(t ) = v0 + at ⇒

x(t ) = x0 + v0 t +

1 2 at 2

However, if the acceleration is not constant, say a mass at the end of a spring,

Fs = −k x(t )

d 2 x dv a(t ) = −k x(t ) / m = 2 = dt dt

The analytic solution is done in a later chapter. Let’s look at a numerical solution. MATLAB code is provided. Students are encouraged to run it and explore it. •The Euler Method to solve a 2nd order DE: convert it to two 2nd order DE’s

dx = v(t , x) dt

vi +1 = vi + ai ∆t , ti +1 = ti + ∆t ,

and

dv = a (t , v) dt

xi +1 = xi + vi +1 ∆t ai = −k xi m .

Given initial conditions:

So that we do,

to be solved on [t0 , t f ]

For N steps

with

∆t = ( t f − t0 ) N

x0 , v0

First example, by calculator (reproduced by a general force MATLAB code): let

k = 1000 N / m, m = 5kg , x0 = 0.1m, v0 = 0.0m / s for

N = 10

so that

∆t = 0.1

on time interval

[0,1s ]

•Create a table of the calculations i

ti = i ∆t

vi +1 = vi + ai ∆t xi +1 = xi + vi +1 ∆t ai = −200 xi m

0

0.0

0.0

0.1

-20

1

0.1

-2.0

-0.1

20

2

0.2

0.0

-0.1

20

3

0.3

2.0

0.1

-20

4

0.4

0.0

0.1

-20

5

0.5

-2.0

-0.1

20

6

0.6

0.0

-0.1

20

7

0.7

2.0

0.1

-20

8

0.8

0.0

0.1

-20

9

0.9

-2.0

-0.1

20

10

1.0

0.0

-0.1

20

•Can create a plot of this rough calculation

Matlab Code for the above example %ho1.m %Calculation of position, velocity, and acceleration for a harmonic %oscillator versus time. The equations of motion are used for small time intervals clear; %NPTS=100;TMAX=1.0;%example Maximum number of points and maximum time TTL=input(' Enter the title name TTL:','s');%string input NPTS=input(' Enter the number calculation steps desired NPTS: '); TMAX=input(' Enter the run time TMAX: '); NT=NPTS/10;%to print only every NT steps %K=1000;M=5.0;C=0.0;E=0.0;W=0.0;x0=0.1;v0=0.0;% example Parameters K=input(' Enter the Spring contant K: '); M=input(' Enter the bob mass M: '); C=input(' Enter the damping coefficient C: '); E=input(' Enter the magnitude of the driving force E: '); W=input(' Enter the driving force frequency W: '); x0=input(' Enter the initial position x0: ');% Initial Conditions v0=input(' Enter the initial velocity v0: ');% Initial Conditions t0=0.0;% start at time t=0 dt=TMAX/NPTS;%time step size fprintf(' Time step used dt=TMAX/NPTS=%7.4f\n',dt);%the time step being used F=-K*x0-C*v0+E*sin(W*t0); % initial force a0=F/M;% initial acceleration fprintf(' t x v a\n');%output column labels v(1)=v0; x(1)=x0; a(1)=a0; t(1)=t0; fprintf('%7.4f %7.4f %7.4f %7.4f\n',t(1),x(1),v(1),a(1));%print initial values for i=1:NPTS v(i+1)=v(i)+a(i)*dt; %new velocity x(i+1)=x(i)+v(i+1)*dt; %new position t(i+1)=t(i)+dt; %new time F=-K*x(i+1)-C*v(i+1)+E*sin(W*t(i+1)); %new force a(i+1)=F/M; %new acceleration % print only every NT steps if(mod(i,NT)==0) fprintf('%7.4f %7.4f %7.4f %7.4f\n',t(i+1),x(i+1),v(i+1),a(i+1)); end; end;

ho1.m continued on next page

ho1.m continued from previous page subplot(3,1,1) plot(t,x,'k-'); ylabel('x(t) (m)','FontSize',14); h=legend('position vs time'); set(h,'FontSize',14); title(TTL,'FontSize',14); subplot(3,1,2) plot(t,v,'b-'); ylabel('v(t) (m/s)','FontSize',14); h=legend('velocity vs time'); set(h,'FontSize',14) subplot(3,1,3) plot(t,a,'r-'); ylabel('a(t) (m/s^2)','FontSize',14); xlabel('time (sec)','FontSize',14); h=legend('acceleration vs time'); set(h,'FontSize',14)

•We also need to be able to visualize analytical solutions – so use small MATLAB scripts provided or modify available ones •Harmonic Motion example: Interacting Spring-Mass System (Computation) Interaction massspring system a)with walls, and b) without walls

d 2 x2 m2 = − k2 x2 − k0 ( x2 − x1 ) 2 dt

d 2 x1 m1 2 = − k1 x1 − k0 ( x1 − x2 ) dt

and

•Case 1: No Walls - Single Mode

k1 = k2 = 0

x1 (t ) = xcm (t ) − xcm 0

m2 − xr (t ) m1 + m2

xr = A sin ω t + B cos ω t ,

xcm (t ) − xcm 0

The analytic solution is:

x2 (t ) = xcm (t ) − xcm 0

ω A = vr 0 = v20 − v10 ,

m x + m2 x2 = 1 1 = vcm t m1 + m2

vcm =

m1 + xr (t ) m1 + m2

B = xr 0 = x20 − x10

m1v1 + m2 v2 m1v10 + m2 v20 = m1 + m2 m1 + m2

•Can create a plot of this calculation

inter_spr1.html

The coupled massspring system without walls with a single mode of vibrations

m1 = m2 = m,

•Case2: Full System - Bimodal

Write the equations in the matrix form where

⎛m 0 ⎞ m≡⎜ ⎟ 0 m ⎝ ⎠

k1 = k2 = k ≠ k0

m  x = − k x − k0 M x

⎛ x1 ⎞ x≡⎜ ⎟ ⎝ x2 ⎠

⎛k 0⎞ k ≡⎜ ⎟ k 0 ⎝ ⎠

⎛ 1 −1⎞ M ≡⎜ ⎟ 1 1 − ⎝ ⎠

Solve using eigenvalue-eigenvector method, get two modes

x1 (t ) = x10 cos ω t cos ωm t + x20 sin ω t sin ωm t x2 (t ) = x10 sin ω t sin ωm t + x20 cos ω t cos ωm t Average ω = (ω + ω ) / 2 1 2 frequency

Modulation ωm = (ω2 − ω1 ) / 2 frequency

•Can create a plot of this calculation

The solution of the full coupled spring-mass bimodal system

inter_spr2.html



Three Dimensional Motion of a charged Particle in an Electromagnetic Field (Computation) - This follows the two dimensional analytic solutions of the charge in Electric, magnetic, and joint E& B fields We have

K K K K K F = qv × B + qE = ma d 2x = q (v y Bz − vz By + Ex ) / m, dt 2

or d2y = q (vz Bx − vx Bz + E y ) / m, dt 2

d 2z = q(vx By − v y Bx + Ez ) / m dt 2

In MATLAB write these as

x → r (1),

x → r (2);

y → r (3),

y → r (4);

z → r (5), z → r (6)

Obtain six 1st order equations given by dr (1) = r (2), dt

dr (2) = q [ r (4) B (3) − r (6) B (2) + E (1) ] / m dt

dr (3) = r (4), dt

dr (4) = q [ r (6) B (1) − r (2) B (3) + E (2) ] / m dt

dr (5) = r (6), dt

dr (6) = q [ r (2) B(2) − r (4) B (1) + E (3) ] / m dt

where we have the field arrays

E = ( E x , E y , E z ) = E (1, 2,3),

B = ( Bx , By , Bz ) = B (1, 2,3)

−8 −9 −9 −8 −9 −8 Field values example: E = [0.5 × 10 ,1 × 10 , -3 × 10 ], B = [1× 10 , -1× 10 ,5.13 × 10 ]

A charged particle moving in the presence of a three dimensional electromagnetic field

• see cycloid3d.html

Systems of Coordinates - Foucault pendulum (computation) a) The Foucault pendulum and b) the forces on it.

K

K

K

K K

K

K K

S-frame (Earth’s center) acceleration: a = − g kˆ ′ + T / m =  r ′ + 2ω × r ′ + ω × (ω × r ′ )

K

K K

Look at x-y plane motion, and ignore ω × (ω × r ′ ) , but keep the Coriolis term, and

K K T = Tx iˆ′ + Ty ˆj ′, r ′ = x ′ iˆ′ + y ′ ˆj ′, get

 x ′ = 2 y ′ω0 sin θ − g x ′ / L  y ′ = −2 x ′ω0 sin θ − g y ′ / L

Tx′ = −T sin α = −T cos β = −T x ′ / L Ty′ = −T sin β = −T cos α = −T y ′ / L

where for Earth

ω0 = 7.272 × 10−5 rad / s

Solve and get: x ′(t ) = x0′ cos ω1t cos ω2 t + y0′ sin ω1t cos ω2 t

with

y ′(t ) = − x0′ sin ω1t cos ω2 t + y0′ cos ω1t cos ω2 t

ω f = g / L ← Pendulum frequency ω1 = ω0 sin θ

← Precessional frequency

Equations (7.8.9) for a Foucault pendulum with a 24 hour period

ω2 ≡ ω12 + ω f 2

θ ← Latitude angle

This is for a Foucault pendulum with a swinging period of one hour (very long!) See Foucault.html

Gravitation: Binary Mass System Simulation

m K K K r1 = rcm − 2 r m m K K K r2 = rcm + 1 r m

Center of mass of a binary mass system

Can write an equation for each mass

K K K K d 2 r1 Gm1 m2 r12 d 2 r2 Gm1 m2 r21 m1 2 = − , m2 2 = − 3 dt r12 dt r213

K K K K K r ≡ r21 = −r12 = r2 − r1

But can also use Center of Mass - Relative Coordinate Method 1 1 1 K K → = + r / / r m m m m ⎛ cm ⎞ ⎛ 1 ⎞ ⎛ 1 ⎞ and convert to an equation 2 µ m1 m2 ⎜ K ⎟=⎜ ⎟⎜ K ⎟ 1 ⎠⎝ r2 ⎠ for the reduced mass ⎝ r ⎠ ⎝ −1

K K Gm m r d r µ 2 = − 13 2 dt r 2

or

whose solution we know

r=−

L2µ

(

µ K µ 1 − ⎡u0 L2µ / µ K µ ⎤ cos θ ⎣ ⎦

1 v2 r 2 ⎛ 1+ e ⎞ = r= r min ⎜ ⎟ G (m1 + m2 ) ⎛ ⎞ u0 v 2 r 2 ⎝ 1 + e cos θ ⎠ cos θ ⎟ ⎜1 + + G m m ( ) 1 2 ⎝ ⎠

Binary system simulation using analytic formulas

1

Then get r1 and r2. Example follows:

Using astronomical units see binary1.html and binary1.avi

)

Rutherford Scattering (simulation)

qtarget = Z t qe qprojectile = Z p qe

Alpha particle with impact parameter directed at a target

Projectile equation of motion with a fixed target

kqe2 Z t Z p d m p (vx iˆ + v y ˆj ) = ( x iˆ + y ˆj ) 3/ 2 dt x2 + y2

(

Use dimensionless units: and let

kqe2τ 2 ≡1⇒τ = mα ab3

mα ab3 = kqe2

)

⎡ kqe2τ 2 ⎤ K ( x iˆ + y ˆj ) d (vx iˆ + v y ˆj ) = ⎢ 3 ⎥ 3/ 2 dt ⎣ mα ab ⎦ m x 2 + y 2

(

take ab = 1 fm

)

K = Z Au Zα

m =1

4(1.66 × 10−27 kg )(10−15 m)3 = 1.695 × 10−22 s 2 Nm (9 × 109 2 )(1.602 × 10−19 C ) 2 C

−15 −22 6 Speed unit: vb = ab τ = 1 × 10 m 1.695 × 10 s = 5.898 × 10 m / s = 0.01965c

Solve these numerically

dx = vx , dt

dvx Kx = dt m x2 + y2

(

)

3/ 2

;

dy = vy , dt

dv y dt

=

rmin = min

Numerical simulation of a projectile alpha particle onto a gold target

Ky

(

m x2 + y2

(

x ( t )2 + y ( t )2

See ruther.html and ruther.avi .

)

3/ 2

)

Motion of Rigid Bodies – Symmetric Top (simulation) Using Eulerian angles

φ ,θ ,ψ

Spinning symmetric top with its symmetry axis (), which is its spin axis as well as its principal axis of symmetry, at angle from the fixed axis

K K ⎛ dL ⎞ K K K ⎛ dL ⎞ =⎜ τ =⎜ ⎟ ⎟ + ω ′′ × L = mg A sin θ iˆ′′ ⎝ dt ⎠ fixed ⎝ dt ⎠ rot

K K L = Iθiˆ′′ + I ϕ sin θ ˆj ′′ + I s ωs kˆ ′′, ω ′′ = θ iˆ′′ + ϕ sin θ ˆj ′′ + ϕ cos θ kˆ ′′ I 3 (ϕ cos θ + ψ ) ≡ I s ωs or

mg A sin θ = Iθ + I s ωsϕ sin θ − I ϕ 2 cos θ sin θ d   cos θ (ϕ sin θ ) − I s ωsθ + Iθϕ dt 0 = I s ω s

0=I

(a)

solve numerically for

φ ( t ) , θ ( t ) ,ψ ( t )

(b)

See top.html and top.avi (c)

spinning fixed point symmetric top a) Numerical solution, b) Plot of the energy and the effective potential, and c) a snapshot of the simulated motion of the top's total angular momentum as well as the body angular momentum vs time

LAGRANGIAN DYNAMICS – Double Pendulum (simulation)

Double Pendulum Coordinates

x1 = L1 sin θ1

x2 = x1 + L2 sin θ 2

y1 = L1 cos θ1

y2 = y1 + L2 cos θ 2

kinetic, potential energies

T=

(

)

(

)

1 1 m1 x12 + y12 + m2 x22 + y 22 , V = m1 gL2 + m1 gh1 + m2 g ( h1 + h2 ) 2 2

Lagrangian Lagrange’s equations • solve numerically

L = T −V =

1 1 m1 L12θ12 + m2 ⎡⎣ L12θ12 + L22θ22 + 2 L1 L2θ1θ2 cos (θ1 − θ 2 ) ⎤⎦ 2 2 − m1 gL2 − ( m1 + m2 ) gL1 (1 − cos θ1 ) − m2 gL2 (1 − cos θ 2 ) .

( m1 + m2 ) L1θ1 + m2 L2θ2 cos (θ1 − θ2 ) = −m2 L2θ22 sin (θ1 − θ 2 ) − ( m1 + m2 ) g sin θ1 m2 L2θ2 + m2 L1θ1 cos (θ1 − θ 2 ) = m2 L1θ12 sin (θ1 − θ 2 ) − m2 g sin θ 2

See doublep.html and doublep.avi

The double pendulum a) Eulerian angles plotted versus time (upper figure) and versus each other (lower figure) b) simulation of the pendulum for the initial conditions shown.

LAGRANGIAN DYNAMICS – Principle of Least Action (simulation) Hamilton’s principle

Three possible paths in the evolution process of the action integral t2

t2

I = δ ∫ Ldt = 0 t1

S ≡ ∫ Ldt t1

Hamilton’s principle: the motion followed by a mechanical system as it moves from a starting point to a final point within a given time will be the motion that provides an extremum for the time integral of the Lagrangian. Example – case of a particle in free fall, we have the Lagrangian and the action: tf tf 1 2 ⎛1 ⎞ L = T − V = mv y − mgy S = Ldt = ⎜ mv 2 − mgy ⎟ dt 2 2 ⎠ t t ⎝ Numerically, make the approximation:





0

0

1 ⎛ y − yk ⎞ tf with Lk ≡ L ( tk ) ≈ m ⎜ k +1 N −1 − mgyk ⎟ 2 ⎝ ∆t ⎠ S = Ldt ≈ ∆t Lk y f − y0 k =1 t0 and the initial guess yk = y0 + ( t k − t0 ) t f − t0 Modify the guess randomly, accept steps that lead to s decrease in dS = S n , N −1 − S n −1, N −1





2

( (

) )

until dS is small. Compare numerical results against the exact solution

y = y0 + v0 t −

Simulation of Hamilton's least action principle for the case of the motion of a single particle free falling near Earth's surface, in one dimension

1 2 gt 2

See least_action.html and least_action.avi

Other Highlights •Harmonic oscillator (undamped, damped, and forced) •Projectile Motion (analytic and numerical) •The pendulum (small, and large angles) •Central Forces -Planetary Motion (analytic, numerical, and simulations) and comparison with data •Eulerian Angle Frame Rotation (visualization) •More on Rutherford Scattering --Comparison with the 1913 Geiger Marsden Data for Silver and Gold

Conclusion •A junior level mechanics textbook has been developed that incorporated computational physics: “Intermediate Classical Mechanics with MATLAB applications.” •The text makes use of the valuable traditional analytic approach in pedagogy. It further incorporates computational techniques to help students visualize, explore, and gain insight to problems beyond idealized situations. •Some programming background is expected and most physics/engineering majors have had programming experience by their junior year. •The emphasis is placed on understanding. The analytic approach is supported and complemented by the computational approach. •Java applications analogue to the MATLAB scripts are available (under development) see below. They use the Open Source Physics (OSP) library of W. Christian and co-workers. http://www.westga.edu/~jhasbun/osp/osp.htm http://www.opensourcephysics.org/

•Comments are welcome. Please contact J. E. Hasbun [email protected]

OPEN SOURCE PHYSICS (OSP) JAVA APPLICATIONS ho1app

inter_spr1App

inter_spr2App

cycloid3dApp

foucaultApp

binary1App

rutherApp

topApp

doublepApp

least_actionApp