Download L15 - unix.eng.ua.edu

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Fictitious force wikipedia , lookup

Momentum wikipedia , lookup

Derivations of the Lorentz transformations wikipedia , lookup

Force wikipedia , lookup

Flow conditioning wikipedia , lookup

Dynamical system wikipedia , lookup

Classical mechanics wikipedia , lookup

Lagrangian mechanics wikipedia , lookup

Kinematics wikipedia , lookup

Velocity-addition formula wikipedia , lookup

Rigid body dynamics wikipedia , lookup

Hamiltonian mechanics wikipedia , lookup

Newton's laws of motion wikipedia , lookup

Centripetal force wikipedia , lookup

Fluid dynamics wikipedia , lookup

Routhian mechanics wikipedia , lookup

Equations of motion wikipedia , lookup

Classical central-force problem wikipedia , lookup

Analytical mechanics wikipedia , lookup

Transcript
1
Statistical Mechanics and MultiScale Simulation Methods
ChBE 591-009
Prof. C. Heath Turner
Lecture 15
• Some materials adapted from Prof. Keith E. Gubbins: http://gubbins.ncsu.edu
• Some materials adapted from Prof. David Kofke: http://www.cbe.buffalo.edu/kofke.htm
2
Review and Preview
 MD of hard disks
• intuitive
• collision detection and impulsive dynamics
 Monte Carlo
• convenient sampling of ensembles
• no dynamics
• biasing possible to improve performance
 MD of soft matter
•
•
•
•
•
equations of motion
integration schemes
evaluation of dynamical properties
extensions to other ensembles
focus on atomic systems for now (deal with molecules later)
3
Classical Equations of Motion
 Several formulations are in use (see other slides on website)
• Newtonian
• Lagrangian
• Hamiltonian
 Advantages of non-Newtonian formulations
•
•
•
•
more general, no need for “fictitious” forces
better suited for multiparticle systems
better handling of constraints
can be formulated from more basic postulates
 Assume conservative forces
F  U
Gradient of a scalar potential energy
4
Newtonian Formulation
 Cartesian spatial coordinates ri = (xi,yi,zi) are primary variables
• for N atoms, system of N 2nd-order differential equations
d 2ri
m 2  mri  Fi
dt
 Sample application: 2D motion in central force field

  yf 

y 
mx  F  eˆ x   f (r )rˆ  eˆ x   xf
x2  y 2
my  F  eˆ y   f (r )rˆ  eˆ y
x2
2
• Polar coordinates are more natural
and convenient
mr 2 
constant angular momentum
mr   f (r ) 
2
mr 3
r
fictitious (centrifugal) force
F   f (r )rˆ
5
Phase Space (again)
 Return to the complete picture of phase space
• full specification of microstate of the system is given by the values of
all positions and all momenta of all atoms
 G = (pN,rN)
• view positions and momenta as completely independent coordinates
 connection between them comes only through equation of motion
 Motion through phase space
• helpful to think of dynamics as “simple” movement through the highdimensional phase space
 facilitate connection to quantum mechanics
 basis for theoretical treatments of dynamics
 understanding of integrators
G
6
Integration Algorithms
 Equations of motion in cartesian coordinates
dr j
dt
dp j
dt

pj
r  (rx , ry )
m
p  ( px , p y )
 Fj
2-dimensional space (for example)
N
F j   Fij
pairwise additive forces
i 1
i j
 Desirable features of an integrator
•
•
•
•
•
•
F
minimal need to compute forces (a very expensive calculation)
good stability for large time steps
good accuracy
conserves energy and momentum
time-reversible
More on these later
area-preserving (symplectic)
7
Verlet Algorithm
1. Equations
 Very simple, very good, very popular algorithm
 Consider expansion of coordinate forward and backward in time
1 r (t ) t 3  O ( t 4 )
r (t   t )  r (t )  m1 p(t ) t  21m F(t ) t 2  3!
1 r (t ) t 3  O ( t 4 )
r (t   t )  r (t )  m1 p(t ) t  21m F(t ) t 2  3!
 Add these together
r (t   t )  r (t   t )  2r (t )  m1 F(t ) t 2  O( t 4 )
 Rearrange
r (t   t )  2r (t )  r (t   t )  m1 F(t ) t 2  O( t 4 )
• update without ever consulting velocities!
8
Verlet Algorithm 2. Flow diagram
One MD Cycle
Configuration r(t)
Previous configuration r(t-t)
One force
evaluation per
time step
Entire Simulation
Initialization
Compute forces F(t)
on all atoms using r(t)
Reset block sums
New configuration
1 move per cycle
Advance all positions according to
r(t+t) = 2r(t)-r(t-t)+F(t)/m t2
Add to block sum
cycles per block
Compute block average
blocks per simulation
Add to block sum
No
End of
block?
Compute final results
Yes
Block
averages
9
Verlet Algorithm 2. Flow Diagram
t-t
r
v
t
t+t
Compute new position from
present and previous positions,
and present force
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
10
Forces 1. Formalism
 Force is the gradient of the potential
F21  u (r12 )
u (r12 )
u (r12 )


e

ey
Force on 1,
x
x1
y1
due to 2
du (r12 )  r12
r12 

e

ey 
x

