Analyzing the MSTIS simulation

Included in this notebook:

  • Opening files for analysis
  • Rates, fluxes, total crossing probabilities, and condition transition probabilities
  • Per-ensemble properties such as path length distributions and interface crossing probabilities
  • Move scheme analysis
  • Replica exchange analysis
  • Replica move history tree visualization
  • Replaying the simulation
  • MORE TO COME! Like free energy projections, path density plots, and more

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import openpathsampling as paths
import numpy as np

The optimum way to use storage depends on whether you're doing production or analysis. For analysis, you should open the file as an AnalysisStorage object. This makes the analysis much faster.


In [2]:
%%time
storage = paths.AnalysisStorage("ala_mstis_production.nc")


CPU times: user 18.4 s, sys: 724 ms, total: 19.1 s
Wall time: 19.7 s

In [3]:
print "PathMovers:", len(storage.pathmovers)
print "Engines:", len(storage.engines)
print "Samples:", len(storage.samples)
print "Ensembles:", len(storage.ensembles)
print "SampleSets:", len(storage.samplesets)
print "Snapshots:", len(storage.snapshots)
print "Trajectories:", len(storage.trajectories)
print "Networks:", len(storage.networks)


PathMovers: 210
Engines: 2
Samples: 1339
Ensembles: 351
SampleSets: 1000
Snapshots: 55256
Trajectories: 849
Networks: 1

In [4]:
%%time
mstis = storage.networks[0]


CPU times: user 1.17 ms, sys: 718 µs, total: 1.89 ms
Wall time: 1.01 ms

In [5]:
%%time
for cv in storage.cvs:
    print cv.name, cv._store_dict


opA None
phi <openpathsampling.chaindict.StoredDict object at 0x12c444b50>
psi <openpathsampling.chaindict.StoredDict object at 0x12c447b10>
opB None
opC None
opD None
opE None
opF None
CPU times: user 4.95 ms, sys: 1.11 ms, total: 6.06 ms
Wall time: 4.61 ms

Reaction rates

TIS methods are especially good at determining reaction rates, and OPS makes it extremely easy to obtain the rate from a TIS network.

Note that, although you can get the rate directly, it is very important to look at other results of the sampling (illustrated in this notebook and in notebooks referred to herein) in order to check the validity of the rates you obtain.

By default, the built-in analysis calculates histograms the maximum value of some order parameter and the pathlength of every sampled ensemble. You can add other things to this list as well, but you must always specify histogram parameters for these two. The pathlength is in units of frames.


In [6]:
mstis.hist_args['max_lambda'] = { 'bin_width' : 2, 'bin_range' : (0.0, 90) }
mstis.hist_args['pathlength'] = { 'bin_width' : 5, 'bin_range' : (0, 100) }

In [7]:
%%time
mstis.rate_matrix(storage.steps, force=True)


CPU times: user 14.7 s, sys: 90.6 ms, total: 14.8 s
Wall time: 14.8 s
Out[7]:
{x|opA(x) in [0.0, 10.0]} {x|opB(x) in [0.0, 10.0]} {x|opC(x) in [0.0, 10.0]} {x|opD(x) in [0.0, 10.0]} {x|opE(x) in [0.0, 10.0]} {x|opF(x) in [0.0, 10.0]}
{x|opA(x) in [0.0, 10.0]} NaN 0.184498025734 /ps 0.0 /ps 0.0 /ps 0.0 /ps 0.0 /ps
{x|opB(x) in [0.0, 10.0]} 0.0572189159501 /ps NaN 0.0 /ps 0.0 /ps 0.0 /ps 0.0 /ps
{x|opC(x) in [0.0, 10.0]} 0.0 /ps 0.0 /ps NaN 0.230253689854 /ps 0.0 /ps 0.0 /ps
{x|opD(x) in [0.0, 10.0]} 0.0 /ps 0.0 /ps 0.0 /ps NaN 0.0 /ps 0.0 /ps
{x|opE(x) in [0.0, 10.0]} 0.0392426652982 /ps 0.0815511638227 /ps 0.0 /ps 0.0 /ps NaN 0.107304162925 /ps
{x|opF(x) in [0.0, 10.0]} 0.0 /ps 0.0 /ps 0.0 /ps 0.0 /ps 1.54681436858 /ps NaN

