westpa 2022.13__cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.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.
Files changed (162) hide show
  1. westpa/__init__.py +14 -0
  2. westpa/_version.py +21 -0
  3. westpa/analysis/__init__.py +5 -0
  4. westpa/analysis/core.py +749 -0
  5. westpa/analysis/statistics.py +27 -0
  6. westpa/analysis/trajectories.py +369 -0
  7. westpa/cli/__init__.py +0 -0
  8. westpa/cli/core/__init__.py +0 -0
  9. westpa/cli/core/w_fork.py +152 -0
  10. westpa/cli/core/w_init.py +230 -0
  11. westpa/cli/core/w_run.py +77 -0
  12. westpa/cli/core/w_states.py +212 -0
  13. westpa/cli/core/w_succ.py +99 -0
  14. westpa/cli/core/w_truncate.py +68 -0
  15. westpa/cli/tools/__init__.py +0 -0
  16. westpa/cli/tools/ploterr.py +506 -0
  17. westpa/cli/tools/plothist.py +706 -0
  18. westpa/cli/tools/w_assign.py +597 -0
  19. westpa/cli/tools/w_bins.py +166 -0
  20. westpa/cli/tools/w_crawl.py +119 -0
  21. westpa/cli/tools/w_direct.py +557 -0
  22. westpa/cli/tools/w_dumpsegs.py +94 -0
  23. westpa/cli/tools/w_eddist.py +506 -0
  24. westpa/cli/tools/w_fluxanl.py +376 -0
  25. westpa/cli/tools/w_ipa.py +832 -0
  26. westpa/cli/tools/w_kinavg.py +127 -0
  27. westpa/cli/tools/w_kinetics.py +96 -0
  28. westpa/cli/tools/w_multi_west.py +414 -0
  29. westpa/cli/tools/w_ntop.py +213 -0
  30. westpa/cli/tools/w_pdist.py +515 -0
  31. westpa/cli/tools/w_postanalysis_matrix.py +82 -0
  32. westpa/cli/tools/w_postanalysis_reweight.py +53 -0
  33. westpa/cli/tools/w_red.py +491 -0
  34. westpa/cli/tools/w_reweight.py +780 -0
  35. westpa/cli/tools/w_select.py +226 -0
  36. westpa/cli/tools/w_stateprobs.py +111 -0
  37. westpa/cli/tools/w_timings.py +113 -0
  38. westpa/cli/tools/w_trace.py +599 -0
  39. westpa/core/__init__.py +0 -0
  40. westpa/core/_rc.py +673 -0
  41. westpa/core/binning/__init__.py +55 -0
  42. westpa/core/binning/_assign.c +36018 -0
  43. westpa/core/binning/_assign.cpython-312-aarch64-linux-gnu.so +0 -0
  44. westpa/core/binning/_assign.pyx +370 -0
  45. westpa/core/binning/assign.py +454 -0
  46. westpa/core/binning/binless.py +96 -0
  47. westpa/core/binning/binless_driver.py +54 -0
  48. westpa/core/binning/binless_manager.py +189 -0
  49. westpa/core/binning/bins.py +47 -0
  50. westpa/core/binning/mab.py +506 -0
  51. westpa/core/binning/mab_driver.py +54 -0
  52. westpa/core/binning/mab_manager.py +197 -0
  53. westpa/core/data_manager.py +1761 -0
  54. westpa/core/extloader.py +74 -0
  55. westpa/core/h5io.py +1079 -0
  56. westpa/core/kinetics/__init__.py +24 -0
  57. westpa/core/kinetics/_kinetics.c +45174 -0
  58. westpa/core/kinetics/_kinetics.cpython-312-aarch64-linux-gnu.so +0 -0
  59. westpa/core/kinetics/_kinetics.pyx +815 -0
  60. westpa/core/kinetics/events.py +147 -0
  61. westpa/core/kinetics/matrates.py +156 -0
  62. westpa/core/kinetics/rate_averaging.py +266 -0
  63. westpa/core/progress.py +218 -0
  64. westpa/core/propagators/__init__.py +54 -0
  65. westpa/core/propagators/executable.py +592 -0
  66. westpa/core/propagators/loaders.py +196 -0
  67. westpa/core/reweight/__init__.py +14 -0
  68. westpa/core/reweight/_reweight.c +36899 -0
  69. westpa/core/reweight/_reweight.cpython-312-aarch64-linux-gnu.so +0 -0
  70. westpa/core/reweight/_reweight.pyx +439 -0
  71. westpa/core/reweight/matrix.py +126 -0
  72. westpa/core/segment.py +119 -0
  73. westpa/core/sim_manager.py +839 -0
  74. westpa/core/states.py +359 -0
  75. westpa/core/systems.py +93 -0
  76. westpa/core/textio.py +74 -0
  77. westpa/core/trajectory.py +603 -0
  78. westpa/core/we_driver.py +910 -0
  79. westpa/core/wm_ops.py +43 -0
  80. westpa/core/yamlcfg.py +298 -0
  81. westpa/fasthist/__init__.py +34 -0
  82. westpa/fasthist/_fasthist.c +38755 -0
  83. westpa/fasthist/_fasthist.cpython-312-aarch64-linux-gnu.so +0 -0
  84. westpa/fasthist/_fasthist.pyx +222 -0
  85. westpa/mclib/__init__.py +271 -0
  86. westpa/mclib/__main__.py +28 -0
  87. westpa/mclib/_mclib.c +34610 -0
  88. westpa/mclib/_mclib.cpython-312-aarch64-linux-gnu.so +0 -0
  89. westpa/mclib/_mclib.pyx +226 -0
  90. westpa/oldtools/__init__.py +4 -0
  91. westpa/oldtools/aframe/__init__.py +35 -0
  92. westpa/oldtools/aframe/atool.py +75 -0
  93. westpa/oldtools/aframe/base_mixin.py +26 -0
  94. westpa/oldtools/aframe/binning.py +178 -0
  95. westpa/oldtools/aframe/data_reader.py +560 -0
  96. westpa/oldtools/aframe/iter_range.py +200 -0
  97. westpa/oldtools/aframe/kinetics.py +117 -0
  98. westpa/oldtools/aframe/mcbs.py +153 -0
  99. westpa/oldtools/aframe/output.py +39 -0
  100. westpa/oldtools/aframe/plotting.py +88 -0
  101. westpa/oldtools/aframe/trajwalker.py +126 -0
  102. westpa/oldtools/aframe/transitions.py +469 -0
  103. westpa/oldtools/cmds/__init__.py +0 -0
  104. westpa/oldtools/cmds/w_ttimes.py +361 -0
  105. westpa/oldtools/files.py +34 -0
  106. westpa/oldtools/miscfn.py +23 -0
  107. westpa/oldtools/stats/__init__.py +4 -0
  108. westpa/oldtools/stats/accumulator.py +35 -0
  109. westpa/oldtools/stats/edfs.py +129 -0
  110. westpa/oldtools/stats/mcbs.py +96 -0
  111. westpa/tools/__init__.py +33 -0
  112. westpa/tools/binning.py +472 -0
  113. westpa/tools/core.py +340 -0
  114. westpa/tools/data_reader.py +159 -0
  115. westpa/tools/dtypes.py +31 -0
  116. westpa/tools/iter_range.py +198 -0
  117. westpa/tools/kinetics_tool.py +343 -0
  118. westpa/tools/plot.py +283 -0
  119. westpa/tools/progress.py +17 -0
  120. westpa/tools/selected_segs.py +154 -0
  121. westpa/tools/wipi.py +751 -0
  122. westpa/trajtree/__init__.py +4 -0
  123. westpa/trajtree/_trajtree.c +17829 -0
  124. westpa/trajtree/_trajtree.cpython-312-aarch64-linux-gnu.so +0 -0
  125. westpa/trajtree/_trajtree.pyx +130 -0
  126. westpa/trajtree/trajtree.py +117 -0
  127. westpa/westext/__init__.py +0 -0
  128. westpa/westext/adaptvoronoi/__init__.py +3 -0
  129. westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
  130. westpa/westext/hamsm_restarting/__init__.py +3 -0
  131. westpa/westext/hamsm_restarting/example_overrides.py +35 -0
  132. westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
  133. westpa/westext/stringmethod/__init__.py +11 -0
  134. westpa/westext/stringmethod/fourier_fitting.py +69 -0
  135. westpa/westext/stringmethod/string_driver.py +253 -0
  136. westpa/westext/stringmethod/string_method.py +306 -0
  137. westpa/westext/weed/BinCluster.py +180 -0
  138. westpa/westext/weed/ProbAdjustEquil.py +100 -0
  139. westpa/westext/weed/UncertMath.py +247 -0
  140. westpa/westext/weed/__init__.py +10 -0
  141. westpa/westext/weed/weed_driver.py +192 -0
  142. westpa/westext/wess/ProbAdjust.py +101 -0
  143. westpa/westext/wess/__init__.py +6 -0
  144. westpa/westext/wess/wess_driver.py +217 -0
  145. westpa/work_managers/__init__.py +57 -0
  146. westpa/work_managers/core.py +396 -0
  147. westpa/work_managers/environment.py +134 -0
  148. westpa/work_managers/mpi.py +318 -0
  149. westpa/work_managers/processes.py +201 -0
  150. westpa/work_managers/serial.py +28 -0
  151. westpa/work_managers/threads.py +79 -0
  152. westpa/work_managers/zeromq/__init__.py +20 -0
  153. westpa/work_managers/zeromq/core.py +635 -0
  154. westpa/work_managers/zeromq/node.py +131 -0
  155. westpa/work_managers/zeromq/work_manager.py +526 -0
  156. westpa/work_managers/zeromq/worker.py +320 -0
  157. westpa-2022.13.dist-info/METADATA +179 -0
  158. westpa-2022.13.dist-info/RECORD +162 -0
  159. westpa-2022.13.dist-info/WHEEL +7 -0
  160. westpa-2022.13.dist-info/entry_points.txt +30 -0
  161. westpa-2022.13.dist-info/licenses/LICENSE +21 -0
  162. westpa-2022.13.dist-info/top_level.txt +1 -0
