gear methods i 1 18 s04 3 - vscht.cz · pdf filegear methods i + 1=18 s04=3...

18
Gear methods I + 1/18 s04/3 Predictor-corrector type: knowledge of history is used to predict an approximate solution, which is made more accurate in the following step we do not want (otherwise good) methods that require several calcu- lations of the r.h.s. a predictor without r.h.s. = polynomial, or equivalently a vector of derivatives: R = ~ r i h ˙ ~ r i h 2 2! ¨ ~ r i h 3 3! ... ~ r i Predictor: R(t + h) pred = 1 1 1 1 0 1 2 3 0 0 1 3 0 0 0 1 R(t)

Upload: ngokhanh

Post on 14-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Gear methods I + 1/18s04/3

Predictor-corrector type: knowledge of history is used to predict anapproximate solution, which is made more accurate in the following step

we do not want (otherwise good) methods that require several calcu-lations of the r.h.s.

a predictor without r.h.s. = polynomial, or equivalently a vector ofderivatives:

R =

~ri

h~rih2

2!~rih3

3!

...~r i

Predictor:

R(t+ h)pred =

1 1 1 1

0 1 2 3

0 0 1 3

0 0 0 1

R(t)

Gear metods II + 2/18s04/3

The error of the predictor:

~Ei =h2

2

~fi(~rN(t+ h)pred)

mi−h2

2~ri(t+ h)

pred

Corrector:

R(t+ h) = R(t+ h)pred +

a0

a1

a2

a3

E

Unknown constants determined from the stability conditions.

For a 1st order equation y ′ = f(y):

E = hf(y(t+ h)pred) − hy ′(t+ h)pred

equivalent to Adams–Bashforth

Gear metods – coefficients[uvodsim/gear.sh]

+ 3/18s04/3

1st order:

M a0 a1 a2 a3 a4 a5

2 1/2 1

3 5/12 1 1/2

4 3/8 1 3/4 1/6

5 251/720 1 11/12 1/3 1/24

6 95/288 1 25/24 35/72 5/48 1/120

2nd order:

M a0a a0

b a1 a2 a3 a4 a5

3c 0 0 1 1

4 1/6 1/6 5/6 1 1/3

5 19/120 19/90 3/4 1 1/2 1/12

6 3/20 3/16 251/360 1 11/18 1/6 1/60

M = predictor length (local order O(hM))a suitable for a r.h.s. without ~rb suitable for a r.h.s. with ~rc velocity Verlet

Comparison of methods4/18s04/3

Verlet:

is time-reversible ⇒ no drift in the total (potential + kinetic) energy

is symplectic ⇒ error in the total energy is bound

is simple

low order (phase error)

(directly) not applicable to a r.h.s. containing velocities(equation r = f(r, r): Nose, rotations, . . . )

difficult change of the timestep

Gear: just opposite (excl. the simplestversion identical to Verlet)

Notes:

a symplectic integerator preserves(with bounded accuracy) the phase spacevolume d~rNd~pN

the quality of energy conservationhelps us to set up the timestep h

Energy conservation: Verlet5/18s04/3

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

t/ps

-80.5

-80.4

-80.3

-80.2

-80.1

-80

Eto

t/kK

h=0.0005 psh=0.001 psh=0.002 ps

Energy conservation: Gear M = 4 + 6/18s04/3

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

t/ps

-80.5

-80.4

-80.3

-80.2

-80.1

-80

Eto

t/kK

h=0.0005 psh=0.001 psh=0.002 ps

Energy conservation: Gear M = 5 + 7/18s04/3

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

t/ps

-80.5

-80.4

-80.3

-80.2

-80.1

-80

Eto

t/kK

h=0.0005 psh=0.001 psh=0.002 ps

Energy conservation: Gear M = 6 + 8/18s04/3

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

t/ps

-80.5

-80.4

-80.3

-80.2

-80.1

-80

Eto

t/kK

h=0.0005 psh=0.001 psh=0.002 ps

Exercise + 9/18s04/3

Write a computer program for a numerical integration of the Newton’sequations for a harmonic oscillator with the force constant K (f(x) = −Kx).Use K = 1 a m = 1 and one of the following methods:

Verlet

velocity Verlet

leap-frog

Runge-Kutta 4th order for y ′′ = f(x,y), y(x0) = y0, y ′(x0) = y′0:

k1 = f(x0,y0,y ′0) ,

k2 = f

(x0 +

h

2,y0 +

1

2hy ′0 +

h2

8k1,y ′0 +

h

2k1

),

k3 = f

(x0 +

h

2,y0 +

1

2hy ′0 +

h2

8k2,y ′0 +

h

2k2

),

k4 = f

(x0 + h,y0 + hy ′0 +

h2

2k3,y ′0 + hk3

),

y1 = y(x0 + h) = y0 + hy ′0 +h2

6(k1 + k2 + k3) ,

y ′1 = y ′(x0 + h) = y ′0 +h

6(k1 + 2k2 + 2k3 + k4) .

Exercise II + 10/18s04/3

Beeman: r(t+ h) = r(t) + v(t)h+4f(t)−f(t−h)

6m h2

v(t+ h) = v(t) +2f(t+h)+5f(t)−f(t−h)

6m h

Gear 2nd order M = 4

Try also the Hamilton equations of motion using:

Gear 1st order

Euler for y ′ = f(y): y(t+ h) = y(t) + f(t)h (where f(t) = f(y(t)))

