Professional Documents
Culture Documents
Poster On Matlab PDF
Poster On Matlab PDF
J. E. Hasbun
Department of Physics
University of West Georgia
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.
∫ dv = ∫ a dt
If the acceleration is constant, an object’s velocity is
1 2
v(t ) = v0 + at ⇒ ∫ dx = ∫ v(t )dt ⇒ x(t ) = x0 + v0 t +
2
at
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 dv
= v(t , x) and = a (t , v) So that we do,
dt dt
vi +1 = vi + ai ∆t , xi +1 = xi + vi +1 ∆t to be solved on [t0 , t f ] with
ti +1 = ti + ∆t , ai = −k xi m . For N steps ∆t = ( t f − t0 ) N
i ti = i ∆t vi +1 = vi + ai ∆t xi +1 = xi + vi +1 ∆t ai = −200 xi m
%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;
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 mass-
spring system
a)with walls, and b)
without walls
d 2 x1 d 2 x2
m1 2 = − k1 x1 − k0 ( x1 − x2 ) and m2 2
= − k2 x2 − k0 ( x2 − x1 )
dt dt
•Case 1: No Walls - Single Mode k1 = k2 = 0 The analytic solution is:
m2 m1
x1 (t ) = xcm (t ) − xcm 0 − xr (t ) x2 (t ) = xcm (t ) − xcm 0 + xr (t )
m1 + m2 m1 + m2
d 2x d2y d 2z
= q (v y Bz − vz By + Ex ) / m, = q (vz Bx − vx Bz + E y ) / m, = q(vx By − v y Bx + Ez ) / m
dt 2 dt 2 dt 2
In MATLAB write these as
dr (5) dr (6)
= r (6), = q [ r (2) B(2) − r (4) B (1) + E (3) ] / m
dt dt
• see
A charged particle cycloid3d.html
moving in the presence
of a three dimensional
electromagnetic field
Systems of Coordinates - Foucault pendulum (computation)
a) The Foucault
pendulum and b)
the forces on it.
K K K K K K K K
r ′ + 2ω × r ′ + ω × (ω × r ′ )
S-frame (Earth’s center) acceleration: a = − g kˆ ′ + T / m =
K K K
Look at x-y plane motion, and ignore ω × (ω × r ′ ) , but keep the Coriolis term, and
K K Tx′ = −T sin α = −T cos β = −T x ′ / L
T = Tx iˆ′ + Ty ˆj ′, r ′ = x ′ iˆ′ + y ′ ˆj ′,
Ty′ = −T sin β = −T cos α = −T y ′ / L
x ′ = 2 y ′ω0 sin θ − g x ′ / L
get ω0 = 7.272 × 10−5 rad / s
y ′ = −2 x ′ω0 sin θ − g y ′ / L
where for Earth
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
See
Foucault.html
Gravitation: Binary Mass
System Simulation
Center of mass
K K m K
r1 = rcm − 2 r of a binary mass
m system
K K m K
r2 = rcm + 1 r
m
Can write an equation for each mass
K K K K
d 2 r1 Gm1 m2 r12 d 2 r2 Gm1 m2 r21 K K K K K
m1 2 = − 3
, m2 2 = − r ≡ r21 = −r12 = r2 − r1
dt r12 dt r213
But can also use Center of Mass - Relative Coordinate Method
K K 1 1 1
⎛ cm ⎞ ⎛ 1
r m / m m / m ⎞ ⎛ 1 ⎞ and convert to an equation
r → = +
⎜ K ⎟=⎜ µ m1 m2
2
⎟⎜ K ⎟
⎝ r ⎠ ⎝ −1 1 ⎠⎝ r2 ⎠ for the reduced mass
K 2 K whose L2µ 1
d r Gm m r r=−
µ 2 = − 13 2
( )
solution we
µ K µ 1 − ⎡u0 L2µ / µ K µ ⎤ cos θ
dt r know ⎣ ⎦
v2 r 2 1 ⎛ 1+ e ⎞
or r= = rmin ⎜ ⎟
Then get r1 and
G (m1 + m2 ) ⎛ u0 v 2 r 2 ⎞ ⎝ 1 + e cos θ ⎠ r2. Example
⎜1 + cos θ ⎟ follows:
⎝ G ( m1 + m 2 ) ⎠
Using
astronomical
Binary system units
simulation using
analytic formulas see
binary1.html
and
binary1.avi
Rutherford Scattering (simulation)
Alpha particle
qtarget = Z t qe with impact
parameter
qprojectile = Z p qe directed at a
target
Projectile
d kqe2 Z t Z p equation of
m p (vx iˆ + v y ˆj ) = ( x iˆ + y ˆj ) motion
( )
3/ 2
dt x2 + y2 with a
fixed target
d ⎡ kqe2τ 2 ⎤ K ( x iˆ + y ˆj )
(vx iˆ + v y ˆj ) = ⎢ take ab = 1 fm
Use dimensionless units: 3 ⎥
( )
3/ 2
dt ⎣ mα ab ⎦ m x 2 + y 2 K = Z Au Zα
and let
kqe2τ 2 mα ab3 4(1.66 × 10−27 kg )(10−15 m)3 m =1
≡1⇒τ = = = 1.695 × 10−22 s
mα ab3 kqe2 Nm 2
(9 × 109 2 )(1.602 × 10−19 C ) 2
C
Speed unit: vb = ab τ = 1 × 10 m 1.695 × 10 s = 5.898 × 10 m / s = 0.01965c
−15 −22 6
rmin = min ( x ( t )2 + y ( t )2 )
Numerical
simulation of a
See
projectile alpha
particle onto a gold ruther.html
target and
ruther.avi
.
Motion of Rigid Bodies – Symmetric Top (simulation)
Using
Eulerian Spinning symmetric top with its
angles symmetry axis (), which is its
spin axis as well as its principal
φ ,θ ,ψ axis of symmetry, at angle from
the fixed axis
K K
K ⎛ dL ⎞ ⎛ dL ⎞ K K
τ =⎜ ⎟ =⎜ ⎟ + ω ′′ × 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
φ ( t ) , θ ( t ) ,ψ ( t )
d
0=I (ϕ sin θ ) − I s ωsθ + Iθϕ
cos θ
dt
0 = I s ω s
(a) (b)
See
top.html
and
top.avi
(c)
Double Pendulum
Coordinates
x1 = L1 sin θ1 x2 = x1 + L2 sin θ 2
y1 = L1 cos θ1 y2 = y1 + L2 cos θ 2
T=
1
2
( ) 1
( )
m1 x12 + y12 + m2 x22 + y 22 , V = m1 gL2 + m1 gh1 + m2 g ( h1 + h2 )
2
1 1
Lagrangian L = T −V = 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 ) .
Lagrange’s
equations ( m1 + m2 ) L1θ1 + m2 L2θ2 cos (θ1 − θ2 ) = −m2 L2θ22 sin (θ1 − θ 2 ) − ( m1 + m2 ) g sin θ1
• solve m2 L2θ2 + m2 L1θ1 cos (θ1 − θ 2 ) = m2 L1θ12 sin (θ1 − θ 2 ) − m2 g sin θ 2
numerically
See
doublep.html
and
doublep.avi
Hamilton’s principle
Three possible paths
in the evolution t2
process of the action I = δ ∫ Ldt = 0
integral t2 t1
S ≡ ∫ Ldt
t1
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
2 t
∫ t ⎝
∫
S = Ldt = ⎜ mv 2 − mgy ⎟ dt
2 ⎠
0 0
See
Simulation of Hamilton's least_action.html
least action principle for and
the case of the motion of least_action.avi
a single particle free
falling near Earth's
surface, in one dimension
Other Highlights
•Central Forces
-Planetary Motion (analytic, numerical, and simulations) and comparison
with data
ho1app
inter_spr1App
inter_spr2App
cycloid3dApp
foucaultApp
binary1App
rutherApp
topApp
doublepApp
least_actionApp