westpa 2022.10__cp312-cp312-macosx_10_9_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of westpa might be problematic. Click here for more details.
- westpa/__init__.py +14 -0
- westpa/_version.py +21 -0
- westpa/analysis/__init__.py +5 -0
- westpa/analysis/core.py +746 -0
- westpa/analysis/statistics.py +27 -0
- westpa/analysis/trajectories.py +360 -0
- westpa/cli/__init__.py +0 -0
- westpa/cli/core/__init__.py +0 -0
- westpa/cli/core/w_fork.py +152 -0
- westpa/cli/core/w_init.py +230 -0
- westpa/cli/core/w_run.py +77 -0
- westpa/cli/core/w_states.py +212 -0
- westpa/cli/core/w_succ.py +99 -0
- westpa/cli/core/w_truncate.py +59 -0
- westpa/cli/tools/__init__.py +0 -0
- westpa/cli/tools/ploterr.py +506 -0
- westpa/cli/tools/plothist.py +706 -0
- westpa/cli/tools/w_assign.py +596 -0
- westpa/cli/tools/w_bins.py +166 -0
- westpa/cli/tools/w_crawl.py +119 -0
- westpa/cli/tools/w_direct.py +547 -0
- westpa/cli/tools/w_dumpsegs.py +94 -0
- westpa/cli/tools/w_eddist.py +506 -0
- westpa/cli/tools/w_fluxanl.py +378 -0
- westpa/cli/tools/w_ipa.py +833 -0
- westpa/cli/tools/w_kinavg.py +127 -0
- westpa/cli/tools/w_kinetics.py +96 -0
- westpa/cli/tools/w_multi_west.py +414 -0
- westpa/cli/tools/w_ntop.py +213 -0
- westpa/cli/tools/w_pdist.py +515 -0
- westpa/cli/tools/w_postanalysis_matrix.py +82 -0
- westpa/cli/tools/w_postanalysis_reweight.py +53 -0
- westpa/cli/tools/w_red.py +486 -0
- westpa/cli/tools/w_reweight.py +780 -0
- westpa/cli/tools/w_select.py +226 -0
- westpa/cli/tools/w_stateprobs.py +111 -0
- westpa/cli/tools/w_trace.py +599 -0
- westpa/core/__init__.py +0 -0
- westpa/core/_rc.py +673 -0
- westpa/core/binning/__init__.py +55 -0
- westpa/core/binning/_assign.cpython-312-darwin.so +0 -0
- westpa/core/binning/assign.py +449 -0
- westpa/core/binning/binless.py +96 -0
- westpa/core/binning/binless_driver.py +54 -0
- westpa/core/binning/binless_manager.py +190 -0
- westpa/core/binning/bins.py +47 -0
- westpa/core/binning/mab.py +427 -0
- westpa/core/binning/mab_driver.py +54 -0
- westpa/core/binning/mab_manager.py +198 -0
- westpa/core/data_manager.py +1694 -0
- westpa/core/extloader.py +74 -0
- westpa/core/h5io.py +995 -0
- westpa/core/kinetics/__init__.py +24 -0
- westpa/core/kinetics/_kinetics.cpython-312-darwin.so +0 -0
- westpa/core/kinetics/events.py +147 -0
- westpa/core/kinetics/matrates.py +156 -0
- westpa/core/kinetics/rate_averaging.py +266 -0
- westpa/core/progress.py +218 -0
- westpa/core/propagators/__init__.py +54 -0
- westpa/core/propagators/executable.py +715 -0
- westpa/core/reweight/__init__.py +14 -0
- westpa/core/reweight/_reweight.cpython-312-darwin.so +0 -0
- westpa/core/reweight/matrix.py +126 -0
- westpa/core/segment.py +119 -0
- westpa/core/sim_manager.py +830 -0
- westpa/core/states.py +359 -0
- westpa/core/systems.py +93 -0
- westpa/core/textio.py +74 -0
- westpa/core/trajectory.py +330 -0
- westpa/core/we_driver.py +908 -0
- westpa/core/wm_ops.py +43 -0
- westpa/core/yamlcfg.py +391 -0
- westpa/fasthist/__init__.py +34 -0
- westpa/fasthist/__main__.py +110 -0
- westpa/fasthist/_fasthist.cpython-312-darwin.so +0 -0
- westpa/mclib/__init__.py +264 -0
- westpa/mclib/__main__.py +28 -0
- westpa/mclib/_mclib.cpython-312-darwin.so +0 -0
- westpa/oldtools/__init__.py +4 -0
- westpa/oldtools/aframe/__init__.py +35 -0
- westpa/oldtools/aframe/atool.py +75 -0
- westpa/oldtools/aframe/base_mixin.py +26 -0
- westpa/oldtools/aframe/binning.py +178 -0
- westpa/oldtools/aframe/data_reader.py +560 -0
- westpa/oldtools/aframe/iter_range.py +200 -0
- westpa/oldtools/aframe/kinetics.py +117 -0
- westpa/oldtools/aframe/mcbs.py +146 -0
- westpa/oldtools/aframe/output.py +39 -0
- westpa/oldtools/aframe/plotting.py +90 -0
- westpa/oldtools/aframe/trajwalker.py +126 -0
- westpa/oldtools/aframe/transitions.py +469 -0
- westpa/oldtools/cmds/__init__.py +0 -0
- westpa/oldtools/cmds/w_ttimes.py +358 -0
- westpa/oldtools/files.py +34 -0
- westpa/oldtools/miscfn.py +23 -0
- westpa/oldtools/stats/__init__.py +4 -0
- westpa/oldtools/stats/accumulator.py +35 -0
- westpa/oldtools/stats/edfs.py +129 -0
- westpa/oldtools/stats/mcbs.py +89 -0
- westpa/tools/__init__.py +33 -0
- westpa/tools/binning.py +472 -0
- westpa/tools/core.py +340 -0
- westpa/tools/data_reader.py +159 -0
- westpa/tools/dtypes.py +31 -0
- westpa/tools/iter_range.py +198 -0
- westpa/tools/kinetics_tool.py +340 -0
- westpa/tools/plot.py +283 -0
- westpa/tools/progress.py +17 -0
- westpa/tools/selected_segs.py +154 -0
- westpa/tools/wipi.py +751 -0
- westpa/trajtree/__init__.py +4 -0
- westpa/trajtree/_trajtree.cpython-312-darwin.so +0 -0
- westpa/trajtree/trajtree.py +117 -0
- westpa/westext/__init__.py +0 -0
- westpa/westext/adaptvoronoi/__init__.py +3 -0
- westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
- westpa/westext/hamsm_restarting/__init__.py +3 -0
- westpa/westext/hamsm_restarting/example_overrides.py +35 -0
- westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
- westpa/westext/stringmethod/__init__.py +11 -0
- westpa/westext/stringmethod/fourier_fitting.py +69 -0
- westpa/westext/stringmethod/string_driver.py +253 -0
- westpa/westext/stringmethod/string_method.py +306 -0
- westpa/westext/weed/BinCluster.py +180 -0
- westpa/westext/weed/ProbAdjustEquil.py +100 -0
- westpa/westext/weed/UncertMath.py +247 -0
- westpa/westext/weed/__init__.py +10 -0
- westpa/westext/weed/weed_driver.py +182 -0
- westpa/westext/wess/ProbAdjust.py +101 -0
- westpa/westext/wess/__init__.py +6 -0
- westpa/westext/wess/wess_driver.py +207 -0
- westpa/work_managers/__init__.py +57 -0
- westpa/work_managers/core.py +396 -0
- westpa/work_managers/environment.py +134 -0
- westpa/work_managers/mpi.py +318 -0
- westpa/work_managers/processes.py +187 -0
- westpa/work_managers/serial.py +28 -0
- westpa/work_managers/threads.py +79 -0
- westpa/work_managers/zeromq/__init__.py +20 -0
- westpa/work_managers/zeromq/core.py +641 -0
- westpa/work_managers/zeromq/node.py +131 -0
- westpa/work_managers/zeromq/work_manager.py +526 -0
- westpa/work_managers/zeromq/worker.py +320 -0
- westpa-2022.10.dist-info/AUTHORS +22 -0
- westpa-2022.10.dist-info/LICENSE +21 -0
- westpa-2022.10.dist-info/METADATA +183 -0
- westpa-2022.10.dist-info/RECORD +150 -0
- westpa-2022.10.dist-info/WHEEL +5 -0
- westpa-2022.10.dist-info/entry_points.txt +29 -0
- westpa-2022.10.dist-info/top_level.txt +1 -0
|
Binary file
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import collections
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
import westpa
|
|
6
|
+
from westpa.tools.selected_segs import AllSegmentSelection
|
|
7
|
+
from . import _trajtree
|
|
8
|
+
from ._trajtree import _trajtree_base # @UnresolvedImport
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
trajnode = collections.namedtuple('trajnode', ('n_iter', 'seg_id'))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TrajTreeSet(_trajtree_base):
|
|
15
|
+
def __init__(self, segsel=None, data_manager=None):
|
|
16
|
+
self.data_manager = data_manager or westpa.rc.get_data_manager()
|
|
17
|
+
self.segsel = segsel or AllSegmentSelection(data_manager=self.data_manager)
|
|
18
|
+
self._build_table(self.segsel, self.data_manager)
|
|
19
|
+
|
|
20
|
+
def __len__(self):
|
|
21
|
+
return len(self.trajtable)
|
|
22
|
+
|
|
23
|
+
def get_roots(self):
|
|
24
|
+
return self.trajtable[self.trajtable['parent_offset'] == -1]
|
|
25
|
+
# return [trajnode(root['n_iter'], root['seg_id']) for root in self._get_roots()]
|
|
26
|
+
|
|
27
|
+
def get_root_indices(self):
|
|
28
|
+
return np.squeeze(np.argwhere(self.trajtable['parent_offset'] == -1))
|
|
29
|
+
|
|
30
|
+
def trace_trajectories(self, visit, get_visitor_state=None, set_visitor_state=None, vargs=None, vkwargs=None):
|
|
31
|
+
if (get_visitor_state or set_visitor_state) and not (get_visitor_state and set_visitor_state):
|
|
32
|
+
raise ValueError('either both or neither of get_visitor_state and set_visitor_state must be specified')
|
|
33
|
+
|
|
34
|
+
vargs = vargs or ()
|
|
35
|
+
vkwargs = vkwargs or {}
|
|
36
|
+
n_visits = 0
|
|
37
|
+
|
|
38
|
+
trajtable = self.trajtable
|
|
39
|
+
|
|
40
|
+
roots = collections.deque(self.get_root_indices())
|
|
41
|
+
print('Examining {:d} roots'.format(len(roots)))
|
|
42
|
+
state_stack = collections.deque([{'subtrees': roots, 'vstate': get_visitor_state() if get_visitor_state else None}])
|
|
43
|
+
while state_stack:
|
|
44
|
+
state = state_stack.pop()
|
|
45
|
+
subtrees = state['subtrees']
|
|
46
|
+
if set_visitor_state:
|
|
47
|
+
set_visitor_state(state['vstate'])
|
|
48
|
+
|
|
49
|
+
while subtrees:
|
|
50
|
+
index = subtrees.popleft()
|
|
51
|
+
node = trajtable[index]
|
|
52
|
+
|
|
53
|
+
state_stack.append({'subtrees': subtrees, 'vstate': get_visitor_state() if get_visitor_state else None})
|
|
54
|
+
|
|
55
|
+
subtrees = collections.deque(self.get_child_indices(index))
|
|
56
|
+
|
|
57
|
+
n_visits += 1
|
|
58
|
+
try:
|
|
59
|
+
visit(node['n_iter'], node['seg_id'], node['weight'], has_children=(len(subtrees) > 0), *vargs, **vkwargs)
|
|
60
|
+
except StopIteration:
|
|
61
|
+
subtrees = collections.deque()
|
|
62
|
+
continue # to next sibling
|
|
63
|
+
|
|
64
|
+
return n_visits
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class FakeTrajTreeSet(TrajTreeSet):
|
|
68
|
+
def __init__(self):
|
|
69
|
+
# _tt_dtype = np.dtype([('n_iter', np.uint32),
|
|
70
|
+
# ('seg_id', np.int64),
|
|
71
|
+
# ('parent_id', np.int64),
|
|
72
|
+
# ('parent_offset', np.int64), # offset of parent segment into this table
|
|
73
|
+
# ('weight', np.float64)]) # weight of this segment
|
|
74
|
+
|
|
75
|
+
self.trajtable = np.array(
|
|
76
|
+
[
|
|
77
|
+
(1, 1, -1, -1, 1.0), # 0
|
|
78
|
+
(1, 11, -1, -1, 1.0), # 1
|
|
79
|
+
(2, 2, 1, 0, 1.0), # 2
|
|
80
|
+
(2, 3, 1, 0, 1.0), # 3
|
|
81
|
+
(2, 4, 1, 0, 1.0), # 4
|
|
82
|
+
(2, 12, 11, 1, 1.0), # 5
|
|
83
|
+
(2, 13, 11, 1, 1.0), # 6
|
|
84
|
+
(3, 5, 2, 2, 1.0), # 7
|
|
85
|
+
(3, 6, 3, 3, 1.0), # 8
|
|
86
|
+
(3, 7, 4, 4, 1.0), # 9
|
|
87
|
+
(3, 8, 4, 4, 1.0), # 10
|
|
88
|
+
(3, 14, 12, 5, 1.0), # 11
|
|
89
|
+
(3, 15, 12, 5, 1.0), # 12
|
|
90
|
+
(4, 9, 5, 7, 1.0), # 13
|
|
91
|
+
(4, 10, 5, 7, 1.0), # 14
|
|
92
|
+
],
|
|
93
|
+
dtype=_trajtree._tt_dtype,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
empty_array = np.array([])
|
|
97
|
+
self.childtable = np.array(
|
|
98
|
+
[
|
|
99
|
+
np.array([2, 3, 4]), # segment 1
|
|
100
|
+
np.array([5, 6]), # segment 11
|
|
101
|
+
np.array([7]), # segment 2
|
|
102
|
+
np.array([8]), # segment 3
|
|
103
|
+
np.array([9, 10]), # segment 4
|
|
104
|
+
np.array([11, 12]), # segment 12
|
|
105
|
+
empty_array, # segment 13
|
|
106
|
+
np.array([13, 14]), # segment 5
|
|
107
|
+
empty_array, # segment 6
|
|
108
|
+
empty_array, # segment 7
|
|
109
|
+
empty_array, # segment 8
|
|
110
|
+
empty_array, # segment 14
|
|
111
|
+
empty_array, # segment 15
|
|
112
|
+
empty_array, # segment 9
|
|
113
|
+
empty_array, # segment 10
|
|
114
|
+
],
|
|
115
|
+
dtype=np.object_,
|
|
116
|
+
)
|
|
117
|
+
self.iter_offsets = {1: 0, 2: 2, 3: 7, 4: 13}
|
|
File without changes
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
import westpa
|
|
6
|
+
from westpa.core import extloader
|
|
7
|
+
from westpa.core.yamlcfg import check_bool, ConfigItemMissing
|
|
8
|
+
from westpa.core.binning import VoronoiBinMapper
|
|
9
|
+
|
|
10
|
+
log = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AdaptiveVoronoiDriver:
|
|
14
|
+
'''
|
|
15
|
+
This plugin implements an adaptive scheme using voronoi bins from
|
|
16
|
+
Zhang 2010, J Chem Phys, 132. The options exposed to the configuration
|
|
17
|
+
file are:
|
|
18
|
+
|
|
19
|
+
- av_enabled (bool, default False): Enables adaptive binning
|
|
20
|
+
- max_centers (int, default 10): The maximum number of voronoi centers to be placed
|
|
21
|
+
- walk_count (integer, default 5): Number of walkers per voronoi center
|
|
22
|
+
- center_freq (ingeter, default 1): Frequency of center placement
|
|
23
|
+
- priority (integer, default 1): Priority in the plugin order
|
|
24
|
+
- dfunc_method (function, non-optional, no default): Non-optional user defined
|
|
25
|
+
function that will be used to calculate distances between voronoi centers and
|
|
26
|
+
data points
|
|
27
|
+
- mapper_func (function, optional): Optional user defined function for building bin
|
|
28
|
+
mappers for more complicated binning schemes e.g. embedding the voronoi binning
|
|
29
|
+
in a portion of the state space. If not defined the plugin will build a
|
|
30
|
+
VoronoiBinMapper with the information it has.
|
|
31
|
+
'''
|
|
32
|
+
|
|
33
|
+
def __init__(self, sim_manager, plugin_config):
|
|
34
|
+
if not sim_manager.work_manager.is_master:
|
|
35
|
+
return
|
|
36
|
+
|
|
37
|
+
self.sim_manager = sim_manager
|
|
38
|
+
self.data_manager = sim_manager.data_manager
|
|
39
|
+
self.system = sim_manager.system
|
|
40
|
+
|
|
41
|
+
# Parameters from config file
|
|
42
|
+
# this enables the adaptive voronoi, allows turning adaptive scheme off
|
|
43
|
+
self.doAdaptiveVoronoi = check_bool(plugin_config.get('av_enabled', False))
|
|
44
|
+
# sets maximim number of centers/voronoi bins
|
|
45
|
+
self.max_centers = plugin_config.get('max_centers', 10)
|
|
46
|
+
# sets number of walkers per bin/voronoi center
|
|
47
|
+
self.walk_count = plugin_config.get('walk_count', 5)
|
|
48
|
+
# center placement frequency in number of iterations
|
|
49
|
+
self.center_freq = plugin_config.get('center_freq', 1)
|
|
50
|
+
# priority of the plugin (allows for order of execution)
|
|
51
|
+
self.priority = plugin_config.get('priority', 0)
|
|
52
|
+
# pulls the distance function that will be used by the plugin
|
|
53
|
+
self.dfunc = self.get_dfunc_method(plugin_config)
|
|
54
|
+
# pulls a user defined function to build the next bin mapper
|
|
55
|
+
self.mapper_func = self.get_mapper_func(plugin_config)
|
|
56
|
+
|
|
57
|
+
# Get initial set of Voronoi centers
|
|
58
|
+
self.centers = self.get_initial_centers()
|
|
59
|
+
self.ncenters = len(self.centers)
|
|
60
|
+
|
|
61
|
+
# Update the BinMapper
|
|
62
|
+
self.update_bin_mapper()
|
|
63
|
+
|
|
64
|
+
westpa.rc.pstatus('-adaptive voronoi mapping --------------\n')
|
|
65
|
+
westpa.rc.pstatus('enabled: {}\n'.format(self.doAdaptiveVoronoi))
|
|
66
|
+
westpa.rc.pstatus('max centers: {}\n'.format(self.max_centers))
|
|
67
|
+
westpa.rc.pstatus('center adding freq: {}\n'.format(self.center_freq))
|
|
68
|
+
westpa.rc.pstatus('centers: {}\n'.format(self.centers))
|
|
69
|
+
westpa.rc.pstatus('----------------------------------------\n')
|
|
70
|
+
westpa.rc.pflush()
|
|
71
|
+
|
|
72
|
+
# Register callback
|
|
73
|
+
if self.doAdaptiveVoronoi:
|
|
74
|
+
sim_manager.register_callback(sim_manager.prepare_new_iteration, self.prepare_new_iteration, self.priority)
|
|
75
|
+
|
|
76
|
+
def dfunc(self):
|
|
77
|
+
'''
|
|
78
|
+
Distance function to be used by the plugin. This function
|
|
79
|
+
will be used to calculate the distance between each point.
|
|
80
|
+
'''
|
|
81
|
+
raise NotImplementedError
|
|
82
|
+
|
|
83
|
+
def get_dfunc_method(self, plugin_config):
|
|
84
|
+
try:
|
|
85
|
+
methodname = plugin_config['dfunc_method']
|
|
86
|
+
except KeyError:
|
|
87
|
+
raise ConfigItemMissing('dfunc_method')
|
|
88
|
+
|
|
89
|
+
dfunc_method = extloader.get_object(methodname)
|
|
90
|
+
|
|
91
|
+
log.info('loaded adaptive voronoi dfunc method {!r}'.format(dfunc_method))
|
|
92
|
+
|
|
93
|
+
return dfunc_method
|
|
94
|
+
|
|
95
|
+
def get_mapper_func(self, plugin_config):
|
|
96
|
+
try:
|
|
97
|
+
methodname = plugin_config['mapper_func']
|
|
98
|
+
except KeyError:
|
|
99
|
+
return False
|
|
100
|
+
|
|
101
|
+
mapper_func = extloader.get_object(methodname)
|
|
102
|
+
|
|
103
|
+
log.info('loaded adaptive voronoi mapper function {!r}'.format(mapper_func))
|
|
104
|
+
|
|
105
|
+
return mapper_func
|
|
106
|
+
|
|
107
|
+
def get_initial_centers(self):
|
|
108
|
+
'''
|
|
109
|
+
This function pulls from the centers from either the
|
|
110
|
+
previous bin mapper or uses the definition from the
|
|
111
|
+
system to calculate the number of centers
|
|
112
|
+
'''
|
|
113
|
+
self.data_manager.open_backing()
|
|
114
|
+
|
|
115
|
+
with self.data_manager.lock:
|
|
116
|
+
n_iter = max(self.data_manager.current_iteration - 1, 1)
|
|
117
|
+
iter_group = self.data_manager.get_iter_group(n_iter)
|
|
118
|
+
|
|
119
|
+
# First attempt to initialize voronoi centers
|
|
120
|
+
# from data rather than system
|
|
121
|
+
centers = None
|
|
122
|
+
try:
|
|
123
|
+
log.info('Voronoi centers from previous bin mapper')
|
|
124
|
+
binhash = iter_group.attrs['binhash']
|
|
125
|
+
bin_mapper = self.data_manager.get_bin_mapper(binhash)
|
|
126
|
+
|
|
127
|
+
centers = bin_mapper.centers
|
|
128
|
+
|
|
129
|
+
except Exception:
|
|
130
|
+
log.warning(
|
|
131
|
+
'Initializing voronoi centers from data failed; \
|
|
132
|
+
Using definition in system instead.'
|
|
133
|
+
)
|
|
134
|
+
centers = self.system.bin_mapper.centers
|
|
135
|
+
|
|
136
|
+
self.data_manager.close_backing()
|
|
137
|
+
return centers
|
|
138
|
+
|
|
139
|
+
def update_bin_mapper(self):
|
|
140
|
+
'''Update the bin_mapper using the current set of voronoi centers'''
|
|
141
|
+
|
|
142
|
+
westpa.rc.pstatus('westext.adaptvoronoi: Updating bin mapper\n')
|
|
143
|
+
westpa.rc.pflush()
|
|
144
|
+
|
|
145
|
+
# self.mapper_func = plugin_config.get('mapper_func', False)
|
|
146
|
+
try:
|
|
147
|
+
dfargs = getattr(self.system, 'dfargs', None)
|
|
148
|
+
dfkwargs = getattr(self.system, 'dfkwargs', None)
|
|
149
|
+
if self.mapper_func:
|
|
150
|
+
# The mapper should take in 1) distance function,
|
|
151
|
+
# 2) centers, 3) dfargs, 4) dfkwargs and return
|
|
152
|
+
# the mapper we want
|
|
153
|
+
self.system.bin_mapper = self.mapper_func(self.dfunc, self.centers, dfargs=dfargs, dfkwargs=dfkwargs)
|
|
154
|
+
else:
|
|
155
|
+
self.system.bin_mapper = VoronoiBinMapper(self.dfunc, self.centers, dfargs=dfargs, dfkwargs=dfkwargs)
|
|
156
|
+
self.ncenters = self.system.bin_mapper.nbins
|
|
157
|
+
new_target_counts = np.empty((self.ncenters,), int)
|
|
158
|
+
new_target_counts[...] = self.walk_count
|
|
159
|
+
self.system.bin_target_counts = new_target_counts
|
|
160
|
+
except (ValueError, TypeError) as e:
|
|
161
|
+
log.error(
|
|
162
|
+
'AdaptiveVoronoiDriver Error: \
|
|
163
|
+
Failed updating the bin mapper: {}'.format(
|
|
164
|
+
e
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
raise
|
|
168
|
+
|
|
169
|
+
def update_centers(self, iter_group):
|
|
170
|
+
'''
|
|
171
|
+
Update the set of Voronoi centers according to
|
|
172
|
+
Zhang 2010, J Chem Phys, 132. A short description
|
|
173
|
+
of the algorithm can be found in the text:
|
|
174
|
+
|
|
175
|
+
1) First reference structure is chosen randomly from
|
|
176
|
+
the first set of given structure
|
|
177
|
+
2) Given a set of n reference structures, for each
|
|
178
|
+
configuration in the iteration the distances to each
|
|
179
|
+
reference structure is calculated and the minimum
|
|
180
|
+
distance is found
|
|
181
|
+
3) The configuration with the minimum distance is
|
|
182
|
+
selected as the next reference
|
|
183
|
+
'''
|
|
184
|
+
|
|
185
|
+
westpa.rc.pstatus('westext.adaptvoronoi: Updating Voronoi centers\n')
|
|
186
|
+
westpa.rc.pflush()
|
|
187
|
+
|
|
188
|
+
# Pull the current coordinates to find distances
|
|
189
|
+
curr_pcoords = iter_group['pcoord']
|
|
190
|
+
# Initialize distance array
|
|
191
|
+
dists = np.zeros(curr_pcoords.shape[0])
|
|
192
|
+
for iwalk, walk in enumerate(curr_pcoords):
|
|
193
|
+
# Calculate distances using the provided function
|
|
194
|
+
# and find the distance to the closest center
|
|
195
|
+
dists[iwalk] = min(self.dfunc(walk[-1], self.centers))
|
|
196
|
+
# Find the maximum of the minimum distances
|
|
197
|
+
max_ind = np.where(dists == dists.max())
|
|
198
|
+
# Use the maximum progress coordinate as our next center
|
|
199
|
+
self.centers = np.vstack((self.centers, curr_pcoords[max_ind[0][0]][-1]))
|
|
200
|
+
|
|
201
|
+
def prepare_new_iteration(self):
|
|
202
|
+
n_iter = self.sim_manager.n_iter
|
|
203
|
+
|
|
204
|
+
with self.data_manager.lock:
|
|
205
|
+
iter_group = self.data_manager.get_iter_group(n_iter)
|
|
206
|
+
|
|
207
|
+
# Check if we are at the correct frequency for updating the bin mapper
|
|
208
|
+
if n_iter % self.center_freq == 0:
|
|
209
|
+
# Check if we still need to add more centers
|
|
210
|
+
if self.ncenters < self.max_centers:
|
|
211
|
+
# First find the center to add
|
|
212
|
+
self.update_centers(iter_group)
|
|
213
|
+
# Update the bin mapper with the new center
|
|
214
|
+
self.update_bin_mapper()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from rich.logging import RichHandler
|
|
4
|
+
|
|
5
|
+
FORMAT = "%(message)s"
|
|
6
|
+
logging.basicConfig(level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()])
|
|
7
|
+
log = logging.getLogger("msm_we")
|
|
8
|
+
log.setLevel(logging.DEBUG)
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def processCoordinates(self, coords):
|
|
14
|
+
log.debug("Processing coordinates")
|
|
15
|
+
|
|
16
|
+
if self.dimReduceMethod == "none":
|
|
17
|
+
nC = np.shape(coords)
|
|
18
|
+
nC = nC[0]
|
|
19
|
+
data = coords.reshape(nC, 3 * self.nAtoms)
|
|
20
|
+
return data
|
|
21
|
+
|
|
22
|
+
if self.dimReduceMethod == "pca" or self.dimReduceMethod == "vamp":
|
|
23
|
+
### NaCl dimensionality reduction
|
|
24
|
+
log.warning("Hardcoded selection: Doing dim reduction for Na, Cl. This is only for testing!")
|
|
25
|
+
indNA = self.reference_structure.topology.select("element Na")
|
|
26
|
+
indCL = self.reference_structure.topology.select("element Cl")
|
|
27
|
+
|
|
28
|
+
diff = np.subtract(coords[:, indNA], coords[:, indCL])
|
|
29
|
+
|
|
30
|
+
dist = np.array(np.sqrt(np.mean(np.power(diff, 2), axis=-1)))
|
|
31
|
+
|
|
32
|
+
return dist
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
log.info("Loading user-override functions for modelWE")
|