In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import openpathsampling as paths
import openpathsampling.storage as st
storage = st.AnalysisStorage("mstis.nc")
In [2]:
len(storage.steps)
Out[2]:
In [3]:
mstis = storage.networks.load(0)
retis = mstis.sampling_transitions[0]
scheme = storage.schemes[0]
In [4]:
sset0 = storage.samplesets[0]
numeric_labels = { s.ensemble : s.replica for s in sset0}
string_labels = { s.ensemble : str(s.replica) for s in sset0 }
numeric_to_string = { numeric_labels[e] : string_labels[e] for e in numeric_labels.keys()}
In [5]:
%%time
trace_1 = paths.trace_ensembles_for_replica(0, storage.steps)
In [6]:
plt.plot([numeric_labels[e] for e in trace_1])
Out[6]:
In [7]:
repx_net = paths.ReplicaNetwork(scheme, storage.steps)
print repx_net
In [8]:
flow = repx_net.flow(bottom=retis.minus_ensemble, top=retis.ensembles[-1])
print flow
In [9]:
flow_num = {numeric_labels[k] : flow[k] for k in flow.keys()}
print flow_num
In [10]:
sorted_vals = []
for k in sorted(flow_num.keys()):
sorted_vals.append(flow_num[k])
In [11]:
plt.plot(sorted(flow_num.keys()), sorted_vals)
Out[11]:
In [12]:
repx_net.trips(bottom=retis.minus_ensemble, top=retis.ensembles[-1])
Out[12]:
In [13]:
repx_net.transition_matrix()
Out[13]:
If you would like to set a different order, that can be done by providing a list of the ensembles in whatever order you choose:
In [14]:
import numpy as np
perm = np.random.permutation(len(mstis.all_ensembles))
print perm
In [15]:
order = [mstis.all_ensembles[p] for p in perm]
repx_net.transition_matrix(index_order=order)
Out[15]:
In [16]:
repx_net.mixing_matrix()
Out[16]:
In [17]:
repxG = paths.ReplicaNetworkGraph(repx_net)
In [18]:
# draw('graphviz') gives better results, but requires pygraphviz
repxG.draw('spring')
Blue is a minus interface, red is a normal interface. Multiple state outer interfaces (not in this example) would be green.
In [19]:
transitions = repx_net.transitions_from_traces(storage.steps)
In [20]:
for (k1, k2) in transitions.keys():
print numeric_labels[k1], numeric_labels[k2], transitions[(k1, k2)]
In [21]:
for (k1, k2) in repx_net.analysis['n_accepted'].keys():
print numeric_labels[k1], numeric_labels[k2], repx_net.analysis['n_accepted'][(k1, k2)]
In [ ]:
In [ ]: