CE 530 Molecular Simulation - University at Buffalokofke/ce530/Lectures/... · 2014. 4. 29. · CE...
Transcript of CE 530 Molecular Simulation - University at Buffalokofke/ce530/Lectures/... · 2014. 4. 29. · CE...
-
1
CE 530 Molecular Simulation
Lecture 21 Histogram Reweighting Methods
David A. Kofke
Department of Chemical Engineering SUNY Buffalo
-
2 Histogram Reweighting ¡ Method to combine results taken at different state conditions ¡ Microcanonical ensemble
¡ Canonical ensemble
¡ The big idea: • Combine simulation data at different temperatures to improve
quality of all data via their mutual relation to Ω(E)
( , , ) 1microstates
E V NΩ = ∑
1( , )N N EeQ
βπ −=r p Probability of a microstate
( ; ) ( )( )
EeE EQ
βπ β
β
−=Ω Probability of an energy
Number of microstates having this energy
Probability of each microstate
-
3 In-class Problem 1. ¡ Consider three energy levels
¡ What are Q, distribution of states and at β = 1?
0 0
1 1
2 2
1 0 ln1100 2.3 ln101000 6.9 ln1000
EEE
Ω = = =Ω = = =Ω = = =
-
4 In-class Problem 1A. ¡ Consider three energy levels
¡ What are Q, distribution of states and at β = 1?
0 1 20 1 2ln1 ln10 ln10001 100 1000
1 1 100 0.1 1000 0.00112
E E EQ e e e
e e e
β β β− − −
− − −
=Ω +Ω +Ω
= + += × + × + ×=
0
1
2
00
11
22
1 0.08312
10 0.83312
1 0.08312
E
E
E
eQ
eQ
eQ
β
β
β
π
π
π
−
−
−
Ω= = =
Ω= = =
Ω= = =
0 0
1 1
2 2
1 0 ln1100 2.3 ln101000 6.9 ln1000
EEE
Ω = = =Ω = = =Ω = = =
0.083 00.833 2.30.083 6.92.49
i iE Eπ== ×+ ×+ ×=
∑
-
5 In-class Problem 1A. ¡ Consider three energy levels
¡ What are Q, distribution of states and at β = 1?
¡ And at β = 3?
0 1 20 1 2ln1 ln10 ln10001 100 1000
1 1 100 0.1 1000 0.00112
E E EQ e e e
e e e
β β β− − −
− − −
=Ω +Ω +Ω
= + += × + × + ×=
0
1
2
00
11
22
1 0.08312
10 0.83312
1 0.08312
E
E
E
eQ
eQ
eQ
β
β
β
π
π
π
−
−
−
Ω= = =
Ω= = =
Ω= = =
0 0
1 1
2 2
1 0 ln1100 2.3 ln101000 6.9 ln1000
EEE
Ω = = =Ω = = =Ω = = =
3ln1 3ln10 3ln1000
3
1 100 1000
1 1 100 0.001 1000 10001.1
Q e e e− − −
−
= + +
= × + × + ×=
0
1
2
1 0.911.11 0.091.10.0 0.001.1
π
π
π
= =
= =
= =
0.083 00.833 2.30.083 6.92.49
i iE Eπ== ×+ ×+ ×=
∑
0.91 00.09 2.30.00 6.90.21
E = ×+ ×+ ×=
-
6
Histogram Reweighting Approach ¡ Knowledge of Ω (E) can be used to obtain averages at any
temperature
¡ Simulations at different temperatures probe different parts of Ω (E) ¡ But simulations at each temperature provides information over a
range of values of Ω (E) ¡ Combine simulation data taken at different temperatures to obtain
better information for each temperature
E
Ω(E) β1 β2 β3
-
7 In-class Problem 2. ¡ Consider simulation data from a system having three energy
levels • M = 100 samples taken at β = 0.5 • mi times observed in level i
¡ What is Ω (E)?
0 0
1 1
2 2
4 0 ln146 2.3 ln10050 9.2 ln10000
m Em Em E
= = == = == = =
-
8 In-class Problem 2. ¡ Consider simulation data from a system having three energy
levels • M = 100 samples taken at β = 0.5 • mi times observed in level i
¡ What is Ω (E)?
0 0
1 1
2 2
4 0 ln146 2.3 ln10050 9.2 ln10000
m Em Em E
= = == = == = =
( ) ( )( )
EeE EQ
βπ
β
−=ΩReminder
-
9 In-class Problem 2. ¡ Consider simulation data from a system having three energy
levels • M = 100 samples taken at β = 0.5 • mi times observed in level i
¡ What is Ω (E)?
0 0
1 1
2 2
4 0 ln146 2.3 ln10050 9.2 ln10000
m Em Em E
= = == = == = =
( )( )( )
EEE eQ
βπβ
−⎛ ⎞Ω= ⎜ ⎟⎝ ⎠Hint
Can get only relative values!
-
10 In-class Problem 2A. ¡ Consider simulation data from a system having three energy
levels • M = 100 samples taken at β = 0.5 • mi times observed in level i
¡ What is Ω (E)?
0 0
1 1
2 2
4 0 ln146 2.3 ln10050 9.2 ln10000
m Em Em E
= = == = == = =
0 0
1 1
2 2
0.50
0.51
0.52
0.04 1 .04
0.46 100 4.6
0.50 10000 50
m UA AM
m UA AM
m UA AM
e Q Q Q
e Q Q Q
e Q Q Q
β
β
β
+
+
+
Ω = = × =
Ω = = × =
Ω = = × =
( 0.5)AQ Q β≡ =
-
11 In-class Problem 3. ¡ Consider simulation data from a system having three energy
levels • M = 100 samples taken at β = 0.5 • mi times observed in level i
¡ What is Ω (E)?
¡ Here’s some more data, taken at β = 1 • what is Ω(E)?
0 0
1 1
2 2
4 0 ln146 2.3 ln10050 9.2 ln10000
m Em Em E
= = == = == = =
( 0.5)AQ Q β≡ =
0 1 250 48 2m m m= = =
0 0
1 1
2 2
0.50
0.51
0.52
0.04 1 .04
0.46 100 4.6
0.50 10000 50
m UA A AM
m UA A AM
m UA A AM
e Q Q Q
e Q Q Q
e Q Q Q
β
β
β
+
+
+
Ω = = × =
Ω = = × =
Ω = = × =
-
12 In-class Problem 3. ¡ Consider simulation data from a system having three energy
levels • M = 100 samples taken at β = 0.5 • mi times observed in level i
¡ What is Ω (E)?
¡ Here’s some more data, taken at β = 1 • what is Ω (E)?
0 0
1 1
2 2
4 0 ln146 2.3 ln10050 9.2 ln10000
m Em Em E
= = == = == = =
0 0
1 1
2 2
0.50
0.51
0.52
0.04 1 .04
0.46 100 4.6
0.50 10000 50
m UA A AM
m UA A AM
m UA A AM
e Q Q Q
e Q Q Q
e Q Q Q
β
β
β
+
+
+
Ω = = × =
Ω = = × =
Ω = = × =
( 0.5)AQ Q β≡ =
0 1 250 48 2m m m= = =
0
1
2
0.50 1 .500.48 100 480.02 10000 200
B B
B B
B B
Q QQ QQ Q
Ω = × =Ω = × =Ω = × =
( 1.0)BQ Q β≡ =
-
13
Reconciling the Data
¡ We have two data sets
¡ Questions of interest • what is the ratio QA/QB? (which then gives us ΔA) • what is the best value of Ω1/Ω0, Ω2/Ω0? • what is the average energy at β = 2?
¡ In-class Problem 4 • make an attempt to answer these questions
0
1
2
.044.650
A
A
A
QQQ
Ω =Ω =Ω =
0
1
2
.5048200
B
B
B
QQQ
Ω =Ω =Ω =
-
14 In-class Problem 4A. ¡ We have two data sets
¡ What is the ratio QA/QB? (which then gives us ΔA) • Consider values from each energy level
¡ What is the best value of Ω1/Ω0, Ω2/Ω0? • Consider values from each temperature
¡ What to do?
0
1
2
.044.650
A
A
A
QQQ
Ω =Ω =Ω =
0
1
2
.5048200
B
B
B
QQQ
Ω =Ω =Ω =
0 1 20 1 2
0.04 4.6 500.50 48 200
0.50 48 2000.04 4.6 5012.5 10.4 4
A A AB B B
A A AB B B
Q Q QQ Q Q
Q Q QQ Q Q
Ω Ω ΩΩ Ω Ω= = =
= = = = = =
1 20 0
1 20 0
4.6 500.04 0.04
48 2000.05 0.5
0.5 115 1250
1 96 400
A AA A
B BB B
Q QQ Q
Q QQ Q
β
β
Ω ΩΩ Ω
Ω ΩΩ Ω
= = = = =
= = = = =
-
15
Accounting for Data Quality
¡ Remember the number of samples that went into each value
• We expect the A-state data to be good for levels 1 and 2 • …while the B-state data are good for levels 0 and 1
¡ Write each Ω as an average of all values, weighted by quality of result
0
1
2
0
1
2
.044.65
600
445
A
A
A
mmm
QQQ
Ω =Ω =Ω =
===
0
2
0
1
2
1
.504820
504820
B
B
B
mm
QQQ m
==
Ω =Ω =Ω ==
( ) ( )0, 0,0 00 0, 0,
A BA BA B
est est estA A B B
m mU UA A B BM M
w w
w e Q w e Qβ β
Ω = Ω + Ω
= +
( ) ( )( )
EeE EQ
βπ
β
−=Ω
-
16
Histogram Variance
¡ Estimate confidence in each simulation result
¡ Assume each histogram follows a Poisson distribution • probability P to observe any given instance of distribution
• the variance for each bin is
0
1
2
0
1
2
.044.65
600
445
A
A
A
mmm
QQQ
Ω =Ω =Ω =
===
0
2
0
1
2
1
.504820
504820
B
B
B
mm
QQQ m
==
Ω =Ω =Ω ==
31 21 2 3
1 2 31 2 3
[{ }] !!
[{ , , }] !! ! !
imi
ii
mm m
P m Mm
P m m m Mm m m
π
π π π
=
=
∏
u1 u2 u3
piInstance
2im i im Mσ π= =
-
17
Variance in Estimate of Ω ¡ Formula for estimate of Ω
¡ Variance
0, 0,0 00
A BA BA B
m mE EestA A B BM Mw e Q w e Q
β βΩ = +
( ) ( )
0 02 20, 0,0
0 02 2
0 00 00 0
0 0
2 22 2 2 2 2 2 21 1
2 22 2 2 21 10, 0,
2 22 2 2 21 1
2 21 10 0
A Best A B
A B
A B
A B
E EA BA B
A A B B
A BA B
E EA A m B B mM M
E EA A A A B B B BM M
e eE EA A B BM Q M Q
E EA A B BM M
w e Q w e Q
w e Q M w e Q M
w e Q w e Q
w e Q w e Q
β β
β β
β β
β β
β β
σ σ σ
π π
− −
Ω
Ω Ω
= +
= +
⎛ ⎞ ⎛ ⎞= +⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠= Ω + Ω
( ) ( )( )
EeE EQ
βπ
β
−=Ω
-
18
Optimizing Weights ¡ Variance
¡ Minimize with respect to weight, subject to normalization • In-class Problem 5
Do it!
0 00
2 2 21 10 0
A Best
A B
E EA A B BM Mw e Q w e Q
β βσΩ = Ω + Ω
-
19
Optimizing Weights ¡ Variance
¡ Minimize with respect to weight, subject to normalization • Lagrange multiplier
¡ Equation for each weight is ¡ Rearrange
¡ Normalize
( )0
2 1est aMin wσ λΩ⎡ ⎤− −⎢ ⎥⎣ ⎦∑
002 aa a
QEa Mw e
β λΩ =
( ) ( )( )
Eie mE E
Q M
βπ
β
−=Ω ≈
0
012
Ea aa
e Ma Qw
βλ
−
Ω=
0
0 0
/Ea a aE EA Be M e MA BQ QA B
e M Qaw
β
β β
−
− −+
=
0 00
2 2 21 10 0
A Best
A B
E EA A B BM Mw e Q w e Q
β βσΩ = Ω + Ω
-
20
Optimal Estimate
¡ Collect results
¡ Combine
0
0 0
/Ea a aE EA Be M e MA BQ QA B
e M Qaw
β
β β
−
− −+
=
0, 0,0 00
A BA BA B
m mE EestA A B BM Mw e Q w e Q
β βΩ = +
0 0 0 00, 0,0 0
0 0
1
0
1
0, 0,
E E E EA B A BA BA B A BA BA B A A B B
E EA BA BA B
m me M e M e M e ME EestA BQ Q Q M Q M
e M e MA BQ Q
e Q e Q
m m
β β β β
β β
β β− − − −
− −
−
−
⎡ ⎤⎡ ⎤ ⎛ ⎞ ⎛ ⎞Ω = + +⎜ ⎟ ⎜ ⎟⎢ ⎥⎢ ⎥⎣ ⎦ ⎝ ⎠ ⎝ ⎠⎣ ⎦
⎡ ⎤ ⎡ ⎤= + +⎣ ⎦⎢ ⎥⎣ ⎦
-
21
Calculating Ω
¡ Formula for Ω
¡ In-class Problem 6 • explain why this formula cannot yet be used
0 0 1
0 0, 0,E EA BA BA B
e M e MestA BQ Q m m
β β− − −⎡ ⎤ ⎡ ⎤Ω = + +⎣ ⎦⎢ ⎥⎣ ⎦
-
22
Calculating Ω
¡ Formula for Ω
¡ We do not know the Q partition functions
¡ One equation for each Ω
¡ Each equation depends on all Ω
¡ Requires iterative solution
0 0 1
0 0, 0,E EA BA BA B
e M e MestA BQ Q m m
β β− − −⎡ ⎤ ⎡ ⎤Ω = + +⎣ ⎦⎢ ⎥⎣ ⎦
0 1 20 1 2
a a aE E EaQ e e e
β β β− − −=Ω +Ω +Ω
0 0
0 01 2 1 20 1 2 0 1 2
1
0 0, 0,E EA BA B
E EE E E EA BA A B B
e M e MestA Be e e e e e
m mβ β
β ββ β β β
− −
− −− − − −
−
Ω +Ω +Ω Ω +Ω +Ω⎡ ⎤ ⎡ ⎤Ω = + +⎣ ⎦⎢ ⎥⎣ ⎦
-
23
In-class Problem 7 ¡ Write the equations for each Ω using the example values
0 0
0 01 2 1 20 1 2 0 1 2
1
0 0, 0,E EA BA B
E EE E E EA BA A B B
e M e MestA Be e e e e e
m mβ β
β ββ β β β
− −
− −− − − −
−
Ω +Ω +Ω Ω +Ω +Ω⎡ ⎤ ⎡ ⎤Ω = + +⎣ ⎦⎢ ⎥⎣ ⎦
0
1
2
0.544650
mmm
β ====
0
1
2
0 ln12.3 ln1009.2 ln10000
EEE
= == == =
0
1
2
150482
mmm
β ====
100A BM M= =
-
24
In-class Problem 7 ¡ Write the equations for each Ω using the example values
¡ Solution
0
1
2
0.544650
mmm
β ====
0
1
2
0 ln12.3 ln1009.2 ln10000
EEE
= == == =
0
1
2
150482
mmm
β ====
100A BM M= =
[ ]0 1 2 0 1 2
10.1 100 0.01 100
1 1 0.1 0.01 1 0.01 0.0001 46 48est −× ×
Ω + Ω + Ω Ω + Ω + Ω⎡ ⎤Ω = + +⎣ ⎦
[ ]0 1 2 0 1 2
11 100 1 100
0 1 0.1 0.01 1 0.01 0.0001 4 50est −× ×
Ω + Ω + Ω Ω + Ω + Ω⎡ ⎤Ω = + +⎣ ⎦
[ ]0 1 2 0 1 2
10.01 100 0.0001 100
2 1 0.1 0.01 1 0.01 0.0001 50 2est −× ×
Ω + Ω + Ω Ω + Ω + Ω⎡ ⎤Ω = + +⎣ ⎦
1 2
0 094.7 943.2Ω Ω= =
Ω Ω
0 0
0 01 2 1 20 1 2 0 1 2
1
0 0, 0,E EA BA B
E EE E E EA BA A B B
e M e MestA Be e e e e e
m mβ β
β ββ β β β
− −
− −− − − −
−
Ω +Ω +Ω Ω +Ω +Ω⎡ ⎤ ⎡ ⎤Ω = + +⎣ ⎦⎢ ⎥⎣ ⎦
-
25
In-class Problem 7A. ¡ Solution
¡ Compare
¡ “Exact” solution
¡ Free energy difference
1 2
0 094.7 943.2Ω Ω= =
Ω Ω
1 20 0
1 20 0
4.6 500.04 0.04
48 2000.05 0.5
0.5 115 1250
1 96 400
A AA A
B BB B
Q QQ Q
Q QQ Q
β
β
Ω ΩΩ Ω
Ω ΩΩ Ω
= = = = =
= = = = =
0
1
2
0.544650
mmm
β ====
0
1
2
150482
mmm
β ====
1 2
0 0100 1000Ω Ω= =
Ω Ω
0 1 2
0 1 2
1 0.1 0.01 9.741 0.01 0.0001
A
B
QQ
Ω + Ω + Ω= =Ω + Ω + Ω
“Design value” = 10
(?)
-
26
Extensions of Technique
¡ Method is usually used in multidimensional form ¡ Useful to apply to grand-canonical ensemble
¡ Can then be used to relate simulation data at different temperature and chemical potential
¡ Many other variations are possible
31!
( , , )
NN N N Eh NN
N E
N U
e d d e
U V N e e
βµ β
βµ β
−
−
Ξ =
= Ω
∑ ∫
∑∑
r p