The self-rates (the rate of returning the to initial state) are undefined, and return not-a-number.

The rate is calcuated according to the formula:

$$k_{AB} = \phi_{A,0} P(B|\lambda_m) \prod_{i=0}^{m-1} P(\lambda_{i+1} | \lambda_i)$$

where $\phi_{A,0}$ is the flux from state A through its innermost interface, $P(B|\lambda_m)$ is the conditional transition probability (the probability that a path which crosses the interface at $\lambda_m$ ends in state B), and $\prod_{i=0}^{m-1} P(\lambda_{i+1} | \lambda_i)$ is the total crossing probability. We can look at each of these terms individually.

Total crossing probability


In [8]:
stateA = storage.volumes["A0"]
stateB = storage.volumes["B0"]
stateC = storage.volumes["C0"]

In [9]:
tcp_AB = mstis.transitions[(stateA, stateB)].tcp
tcp_AC = mstis.transitions[(stateA, stateC)].tcp
tcp_BC = mstis.transitions[(stateB, stateC)].tcp
tcp_BA = mstis.transitions[(stateB, stateA)].tcp
tcp_CA = mstis.transitions[(stateC, stateA)].tcp
tcp_CB = mstis.transitions[(stateC, stateB)].tcp

plt.plot(tcp_AB.x, tcp_AB)
plt.plot(tcp_CA.x, tcp_CA)
plt.plot(tcp_BC.x, tcp_BC)
plt.plot(tcp_AC.x, tcp_AC) # same as tcp_AB in MSTIS


Out[9]:
[<matplotlib.lines.Line2D at 0x13feb01d0>]

We normally look at these on a log scale:


In [10]:
plt.plot(tcp_AB.x, np.log(tcp_AB))
plt.plot(tcp_CA.x, np.log(tcp_CA))
plt.plot(tcp_BC.x, np.log(tcp_BC))


Out[10]:
[<matplotlib.lines.Line2D at 0x140320bd0>]

Flux

Here we also calculate the flux contribution to each transition. The flux is calculated based on


In [11]:
import pandas as pd
flux_matrix = pd.DataFrame(columns=mstis.states, index=mstis.states)
for state_pair in mstis.transitions:
    transition = mstis.transitions[state_pair]
    flux_matrix.set_value(state_pair[0], state_pair[1], transition._flux)

flux_matrix


Out[11]:
{x|opA(x) in [0.0, 10.0]} {x|opB(x) in [0.0, 10.0]} {x|opC(x) in [0.0, 10.0]} {x|opD(x) in [0.0, 10.0]} {x|opE(x) in [0.0, 10.0]} {x|opF(x) in [0.0, 10.0]}
{x|opA(x) in [0.0, 10.0]} NaN 1.67597765363 /ps 1.67597765363 /ps 1.67597765363 /ps 1.67597765363 /ps 1.67597765363 /ps
{x|opB(x) in [0.0, 10.0]} 2.17391304348 /ps NaN 2.17391304348 /ps 2.17391304348 /ps 2.17391304348 /ps 2.17391304348 /ps
{x|opC(x) in [0.0, 10.0]} 2.45398773006 /ps 2.45398773006 /ps NaN 2.45398773006 /ps 2.45398773006 /ps 2.45398773006 /ps
{x|opD(x) in [0.0, 10.0]} 1.78571428571 /ps 1.78571428571 /ps 1.78571428571 /ps NaN 1.78571428571 /ps 1.78571428571 /ps
{x|opE(x) in [0.0, 10.0]} 8.33333333333 /ps 8.33333333333 /ps 8.33333333333 /ps 8.33333333333 /ps NaN 8.33333333333 /ps
{x|opF(x) in [0.0, 10.0]} 2.94117647059 /ps 2.94117647059 /ps 2.94117647059 /ps 2.94117647059 /ps 2.94117647059 /ps NaN