dr12  x1
y1 
f (r )
  12  x12e x  y12e y 
r12
F21  F12
x12
y12
2
1
r12
1/ 2
r12  ( x2  x1 ) 2  ( y2  y1 ) 2 
4
Energy
Force
2
0
-2
1.0
1.5
2.0
Separation, r/s
2.5
11
Forces 2. LJ Model
 Force is the gradient of the potential
F21  
f (r12 )
 x12e x  y12e y 
r12 
x12
y12
2
e.g., Lennard-Jones model
1
r12
1/ 2
r12  ( x2  x1 ) 2  ( y2  y1 ) 2 
 s 12  s 6 
u (r )  4      
 r  
 r 
4
du
f (r )  
dr
13
7
2
48  s 
1s  

     
s  r 
2  r  
0
14
8

48  s 
1 s 
F21   2        x12e x  y12e y 
2  r12  
s  r12 
-2

Energy
Force
1.0
1.5
2.0
Separation, r/s
2.5
12
Verlet Algorithm. 4. Loose Ends
 Initialization
• how to get position at “previous time step” when starting out?
• simple approximation
r(t0   t )  r(t0 )  v(t0 ) t
 Obtaining the velocities
• not evaluated during normal course of algorithm
• needed to compute some properties, e.g.
 temperature
 diffusion constant
• finite difference
v(t ) 
1
r(t   t )  r(t   t )  O( t 2 )
2 t
13
Verlet Algorithm 5. Performance Issues
 Time reversible
• forward time step
r (t   t )  2r (t )  r (t   t )  m1 F(t ) t 2
• replace t with t
r (t  ( t ))  2r (t )  r (t  ( t ))  m1 F(t )(  t ) 2
r (t   t )  2r (t )  r (t   t )  m1 F (t ) t 2
• same algorithm, with same positions and forces, moves system
backward in time
 Numerical imprecision of adding large/small numbers
O(t1)
O(t1)
r (t   t )  r (t )  r (t )  r (t   t )  m1 F(t ) t 2
O(t0)
O(t0)
O(t2)
14
Initial Velocities
(from Lecture 3)
 Random direction
• randomize each component independently
• randomize direction by choosing point on spherical surface
 Magnitude consistent with desired temperature. Choices:
•
•
•
•
Maxwell-Boltzmann: prob(vx )  exp   12 mvx2 / kT 
2
Uniform over (-1/2,+1/2), then scale so that N1  vi, x  kT / m
Constant at vx   kT / m
Same for y, z components
 Be sure to shift so center-of-mass momentum is zero
Px  N1  pi, x
pi, x  pi, x  Px
15
Leapfrog Algorithm
 Eliminates addition of small numbers O(t2) to differences in
large ones O(t0)
 Algorithm
r (t   t )  r (t )  v(t  12  t ) t
v(t  12  t )  v(t  12  t )  m1 F(t ) t
 Mathematically equivalent to Verlet algorithm
r (t   t )  r (t )   v(t  12  t )  m1 F(t ) t   t
r(t) as evaluated from
r(t )  r(t   t )  v(t  12  t ) t
previous time step
16
Leapfrog Algorithm 2. Flow Diagram
t-t
r
v
t
t+t
Compute velocity at
next half-step
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
17
Leapfrog Algorithm 2. Flow Diagram
t-t
r
t
t+t
Compute next position
v
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
18
Leapfrog Algorithm. 3. Loose Ends
 Initialization
• how to get velocity at “previous time step” when starting out?
• simple approximation
v(t0   t )  v(t0 )  m1 F(t0 ) 12  t
 Obtaining the velocities
• interpolate
1
v (t )   v (t  12  t )  v (t  12  t ) 
2
19
Velocity Verlet Algorithm
 Roundoff advantage of leapfrog, but better treatment of
velocities
 Algorithm
r (t   t )  r (t )  v(t ) t  21m F(t ) t 2
v(t   t )  v(t )  21m  F(t )  F(t   t ) t
 Implemented in stages
•
•
•
•
•
evaluate current force
compute r at new time
add current-force term to velocity (gives v at half-time step)
compute new force
add new-force term to velocity
 Also mathematically equivalent to Verlet algorithm
(in giving values of r)
20
Velocity Verlet Algorithm
2. Flow Diagram
t-t
r
t
t+t
Compute new position
v
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
21
Velocity Verlet Algorithm
2. Flow Diagram
t-t
r
t
t+t
Compute velocity at half step
v
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
22
Velocity Verlet Algorithm
2. Flow Diagram
t-t
r
t
t+t
Compute force at new position
v
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
23
Velocity Verlet Algorithm
2. Flow Diagram
t-t
r
t
t+t
Compute velocity at full step
v
F
Schematic from Allen & Tildesley, Computer Simulation of Liquids
24
Other Algorithms
 Predictor-Corrector
• not time reversible
• easier to apply in some instances
 constraints
 rigid rotations
 Beeman
• better treatment of velocities
 Velocity-corrected Verlet
25
Summary
 Several formulations of mechanics
• Hamiltonian preferred
 independence of choice of coordinates
 emphasis on phase space
 Integration algorithms
• Calculation of forces
• Simple Verlet algorithsm
 Verlet
 Leapfrog
 Velocity Verlet
 Next up: Calculation of dynamical properties