Computer modeling methods
Part 2
Bogdan Kuchta
Laboratoire MADIREL
Universit Aix-Marseille
European Master
http:bogdan!"uchta!perso!s#r!#r
References:
A. R. Leach Molecular Modelling Longman London !"##$% pp. &"&-&"'
(. )ren*el and +. ,mit -nderstanding Molecular ,imulation 2
nd
ed.
Academic Press !2..2% pp. 2&-2/
M. P. Allen and (. 0. 1ildesle2 Computer ,imulation of Li3uids
Clarendon Press 45ford !"#'/% pp. ""&-"26
- A. 7incliffe Molecular modelling for 8eginners 0. 9ile: ; ,on
Mar"ov chain:
1he Metropolis method generates a Mar*o< chain =hich satisfies 2 conditions:
". 1he outcome of each trial depends onl2 on the preceding trial and not on
an2 prior trials
2. Each trial 8elongs to a finite set of possi8le states.
1hus the first condition ma*es a clear distinction 8et=een M$ and MD.
>n M( =hich is deterministic all states are connected in time
ta*en from ?. E. @u88ins lectures on Multi%&cale Modeling o# Matter
http:AAchum8a.che.ncsu.eduA
Monte Carlo: 8asis
'ransition Matrix ('M):
,uppose the s2stem is in state m !5
B
%
m
. 1he pro8a8ilit2 of a transition to
state n =ith !5
B
%
n
is
mn
!5
B
%
m
!5
B
%
n
*n
C pro8a8ilit2 of mo<ing
from m to n
Let M8e the total num8er of possi8le states. 1hen the elements p
mn
form
a M 5 Mmatri5 called the transition *atrix :
|
|
|
|
|
\
|
=
MM M M
M
M
K
M M M
K
K
2 1
2 22 21
1 12 11
!Each ro= must sum to " i.e n must 8e one of the possi8le states%
1 =
n
mn
for mC"2D.M
'heor+ behind the i*portance sa*pling
1he probabilit+ that the s2stem is in a particular state is gi<en 82 the ro=
matri5
( )
1 2 m n M
= K K K
1hus
i
C pro8a8ilit2 that the s2stem is in state i =ith energ2 E
i
and
configuration !5
B
%
i
.
(,ote: these states do not have to be e-uilibriu* ones . the+ are not e-uilibriu*/ usuall+)!
Let !"% represent the initial randoml2 chosen configuration.
1hen the pro8a8ilit2 of the second state is :
( ) ( ) 1 2 =
And the third state is: ( ) ( ) ( ) 1 2 3 = =
etc.
'heor+ behind the i*portance sa*pling
1he e3uili8rium distri8ution of the s2stem is found 82 appl2ing an
infinite num8er of times. Mar"ov chain gi<es this limiting distri8ution:
( )
M
M
limit
1 lim
=
li*it
must o8e2 the +oltEmann distri8ution la= i.e. it
*ust be proportional to exp0.E(x
,
)"'1!
E5ample:
Consider a s2stem that can onl2 e5ist in t=o states E
"
and E
2
=hich ha<e <alues such that e5p!E
"
A*1% :
e5p!E
2
A*1% C 2:". 1he follo=ing transition matri5
pro<ides this
limit
:
|
\
|
=
0 1
5 . 0 5 . 0
23
C e5p!E
2
A*1% Ae5p!E
"
A*1% C "A2 F
22
C " -
"2
C "A2
32
42 e5p!E
"
A*1% Ae5p!E
2
A*1% C 2 F
33
C " -
2"
C .
new
old
U
U
e
e
567 8888
>n our situation :
'heor+ behind the i*portance sa*pling
,uppose the initial state is in E
"
i.e. (2) 4 (
2
2
) 4 (2 9)! 1hen the
second state is
( ) ( ) ( ) ( ) 5 . 0 5 . 0
0 1
5 . 0 5 . 0
0 1 1 2 = |
\
|
= =
and
( ) ( ) ( )
( ) ( ) ( ) 375 . 0 625 . 0
0 1
5 . 0 5 . 0
25 . 0 75 . 0 4
25 . 0 75 . 0
0 1
5 . 0 5 . 0
5 . 0 5 . 0 3
= |
\
|
=
= |
\
|
=
,uccessi<e applications of leads to
|
\
|
=
3
1
3
2
limit
'heor+ behind the i*portance sa*pling
9hen the limiting distri8ution is reached application of simpl2 gi<es the limiting
distri8ution 8ac*
limit limit
=
1hus in the a8o<e e5ample
|
\
|
= |
\
|
|
\
|
3
1
3
2
0 1
5 . 0 5 . 0
3
1
3
2
|
\
|
=
Z
kT E
Z
kT E ) / exp(
,
) / exp(
2 1
) / exp( ) / exp(
2 1
kT E kT E Z + =
'heor+ behind the i*portance sa*pling
&tochastic Matrix (&M):
1he stochastic matri5 =ith elements
mn
gi<es the probabilit+
o# choosing the t=o states mand n, 8et=een =hich the mo<e is
made. >t is also called the underl+ing *atrix of the Mar*o<
chain. 1he 'M ! ) and &M! % are related 82
mn mn mn
p =
Pro8a8ilit2 of a
transition from
mto n
C
Pro8a8ilit2 of
choosing states
m n
G
Pro8a8ilit2 of
accepting a trial
mo<e from mto n
is assumed to 8e s2mmetrical
mn
=
nm
.
1he pro8a8ilit2 of choosing states mand n must 8e the same =hether the
mo<e is from mto n or n to m.
>n general this can 8e <iolated HHHHHHH
'heor+ behind the i*portance sa*pling
Microscopic reversibilit+:
1he condition of microscopic re<ersi8ilit2 states that at e-uilibriu* the rate of
transition from mto n must e3ual the rate of transition from n to m.
!$%
1he rate o# transition from mto n is the product of the pro8a8ilit2 from
mto n,
mn
times the pro8a8ilit2 densit2 of the initial state m
m
. >t re3uires
1his is necessar2 to maintain the e-uilibriu* distribution once it is reached.
n nm m mn
=
E3uation:
n
nm
C
*
mn
is sometimes called the
detailed balance condition or *icroscopic reversibilit+.
'heor+ behind the i*portance sa*pling
,o if
n
I e5p!--%
( ) ( )
{ }
exp
N N
mn n
n m
nm m
p
x x
p
(
= =
U U
1urn the pro8lem around...
Dgi<en a desired =hat transition pro8a8ilities =ill 2ield this as a limiting
distri8utionJ
Construct transition probabilities to satisf2 detailed 8alance
1his 8ecomes generall2
nm nm n mn mn m
p p =
- ,ince is s2mmetric
mn
C
nm
this 8ecomes
nm n mn m
p p =
m
n
nm
mn
p
p
=
'heor+ behind the i*portance sa*pling
:ther choices are possible !see Allen ; 1ildesle2% 8ut the Metropolis scheme seems more
efficient than others.
mn
=
=
=
' '
' '
1
n m
n m
m
n
mn
mn
if
n
K
m
n L m
if
n
<
m
n L m
if n C m
'he Metropolis sche*e:
- 9e need an acceptance pro8a8ilit2 scheme for p
mn
that o8e2s detailed
8alance condition
- Also p
mn
cannot 8e greater than " since it is a pro8a8ilit2
- Metropolis et al. chose to use
p
mn
m
n
=
=1
if
n
K
m
i.e. if E!x
N
%
n
M E !x
N
%
m
if
n
;
m
i.e. if E!x
N
%
n
N E!x
N
%
m
)rom the a8o<e the transition
pro8a8ilit2 is :
'heor+ behind the i*portance sa*pling
- 1his can 8e summariEed 82 =riting the acceptance pro8a8ilit2 P
acc
p
mn
as:
( )
min 1, exp
acc
P kT = (
U
!".%
"
e5p!--A*1%
. rnd "
>f rnd e5p!--A*1% - mo<e accepted
4ther=ise - no
-
>) !E(>).le....% then
GR C RB(M!%
R1E,1 C 1EMP O L4@!GR%
>) !E(>).L1.R1E,1% RE1-RB
>AC1 C >AC1 P "
endif
E(>) C --
ln!rnd% --A*1
Algorith* behind the theor+
subroutine translate(IL)
INCLUDE 'global.inc'
* move the molecule (translational move)
* XCT,YCT,ZCT are the trial positions
* EDIF = H(OLD) - H(NEW)
* GDIF = EGG(old) - EGG(new)
XCT = XC(IL) + TD - TD2 * RNDM()
YCT = YC(IL) + TD - TD2 * RNDM()
ZCT = ZC(IL) + TD - TD2 * RNDM()
zcg = zct
if (zct.gt.zpore) zcg=zct - zpore
if(zct.lt.0) zcg =zct + zpore
iper = 0
if(zcg.ne.zct)iper = 1
call POTgr(XCT,YCT,ZCg,EG) ! calculate interaction with the wall
call ener1(XCT,YCT,ZCT,entot,IL) ! calculates interaction with others
GDIF = EGG(IL)-EG
UDIF = GDIF
Algorith* behind the theor+
max = NABL1(IL)
if(max.ne.0) then
do LL= 1,max
L = LIST1(IL,LL,4)
UDIF = UDIF + UU(L,IL) - UTT(L,IL)
enddo
endif
* the difference in enthalpy (EDIF) and energy (UDIF)
* is the same when 1 molecule is moved,so:
EDIF = UDIF
if (EDIF.le.0.0) then
XR = RNDM()
RTEST = TEMP * LOG(XR)
IF (EDIF.LT.RTEST) RETURN
IACT = IACT + 1
endif
IAT = IAT + 1
* *** *************************************************************
* store the new accepted position
XC(IL) = XCT
YC(IL) = YCT
ZC(IL) = ZCg
Metropolis algorithm
(canonical)
Algorith* behind the theor+
UNIVERSITE MONTPELLIER II UNIVERSITE de PROVENCE
MAIN
Initial con#iguration r
n
1rial translational andAor orientational mo<es.
Attempts to insert andAor remo<e a molecule
$alculate the energ+ di##erence
Accept or re:ect the ne= configuration
according to the +oltEmann distri8ution
Final configuration (positions
and orientations of N molecules)
OUTPUT
INITIAL
Calculate initial energ of the sstem
Prepare the neigh!or list"
#$CO#%
&tore energies and positions after each !in"
ccle
step
!in
'CMC algorithm
INPUT
Initial configuration (positions
and orientations of N molecules)
-1he usual scheme for putting Metropolis into practice is
"% A randoml2 chosen molecule i is made to undergo a random
displacement r from its initial position to a ne= position =ithin a
cu8e of length L centered on the original position of i. -suall2 L
is chosen so that IQ.R of trial mo<es are accepted. >f L is too small
=e get a higher acceptance rate 8ut this ma2 not sample all
configurations efficientl2. >f L is too large most trials are re:ected
2% Calculate E!5
B
%
n
and E C E!5
B
%
n
E!5
B
%
m
6% >f E is negati<e i.e.
n
A
m
N " the mo<e is accepted
&% >f E is positi<e i.e. p
n
Ap
m
S " the mo<e is accepted =ith pro8a8ilit2
p
n
Ap
m
C e5pTE A*1U. 1he decision to accept or re:ect the mo<e is
made 82 generating a random num8er E =ith a <alue 8et=een . and ".
>f E M e5pTE A*1U the mo<e is accepted other=ise it is re:ected. >f it
is re:ected the old state m is again counted as the ne= configuration
in the chain.
Q% )or adsorption: @CMC =e need to insert !adsor8% and remo<e !desor8%
molecules
'he Metropolis Method
L<univers . ense*ble *icrocanoni-ue absolu (,=E)
>l est constituV de s2stWmes identi3ues de point de <ue macroscopi3ue et de mXme
Vnergie.
En prati3ue e5pVrimentalement il est impossi8le de fi5er e5actement lYVnergie pour un
s2stWme donnV.
Pro8a8ilitV dYun Vtat i: >
i
4 25
L<ense*ble canoni-ue fluctuation dZVnergie [ cause de contact du s2stWme a<ec
lZen<ironnement !B\1%
-n s2stWme est plongV dans un thermostat a<ec le3uel il peut changer de l<nergie
sous #or*e de chaleur. LYVtat dYV3uili8re correspond du point de <ue macroscopi3ue [
lZVgalitV des tempVratures du s2stWme et du thermostat. $et -uilibre a une caract?re
d+na*i-ue a<ec dYincessantes fluctuations de lYVnergie mo2enne.
Pro8a8ilitV dYun Vtat i: >
i
4 e
%Ui"'
@
Ense*bles
Rappel : SAN C P
i
A
i
! C p!5%A!5% d5 %
L<ense*ble grand canoni-ue on autorise les fluctuation du nom8re de particules
!\1%
Le s2stWme est en relation a<ec un ] rVser<oir de particules ^ a<ec le3uel il peut
Vchanger non seulement de lYVnergie mais aussi des particules.
Pro8a8ilitV dYun Vtat i: >
i
4 e
%(U
i
% ,
i
)"'
@ A
- potentiel chimi3ue F
_ C e
-!-
i
- B
i
%A*1
Ense*bles
E5amples of calculated properties
Internal Energ+:
1he a<erage potential !configurational% energ2 is easil2 o8tained as the ensem8le a<erage
of the energies of the states that are e5amined during the course of a simulation:
Bote that =hat =e calculate in a MC simulation is the configurational contri8ution to the
measured properties.
----------------------------------------------------
After o8taining the simulation a<erages =e can add the "inetic energ+
6R1A2 !ideal gas%
and intra*olecular contri8utions !e.g. electronic rotation <i8ration internal rotation% to
the measured properties.
1
1
M
i
i
U
M
=
= =
U U
=here Mis the num8er of states <isited
,imple 1hermod2namic properties in MC-B\1
&imple Thermodnamic properties in MC(N)T
0 2000 4000 6000 8000 10000
-1100
-1000
-900
-800
-700
E
n
e
r
g
y
(
K
)
MC steps
-1100 -1000 -900 -800 -700
0
200
400
600
800
1000
1200
1400
1600
1800
D
i
s
t
r
i
b
u
t
i
o
n
-
1
1
0
0
-
1
0
0
0
-
9
0
0
-
8
0
0
-
7
0
0
0
2
0
0
4
0
0
6
0
0
8
0
0
1
0
0
0
1
2
0
0
1
4
0
0
1
6
0
0
1
8
0
0
D i s t r i b u t i o n
1
1
M
i
i
U
M
=
= =
U U
0 5000 10000 15000 20000 25000 30000
-1200
-1000
-800
-600
-400
E
n
e
r
g
y
(
K
)
Monte Carlo steps / 10
3
6eat $apacit+:
1he heat capacit2 is defined as:
1herefore this 3uantit2 can 8e calculated 82 performing a series of simulations
at different temperatures and then differentiating the energ2 =ith respect to
the temperature. 1he differentiation can 8e done numericall2 of 82 fitting a
pol2nomial to the data and then anal2ticall2 differentiating the fitted function.
V
V
T
U
C
|
\
|
=
,imple 1hermod2namic properties in MC-B\1
6eat $apacit+!
1he heat capacit2 can also 8e calculated from a single simulation 82 considering the
instantaneous fluctuations in the energ2:
1he pre<ious e3uations gi<e the potential (con#igurational) contri8ution to the heat
capacit2. 9e =ill need to compute the *inetic part separatel2. )or e5ample for a
s2stem of N atoms the "inetic part can 8e calculated easil2 gi<ing the follo=ing =ell-
*no=n result:
Can calculate man2 other properties from <aria8le fluctuations in simulations !see e.g.
Allen ; 1ildesle2 pp. Q"-Q&%
( )
2
2
2
2 2
V
C
kT kT
= =
U U
U U
proof: appendix 6.2 Leach,
llen ! "ilde#le$ pp. %&-%'
Nk C
id
V
2
3
=
ideal ga# part of the #pecific heat
,imple 1hermod2namic properties in MC-B\1
&imple Thermodnamic properties in MC(N)T
40 50 60 70 80 90 100 110 120 130
-1400
-1350
-1300
-1250
-1200
-1150
-1100
-1050
N constant
P(T) path
E
n
e
r
g
y
(
K
)
Temperature (K)
40 50 60 70 80 90 100 110 120 130
4
6
8
10
12
14
16
18
20
N const
P(T) path
T
o
t
a
l
e
n
e
r
g
y
f
l
u
c
t
u
a
t
i
o
n
s
Temperature (K)
( )
2
2
2
2 2
V
C
kT kT
= =
U U
U U
1
1
M
i
i
U
M
=
= =
U U
V
V
T
U
C
|
\
|
=
>ressure:
1he pressure is usuall2 calculated in a simulation <ia the <irial theorem of Clausius. 1he
<irial is defined as the e5pectation <alue of the sum of the products of the coordinates of
the particles and the forces acting on them. >t can 8e sho=n that:
=here
)or a proof of this see Leach pp. 6.# or Allen ; 1ildesle2 pp. &$-&#
( )
= + = = + =
= =
N
i
N
i j
ij
N
i
N
i j
ij ij
r w
V V
NkT
F r
V V
NkT
P
1 1 1 1
3
1
3
1
( )
( )
dr
r du
r r w =
the deri<ati<e of the pair potential used in the
simulation
,imple 1hermod2namic properties
&tructural >roperties in M$%,='
Radial distribution #unction:
1his gi<es the pro8a8ilit2 of finding an atom !or molecule% a distance r from
another atom !or molecule% as compared to the ideal gas distri8ution
>f > ha<e one atom at some
central position ho= man2
atoms can > e5pect to find at a
distance 8et=een r and
rPdr a=a2 from itJ
figure ta*en from ,. C. @lotEerYs lectures on Computational Banoscience of ,oft Materials
-ni<ersit2 of MichiganF http:AA===.engin.umich.eduAdeptAchemeApeopleAglotEertch.html
Radial distribution #unction (cont!):
1he neigh8ors around each atom are sorted into distance 8ins and the
num8er of neigh8ors in each 8in is normaliEed and a<eraged o<er the entire
simulation
A<eraged o<er e<er2 atom and o<er man2 different configurations
generated 82 the MC method
Can 8e done `on the #l+a !during run% or in post%anal+sis !from stored
data files%.
ta*en from ,. C. @lotEerYs lectures on Computational Banoscience of ,oft Materials -ni<ersit2 of Michigan
http:AA===.engin.umich.eduAdeptAchemeApeopleAglotEertch.html
&tructural >roperties in M$%,='
Radial distribution #unction:
Consider a spherical shell of thic*ness dr at a distance r
from a chosen atom. 1he <olume of the shell is:
>n 2-d:
>f the num8er of atoms per unit <olume is the num8er densit2 then if the
atoms =ere randoml2 distri8uted the total num8er in the shell =ould 8e
&r
2
dr !2rdr in 2-d% since C NA(.
ta*en from ,. C. @lotEerYs lectures on Computational Banoscience of ,oft Materials -ni<ersit2 of Michigan
http:AA===.engin.umich.eduAdeptAchemeApeopleAglotEertch.html
( )
dr r V
dr rdr dr r r dr r V
2
3 2 2 3
3
4
3
4
4 4
3
4
3
4
+ + = + =
( )
rdr A
dr rdr r dr r A
2
2
2 2
2
+ = + =
&tructural >roperties in M$%,='
ta*en from ,. C. @lotEerYs lectures on Computational Banoscience of ,oft Materials -ni<ersit2 of Michigan
http:AA===.engin.umich.eduAdeptAchemeApeopleAglotEertch.html
( )
( )
( ) ( )
= >
=
=
N
i
N
i j
ij
r r r dn
dr r
r dn
N
r g
1
2
4
1
(i<ide 82 b of
atoms summed
o<er in outer sum
of dn!r%
Actual b of
atoms in a shell
of =idth dr
at r
,um o<er atoms
)or each atom count the
num8er of atoms a distance
r a=a2
(i<ide 82 b of atoms
in the shell of =idth dr
at r if atoms distri8uted
randoml2 !li*e an ideal gas%
g!r% gi<es the
pro8a8ilit2
of finding an
atom a scalar
distance r from
another atom
compared to
the ideal gas
pro8a8ilit2.
&tructural >roperties in M$%,='
Radial distribution #unction:
ta*en from ,. C. @lotEerYs lectures on Computational Banoscience of ,oft Materials -ni<ersit2 of Michigan
http:AA===.engin.umich.eduAdeptAchemeApeopleAglotEertch.html
&tructural >roperties in M$%,='
Nbin N Energy_wall Energy_total
1 154 -.7704136000E+03 -.1162552000E+04
2 159 -.7655882000E+03 -.1162659000E+04
3 160 -.7707390000E+03 -.1165556000E+04
4 163 -.7535974000E+03 -.1157627000E+04
5 166 -.7421404000E+03 -.1146248000E+04
6 163 -.7624775000E+03 -.1171144000E+04
7 161 -.7582797000E+03 -.1152653000E+04
8 164 -.7566785000E+03 -.1159382000E+04
9 169 -.7399601000E+03 -.1153505000E+04
10 162 -.7740249000E+03 -.1180890000E+04
11 164 -.7633221000E+03 -.1166162000E+04
12 165 -.7596610000E+03 -.1173743000E+04
13 166 -.7547378000E+03 -.1164632000E+04
14 168 -.7503984000E+03 -.1165403000E+04
.
mc_ene.dat
0 500 1000 1500 2000
0
100
200
300
400
500
600
N
Nbin
0 500 1000 1500 2000
-1600
-1400
-1200
-1000
-800
-600
-400
-200
E
n
e
r
g
y
Nbin
Non-equilibrium situation
Nbin N
x y z
1 154
10.886520 -14.887360 9.244424
10.898990 14.983010 21.000650
14.028510 11.913710 2.990251
-14.459990 11.605350 .722188
1.908520 18.285780 22.916110
1.256716 -18.238170 4.253842
13.606980 -12.499060 7.607756
-15.536920 -9.600965 16.492660
-15.764630 -9.760927 24.275380
-4.318254 -17.841070 23.939530
15.933630 -9.115001 17.567660
.
..
mc.pos
-20 -15 -10 -5 0 5 10 15 20
-20
-15
-10
-5
0
5
10
15
20
Y
A
x
i
s
T
i
t
l
e
X Axis Title
-20 -15 -10 -5 0 5 10 15 20
-20
-15
-10
-5
0
5
10
15
20
Y
A
x
i
s
T
i
t
l
e
X Axis Title
-20 -15 -10 -5 0 5 10 15 20
-20
-15
-10
-5
0
5
10
15
20
Y
A
x
i
s
T
i
t
l
e
X Axis Title
Nbin = 1
N = 154
Nbin = 1000
N = 258
Nbin = 2000
N = 615
Equilibrium situation
0 2000 4000 6000 8000 10000
-1600
-1400
-1200
-1000
-800
-600
-400
-200
E
n
e
r
g
y
MC steps/10
6
0 2000 4000 6000 8000 10000
0
100
200
300
400
500
N
MC steps/10
6
Mean values Variation
-337.7 13.5
-1160.2 15.3
-1497.9 10.2
234.7 16.2
p <N>
0.05 234.7 16.2
0.1 362.8 7.6
0.2 385.8 5.8
0.3 401.9 6.9
0.4 421.2 9.7
0.5 448.3 13.2
0.7 558.3 31.6
0.8 691.6 26.7
0.9 1259.1 8.3
0.0 0.2 0.4 0.6 0.8 1.0
0
200
400
600
800
1000
1200
1400
<
N
>
Pressure
T = const
!a% !8%
BreeCing o# $$l
D
in a *ulti%Ealled carbon nanotube Eith D 4 F n*
!a% (ensit2 profileF !8% snapshots of t2pical configurations of the adsor8ed
phase. 1he car8on nanotu8e =alls are not sho=n for clarit2
!ta*en from ). R. 7ung et al. Mol. Ph$#. !2..&%%
0
2
4
6
8
0 1 2 3 4 5
Reduced radial position r *
R
e
d
u
c
e
d
l
o
c
a
l
d
e
n
s
i
t
y
*
T=290 K
T=252 K
T=228 K
T=192 K
,ome e5amples:
Grand $anonical Ense*ble
Energ2 densit2 in pore la2er thic*ness total a8solute and e5cess adsorption
M$ proHect I . adsorbent characteriCation
5 10 15 20 25 30 35
0
5000
10000
Y
A
x
i
s
T
i
t
l
e
X Axis Title
0 1 2 3 4 5 6
0
200
400
600
800
1000
1200
N
Pressure (bar)
5 10 15 20 25 30 35
0
5000
10000
Y
A
x
i
s
T
i
t
l
e
X Axis Title
M$ proHect D . energ+ o# adsorption
C7
&
7
2
in car8on pores isosteric heat of adsorption
s
m
n
p
T
1
T
2
> T
1
p
1
p
2
s
m n
ads
p
p
T T
T T
R h
/
1
2
1 2
2 1
ln .
.
.
=
&
Isosteric enthalpy
=
g
u
+pv
-Ts
= u
g
+pv
g
- Ts
g
u
-Ts
= u
g
+RT - Ts
g
(v
= 0, pv
g
=RT)
s
g
=s
g,0
R ln(p/p
0
)
ads
h = u
- u
g
- RT const.
ads
s
0
= s
- s
g,0
const.
R
s
RT
h
p
p
R
s s
RT
RT u u
p
p
ads ads
g, g
0
0
0
0
ln
ln
=
|
|
\
|
=
|
|
\
|
( )
( )
|
|
|
|
\
|
|
\
|
=
|
\
|
T
p
R h
RT
h
p
T
ads
ads
1
ln
ln
2
|
|
\
|
=
1
2
1 2
2 1
ln
p
p
T T
T RT
h
ads
Adsorption is a
phenomenon
exothermic !!!
M$ proHect D . energ+ o# adsorption
M$ proHects . running si*ulation
@
9hat is the minimal length n *
n steps
m bins
Trajectory mn
2
2
lim
m
n
nc
n
n
=
n
Pro8lem: )luid adsorption in c2lindrical pores. Pro8lem: )luid adsorption in c2lindrical pores.
\1- constant
!gas% C !adsor8ate%
!gas ideal% C
.
!gas% P *
+
1 ln!P%
\1 P\1 - constant
Grand $anonical Monte $arlo
E5ternal ideal gas
pressure >
9e must first choose a set of independent variables (ense*ble)/ and then deri<e the
distri8ution la= for the pro8a8ilit2 the s2stem is in a certain !3uantum or classical%
state. 1he most commonl2 used ensem8les are:
B\E Microcanonical ensem8le
B\1 Canonical ensem8le
/=/' Grand canonical ense*ble
BP1 >sothermal-iso8aric ensem8le
>robabilit+ distribution laE:
( )
k
E N
Nk
e
P
= =
pro8a8ilit2 s2stem is in 3uantum
state ) and has N molecules
0 0
k
E N N
N
N k N
e e e Q
= =
=here C "A)"
C chemical potential per molecule C
E
)
C energ2 of s2stem in 3.s. ) P T
N
G
,
|
\
|
= grand partition function ( ) T V , , =
Grand $anonical Ense*ble: &tatistical Approach
Derivation o# the li*iting distribution:
1he grand partition function :
Let us assu*e that Ee are dealing Eith a classical s+ste* o# , identical particles contained in a cubic
box o# length L 4 =
2I
! Replacing the expression #or the classical partition #unction in the canonical
ense*ble/ J
,
:
( )
3
0 0
0 0
1
exp
!
L L
N N
N N
N
N
N N
e Q e dr r
N
(
= =
K U
( )
0 0
, ,
K
N N
N
N K N
V T e e e Q
= = =
U
1 2
2
2
h
mkT
| |
=
|
\
=here C thermal de +roglie =a<elength
Grand $anonical Ense*ble: &tatistical Approach
1herefore the corresponding probabilit+ densit+ is :
( ) N r U
N
N
N
+
= ) ( exp
1
) (
3
r
Thermodynamic properties in terms of
1) Average number of molecules
1
k
E N
Nk
N k Nk
N P N e e N
= =
or
V
N |
\
|
=
ln 1
2) The function PV
A thermodynamic identity is
( )
T V
PV
N
,
|
\
|
=
= = ln kT PV
central equation for the
grand canonical ensemble
Grand $anonical Ense*ble: statistical Approach
>nsertionA(eletion 1rial Mo<e
2! Li*iting probabilit+
+ 'i,es ne- configuration of the same ,olume !ut different num!er of
molecules
+ Choose -ith e.ual pro!a!ilit/
0 insertion trial/ add a molecule to a randoml selected position
0 deletion trial/ remo,e a randoml selected molecule from the
sstem
+ Limiting pro!a!ilit
0 grand(canonical ensem!le/
( )
N N
N
N N N
d N r U d p r r r r +
= = ) ( exp
1
) ( ) (
3
Grand Canonical Monte Carlo
2 / 1
2
2
|
|
\
|
=
T mk
h
B
=here is thermal de +roglie =a<elength
>nsertionA(eletion 1rial Mo<e
3! Anal+sis o# 'rial >robabilities
Transition matri1
E<ent
Tre<erse e<entU
Pro8a8ilit2
Tre<erse pro8a8ilit2U
,elect insertion trial
Tselect deletion trialU
c
Tc U
Place molecule at r
BP"
Tdelete molecule BP"U
drA\
T"A!BP"%U
Accept mo<e
Taccept mo<eU
min!"%
Tmin!""A%U
*or+ard-#tep
trial
pro,a,ilit$
1
min(1, )
2
d
V
r
-e.er#e-#tep
trial
pro,a,ilit$
1
1 1
min(1, )
2 1 N
+
i# formulated to #ati#f$
detailed ,alance
adapted from D. A. Kofkes lectures on Molecular Simulation, SUNY Buffalo
http://www.eng.buffalo.edu/~kofke/ce530/index.html
Con<ention
insert: !BP"% C BoldP"
delete: !BP"% C Bold
Grand Canonical Monte Carlo
>nsertionA(eletion 1rial Mo<e
I! Anal+sis o# Detailed Balance
(etailed 8alance
p
i
i/
p
/
/i
C
Limiting
di#tri,ution
*or+ard-#tep
trial
pro,a,ilit$
1
min(1, )
2
d
V
r
-e.er#e-#tep
trial
pro,a,ilit$
1
1 1
min(1, )
2 1 N
+
adapted from D. A. Kofkes lectures on Molecular Simulation, SUNY Buffalo
http://www.eng.buffalo.edu/~kofke/ce530/index.html
( )
N N
dN
N
d N r U p r r +
= ) ( exp
1
) (
(etailed specification of trial mo<es and and pro8a8ilities
Grand Canonical Monte Carlo
*or+ard-#tep
trial
pro,a,ilit$
1
min(1, )
2
d
V
r
-e.er#e-#tep
trial
pro,a,ilit$
1
1 1
min(1, )
2 1 N
+
Limiting
di#tri,ution
( )
N N
dN
N
d N r U p r r +
= ) ( exp
1
) (
>nsertionA(eletion 1rial Mo<e
I! Anal+sis o# Detailed Balance
(etailed 8alance
( 1) 1
1
( 1)
1 1 1
min(1, ) min(1, )
2 2 1
old new
U N N U N N
dN d N
e d d e d
V N
+ + + +
+
( (
=
( (
+
r r r
pi i/ p/ /i
C
Grand Canonical Monte Carlo
>nsertionA(eletion 1rial Mo<e
I! Anal+sis o# Detailed Balance
+
+
=
new old
U
d
U
e
N
e
V ) 1 (
1 1
(etailed 8alance
( 1) 1
1
( 1)
1 1 1
min(1, ) min(1, )
2 2 1
old new
U N N U N N
dN d N
e d d e d
V N
+ + + +
+
( (
=
( (
+
r r r
p
i
i/
p
/
/i
C
*or+ard-#tep
trial
pro,a,ilit$
1
min(1, )
2
d
V
r
-e.er#e-#tep
trial
pro,a,ilit$
1
1 1
min(1, )
2 1 N
+
Acceptance pro8a8ilit2
+
+
=
) (
) 1 (
old new
U U
d
e
N
V
Remem8er
insert: !BP"% C BoldP"
delete: !BP"% C Bold
Grand Canonical Monte Carlo
( )
{ }
min 1, exp
acc new old
P = (
U U
Canonical limit !BCconst%:
Acceptable trial *oves are:
>article *ove: a particle is selected at random and gi<en a ne= conformation !e.g.
for atoms a random displacement%. 1he detailed 8alance condition gi<es:
1herefore the acceptance criteria for this trial mo<e is gi<en 82:
( )
N N
N
N
d N r U r r +
= ) ( exp
1
) (
3
)) ( exp(
) exp(
) exp(
old new
old
new
new
new
old new
new old
U U
U
U
p
p
=
= =
Grand Canonical Monte Carlo
Insertion trial: a particle is inserted at a random position. 1he old configuration has
B particles and the ne= has BP" particles. 1he detailed 8alance condition gi<es:
( )
( ) ( )
{ }
3
min 1, exp 1
1
acc new old
V
P N N
N
(
= + + (
(
+
U U
1herefore the acceptance criteria for this trial mo<e is gi<en 82:
+
+
=
) (
3
) 1 (
old new
U U
e
N
V
P
acc
C min!"%
Remem8er
insert: !BP"% C BoldP"
delete: !BP"% C Bold
Grand Canonical Monte Carlo
call pos_gen(xct,yct,zct,rpore,ypore,zpore)
call ener0(xct,yct,zct,enn)
call potgr(xct,yct,zct,EG)
ent = enn + EG
coefi = zz*vol/(npart+1)
rtest = temp*log(rndm())
etest = -ent + temp*log(coefi)
if (rtest.lt.etest) then
IAA = IAA +1
xc(npart+1) = xct
yc(npart+1) = yct
zc(npart+1) = zct
call update_add
endif
KInsertL algorith*
)or an atomic ideal gas adsorption:
( ) [ ]
|
\
|
+
+
= ) ( ) 1 ( exp
1
, 1 min N U N U
N
VP
P
acc
[ ] exp
3
=
T k
P
B
)or a molecular ideal gas adsorption:
Grand Canonical Monte Carlo
[ ]
rot
q kT
P 1
exp
3
=
( ) [ ]
|
|
\
|
+
+
= ) ( ) 1 ( exp
1
, 1 min N U N U
N
VP
q
P
rot
acc
Deletion trial: a randoml2 selected particle is remo<ed from the s2stem. 1he old
configuration has N particles and the ne= has N 0 " particles. 1he detailed 8alance
condition gi<es:
( ) ( )
{ }
3
min 1, exp 1
acc new old
N
P N N
V
(
= + (
(
U U
1herefore the acceptance criteria for this trial mo<e is gi<en 82:
+
+
=
) (
3
) 1 (
old new
U U
e
N
V
P
acc
C min!""A%
Remem8er
insert: !BP"% C BoldP"
delete: !BP"% C Bold
Grand Canonical Monte Carlo
ip=INT(npart*rndm())+1
if(ip.gt.npart) ip=npart
eno = ENmol(ip)
coef = npart/(zz*vol)
rtest = temp*log(rndm())
etest = eno + temp*log(coef)
if (rtest.lt.etest) then
IAR = IAR + 1
call update_remove(ip)
endif
KRe*oveL algorith*
)or an atomic ideal gas adsorption:
( ) [ ]
|
|
\
|
= ) 1 ( ) ( exp
1
, 1 min N U N U
VP
N
P
id
acc
Grand Canonical Monte Carlo
)or a molecular ideal gas adsorption:
[ ] = exp
3
T k
P
B
[ ]
rot
q kT
p
kT
1
exp exp
3
= =
(
( ) [ ]
|
|
\
|
= ) 1 ( ) ( exp , 1 min N U N U
VP
N q
P
id
rot
acc
MC in the @rand Canonical !\1% Ensem8le
@CMC =or*s 8est if the acceptance of trial mo<es 82 =hich particles are added or
remo<ed is not too lo=.
)or atomic fluids this condition effecti<el2 limits
the ma5imum densit2 at =hich the method can 8e
used to a8out t=ice the critical densit2
,pecial tric*s are needed to e5tend the @CMC
method to higher densities
!see e.g. M. MeEei Mol. Ph$#. D9 #." !"#'.%%
@CMC is easil2 implemented for mi5tures and inhomogeneous s2stems such as fluids
near interfaces
Mar*o< process is a stochastic process =ith no memor2
)ull specification of process is gi<en 82 a matri5 of transition pro8a8ilities
A distri8ution of states are generated 82 repeatedl2 stepping from one state to
another according to
A desired limiting distri8ution can 8e used to construct transition pro8a8ilities
using detailed 8alance
Man2 different P matrices can 8e constructed to satisf2 detailed 8alance
Metropolis algorithm is one such choice =idel2 used in MC simulation
Mar*o< Monte Carlo is good for e<aluating a<erages 8ut not a8solute integrals
&u**ar+
2
3 4f
2
5 ( 4f5
2
-here
= =
= =
n
i
i
n
i
i
x f
n
f x f
n
f
1
2
1
2
) (
1
) (
1
The accurac depends on the num!er of trials in the MC method" One possi!le
measure of the error is the ,ariance
2
:
cannot !e a direct measure of the error 6666
One -a to o!tain an estimate for the error is to ma7e additional runs of n trials each"
$ach run of n trials ields a mean ,alue (or measurement) -hich -e denote as M
" The
magnitude of the differences !et-een the measurements is a measure of the error
associated -ith a single measurement/
m
m
2
3 4M
2
5 ( 4M5
2
-here
= =
= =
m m
M
m
M M
m
M
1
2
1
2
1 1
Simulation error analysis
$rror estimation (standard mean de,iation) /
m
3 8m
982
Simulation error analysis
@
9hat is the minimal length n *
n steps
m bins
Trajectory mn
2
2
lim
m
n
nc
n
n
=
n
$rror estimation (standard mean de,iation) /
m
3 8n
982
Proof/
One ma sho- that this relation is e1act in the limit of a ,er large num!er of
measurements
= = =
=
= =
=
m n
i
i
m
n
i
i
x
nm
M
m
M
x
n
M
1 1
,
1
1
,
1 1
1
The difference !et-een measurement and the mean /
=
=
=
m
m
e
m
M M e
1
2 2
1
:e no- relate m to the ,ariance of the indi,idual trials /
M x d
i i
=
, ,
:e -rite/
= = =
= = = =
n
i
i
n
i
i
n
i
i
d
n
M x
n
M x
n
M M e
1
,
1
,
1
,
1
) (
1 1
Simulation error analysis
|
|
\
|
|
\
|
= =
= = = =
n
j
j
m n
i
i
m
m
d
n
d
n m
e
m
1
,
1 1
,
1
2 2
1 1 1 1
= = =
= =
m n
i
i
m
m
d
mn
e
m
1 1
,
2
2
1
2 2
1 1
n
m
2
2
=
:e ma calculate /
:e e1pect that d
;I
are independent and e.uall positi,e or negati,e on
a,erage" <ence in the limit of a ,er large num!er of measurements; -e
e1pect that onl the terms -ith i3= -ill sur,i,e/
>ecause the definition of the ,ariance; -e ha,e/
|
\
|
=
= =
m n
i
i m
d
mn
1 1
2
,
2
1
Simulation error analysis
Molecular (2namics modeling methods
>ntroduction
Molecular d+na*ics
E5ploration of the h2per-energ2 surface in a
d2namic =a2 82 sol<ing the Be=ton e3uation
of motion
>nitial data:
Borce #ields
Initial con#iguration
Initial velocities
) ,..., (
i
N i i
i i
i
i
i
i
r r F
r
U
r
H
p
m
p
p
H
r
=
=
=
=
&
&
r
i
!tPt% C r
i
!t% P <
i
!t% t
<
i
!tPt% C <
i
!t% P f
i
!t% tAm
i
Choice of t: it has 8e relati<el2 small
in comparison =ith the t2pical
oscillation time of the studied
phenomenon
Advantages:
Due to the #act that te*perature
e##ects are included/ the s+ste*
*a+ overco*e energ+ barriers
Molecular (2namics
(ifferences +et=een MC and M(
M( gi<es information a8out d2namical 8eha<ior as =ell as e3uili8rium
thermod2namic properties. 1hus transport properties can 8e
calculated. MC can onl2 gi<e static e3uili8rium properties
MC can 8e more easil2 adapted to other ensem8les:
- , (, " !grand canonical%
- N, (, " !canonical%
- N, P, " !iso8aric-isothermic%
>n MC motions are artificial - in M( the2 are natural
>n MC =e can use special techni3ues to achie<e e3uili8rium. )or
e5ample can do8ser<eY formation of micelles slo= phase transitions.
Be=tonian )ormulation
Cartesian spatial coordinates r
i
C !5
i
2
i
E
i
% are primar2
<aria8les
for B atoms s2stem of B 2nd-order differential
e3uations
2
2
i
i i
d
m m
dt
=
r
r F &&
Assume conser<ati<e forces
U = F
r r
Gradient o# a scalar potential energ+
Integration Algorithms
Equations of motion in cartesian coordinates
Desirable features of an integrator
minimal need to compute forces (a very expensive calculation)
good stability for large time steps
good accuracy
conserves energy and momentum
time-reversible
j j
j
j
d
dt m
d
dt
=
=
r p
p
F
1
( , )
( , )
x y
x y
N
j ij
i
i j
r r
p p
=
=
=
=
r
p
F F
pairwise additive forces
2-dimensional space (for example)
F
\er2 simple <er2 good <er2 popular algorithm
Consider e5pansion of coordinate for=ard and 8ac*=ard in time
Add these together
Rearrange
update =ithout e<er consulting <elocitiesH
\erlet Algorithm
". E3uations
2 3 4
1 1 1
2 3!
2 3 4
1 1 1
2 3!
( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( )
m m
m m
t t t t t t t t t O t
t t t t t t t t t O t
+ = + + + +
= + +
r r p F r
r r p F r
&&&
&&&
2 4
1
( ) ( ) 2 ( ) ( ) ( )
m
t t t t t t t O t + + = + + r r r F
2 4
1
( ) 2 ( ) ( ) ( ) ( )
m
t t t t t t t O t + = + + r r r F
ta*en from (. A. ?of*eYs lectures on Molecular ,imulation ,-Be +uffalo
http:AA===.eng.8uffalo.eduAI*of*eAceQ6.Ainde5.html
\erlet Algorithm 2. )lo= diagram
Configuration r!t%
Pre<ious configuration r!t-dt%
Compute forces B!t%
on all atoms using r!t%
Ad<ance all positions according to
r!tPdt% C 2r!t%-r!t-dt%PB!t%Am dt
2
Add to 8loc* sum
End of
8loc*J
Bo +loc*
a<erages
ees
>nitialiEation
Reset 8loc* sums
Compute 8loc* a<erage
Compute final results
8loc*s per simulation
Entire ,imulation
" mo<e per c2cle
Be= configuration
c2cles per 8loc*
Add to 8loc* sum
4ne M( C2cle
4ne force
e<aluation per
time step
\erlet Algorithm 2. )lo= (iagram
r
v
B
t-dt t tPdt
@i<en current position and
position at end of pre<ious
time step
1chematic from llen ! "ilde#le$, 2omputer 1imulation of Li3uid#
\erlet Algorithm 2. )lo= (iagram
r
v
B
t-dt t tPdt
Compute the force at the
current position
1chematic from llen ! "ilde#le$, 2omputer 1imulation of Li3uid#
\erlet Algorithm 2. )lo= (iagram
r
v
B
t-dt t tPdt
Compute ne= position from
present and pre<ious
positions and present force
1chematic from llen ! "ilde#le$, 2omputer 1imulation of Li3uid#
\erlet Algorithm 2. )lo= (iagram
r
v
B
t-2dt t-dt t tPdt
Ad<ance to ne5t time step
repeat
1chematic from llen ! "ilde#le$, 2omputer 1imulation of Li3uid#
\erlet Algorithm. 6. Loose Ends
>nitialiEation
ho= to get position at `pre<ious time stepa =hen starting outJ
simple appro5imation
48taining the <elocities
not e<aluated during normal course of algorithm
needed to compute some properties e.g.
temperature
diffusion constant
finite difference
0 0 0
( ) ( ) ( ) t t t t t = r r v
[ ]
2
1
( ) ( ) ( ) ( )
2
t t t t t O t
t
= + + v r r
ta*en from (. A. ?of*eYs lectures on Molecular ,imulation ,-Be +uffalo
http:AA===.eng.8uffalo.eduAI*of*eAceQ6.Ainde5.html
>nitial \elocities
Random direction
randomiEe each component independentl2
randomiEe direction 82 choosing point on spherical surface
Magnitude consistent =ith desired temperature. Choices:
Ma5=ell-+oltEmann:
-niform o<er !-"A2P"A2% then scale so that
Constant at
,ame for 2 E components
+e sure to shift so center-of-mass momentum is Eero
( )
2
1
2
( ) exp /
x x
prob v mv kT
/
x
v kT m =
2
1
,
/
i x
N
v kT m =
1
,
, ,
x i x
N
i x i x x
P p
p p P
ta*en from (. A. ?of*eYs lectures on Molecular ,imulation ,-Be +uffalo
http:AA===.eng.8uffalo.eduAI*of*eAceQ6.Ainde5.html
\elocit2 \erlet Algorithm
Round-off ad<antage of leapfrog 8ut 8etter treatment of <elocities
Algorithm
>mplemented in stages
e<aluate current force
compute r at ne= time
add current-force term to <elocit2 !gi<es v at half-time step%
compute ne= force
add ne=-force term to <elocit2
Also mathematicall2 e3ui<alent to \erlet algorithm
!in gi<ing <alues of r%
[ ]
2
1
2
1
2
( ) ( ) ( ) ( )
( ) ( ) ( ) ( )
m
m
t t t t t t t
t t t t t t t
+ = + +
+ = + + +
r r v F
v v F F
ta*en from (. A. ?of*eYs lectures on Molecular ,imulation ,-Be +uffalo
http:AA===.eng.8uffalo.eduAI*of*eAceQ6.Ainde5.html
A8 initio !()1% modeling methods
>ntroduction