Conditional transition probability


In [12]:
outer_ctp_matrix = pd.DataFrame(columns=mstis.states, index=mstis.states)
for state_pair in mstis.transitions:
    transition = mstis.transitions[state_pair]
    outer_ctp_matrix.set_value(state_pair[0], state_pair[1], transition.ctp[transition.ensembles[-1]])    

outer_ctp_matrix


Out[12]:
{x|opA(x) in [0.0, 10.0]} {x|opB(x) in [0.0, 10.0]} {x|opC(x) in [0.0, 10.0]} {x|opD(x) in [0.0, 10.0]} {x|opE(x) in [0.0, 10.0]} {x|opF(x) in [0.0, 10.0]}
{x|opA(x) in [0.0, 10.0]} NaN 0.179439 0 0.0616822 0 0
{x|opB(x) in [0.0, 10.0]} 0.199065 NaN 0 0.342991 0 0
{x|opC(x) in [0.0, 10.0]} 0 0.0607477 NaN 0.278505 0 0
{x|opD(x) in [0.0, 10.0]} 0 0.140187 0 NaN 0 0
{x|opE(x) in [0.0, 10.0]} 0 0 0 0.445794 NaN 0
{x|opF(x) in [0.0, 10.0]} 0 0.108411 0 0 0.486916 NaN

In [13]:
ctp_by_interface = pd.DataFrame(index=mstis.transitions)
for state_pair in mstis.transitions:
    transition = mstis.transitions[state_pair]
    for ensemble_i in range(len(transition.ensembles)):
        ctp_by_interface.set_value(
            state_pair, ensemble_i,
            transition.conditional_transition_probability(
                storage.steps,
                transition.ensembles[ensemble_i]
        ))
    
    
ctp_by_interface


