6.189 IAP 2007 MIT
6.189 IAP 2007
Student Project Presentation
Molecular Dynamics
Pintilie
Molecular Dynamics on the Playstation 3
Greg Pintilie
Overview
• Molecular Dynamics• Algorithm• Parallelization Approaches
Molecular Dynamics• Potential Energy:
( ) bondednonbondedp EExE −+=v
Molecular Dynamics• Potential Energy:
( ) bondednonbondedp EExE −+=v
impdihanglesbondsbonded EEEE ,++=
Molecular Dynamics• Potential Energy:
( )∑ −=bonds
bbonds llkE 20
( ) bondednonbondedp EExE −+=v
impdihanglesbondsbonded EEEE ,++=
Molecular Dynamics• Potential Energy:
( )20∑ −=
anglesangles kE θθθ
( ) bondednonbondedp EExE −+=v
impdihanglesbondsbonded EEEE ,++=
Molecular Dynamics• Potential Energy:
( )( ) ( ) ( )∑∑ −+−+−=impropersdihedrals
impdih kknkF 00, cos1 ωωθθφ ωθφ
( ) bondednonbondedp EExE −+=v
impdihanglesbondsbonded EEEE ,++=
Molecular Dynamics• Potential Energy:
( )∑ −=bonds
bbonds bbkE 20
( )20∑ −=
anglesangles kE θθθ
( ) bondednonbondedp EExE −+=v
( )( ) ( ) ( )∑∑ −+−+−=impropersdihedrals
impdih kknkF 00, cos1 ωωθθφ ωθφ
impdihanglesbondsbonded EEEE ,++=
Molecular Dynamics• Potential Energy:
ticelectrostaWaalsdervanbondednon EEE += −−−
( ) bondednonbondedp EExE −+=v
Molecular Dynamics• Potential Energy:
ticelectrostaWaalsdervanbondednon EEE += −−−
∑ ⎟⎟⎠
⎞⎜⎜⎝
⎛−=−−
kiatoms ik
ik
ik
ikWaalsdervan r
CrA
E,_
612
( ) bondednonbondedp EExE −+=v
Molecular Dynamics• Potential Energy:
ticelectrostaWaalsdervanbondednon EEE += −−−
∑ ⎟⎟⎠
⎞⎜⎜⎝
⎛−=−−
kiatoms ik
ik
ik
ikWaalsdervan r
CrA
E,_
612
∑=kiatoms ik
kiticelectrosta Dr
qqE
,_
( ) bondednonbondedp EExE −+=v
• Compute forces :
• Integrate to obtain velocity, position:
Molecular Dynamics
( )mtftttvttv
vv Δ+⎟
⎠⎞
⎜⎝⎛ Δ−=⎟
⎠⎞
⎜⎝⎛ Δ+
21
21
( ) ( ) ⎟⎠⎞
⎜⎝⎛ Δ+⋅Δ+=Δ+ ttvttxttx
21vvv
( ) ( ) ( )xEx
taMtf pv
vvv
∂∂
−==
• Kinetic Energy/Temperature:– from classical equipartition theory, each degree
of freedom has, at thermal equilibrium, this much energy:
Kinetic Energy
TkB21
TkNvmE BF
N
iiik 2
121 3
1
2 == ∑=
Langevin Dynamics
( ) )(tRMvxEaMF p +−−∇== γvv
0)( =tR )'(2)'(),( ttTMktRtR BT −= δγ
• Account for collisions with imaginary molecules (heat bath)
• e.g. in solvent such as water
Solvation in Dielectric Material• Molecules that are polar/ionic ‘shield’
electrostatic forces• Water:
– distance-dependent dielectric:
∑=kiatoms ik
kiticelectrosta Dr
qqE
,_
rD =
∑=kiatoms ik
kiticelectrosta r
qqE
,_2
Non-bonded Cut-offs
• Cut-off ~12A∑
⎪⎭
⎪⎬⎫
⎪⎩
⎪⎨⎧
+⎟⎟⎠
⎞⎜⎜⎝
⎛−=−
kiatoms ik
ki
ik
ik
ik
ikbondednon Dr
qqrC
rA
E,_
612
Non-bonded Cut-offs
• Cut-off ~12A∑
⎪⎭
⎪⎬⎫
⎪⎩
⎪⎨⎧
+⎟⎟⎠
⎞⎜⎜⎝
⎛−=−
kiatoms ik
ki
ik
ik
ik
ikbondednon Dr
qqrC
rA
E,_
612
Basic MD Algorithm
Integrate
Compute ‘non-bonded’ forcesatom pairs
Compute ‘bonded’ forcesbonds, angles, dihedrals, impropers
if i % ap_freq == 0find atom pairs
For i=0 to numsteps
Data Structures
AtomVector pos, vel, forcedouble Massdouble Chargedouble Rmindouble Eps
Vectordouble x, y, z
BondAtom *a1, *a2double k, b0
AngleAtom *a1, *a2, *a3double k, t0
ImproperAtom *a1, *a2, *a3, *a4double k, t0
DihedralAtom *a1, *a2, *a3, *a4list DihedralValue vals
DihedralValuedouble k, phaseint n
Atom PairAtom *a1, *a2double eij
Moleculelist Atom atomslist Bond bondslist Angle angleslist Improper improperslist Dihedrals dihedralslist AtomPair atompairs
Bonded Forces Non-Bonded Forces
• A8m– ‘Bonded’ - total 41,652
• 146 atoms x 104 bytes = 15,184• 147 bonds x 24 bytes= 3,528• 275 angles x 28 bytes = 7,700• 393 dihedrals x 16 bytes +
414 dihedral values x 20 bytes = 14,568• 21 impropers 32 bytes = 672
– ‘Non-bonded’ – total 176,000• 11,000 Atom Pairs x 16 bytes
– (1-3 bonded atoms excluded)
• 10 x A8m– ‘Bonded’ – total 416,520– ‘Non-bonded’ – total 16,976,000
• 20 x A8m– ‘Bonded’ – total 833,040– ‘Non-bonded’ – total 68,064,000
Sequential Algorithm
10ms10msintegrate
150ms116,434 pairs
1,480ms1,060,850 pairs
‘non-bonded’ forcesatom pairs
50ms50ms‘bonded’ forcesbonds, angles, dihedrals, impropers
Bf / Kd6,090 / 880 ms24,440 / 1,750 ms
0 msif i%ap_freq==0find atom pairs
With cutoffNo cutoffFor i=0 to numsteps
Parallelization Approaches
• Force Decomposition
……
……
A3A1
A2A1
• force operation includes both atom positions, returns the force on both atoms
• scales well with system size and #processorsAn
…
A2
A1
Parallelization Approaches
• Force Decomposition
……
……
A3A1
A2A1
for j=0 to #SPUs•send control block to SPU-j
for step i=0 to num steps•compute bonded forces•compute non-bonded forces
• while non-bonded operations remaining• for j=0 to #SPUs
• create block with force-operations (200)• send control block with #ops to SPU-j• tell SPU-j to start processing
• for j=0 to #SPUs• if SPU-j finished, add forces to atoms
• break if all SPUs finished• integrate forces
PPUiter 0
iter 1
iter 2
Parallelization Approaches
• Force Decomposition - performance
260270280310390630310
6SPUs5SPUs4SPUs3SPUs2SPUs1SPUPPU
Non-bonded Forces Computation Time
0
100
200
300
400
500
600
700
PPU 1SPU 2SPUs 3SPUs 4SPUs 5SPUs 6SPUs
ms
Parallelization Approaches
• Atomic Decomposition
……
……
A3A1
A2A1
An
…
A2
A1 • atoms and forces stored independently
• doesn’t scale as easily with system size
Parallelization Approaches
• Spatial Decomposition• not load-balanced
• atom positions must be communicated between processors
• periodically re-assign atoms
State of the Art - NAMD
• force-spatial decomposition