Skip to content

Commit b5ec9ce

Browse files
committed
Wizard ready for 2-state TPS demo
1 parent 5d2e3f8 commit b5ec9ce

6 files changed

Lines changed: 88 additions & 47 deletions

File tree

‎paths_cli/commands/wizard.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import click
2+
from paths_cli.wizard.two_state_tps import TWO_STATE_TPS_WIZARD
3+
4+
@click.command(
5+
'wizard',
6+
short_help="run wizard for setting up simulations",
7+
)
8+
def wizard():
9+
TWO_STATE_TPS_WIZARD.run_wizard()
10+
11+
CLI = wizard
12+
SECTION = "Simulation setup"

‎paths_cli/tests/wizard/test_wizard.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
CoordinateFunctionCV
1010

1111
from paths_cli.wizard.wizard import *
12+
from paths_cli.wizard.steps import SINGLE_ENGINE_STEP
1213

1314

1415

‎paths_cli/wizard/steps.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from collections import namedtuple
2+
from functools import partial
3+
4+
from paths_cli.wizard.cvs import cvs
5+
from paths_cli.wizard.engines import engines
6+
from paths_cli.wizard.volumes import volumes
7+
from paths_cli.wizard.tps import (
8+
flex_length_tps_network, fixed_length_tps_network, tps_scheme
9+
)
10+
11+
WizardStep = namedtuple('WizardStep', ['func', 'display_name', 'store_name',
12+
'minimum', 'maximum'])
13+
14+
SINGLE_ENGINE_STEP = WizardStep(func=engines,
15+
display_name="engine",
16+
store_name="engines",
17+
minimum=1,
18+
maximum=1)
19+
20+
CVS_STEP = WizardStep(func=cvs,
21+
display_name="CV",
22+
store_name='cvs',
23+
minimum=1,
24+
maximum=float('inf'))
25+
26+
MULTIPLE_STATES_STEP = WizardStep(func=partial(volumes, as_state=True),
27+
display_name="state",
28+
store_name="states",
29+
minimum=2,
30+
maximum=float('inf'))
31+
32+

‎paths_cli/wizard/two_state_tps.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from paths_cli.wizard.steps import (
2+
SINGLE_ENGINE_STEP, CVS_STEP, WizardStep
3+
)
4+
from paths_cli.wizard.volumes import volumes
5+
from paths_cli.wizard.tps import tps_scheme
6+
from paths_cli.wizard.wizard import Wizard
7+
8+
def two_state_tps(wizard, fixed_length=False):
9+
import openpathsampling as paths
10+
wizard.say("Now let's define the stable states for your system. "
11+
"Let's start with your initial state.")
12+
initial_state = volumes(wizard, as_state=True, intro="")
13+
wizard.register(initial_state, 'initial state', 'states')
14+
wizard.say("Next let's define your final state.")
15+
final_state = volumes(wizard, as_state=True, intro="")
16+
wizard.register(final_state, 'final state', 'states')
17+
if fixed_length:
18+
...
19+
else:
20+
network = paths.TPSNetwork(initial_state, final_state)
21+
scheme = tps_scheme(wizard, network=network)
22+
return scheme
23+
24+
25+
TWO_STATE_TPS_WIZARD = Wizard([
26+
SINGLE_ENGINE_STEP,
27+
CVS_STEP,
28+
WizardStep(func=two_state_tps,
29+
display_name="TPS setup",
30+
store_name='schemes',
31+
minimum=1,
32+
maximum=1)
33+
])

‎paths_cli/wizard/volumes.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ def cv_defined_volume(wizard):
8383
'Complement of a volume (not in given volume)': negated_volume,
8484
}
8585

86-
def volumes(wizard, as_state=False):
87-
intro = _vol_intro(wizard, as_state)
88-
if intro is not None:
89-
wizard.say(_vol_intro(wizard, as_state))
86+
def volumes(wizard, as_state=False, intro=None):
87+
if intro is None:
88+
intro = _vol_intro(wizard, as_state)
89+
90+
if intro: # disallow None and ""
91+
wizard.say(intro)
9092

9193
wizard.say("You can describe this as either a range of values for some "
9294
"CV, or as some combination of other such volumes "

‎paths_cli/wizard/wizard.py‎

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
from functools import partial
44
import textwrap
55

6-
from paths_cli.wizard.cvs import cvs
7-
from paths_cli.wizard.engines import engines
8-
from paths_cli.wizard.volumes import volumes
9-
from paths_cli.wizard.tps import (
10-
flex_length_tps_network, fixed_length_tps_network, tps_scheme
11-
)
126
from paths_cli.wizard.tools import yes_no, a_an
137
from paths_cli.wizard.core import get_object
148
from paths_cli.wizard.errors import (
@@ -247,6 +241,9 @@ def _ask_do_another(self, obj_type):
247241
return do_another
248242

249243
def run_wizard(self):
244+
self.start("Hi! I'm the OpenPathSampling Wizard.")
245+
# TODO: next line is only temporary
246+
self.say("Today I'll help you set up a 2-state TPS simulation.")
250247
self._patch() # try to hide the slowness of our first import
251248
for step in self.steps:
252249
req = step.store_name, step.minimum, step.maximum
@@ -269,45 +266,9 @@ def run_wizard(self):
269266
storage = self.get_storage()
270267
self.save_to_file(storage)
271268

272-
from collections import namedtuple
273-
WizardStep = namedtuple('WizardStep', ['func', 'display_name', 'store_name',
274-
'minimum', 'maximum'])
275-
276-
SINGLE_ENGINE_STEP = WizardStep(func=engines,
277-
display_name="engine",
278-
store_name="engines",
279-
minimum=1,
280-
maximum=1)
281-
282-
CVS_STEP = WizardStep(func=cvs,
283-
display_name="CV",
284-
store_name='cvs',
285-
minimum=1,
286-
maximum=float('inf'))
287-
288-
MULTIPLE_STATES_STEP = WizardStep(func=partial(volumes, as_state=True),
289-
display_name="state",
290-
store_name="states",
291-
minimum=2,
292-
maximum=float('inf'))
293-
294-
FLEX_LENGTH_TPS_WIZARD = Wizard([
295-
SINGLE_ENGINE_STEP,
296-
CVS_STEP,
297-
MULTIPLE_STATES_STEP,
298-
WizardStep(func=flex_length_tps_network,
299-
display_name="network",
300-
store_name="networks",
301-
minimum=1,
302-
maximum=1),
303-
WizardStep(func=tps_scheme,
304-
display_name="move scheme",
305-
store_name="schemes",
306-
minimum=1,
307-
maximum=1),
308-
])
309269

310270
# FIXED_LENGTH_TPS_WIZARD
271+
# MULTIPLE_STATE_TPS_WIZARD
311272
# TWO_STATE_TIS_WIZARD
312273
# MULTIPLE_STATE_TIS_WIZARD
313274
# MULTIPLE_INTERFACE_SET_TIS_WIZARD

0 commit comments

Comments
 (0)