Out[13]:
0 1 2 3
({x|opA(x) in [0.0, 10.0]}, {x|opE(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opD(x) in [0.0, 10.0]}, {x|opF(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opF(x) in [0.0, 10.0]}, {x|opB(x) in [0.0, 10.0]}) 0.736449 0.797196 0.083178 0.108411
({x|opC(x) in [0.0, 10.0]}, {x|opA(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opE(x) in [0.0, 10.0]}, {x|opB(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opE(x) in [0.0, 10.0]}, {x|opC(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opE(x) in [0.0, 10.0]}, {x|opD(x) in [0.0, 10.0]}) 0.302804 0.051402 0.200000 0.445794
({x|opB(x) in [0.0, 10.0]}, {x|opF(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opF(x) in [0.0, 10.0]}, {x|opE(x) in [0.0, 10.0]}) 0.085981 0.052336 0.026168 0.486916
({x|opA(x) in [0.0, 10.0]}, {x|opF(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opB(x) in [0.0, 10.0]}, {x|opD(x) in [0.0, 10.0]}) 0.071028 0.026168 0.198131 0.342991
({x|opC(x) in [0.0, 10.0]}, {x|opE(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opA(x) in [0.0, 10.0]}, {x|opB(x) in [0.0, 10.0]}) 0.173832 0.208411 0.423364 0.179439
({x|opA(x) in [0.0, 10.0]}, {x|opD(x) in [0.0, 10.0]}) 0.000000 0.000000 0.052336 0.061682
({x|opB(x) in [0.0, 10.0]}, {x|opE(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opB(x) in [0.0, 10.0]}, {x|opA(x) in [0.0, 10.0]}) 0.214953 0.066355 0.221495 0.199065
({x|opE(x) in [0.0, 10.0]}, {x|opF(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opA(x) in [0.0, 10.0]}, {x|opC(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opD(x) in [0.0, 10.0]}, {x|opB(x) in [0.0, 10.0]}) 0.000000 0.000000 0.140187 NaN
({x|opF(x) in [0.0, 10.0]}, {x|opA(x) in [0.0, 10.0]}) 0.000000 0.012150 0.000000 0.000000
({x|opE(x) in [0.0, 10.0]}, {x|opA(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opD(x) in [0.0, 10.0]}, {x|opE(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opD(x) in [0.0, 10.0]}, {x|opC(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opD(x) in [0.0, 10.0]}, {x|opA(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opF(x) in [0.0, 10.0]}, {x|opC(x) in [0.0, 10.0]}) 0.000000 0.000000 0.015888 0.000000
({x|opF(x) in [0.0, 10.0]}, {x|opD(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 0.000000
({x|opC(x) in [0.0, 10.0]}, {x|opB(x) in [0.0, 10.0]}) 0.000000 0.099065 0.060748 NaN
({x|opC(x) in [0.0, 10.0]}, {x|opD(x) in [0.0, 10.0]}) 0.000000 0.538318 0.278505 NaN
({x|opC(x) in [0.0, 10.0]}, {x|opF(x) in [0.0, 10.0]}) 0.000000 0.000000 0.000000 NaN
({x|opB(x) in [0.0, 10.0]}, {x|opC(x) in [0.0, 10.0]}) 0.042056 0.241121 0.014953 0.000000

Path ensemble properties


In [14]:
hists_A = mstis.transitions[(stateA, stateB)].histograms
hists_B = mstis.transitions[(stateB, stateC)].histograms
hists_C = mstis.transitions[(stateC, stateB)].histograms

Interface crossing probabilities

We obtain the total crossing probability, shown above, by combining the individual crossing probabilities of


In [15]:
for hist in [hists_A, hists_B, hists_C]:
    for ens in hist['max_lambda']:
        normalized = hist['max_lambda'][ens].normalized()
        plt.plot(normalized.x, normalized)



In [16]:
# add visualization of the sum

In [17]:
for hist in [hists_A, hists_B, hists_C]:
    for ens in hist['max_lambda']:
        reverse_cumulative = hist['max_lambda'][ens].reverse_cumulative()
        plt.plot(reverse_cumulative.x, reverse_cumulative)



In [18]:
for hist in [hists_A, hists_B, hists_C]:
    for ens in hist['max_lambda']:
        reverse_cumulative = hist['max_lambda'][ens].reverse_cumulative()
        plt.plot(reverse_cumulative.x, np.log(reverse_cumulative))


Path length histograms


In [19]:
for hist in [hists_A, hists_B, hists_C]:
    for ens in hist['pathlength']:
        normalized = hist['pathlength'][ens].normalized()
        plt.plot(normalized.x, normalized)



In [20]:
for ens in hists_A['pathlength']:
    normalized = hists_A['pathlength'][ens].normalized()
    plt.plot(normalized.x, normalized)


Sampling properties

The properties we illustrated above were properties of the path ensembles. If your path ensembles are sufficiently well-sampled, these will never depend on how you sample them.

But to figure out whether you've done a good job of sampling, you often want to look at properties related to the sampling process. OPS also makes these very easy.


In [ ]:

Move scheme analysis


In [21]:
scheme = storage.schemes[0]

In [22]:
scheme.move_summary(storage.steps)


ms_outer_shooting ran 1.590% (expected 2.14%) of the cycles with acceptance 10/17 (58.82%)
repex ran 23.667% (expected 23.55%) of the cycles with acceptance 144/253 (56.92%)
shooting ran 46.305% (expected 47.11%) of the cycles with acceptance 356/495 (71.92%)
minus ran 2.900% (expected 2.57%) of the cycles with acceptance 21/31 (67.74%)
pathreversal ran 25.538% (expected 24.63%) of the cycles with acceptance 184/273 (67.40%)

In [23]:
scheme.move_summary(storage.steps, 'shooting')


OneWayShootingMover I'face 1 ran 2.619% (expected 2.14%) of the cycles with acceptance 21/28 (75.00%)
OneWayShootingMover I'face 0 ran 1.871% (expected 2.14%) of the cycles with acceptance 15/20 (75.00%)
OneWayShootingMover I'face 3 ran 1.403% (expected 2.14%) of the cycles with acceptance 8/15 (53.33%)
OneWayShootingMover I'face 2 ran 1.777% (expected 2.14%) of the cycles with acceptance 13/19 (68.42%)
OneWayShootingMover I'face 1 ran 1.777% (expected 2.14%) of the cycles with acceptance 15/19 (78.95%)
OneWayShootingMover I'face 3 ran 2.526% (expected 2.14%) of the cycles with acceptance 11/27 (40.74%)
OneWayShootingMover I'face 3 ran 2.058% (expected 2.14%) of the cycles with acceptance 14/22 (63.64%)
OneWayShootingMover I'face 2 ran 2.339% (expected 2.14%) of the cycles with acceptance 20/25 (80.00%)
OneWayShootingMover I'face 1 ran 2.245% (expected 2.14%) of the cycles with acceptance 22/24 (91.67%)
OneWayShootingMover I'face 2 ran 2.526% (expected 2.14%) of the cycles with acceptance 19/27 (70.37%)
OneWayShootingMover I'face 2 ran 2.152% (expected 2.14%) of the cycles with acceptance 13/23 (56.52%)
OneWayShootingMover I'face 0 ran 1.684% (expected 2.14%) of the cycles with acceptance 17/18 (94.44%)
OneWayShootingMover I'face 2 ran 2.526% (expected 2.14%) of the cycles with acceptance 17/27 (62.96%)
OneWayShootingMover I'face 0 ran 2.432% (expected 2.14%) of the cycles with acceptance 23/26 (88.46%)
OneWayShootingMover I'face 0 ran 1.777% (expected 2.14%) of the cycles with acceptance 12/19 (63.16%)
OneWayShootingMover I'face 2 ran 2.619% (expected 2.14%) of the cycles with acceptance 19/28 (67.86%)
OneWayShootingMover I'face 1 ran 1.964% (expected 2.14%) of the cycles with acceptance 16/21 (76.19%)
OneWayShootingMover I'face 1 ran 1.403% (expected 2.14%) of the cycles with acceptance 10/15 (66.67%)
OneWayShootingMover I'face 3 ran 2.526% (expected 2.14%) of the cycles with acceptance 18/27 (66.67%)
OneWayShootingMover I'face 0 ran 2.058% (expected 2.14%) of the cycles with acceptance 16/22 (72.73%)
OneWayShootingMover I'face 0 ran 1.964% (expected 2.14%) of the cycles with acceptance 15/21 (71.43%)
OneWayShootingMover I'face 1 ran 2.058% (expected 2.14%) of the cycles with acceptance 22/22 (100.00%)

In [24]:
scheme.move_summary(storage.steps, 'minus')


Minus ran 0.561% (expected 0.43%) of the cycles with acceptance 2/6 (33.33%)
Minus ran 0.281% (expected 0.43%) of the cycles with acceptance 2/3 (66.67%)
Minus ran 0.842% (expected 0.43%) of the cycles with acceptance 8/9 (88.89%)
Minus ran 0.187% (expected 0.43%) of the cycles with acceptance 2/2 (100.00%)
Minus ran 0.842% (expected 0.43%) of the cycles with acceptance 6/9 (66.67%)
Minus ran 0.187% (expected 0.43%) of the cycles with acceptance 1/2 (50.00%)

In [25]:
scheme.move_summary(storage.steps, 'repex')


ReplicaExchange ran 1.216% (expected 1.07%) of the cycles with acceptance 0/13 (0.00%)
ReplicaExchange ran 1.310% (expected 1.07%) of the cycles with acceptance 14/14 (100.00%)
ReplicaExchange ran 1.216% (expected 1.07%) of the cycles with acceptance 0/13 (0.00%)
ReplicaExchange ran 0.748% (expected 1.07%) of the cycles with acceptance 0/8 (0.00%)
ReplicaExchange ran 0.748% (expected 1.07%) of the cycles with acceptance 8/8 (100.00%)
ReplicaExchange ran 1.590% (expected 1.07%) of the cycles with acceptance 17/17 (100.00%)
ReplicaExchange ran 1.216% (expected 1.07%) of the cycles with acceptance 1/13 (7.69%)
ReplicaExchange ran 1.029% (expected 1.07%) of the cycles with acceptance 11/11 (100.00%)
ReplicaExchange ran 1.403% (expected 1.07%) of the cycles with acceptance 10/15 (66.67%)
ReplicaExchange ran 0.655% (expected 1.07%) of the cycles with acceptance 5/7 (71.43%)
ReplicaExchange ran 0.655% (expected 1.07%) of the cycles with acceptance 7/7 (100.00%)
ReplicaExchange ran 1.216% (expected 1.07%) of the cycles with acceptance 0/13 (0.00%)
ReplicaExchange ran 1.497% (expected 1.07%) of the cycles with acceptance 10/16 (62.50%)
ReplicaExchange ran 1.310% (expected 1.07%) of the cycles with acceptance 9/14 (64.29%)
ReplicaExchange ran 0.468% (expected 1.07%) of the cycles with acceptance 4/5 (80.00%)
ReplicaExchange ran 0.935% (expected 1.07%) of the cycles with acceptance 10/10 (100.00%)
ReplicaExchange ran 0.561% (expected 1.07%) of the cycles with acceptance 4/6 (66.67%)
ReplicaExchange ran 1.403% (expected 1.07%) of the cycles with acceptance 11/15 (73.33%)
ReplicaExchange ran 1.497% (expected 1.07%) of the cycles with acceptance 3/16 (18.75%)
ReplicaExchange ran 1.123% (expected 1.07%) of the cycles with acceptance 0/12 (0.00%)
ReplicaExchange ran 0.935% (expected 1.07%) of the cycles with acceptance 10/10 (100.00%)
ReplicaExchange ran 0.935% (expected 1.07%) of the cycles with acceptance 10/10 (100.00%)

In [26]:
scheme.move_summary(storage.steps, 'pathreversal')


PathReversal ran 1.029% (expected 1.07%) of the cycles with acceptance 2/11 (18.18%)
PathReversal ran 1.777% (expected 1.07%) of the cycles with acceptance 19/19 (100.00%)
PathReversal ran 1.216% (expected 1.07%) of the cycles with acceptance 7/13 (53.85%)
PathReversal ran 0.935% (expected 1.07%) of the cycles with acceptance 7/10 (70.00%)
PathReversal ran 0.748% (expected 1.07%) of the cycles with acceptance 7/8 (87.50%)
PathReversal ran 1.216% (expected 1.07%) of the cycles with acceptance 9/13 (69.23%)
PathReversal ran 1.310% (expected 1.07%) of the cycles with acceptance 7/14 (50.00%)
PathReversal ran 1.123% (expected 1.07%) of the cycles with acceptance 11/12 (91.67%)
PathReversal ran 0.561% (expected 1.07%) of the cycles with acceptance 6/6 (100.00%)
PathReversal ran 0.935% (expected 1.07%) of the cycles with acceptance 3/10 (30.00%)
PathReversal ran 1.497% (expected 1.07%) of the cycles with acceptance 9/16 (56.25%)
PathReversal ran 0.935% (expected 1.07%) of the cycles with acceptance 8/10 (80.00%)
PathReversal ran 1.310% (expected 1.07%) of the cycles with acceptance 7/14 (50.00%)
PathReversal ran 1.310% (expected 1.07%) of the cycles with acceptance 9/14 (64.29%)
PathReversal ran 1.123% (expected 1.07%) of the cycles with acceptance 5/12 (41.67%)
PathReversal ran 0.935% (expected 1.07%) of the cycles with acceptance 10/10 (100.00%)
PathReversal ran 1.029% (expected 1.07%) of the cycles with acceptance 6/11 (54.55%)
PathReversal ran 1.684% (expected 1.07%) of the cycles with acceptance 11/18 (61.11%)
PathReversal ran 0.842% (expected 1.07%) of the cycles with acceptance 7/9 (77.78%)
PathReversal ran 0.655% (expected 1.07%) of the cycles with acceptance 7/7 (100.00%)
PathReversal ran 0.655% (expected 1.07%) of the cycles with acceptance 3/7 (42.86%)
PathReversal ran 1.310% (expected 1.07%) of the cycles with acceptance 9/14 (64.29%)
PathReversal ran 1.403% (expected 1.07%) of the cycles with acceptance 15/15 (100.00%)

Replica exchange sampling

See the notebook repex_networks.ipynb for more details on tools to study the convergence of replica exchange. However, a few simple examples are shown here. All of these are analyzed with a separate object, ReplicaNetwork.


In [27]:
repx_net = paths.ReplicaNetwork(scheme, storage.steps)

Replica exchange mixing matrix


In [28]:
repx_net.mixing_matrix()


Out[28]:
7 6 5 4 28 27 15 16 17 22 ... 3 2 1 0 26 25 11 12 13 14
7 0.000000 0.035211 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
6 0.035211 0.000000 0.038732 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
5 0.000000 0.038732 0.000000 0.035211 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
4 0.000000 0.000000 0.035211 0.000000 0.003521 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
28 0.000000 0.000000 0.000000 0.003521 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
27 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.007042 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
15 0.000000 0.000000 0.000000 0.000000 0.000000 0.007042 0.000000 0.049296 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
16 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.049296 0.000000 0.003521 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
17 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.003521 0.000000 0.035211 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
22 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.035211 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
10 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
9 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
8 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
23 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
21 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
20 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
19 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
18 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
24 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
3 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.035211 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
2 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.035211 0.000000 0.038732 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.038732 0.000000 0.031690 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.031690 0.000000 0.021127 0.000000 0.000000 0.000000 0.000000 0.000000
26 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.021127 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
25 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.007042 0.000000 0.000000 0.000000
11 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.007042 0.000000 0.024648 0.000000 0.000000
12 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.024648 0.000000 0.028169 0.000000
13 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.028169 0.000000 0.010563
14 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.010563 0.000000

29 rows × 29 columns

Replica exchange graph

The mixing matrix tells a story of how well various interfaces are connected to other interfaces. The replica exchange graph is essentially a visualization of the mixing matrix (actually, of the transition matrix -- the mixing matrix is a symmetrized version of the transition matrix).

Note: We're still developing better layout tools to visualize these.


In [29]:
repxG = paths.ReplicaNetworkGraph(repx_net)
repxG.draw('spring')


Replica exchange flow

Replica flow is defined as TODO

Flow is designed for calculations where the replica exchange graph is linear, which ours clearly is not. However, we can define the flow over a subset of the interfaces.

Replica move history tree


In [30]:
import openpathsampling.visualize as vis
reload(vis)
from IPython.display import SVG

In [38]:
tree = vis.PathTree(
    [step for step in storage.steps if not isinstance(step.change, paths.EmptyPathMoveChange)],
    vis.ReplicaEvolution(replica=3, accepted=False)
)
tree.options.css['width'] = 'inherit'

SVG(tree.svg())


Out[38]:
+R+FRBBFFBFRBRBFBRBFRFRFBRRFFRBFBRBBF++RBFcorstep*11829615016119724326227832433537539642245351953055059061361762763166166767068069371977487689690696198999610231034104210561070

In [37]:
decorrelated = tree.generator.decorrelated
print "We have " + str(len(decorrelated)) + " decorrelated trajectories."


We have 2 decorrelated trajectories.

In [ ]:

Visualizing trajectories

Histogramming data (TODO)


In [ ]: