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.
- westpa/__init__.py +14 -0
- westpa/_version.py +21 -0
- westpa/analysis/__init__.py +5 -0
- westpa/analysis/core.py +749 -0
- westpa/analysis/statistics.py +27 -0
- westpa/analysis/trajectories.py +369 -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 +68 -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 +597 -0
- westpa/cli/tools/w_bins.py +166 -0
- westpa/cli/tools/w_crawl.py +119 -0
- westpa/cli/tools/w_direct.py +557 -0
- westpa/cli/tools/w_dumpsegs.py +94 -0
- westpa/cli/tools/w_eddist.py +506 -0
- westpa/cli/tools/w_fluxanl.py +376 -0
- westpa/cli/tools/w_ipa.py +832 -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 +491 -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_timings.py +113 -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.c +36018 -0
- westpa/core/binning/_assign.cpython-312-aarch64-linux-gnu.so +0 -0
- westpa/core/binning/_assign.pyx +370 -0
- westpa/core/binning/assign.py +454 -0
- westpa/core/binning/binless.py +96 -0
- westpa/core/binning/binless_driver.py +54 -0
- westpa/core/binning/binless_manager.py +189 -0
- westpa/core/binning/bins.py +47 -0
- westpa/core/binning/mab.py +506 -0
- westpa/core/binning/mab_driver.py +54 -0
- westpa/core/binning/mab_manager.py +197 -0
- westpa/core/data_manager.py +1761 -0
- westpa/core/extloader.py +74 -0
- westpa/core/h5io.py +1079 -0
- westpa/core/kinetics/__init__.py +24 -0
- westpa/core/kinetics/_kinetics.c +45174 -0
- westpa/core/kinetics/_kinetics.cpython-312-aarch64-linux-gnu.so +0 -0
- westpa/core/kinetics/_kinetics.pyx +815 -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 +592 -0
- westpa/core/propagators/loaders.py +196 -0
- westpa/core/reweight/__init__.py +14 -0
- westpa/core/reweight/_reweight.c +36899 -0
- westpa/core/reweight/_reweight.cpython-312-aarch64-linux-gnu.so +0 -0
- westpa/core/reweight/_reweight.pyx +439 -0
- westpa/core/reweight/matrix.py +126 -0
- westpa/core/segment.py +119 -0
- westpa/core/sim_manager.py +839 -0
- westpa/core/states.py +359 -0
- westpa/core/systems.py +93 -0
- westpa/core/textio.py +74 -0
- westpa/core/trajectory.py +603 -0
- westpa/core/we_driver.py +910 -0
- westpa/core/wm_ops.py +43 -0
- westpa/core/yamlcfg.py +298 -0
- westpa/fasthist/__init__.py +34 -0
- westpa/fasthist/_fasthist.c +38755 -0
- westpa/fasthist/_fasthist.cpython-312-aarch64-linux-gnu.so +0 -0
- westpa/fasthist/_fasthist.pyx +222 -0
- westpa/mclib/__init__.py +271 -0
- westpa/mclib/__main__.py +28 -0
- westpa/mclib/_mclib.c +34610 -0
- westpa/mclib/_mclib.cpython-312-aarch64-linux-gnu.so +0 -0
- westpa/mclib/_mclib.pyx +226 -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 +153 -0
- westpa/oldtools/aframe/output.py +39 -0
- westpa/oldtools/aframe/plotting.py +88 -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 +361 -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 +96 -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 +343 -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.c +17829 -0
- westpa/trajtree/_trajtree.cpython-312-aarch64-linux-gnu.so +0 -0
- westpa/trajtree/_trajtree.pyx +130 -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 +192 -0
- westpa/westext/wess/ProbAdjust.py +101 -0
- westpa/westext/wess/__init__.py +6 -0
- westpa/westext/wess/wess_driver.py +217 -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 +201 -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 +635 -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.13.dist-info/METADATA +179 -0
- westpa-2022.13.dist-info/RECORD +162 -0
- westpa-2022.13.dist-info/WHEEL +7 -0
- westpa-2022.13.dist-info/entry_points.txt +30 -0
- westpa-2022.13.dist-info/licenses/LICENSE +21 -0
- westpa-2022.13.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import io
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
import westpa
|
|
9
|
+
|
|
10
|
+
from westpa.core.states import BasisState, TargetState
|
|
11
|
+
|
|
12
|
+
import westpa.work_managers as work_managers
|
|
13
|
+
from westpa.work_managers import make_work_manager
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger('w_init')
|
|
17
|
+
EPS = np.finfo(np.float64).eps
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def entry_point():
|
|
21
|
+
parser = argparse.ArgumentParser(
|
|
22
|
+
'w_init',
|
|
23
|
+
description='''\
|
|
24
|
+
Initialize a new WEST simulation, creating the WEST HDF5 file and preparing the first
|
|
25
|
+
iteration's segments.
|
|
26
|
+
|
|
27
|
+
Initial states are generated from one or more "basis states" which are specified either in a file specified with --bstates-from, or
|
|
28
|
+
by one or more "--bstate" arguments. If neither --bstates-from nor at least one "--bstate" argument is provided, then a default
|
|
29
|
+
basis state of probability one identified by the state ID zero and label "basis" will be created (a warning will be printed in this
|
|
30
|
+
case, to remind you of this behavior, in case it is not what you wanted).
|
|
31
|
+
|
|
32
|
+
Target states for (non-equilibrium) steady-state simulations are specified either in a file specified with --tstates-from, or
|
|
33
|
+
by one or more --tstate arguments. If neither --tstates-from nor at least one --tstate argument is provided, then an equilibrium
|
|
34
|
+
simulation (without any sinks) will be performed.
|
|
35
|
+
''',
|
|
36
|
+
)
|
|
37
|
+
westpa.rc.add_args(parser)
|
|
38
|
+
parser.add_argument('--force', dest='force', action='store_true', help='Overwrite any existing simulation data')
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
'--bstate-file',
|
|
41
|
+
'--bstates-from',
|
|
42
|
+
metavar='BSTATE_FILE',
|
|
43
|
+
help='Read basis state names, probabilities, and (optionally) data references from BSTATE_FILE.',
|
|
44
|
+
)
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
'--bstate',
|
|
47
|
+
action='append',
|
|
48
|
+
dest='bstates',
|
|
49
|
+
help='''Add the given basis state (specified as a string 'label,probability[,auxref]')
|
|
50
|
+
to the list of basis states (after those specified in --bstates-from, if any). This argument
|
|
51
|
+
may be specified more than once, in which case the given states are appended in the order
|
|
52
|
+
they are given on the command line.''',
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
'--tstate-file',
|
|
56
|
+
'--tstates-from',
|
|
57
|
+
metavar='TSTATE_FILE',
|
|
58
|
+
help='''Read target state names and representative progress coordinates from TSTATE_FILE. WESTPA uses the
|
|
59
|
+
representative progress coordinate of a target state and converts the **entire** bin
|
|
60
|
+
containing that progress coordinate into a recycling sink.''',
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
'--tstate',
|
|
64
|
+
action='append',
|
|
65
|
+
dest='tstates',
|
|
66
|
+
help='''Add the given target state (specified as a string 'label,pcoord0[,pcoord1[,...]]') to the
|
|
67
|
+
list of target states (after those specified in the file given by --tstates-from, if any).
|
|
68
|
+
This argument may be specified more than once, in which case the given states are appended
|
|
69
|
+
in the order they appear on the command line.''',
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
'--sstate-file',
|
|
74
|
+
'--sstates-from',
|
|
75
|
+
metavar='SSTATE_FILE',
|
|
76
|
+
help='Read start state names, probabilities, and (optionally) data references from SSTATE_FILE.',
|
|
77
|
+
)
|
|
78
|
+
parser.add_argument(
|
|
79
|
+
'--sstate',
|
|
80
|
+
action='append',
|
|
81
|
+
dest='sstates',
|
|
82
|
+
help='''Add the given start state (specified as a string 'label,probability[,auxref]')
|
|
83
|
+
to the list of start states (after those specified in --sstates-from, if any). This argument
|
|
84
|
+
may be specified more than once, in which case the given states are appended in the order
|
|
85
|
+
they are given on the command line.''',
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
parser.add_argument(
|
|
89
|
+
'--segs-per-state',
|
|
90
|
+
type=int,
|
|
91
|
+
metavar='N',
|
|
92
|
+
default=1,
|
|
93
|
+
help='''Initialize N segments from each basis state (default: %(default)s).''',
|
|
94
|
+
)
|
|
95
|
+
parser.add_argument(
|
|
96
|
+
'--no-we',
|
|
97
|
+
'--shotgun',
|
|
98
|
+
dest='shotgun',
|
|
99
|
+
action='store_true',
|
|
100
|
+
help='''Do not run the weighted ensemble bin/split/merge algorithm on newly-created segments.''',
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# TODO: Does this belong here or not? I like that it's parsing arguments, which is the purpose of entry_point.
|
|
104
|
+
# I don't necessarily like that it's setting state across different parts of the program.
|
|
105
|
+
|
|
106
|
+
work_managers.environment.add_wm_args(parser)
|
|
107
|
+
args = parser.parse_args()
|
|
108
|
+
westpa.rc.process_args(args)
|
|
109
|
+
work_managers.environment.process_wm_args(args)
|
|
110
|
+
|
|
111
|
+
initialize(
|
|
112
|
+
args.tstates,
|
|
113
|
+
args.tstate_file,
|
|
114
|
+
args.bstates,
|
|
115
|
+
args.bstate_file,
|
|
116
|
+
args.sstates,
|
|
117
|
+
args.sstate_file,
|
|
118
|
+
args.segs_per_state,
|
|
119
|
+
args.shotgun,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def initialize(tstates, tstate_file, bstates, bstate_file, sstates=None, sstate_file=None, segs_per_state=1, shotgun=False):
|
|
124
|
+
"""
|
|
125
|
+
Initialize a WESTPA simulation.
|
|
126
|
+
|
|
127
|
+
tstates : list of str
|
|
128
|
+
|
|
129
|
+
tstate_file : str
|
|
130
|
+
|
|
131
|
+
bstates : list of str
|
|
132
|
+
|
|
133
|
+
bstate_file : str
|
|
134
|
+
|
|
135
|
+
sstates : list of str
|
|
136
|
+
|
|
137
|
+
sstate_file : str
|
|
138
|
+
|
|
139
|
+
segs_per_state : int
|
|
140
|
+
|
|
141
|
+
shotgun : bool
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
westpa.rc.work_manager = work_manager = make_work_manager()
|
|
145
|
+
|
|
146
|
+
system = westpa.rc.get_system_driver()
|
|
147
|
+
sim_manager = westpa.rc.get_sim_manager()
|
|
148
|
+
|
|
149
|
+
data_manager = westpa.rc.get_data_manager()
|
|
150
|
+
|
|
151
|
+
data_manager.system = system
|
|
152
|
+
|
|
153
|
+
with work_manager:
|
|
154
|
+
if work_manager.is_master:
|
|
155
|
+
# Process target states
|
|
156
|
+
target_states = []
|
|
157
|
+
if tstate_file:
|
|
158
|
+
target_states.extend(TargetState.states_from_file(tstate_file, system.pcoord_dtype))
|
|
159
|
+
if tstates:
|
|
160
|
+
tstates_strio = io.StringIO('\n'.join(tstates).replace(',', ' '))
|
|
161
|
+
target_states.extend(TargetState.states_from_file(tstates_strio, system.pcoord_dtype))
|
|
162
|
+
del tstates_strio
|
|
163
|
+
|
|
164
|
+
# Process basis states
|
|
165
|
+
basis_states = []
|
|
166
|
+
if bstate_file:
|
|
167
|
+
basis_states.extend(BasisState.states_from_file(bstate_file))
|
|
168
|
+
if bstates:
|
|
169
|
+
for bstate_str in bstates:
|
|
170
|
+
fields = bstate_str.split(',')
|
|
171
|
+
label = fields[0]
|
|
172
|
+
probability = float(fields[1])
|
|
173
|
+
try:
|
|
174
|
+
auxref = fields[2]
|
|
175
|
+
except IndexError:
|
|
176
|
+
auxref = None
|
|
177
|
+
basis_states.append(BasisState(label=label, probability=probability, auxref=auxref))
|
|
178
|
+
|
|
179
|
+
# Process the list of start states, creating a BasisState from each
|
|
180
|
+
start_states = []
|
|
181
|
+
if sstate_file:
|
|
182
|
+
start_states.extend(BasisState.states_from_file(sstate_file))
|
|
183
|
+
if sstates:
|
|
184
|
+
for sstate_str in sstates:
|
|
185
|
+
fields = sstate_str.split(',')
|
|
186
|
+
label = fields[0]
|
|
187
|
+
probability = float(fields[1])
|
|
188
|
+
try:
|
|
189
|
+
auxref = fields[2]
|
|
190
|
+
except IndexError:
|
|
191
|
+
auxref = None
|
|
192
|
+
start_states.append(BasisState(label=label, probability=probability, auxref=auxref))
|
|
193
|
+
|
|
194
|
+
if not basis_states:
|
|
195
|
+
log.error('At least one basis state is required')
|
|
196
|
+
sys.exit(3)
|
|
197
|
+
|
|
198
|
+
# Check that the total probability of basis states adds to one
|
|
199
|
+
bstate_prob, sstate_prob = (
|
|
200
|
+
sum(bstate.probability for bstate in basis_states),
|
|
201
|
+
sum(sstate.probability for sstate in start_states),
|
|
202
|
+
)
|
|
203
|
+
# tprob = sum(bstate.probability for bstate in basis_states)
|
|
204
|
+
tprob = bstate_prob + sstate_prob
|
|
205
|
+
if abs(1.0 - tprob) > len(basis_states) * EPS:
|
|
206
|
+
pscale = 1 / tprob
|
|
207
|
+
log.warning(
|
|
208
|
+
'Basis state probabilities do not add to unity (basis: {:.2f}, start states: {:.2f}); rescaling by {:g}. If using start states, some rescaling is normal.'.format(
|
|
209
|
+
bstate_prob, sstate_prob, pscale
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
for bstate in basis_states:
|
|
213
|
+
bstate.probability *= pscale
|
|
214
|
+
for sstate in start_states:
|
|
215
|
+
sstate.probability *= pscale
|
|
216
|
+
|
|
217
|
+
# Prepare simulation
|
|
218
|
+
sim_manager.initialize_simulation(
|
|
219
|
+
basis_states=basis_states,
|
|
220
|
+
target_states=target_states,
|
|
221
|
+
start_states=start_states,
|
|
222
|
+
segs_per_state=segs_per_state,
|
|
223
|
+
suppress_we=shotgun,
|
|
224
|
+
)
|
|
225
|
+
else:
|
|
226
|
+
work_manager.run()
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
if __name__ == '__main__':
|
|
230
|
+
entry_point()
|
westpa/cli/core/w_run.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
import traceback
|
|
4
|
+
|
|
5
|
+
import westpa
|
|
6
|
+
import westpa.work_managers as work_managers
|
|
7
|
+
from westpa.work_managers import make_work_manager
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
log = logging.getLogger('w_run')
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def entry_point():
|
|
14
|
+
parser = argparse.ArgumentParser('w_run', 'start/continue a WEST simulation')
|
|
15
|
+
westpa.rc.add_args(parser)
|
|
16
|
+
parser.add_argument(
|
|
17
|
+
'--oneseg',
|
|
18
|
+
dest='only_one_segment',
|
|
19
|
+
action='store_true',
|
|
20
|
+
help='only propagate one segment (useful for debugging propagators)',
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
work_managers.environment.add_wm_args(parser)
|
|
24
|
+
|
|
25
|
+
args = parser.parse_args()
|
|
26
|
+
westpa.rc.process_args(args)
|
|
27
|
+
work_managers.environment.process_wm_args(args)
|
|
28
|
+
|
|
29
|
+
run_simulation()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def run_simulation():
|
|
33
|
+
work_manager = westpa.rc.work_manager = make_work_manager()
|
|
34
|
+
|
|
35
|
+
# Load the sim manager and other drivers
|
|
36
|
+
sim_manager = westpa.rc.get_sim_manager()
|
|
37
|
+
system = westpa.rc.get_system_driver()
|
|
38
|
+
data_manager = westpa.rc.get_data_manager()
|
|
39
|
+
we_driver = westpa.rc.get_we_driver()
|
|
40
|
+
propagator = westpa.rc.get_propagator()
|
|
41
|
+
|
|
42
|
+
propagator.system = system
|
|
43
|
+
data_manager.system = system
|
|
44
|
+
we_driver.system = system
|
|
45
|
+
|
|
46
|
+
sim_manager.data_manager = data_manager
|
|
47
|
+
sim_manager.system = system
|
|
48
|
+
sim_manager.propagator = propagator
|
|
49
|
+
sim_manager.we_driver = we_driver
|
|
50
|
+
|
|
51
|
+
with work_manager:
|
|
52
|
+
if work_manager.is_master:
|
|
53
|
+
work_manager.install_sigint_handler()
|
|
54
|
+
sim_manager.load_plugins()
|
|
55
|
+
|
|
56
|
+
log.debug('preparing run')
|
|
57
|
+
sim_manager.prepare_run()
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
log.debug('beginning run')
|
|
61
|
+
sim_manager.run()
|
|
62
|
+
|
|
63
|
+
log.debug('finalizing run')
|
|
64
|
+
sim_manager.finalize_run()
|
|
65
|
+
except KeyboardInterrupt:
|
|
66
|
+
westpa.rc.pstatus('interrupted; shutting down')
|
|
67
|
+
except Exception as e:
|
|
68
|
+
westpa.rc.pstatus('exception caught; shutting down')
|
|
69
|
+
if str(e) != '':
|
|
70
|
+
log.error(f'error message: {e}')
|
|
71
|
+
log.error(traceback.format_exc())
|
|
72
|
+
else:
|
|
73
|
+
work_manager.run()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if __name__ == '__main__':
|
|
77
|
+
entry_point()
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import io
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
import westpa.work_managers as work_managers
|
|
9
|
+
from westpa.work_managers import make_work_manager
|
|
10
|
+
|
|
11
|
+
import westpa
|
|
12
|
+
from westpa.core.segment import Segment
|
|
13
|
+
from westpa.core.states import BasisState, TargetState
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger('w_states')
|
|
17
|
+
EPS = np.finfo(np.float64).eps
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def entry_point():
|
|
21
|
+
parser = argparse.ArgumentParser(
|
|
22
|
+
'w_states',
|
|
23
|
+
description='''\
|
|
24
|
+
Display or manipulate basis (initial) or target (recycling) states for a WEST simulation. By default, states are
|
|
25
|
+
displayed (or dumped to files). If ``--replace`` is specified, all basis/target states are replaced for the
|
|
26
|
+
next iteration. If ``--append`` is specified, the given target state(s) are appended to the list for the
|
|
27
|
+
next iteration.
|
|
28
|
+
|
|
29
|
+
Appending basis states is not permitted, as this would require renormalizing basis state
|
|
30
|
+
probabilities in ways that may be error-prone. Instead, use ``w_states --show --bstate-file=bstates.txt``
|
|
31
|
+
and then edit the resulting ``bstates.txt`` file to include the new desired basis states, then use
|
|
32
|
+
``w_states --replace --bstate-file=bstates.txt`` to update the WEST HDF5 file appropriately.
|
|
33
|
+
''',
|
|
34
|
+
)
|
|
35
|
+
westpa.rc.add_args(parser)
|
|
36
|
+
smgroup = parser.add_argument_group('modes of operation')
|
|
37
|
+
mode_group = smgroup.add_mutually_exclusive_group()
|
|
38
|
+
mode_group.add_argument(
|
|
39
|
+
'--show', dest='mode', action='store_const', const='show', help='Display current basis/target states (or dump to files).'
|
|
40
|
+
)
|
|
41
|
+
mode_group.add_argument(
|
|
42
|
+
'--append',
|
|
43
|
+
dest='mode',
|
|
44
|
+
action='store_const',
|
|
45
|
+
const='append',
|
|
46
|
+
help='Append the given basis/target states to those currently in use.',
|
|
47
|
+
)
|
|
48
|
+
mode_group.add_argument(
|
|
49
|
+
'--replace',
|
|
50
|
+
dest='mode',
|
|
51
|
+
action='store_const',
|
|
52
|
+
const='replace',
|
|
53
|
+
help='Replace current basis/target states with those specified.',
|
|
54
|
+
)
|
|
55
|
+
parser.add_argument(
|
|
56
|
+
'--bstate-file',
|
|
57
|
+
metavar='BSTATE_FILE',
|
|
58
|
+
help='''Read (--append/--replace) or write (--show) basis state names, probabilities,
|
|
59
|
+
and data references from/to BSTATE_FILE.''',
|
|
60
|
+
)
|
|
61
|
+
parser.add_argument(
|
|
62
|
+
'--bstate',
|
|
63
|
+
action='append',
|
|
64
|
+
dest='bstates',
|
|
65
|
+
help='''Add the given basis state (specified as a string 'label,probability[,auxref]')
|
|
66
|
+
to the list of basis states (after those specified in --bstate-file, if any). This argument
|
|
67
|
+
may be specified more than once, in which case the given states are appended in the order
|
|
68
|
+
they are given on the command line.''',
|
|
69
|
+
)
|
|
70
|
+
parser.add_argument(
|
|
71
|
+
'--tstate-file',
|
|
72
|
+
metavar='TSTATE_FILE',
|
|
73
|
+
help='''Read (--append/--replace) or write (--show) target state names
|
|
74
|
+
and representative progress coordinates from/to TSTATE_FILE''',
|
|
75
|
+
)
|
|
76
|
+
parser.add_argument(
|
|
77
|
+
'--tstate',
|
|
78
|
+
action='append',
|
|
79
|
+
dest='tstates',
|
|
80
|
+
help='''Add the given target state (specified as a string 'label,pcoord0[,pcoord1[,...]]') to the
|
|
81
|
+
list of target states (after those specified in the file given by --tstates-from, if any).
|
|
82
|
+
This argument may be specified more than once, in which case the given states are appended
|
|
83
|
+
in the order they appear on the command line.''',
|
|
84
|
+
)
|
|
85
|
+
parser.set_defaults(mode='show')
|
|
86
|
+
|
|
87
|
+
work_managers.environment.add_wm_args(parser)
|
|
88
|
+
args = parser.parse_args()
|
|
89
|
+
westpa.rc.process_args(args)
|
|
90
|
+
work_managers.environment.process_wm_args(args)
|
|
91
|
+
|
|
92
|
+
# Need to have something to pass to initialize
|
|
93
|
+
if not hasattr(args, 'bstates'):
|
|
94
|
+
args.bstates = None
|
|
95
|
+
if not hasattr(args, 'tstates'):
|
|
96
|
+
args.tstates = None
|
|
97
|
+
if not hasattr(args, 'tstate_file'):
|
|
98
|
+
args.tstate_file = None
|
|
99
|
+
|
|
100
|
+
initialize(args.mode, args.bstates, args.bstate_file, args.tstates, args.tstate_file)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# TODO: This would benefit from a refactor to set default args to None, and replace some of those "if <argument>" clauses
|
|
104
|
+
def initialize(mode, bstates, _bstate_file, tstates, _tstate_file):
|
|
105
|
+
work_manager = make_work_manager()
|
|
106
|
+
|
|
107
|
+
system = westpa.rc.get_system_driver()
|
|
108
|
+
|
|
109
|
+
with work_manager:
|
|
110
|
+
if work_manager.is_master:
|
|
111
|
+
data_manager = westpa.rc.get_data_manager()
|
|
112
|
+
data_manager.open_backing(mode='a')
|
|
113
|
+
sim_manager = westpa.rc.get_sim_manager()
|
|
114
|
+
n_iter = data_manager.current_iteration
|
|
115
|
+
|
|
116
|
+
assert mode in ('show', 'replace', 'append')
|
|
117
|
+
if mode == 'show':
|
|
118
|
+
basis_states = data_manager.get_basis_states(n_iter)
|
|
119
|
+
if basis_states:
|
|
120
|
+
bstate_file = sys.stdout if not _bstate_file else open(_bstate_file, 'wt')
|
|
121
|
+
bstate_file.write('# Basis states for iteration {:d}\n'.format(n_iter))
|
|
122
|
+
BasisState.states_to_file(basis_states, bstate_file)
|
|
123
|
+
|
|
124
|
+
target_states = data_manager.get_target_states(n_iter)
|
|
125
|
+
if target_states:
|
|
126
|
+
tstate_file = sys.stdout if not _tstate_file else open(_tstate_file, 'wt')
|
|
127
|
+
tstate_file.write('# Target states for iteration {:d}\n'.format(n_iter))
|
|
128
|
+
TargetState.states_to_file(target_states, tstate_file)
|
|
129
|
+
|
|
130
|
+
elif mode == 'replace':
|
|
131
|
+
seg_index = data_manager.get_seg_index(n_iter)
|
|
132
|
+
if (seg_index['status'] == Segment.SEG_STATUS_COMPLETE).any():
|
|
133
|
+
print('Iteration {:d} has completed segments; applying new states to iteration {:d}'.format(n_iter, n_iter + 1))
|
|
134
|
+
n_iter += 1
|
|
135
|
+
|
|
136
|
+
basis_states = []
|
|
137
|
+
if _bstate_file:
|
|
138
|
+
basis_states.extend(BasisState.states_from_file(_bstate_file))
|
|
139
|
+
if bstates:
|
|
140
|
+
for bstate_str in bstates:
|
|
141
|
+
fields = bstate_str.split(',')
|
|
142
|
+
label = fields[0]
|
|
143
|
+
probability = float(fields[1])
|
|
144
|
+
try:
|
|
145
|
+
auxref = fields[2]
|
|
146
|
+
except IndexError:
|
|
147
|
+
auxref = None
|
|
148
|
+
basis_states.append(BasisState(label=label, probability=probability, auxref=auxref))
|
|
149
|
+
|
|
150
|
+
if basis_states:
|
|
151
|
+
# Check that the total probability of basis states adds to one
|
|
152
|
+
tprob = sum(bstate.probability for bstate in basis_states)
|
|
153
|
+
if abs(1.0 - tprob) > len(basis_states) * EPS:
|
|
154
|
+
pscale = 1 / tprob
|
|
155
|
+
log.warning('Basis state probabilities do not add to unity; rescaling by {:g}'.format(pscale))
|
|
156
|
+
for bstate in basis_states:
|
|
157
|
+
bstate.probability *= pscale
|
|
158
|
+
|
|
159
|
+
# Assign progress coordinates to basis states
|
|
160
|
+
sim_manager.get_bstate_pcoords(basis_states)
|
|
161
|
+
data_manager.create_ibstate_group(basis_states, n_iter)
|
|
162
|
+
sim_manager.report_basis_states(basis_states)
|
|
163
|
+
|
|
164
|
+
# Now handle target states
|
|
165
|
+
target_states = []
|
|
166
|
+
if _tstate_file:
|
|
167
|
+
target_states.extend(TargetState.states_from_file(_tstate_file, system.pcoord_dtype))
|
|
168
|
+
if tstates:
|
|
169
|
+
tstates_strio = io.StringIO('\n'.join(tstates).replace(',', ' '))
|
|
170
|
+
target_states.extend(TargetState.states_from_file(tstates_strio, system.pcoord_dtype))
|
|
171
|
+
del tstates_strio
|
|
172
|
+
|
|
173
|
+
if not target_states:
|
|
174
|
+
westpa.rc.pstatus('No target states specified.')
|
|
175
|
+
else:
|
|
176
|
+
data_manager.save_target_states(target_states, n_iter)
|
|
177
|
+
sim_manager.report_target_states(target_states)
|
|
178
|
+
|
|
179
|
+
data_manager.update_iter_group_links(n_iter)
|
|
180
|
+
|
|
181
|
+
else: # args.mode == 'append'
|
|
182
|
+
if _bstate_file or bstates:
|
|
183
|
+
sys.stderr.write('refusing to append basis states; use --show followed by --replace instead\n')
|
|
184
|
+
sys.exit(2)
|
|
185
|
+
|
|
186
|
+
target_states = data_manager.get_target_states(n_iter)
|
|
187
|
+
|
|
188
|
+
seg_index = data_manager.get_seg_index(n_iter)
|
|
189
|
+
if (seg_index['status'] == Segment.SEG_STATUS_COMPLETE).any():
|
|
190
|
+
print('Iteration {:d} has completed segments; applying new states to iteration {:d}'.format(n_iter, n_iter + 1))
|
|
191
|
+
n_iter += 1
|
|
192
|
+
|
|
193
|
+
if _tstate_file:
|
|
194
|
+
target_states.extend(TargetState.states_from_file(_tstate_file, system.pcoord_dtype))
|
|
195
|
+
if tstates:
|
|
196
|
+
tstates_strio = io.StringIO('\n'.join(tstates).replace(',', ' '))
|
|
197
|
+
target_states.extend(TargetState.states_from_file(tstates_strio, system.pcoord_dtype))
|
|
198
|
+
del tstates_strio
|
|
199
|
+
|
|
200
|
+
if not target_states:
|
|
201
|
+
westpa.rc.pstatus('No target states specified.')
|
|
202
|
+
else:
|
|
203
|
+
data_manager.save_target_states(target_states, n_iter)
|
|
204
|
+
sim_manager.report_target_states(target_states)
|
|
205
|
+
|
|
206
|
+
data_manager.update_iter_group_links(n_iter)
|
|
207
|
+
else:
|
|
208
|
+
work_manager.run()
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
if __name__ == '__main__':
|
|
212
|
+
entry_point()
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
import westpa
|
|
7
|
+
|
|
8
|
+
from westpa.core.segment import Segment
|
|
9
|
+
from westpa.oldtools.aframe import WESTAnalysisTool, WESTDataReaderMixin, CommonOutputMixin
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
|
|
13
|
+
log = logging.getLogger('w_succ')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class WSucc(CommonOutputMixin, WESTDataReaderMixin, WESTAnalysisTool):
|
|
17
|
+
def __init__(self):
|
|
18
|
+
super().__init__()
|
|
19
|
+
self.include_args['CommonOutputMixin']['print_bin_labels'] = False
|
|
20
|
+
self.output_file = sys.stdout
|
|
21
|
+
|
|
22
|
+
def find_successful_trajs(self):
|
|
23
|
+
pcoord_formats = {
|
|
24
|
+
'u8': '%20d',
|
|
25
|
+
'i8': '%20d',
|
|
26
|
+
'u4': '%10d',
|
|
27
|
+
'i4': '%11d',
|
|
28
|
+
'u2': '%5d',
|
|
29
|
+
'i2': '%6d',
|
|
30
|
+
'f4': '%14.7g',
|
|
31
|
+
'f8': '%23.15g',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if not self.output_suppress_headers:
|
|
35
|
+
self.output_file.write(
|
|
36
|
+
'''\
|
|
37
|
+
# successful (recycled) segments
|
|
38
|
+
# column 0: iteration
|
|
39
|
+
# column 1: seg_id
|
|
40
|
+
# column 2: weight
|
|
41
|
+
# column>2: final progress coordinate value
|
|
42
|
+
'''
|
|
43
|
+
)
|
|
44
|
+
for n_iter in range(1, self.data_manager.current_iteration):
|
|
45
|
+
seg_index = self.get_seg_index(n_iter)
|
|
46
|
+
all_seg_ids = np.arange(len(seg_index), dtype=np.int_)
|
|
47
|
+
recycled_seg_ids = all_seg_ids[seg_index[:]['endpoint_type'] == Segment.SEG_ENDPOINT_RECYCLED]
|
|
48
|
+
|
|
49
|
+
if len(recycled_seg_ids) == 0:
|
|
50
|
+
# Attemping to retrieve a 0-length selection from HDF5 (the pcoords below) fails
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
pcoord_ds = self.get_pcoord_dataset(n_iter)
|
|
54
|
+
pcoord_len = pcoord_ds.shape[1]
|
|
55
|
+
pcoord_ndim = pcoord_ds.shape[2]
|
|
56
|
+
final_pcoords = self.get_pcoord_dataset(n_iter)[recycled_seg_ids, pcoord_len - 1, :]
|
|
57
|
+
# The above HDF5 selection always returns a vector; we want a 2-d array
|
|
58
|
+
final_pcoords.shape = (len(recycled_seg_ids), pcoord_ndim)
|
|
59
|
+
|
|
60
|
+
for ipc, seg_id in enumerate(recycled_seg_ids):
|
|
61
|
+
self.output_file.write('%8d %8d %20.14g' % (n_iter, seg_id, seg_index[seg_id]['weight']))
|
|
62
|
+
fields = ['']
|
|
63
|
+
for field in final_pcoords[ipc]:
|
|
64
|
+
fields.append(pcoord_formats.get(field.dtype.str[1:], '%s') % field)
|
|
65
|
+
self.output_file.write(' '.join(fields))
|
|
66
|
+
self.output_file.write('\n')
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def entry_point():
|
|
70
|
+
wsucc = WSucc()
|
|
71
|
+
|
|
72
|
+
parser = argparse.ArgumentParser(
|
|
73
|
+
'w_succ',
|
|
74
|
+
description='''\
|
|
75
|
+
List segments which successfully reach a target state''',
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
westpa.rc.add_args(parser)
|
|
79
|
+
wsucc.add_args(parser)
|
|
80
|
+
|
|
81
|
+
parser.add_argument(
|
|
82
|
+
'-o',
|
|
83
|
+
'--output',
|
|
84
|
+
dest='output_file',
|
|
85
|
+
help='Store output in OUTPUT_FILE (default: write to standard output).',
|
|
86
|
+
type=argparse.FileType('wt'),
|
|
87
|
+
default=sys.stdout,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
args = parser.parse_args()
|
|
91
|
+
westpa.rc.process_args(args, config_required=False)
|
|
92
|
+
wsucc.process_args(args)
|
|
93
|
+
wsucc.output_file = args.output_file
|
|
94
|
+
|
|
95
|
+
wsucc.find_successful_trajs()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == '__main__':
|
|
99
|
+
entry_point()
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from argparse import ArgumentParser
|
|
3
|
+
|
|
4
|
+
import westpa
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
log = logging.getLogger('w_truncate')
|
|
8
|
+
|
|
9
|
+
warning_string = '''\
|
|
10
|
+
NOTE: w_truncate only deletes iteration groups from the HDF5 data store.
|
|
11
|
+
It is recommended that any iteration data saved to the file system (e.g. in the
|
|
12
|
+
traj_segs directory) is deleted or moved for the corresponding iterations.
|
|
13
|
+
'''
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def entry_point():
|
|
17
|
+
parser = ArgumentParser(
|
|
18
|
+
'w_truncate',
|
|
19
|
+
description='''\
|
|
20
|
+
Remove all iterations after a certain point in a WESTPA simulation.
|
|
21
|
+
''',
|
|
22
|
+
epilog=warning_string,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
westpa.rc.add_args(parser)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
'-W',
|
|
28
|
+
'--west-data',
|
|
29
|
+
dest='we_h5filename',
|
|
30
|
+
metavar='WEST_H5FILE',
|
|
31
|
+
help='''Take WEST data from WEST_H5FILE (default: read from the HDF5 file specified in west.cfg).''',
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument('-n', '--iter', dest='n_iter', type=int, default=0, help='Truncate this iteration and those following.')
|
|
34
|
+
|
|
35
|
+
args = parser.parse_args()
|
|
36
|
+
westpa.rc.process_args(args, config_required=False)
|
|
37
|
+
dm = westpa.rc.get_data_manager()
|
|
38
|
+
if args.we_h5filename:
|
|
39
|
+
dm.we_h5filename = args.we_h5filename
|
|
40
|
+
|
|
41
|
+
dm.open_backing()
|
|
42
|
+
# max_iter = dm.current_iteration
|
|
43
|
+
|
|
44
|
+
if args.n_iter > dm.current_iteration:
|
|
45
|
+
parser.error(
|
|
46
|
+
'Provided iteration {} > current iteration {} of the {} HDF5 file. Exiting without doing anything.'.format(
|
|
47
|
+
args.n_iter, dm.current_iteration, dm.we_h5filename.split('/')[-1]
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
else:
|
|
51
|
+
n_iter = args.n_iter if args.n_iter > 0 else dm.current_iteration
|
|
52
|
+
|
|
53
|
+
for i in range(n_iter, dm.current_iteration + 1):
|
|
54
|
+
dm.del_iter_group(i)
|
|
55
|
+
|
|
56
|
+
dm.del_iter_summary(n_iter)
|
|
57
|
+
dm.current_iteration = n_iter - 1
|
|
58
|
+
|
|
59
|
+
westpa.rc.pstatus('simulation data truncated after iteration {}'.format(dm.current_iteration))
|
|
60
|
+
westpa.rc.pstatus('\n' + warning_string)
|
|
61
|
+
westpa.rc.pflush()
|
|
62
|
+
|
|
63
|
+
dm.flush_backing()
|
|
64
|
+
dm.close_backing()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == '__main__':
|
|
68
|
+
entry_point()
|
|
File without changes
|