@@ -0,0 +1,189 @@
1
+ import logging
2
+
3
+ from westpa.core.binning.binless import BinlessMapper
4
+ from westpa.core.sim_manager import WESimManager, grouper
5
+ from westpa.core.states import InitialState, pare_basis_initial_states
6
+ from westpa.core import wm_ops
7
+ from westpa.core.segment import Segment
8
+ import numpy as np
9
+
10
+ log = logging.getLogger(__name__)
11
+
12
+
13
+ class BinlessSimManager(WESimManager):
14
+ def initialize_simulation(self, basis_states, target_states, start_states, segs_per_state=1, suppress_we=False):
15
+ if len(target_states) > 0:
16
+ if isinstance(self.system.bin_mapper, BinlessMapper):
17
+ log.error("BinlessMapper cannot be an outer binning scheme with a target state\n")
18
+
19
+ super().initialize_simulation(
20
+ basis_states, target_states, start_states, segs_per_state=segs_per_state, suppress_we=suppress_we
21
+ )
22
+
23
+ def propagate(self):
24
+ log.debug("BinlessManager in use")
25
+ segments = list(self.incomplete_segments.values())
26
+ log.debug('iteration {:d}: propagating {:d} segments'.format(self.n_iter, len(segments)))
27
+
28
+ # all futures dispatched for this iteration
29
+ futures = set()
30
+ segment_futures = set()
31
+
32
+ # Immediately dispatch any necessary initial state generation
33
+ istate_gen_futures = self.get_istate_futures()
34
+ futures.update(istate_gen_futures)
35
+
36
+ # Dispatch propagation tasks using work manager
37
+ for segment_block in grouper(self.propagator_block_size, segments):
38
+ segment_block = [_f for _f in segment_block if _f]
39
+ pbstates, pistates = pare_basis_initial_states(
40
+ self.current_iter_bstates, list(self.current_iter_istates.values()), segment_block
41
+ )
42
+ future = self.work_manager.submit(wm_ops.propagate, args=(pbstates, pistates, segment_block))
43
+ futures.add(future)
44
+ segment_futures.add(future)
45
+
46
+ while futures and self.work_manager.running:
47
+ future = self.work_manager.wait_any(futures)
48
+ futures.remove(future)
49
+
50
+ if future in segment_futures:
51
+ segment_futures.remove(future)
52
+ incoming = future.get_result()
53
+ self.n_propagated += 1
54
+
55
+ self.segments.update({segment.seg_id: segment for segment in incoming})
56
+ self.completed_segments.update({segment.seg_id: segment for segment in incoming})
57
+
58
+ new_istate_futures = self.get_istate_futures()
59
+ istate_gen_futures.update(new_istate_futures)
60
+ futures.update(new_istate_futures)
61
+
62
+ with self.data_manager.expiring_flushing_lock():
63
+ self.data_manager.update_segments(self.n_iter, incoming)
64
+
65
+ elif future in istate_gen_futures:
66
+ istate_gen_futures.remove(future)
67
+ _basis_state, initial_state = future.get_result()
68
+ log.debug('received newly-prepared initial state {!r}'.format(initial_state))
69
+ initial_state.istate_status = InitialState.ISTATE_STATUS_PREPARED
70
+ with self.data_manager.expiring_flushing_lock():
71
+ self.data_manager.update_initial_states([initial_state], n_iter=self.n_iter + 1)
72
+ self.we_driver.avail_initial_states[initial_state.state_id] = initial_state
73
+ else:
74
+ log.error('unknown future {!r} received from work manager'.format(future))
75
+ raise AssertionError('untracked future {!r}'.format(future))
76
+
77
+ # Collectively assign all segments to their bins...
78
+ self.we_driver.assign(self.segments.values())
79
+
80
+ # For cases where we need even more istates for recycled trajectories
81
+ # futures should be empty at this point.
82
+ istate_gen_futures = self.get_istate_futures()
83
+ futures.update(istate_gen_futures)
84
+
85
+ # Wait for istate_gen_futures and catch untracked futures.
86
+ while futures and self.work_manager.running:
87
+ future = self.work_manager.wait_any(futures)
88
+ futures.remove(future)
89
+
90
+ if future in istate_gen_futures:
91
+ istate_gen_futures.remove(future)
92
+ _basis_state, initial_state = future.get_result()
93
+ log.debug('received newly-prepared initial state {!r}'.format(initial_state))
94
+ initial_state.istate_status = InitialState.ISTATE_STATUS_PREPARED
95
+ with self.data_manager.expiring_flushing_lock():
96
+ self.data_manager.update_initial_states([initial_state], n_iter=self.n_iter + 1)
97
+ self.we_driver.avail_initial_states[initial_state.state_id] = initial_state
98
+ else:
99
+ log.error('unknown future {!r} received from work manager'.format(future))
100
+ raise AssertionError('untracked future {!r}'.format(future))
101
+
102
+ log.debug('done with propagation')
103
+ self.save_bin_data()
104
+ self.data_manager.flush_backing()
105
+
106
+ def prepare_iteration(self):
107
+ log.debug('beginning iteration {:d}'.format(self.n_iter))
108
+
109
+ # the WE driver needs a list of all target states for this iteration
110
+ # along with information about any new weights introduced (e.g. by recycling)
111
+ target_states = self.data_manager.get_target_states(self.n_iter)
112
+ new_weights = self.data_manager.get_new_weight_data(self.n_iter)
113
+
114
+ self.we_driver.new_iteration(target_states=target_states, new_weights=new_weights)
115
+
116
+ # Get basis states used in this iteration
117
+ self.current_iter_bstates = self.data_manager.get_basis_states(self.n_iter)
118
+
119
+ # Get the segments for this iteration and separate into complete and incomplete
120
+ if self.segments is None:
121
+ segments = self.segments = {segment.seg_id: segment for segment in self.data_manager.get_segments()}
122
+ log.debug('loaded {:d} segments'.format(len(segments)))
123
+ else:
124
+ segments = self.segments
125
+ log.debug('using {:d} pre-existing segments'.format(len(segments)))
126
+
127
+ completed_segments = self.completed_segments = {}
128
+ incomplete_segments = self.incomplete_segments = {}
129
+ for segment in segments.values():
130
+ if segment.status == Segment.SEG_STATUS_COMPLETE:
131
+ completed_segments[segment.seg_id] = segment
132
+ else:
133
+ incomplete_segments[segment.seg_id] = segment
134
+ log.debug('{:d} segments are complete; {:d} are incomplete'.format(len(completed_segments), len(incomplete_segments)))
135
+
136
+ if len(incomplete_segments) == len(segments):
137
+ # Starting a new iteration
138
+ self.rc.pstatus('Beginning iteration {:d}'.format(self.n_iter))
139
+ elif incomplete_segments:
140
+ self.rc.pstatus('Continuing iteration {:d}'.format(self.n_iter))
141
+ self.rc.pstatus(
142
+ '{:d} segments remain in iteration {:d} ({:d} total)'.format(len(incomplete_segments), self.n_iter, len(segments))
143
+ )
144
+
145
+ # Get the initial states active for this iteration (so that the propagator has them if necessary)
146
+ self.current_iter_istates = {
147
+ state.state_id: state for state in self.data_manager.get_segment_initial_states(list(segments.values()))
148
+ }
149
+ log.debug('This iteration uses {:d} initial states'.format(len(self.current_iter_istates)))
150
+
151
+ # Assign this iteration's segments' initial points to bins and report on bin population
152
+ initial_pcoords = self.system.new_pcoord_array(len(segments))
153
+ initial_binning = self.system.bin_mapper.construct_bins()
154
+ for iseg, segment in enumerate(segments.values()):
155
+ initial_pcoords[iseg] = segment.pcoord[0]
156
+ initial_assignments = self.system.bin_mapper.assign(initial_pcoords)
157
+ for segment, assignment in zip(iter(segments.values()), initial_assignments):
158
+ initial_binning[assignment].add(segment)
159
+ self.report_bin_statistics(initial_binning, [], save_summary=True)
160
+ del initial_pcoords, initial_binning
161
+
162
+ self.rc.pstatus("Binless scheme in use")
163
+
164
+ self.rc.pstatus("Waiting for segments to complete...")
165
+
166
+ # Let the WE driver assign completed segments
167
+ if completed_segments and len(incomplete_segments) == 0:
168
+ self.we_driver.assign(list(completed_segments.values()))
169
+
170
+ # load restart data
171
+ self.data_manager.prepare_segment_restarts(
172
+ incomplete_segments.values(), self.current_iter_bstates, self.current_iter_istates
173
+ )
174
+
175
+ # Get the basis states and initial states for the next iteration, necessary for doing on-the-fly recycling
176
+ self.next_iter_bstates = self.data_manager.get_basis_states(self.n_iter + 1)
177
+ self.next_iter_bstate_cprobs = np.add.accumulate([bstate.probability for bstate in self.next_iter_bstates])
178
+
179
+ self.we_driver.avail_initial_states = {
180
+ istate.state_id: istate for istate in self.data_manager.get_unused_initial_states(n_iter=self.n_iter + 1)
181
+ }
182
+ log.debug('{:d} unused initial states found'.format(len(self.we_driver.avail_initial_states)))
183
+
184
+ # Invoke callbacks
185
+ self.invoke_callbacks(self.prepare_iteration)
186
+
187
+ # dispatch and immediately wait on result for prep_iter
188
+ log.debug('dispatching propagator prep_iter to work manager')
189
+ self.work_manager.submit(wm_ops.prep_iter, args=(self.n_iter, segments)).get_result()
@@ -0,0 +1,47 @@
1
+ import logging
2
+
3
+ import numpy as np
4
+
5
+ log = logging.getLogger(__name__)
6
+
7
+ EPS = np.finfo(np.float64).eps
8
+
9
+
10
+ class Bin(set):
11
+ def __init__(self, iterable=None, label=None):
12
+ super().__init__(iterable or [])
13
+ self.label = label
14
+
15
+ def __repr__(self):
16
+ return '<{classname} at 0x{id:x}, label={label!r}, count={count:d}, weight={weight:g}>'.format(
17
+ classname=self.__class__.__name__, id=id(self), label=self.label, count=len(self), weight=self.weight
18
+ )
19
+
20
+ @property
21
+ def weight(self):
22
+ 'Total weight of all walkers in this bin'
23
+
24
+ weight = 0.0
25
+ for particle in self:
26
+ weight += particle.weight
27
+ return weight
28
+
29
+ def reweight(self, new_weight):
30
+ """Reweight all walkers in this bin so that the total weight is new_weight"""
31
+
32
+ if len(self) == 0 and new_weight == 0:
33
+ return
34
+
35
+ if len(self) == 0 and new_weight != 0:
36
+ raise ValueError('cannot reweight empty ParticleCollection')
37
+
38
+ current_weight = self.weight
39
+ log.debug('reweighting collection of {:d} particles from {:g} to {:g}'.format(len(self), current_weight, new_weight))
40
+ assert (new_weight == 0 and current_weight == 0) or new_weight > 0
41
+
42
+ wrat = new_weight / current_weight
43
+ for p in self:
44
+ p.weight *= wrat
45
+
46
+ log.debug('new weight: {:g}'.format(self.weight))
47
+ assert abs(new_weight - self.weight) <= EPS * len(self)