Adams-Bashforth various orders:

y(t+ h) = y(t) + h2[3f(t)h− f(t− h)]

y(t+ h) = y(t) + h12[23f(t) − 16f(t− h) + 5f(t− 2h)]

y(t+ h) = y(t) + h24[55f(t) − 59f(t− h) + 37f(t− 2h) − 9f(t− 3h)]

Runge-Kutta 4th order (for the 1st order differential equation)

Temperature11/18s04/3

The temperature is measured in the standard (microcanonical) MD.

T =

⟨Ekin12kBf

⟩= 〈Tkin〉

f = 3N− fconserved ≈ 3NExample: molecules in a spherical cavity:

fconserve = 1energy + 3rotations

Generally from the equipartition theorem:⟨p∂H

∂p

⟩= kBT

where p is any component of any momentum (vector)

NOTE: the averaged kinetic temperature should not depend on (a subsetof) the degrees of freedom used. Typically, one may easily separate:

Ttr from the velocities of the centers of mass

Trot+in from rotations and internal degrees of freedom.

disagreement Ttr 6= Trot+in indicates various problems (bad equilibration,too long timestep, . . . ).

Constant temperature in MD: methods[simolant]12/18

s04/3

canonical (yield [almost] accurate canonical ensemble):– Maxwell–Boltzmann

p(xi) =1

σ√

2πexp

(−x2

2σ2

), σ2 =

⟨x2i

⟩=kBT

mi

once a while all particles– Andersen: randomly visit particles (usually better)– Langevin: small random force added to all particles at every step– Canonical Sampling through the Velocity Rescaling (Bussi)– Nose–Hoover: one (or more) degrees of freedom added,

averaging of it (them) ⇒ canonical ensembleproblem: more tricks needed with Verlet (r.h.s. depends on velocities)

– Modified Berendsen– Gaussian rescaling: Ekin = const, canonical in the config. space only

approximate– velocity rescaling: ~vi,new = ~vi(T/Tkin)

1/2

– Berendsen (friction): ~vi,new = ~vi(T/Tkin)q, q < 1/2,

it is equivalent to: ~ri =~fimi

− η(Tkin − T)~ri, η =q

Th

Nose–Hoover thermostat + 13/18s04/3

one degree of freedom added: “position” s and “velocity” s

+ kinetic energy Ms2 s

2

+ potential energy −fkBT ln s

...

Equations of motion (ξ = ln s):

~ri =~fimi

− ~riξ

ξ =

(Tkin

T− 1

)τ−2

Thermostat time constant:

τ =

√Ms

fkBT

Provided that the system is ergodic, it can be proven that we get the

canonical ensemble

Thermostats[simolant -H.1 -I9 -N50]14/18

s04/3

Nose–Hoover

canonical

high quality

good also for small systems

(N-H chain)

oscillations, decoupling

(fine tuning of τ)

worse for start

equations of motion w. velocities

Berendsen

simple

exponential relaxation

(i.e., good also for start)

flying icecube

not canonical

poor for small systems

Maxwell–Boltzmann etc.

canonical

exponential relaxation

kinetics lost

problematic with constrained dy-

namics

Show flying icecube simolant: periodic b.c., τ = min, lower ρ, max. speed

old simolant: periodic b.c., N=100, L=40, hot key ’=’, tau=0.2

Thermostats: application to water15/18s04/3

250 molecules of SPC/E water started from an fcc

lattice of randomly oriented molecules, τ = 0.1 ps

0 1 2

t/ps

0

500

1000

T/K

Berendsen

0 1 2

t/ps

0

500

1000

T/K

Berendsen CM

0 1 2

t/ps

0

500

1000

T/K

Berendsen IN

0 1 2

t/ps

0

500

1000

T/K

Maxwell CM

0 1 2

t/ps

0

500

1000

T/K

Nose

0 1 2

t/ps

0

500

1000

T/K

Andersen CM

T : — total — center-of-mass — rotations

see simul/spce/water.*

Try molecular dynamics by yourself16/18s04/3

Installation of SIMOLANT (Windows):

http://old.vscht.cz/fch/software/simolant

Download simolant-win32.zip

Create a folder and unpack SIMOLANT there.

Do not run directly from

simolant-win32.zip

– help would not work

– you could not find

saved files

Run simolant.exe.

Watch energy conservation by yourself17/18s04/3

Slider “measurement block” to the left

(1–3 values averaged per 1 point shown)

The default is one energy calculated

per 3 MD steps (stride). This can be

changed by slider “simulation speed”.

if still too slow, decrease the number of particles by slider “N”

Menu: Show → Energy convergence profileThe time development of energy is always scaled from minimum to

maximum: Note the value of max-min reported

Reset the graph by button reset

Menu: Method → Molecular dynamics (NVE)

– write “dt=0.01” to the cmd: field

– write “dt=0.02” to the cmd: field

and observe the difference

– for too long dt, the simulation will switch to MC to avoid crash

– do not forget to return the default (automatic setup) by “dt=0”

Try thermostats by yourself18/18s04/3

Menu: Method → Molecular dynamics (Berendsen thermostat)– observe the total energy

– what happens if you change temperature?

– what happens if you change the correlation time (slider τ)?

Do not change the parameters too fast!

Repeat for other thermostats.

Repeat for different samples; e.g., liquid:

slider “T”: T ≈ 0.2

slider “ρ”: ρ ≈ 0.6