Skip to content

Commit 42aa3c9

Browse files
committed
More tests; work toward handling Spring Shooting
1 parent a85118f commit 42aa3c9

3 files changed

Lines changed: 38 additions & 8 deletions

File tree

‎paths_cli/tests/wizard/conftest.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,24 @@ def ad_engine(ad_openmm):
4747
).named('ad_engine')
4848
return engine
4949

50-
# TODO: add fixtures for all the AD things: CVs, states
50+
@pytest.fixture
51+
def toy_engine():
52+
pes = (paths.engines.toy.OuterWalls([1.0, 1.0], [1.0, 1.0])
53+
+ paths.engines.toy.Gaussian(-1.0, [12.0, 12.0], [-0.5, 0.0])
54+
+ paths.engines.toy.Gaussian(-1.0, [12.0, 12.0], [0.5, 0.0]))
55+
topology = paths.engines.toy.Topology(n_spatial=2,
56+
masses=[1.0],
57+
pes=pes)
58+
integ = paths.engines.toy.LangevinBAOABIntegrator(
59+
dt=0.02,
60+
temperature=0.1,
61+
gamma=2.5
62+
)
63+
options = {'integ': integ,
64+
'n_frames_max': 5000,
65+
'n_steps_per_frame': 1}
66+
engine = paths.engines.toy.Engine(
67+
options=options,
68+
topology=topology
69+
).named('toy-engine')
70+
return engine

‎paths_cli/wizard/shooting.py‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ def uniform_selector(wizard):
1212

1313
def gaussian_selector(wizard):
1414
import openpathsampling as paths
15-
cv = wizard.ask_enumerate("Which CV do you want the Gaussian to be "
16-
"based on?", options=wizard.cvs.keys())
15+
cv_name = wizard.ask_enumerate("Which CV do you want the Gaussian to "
16+
"be based on?",
17+
options=wizard.cvs.keys())
18+
cv = wizard.cvs[cv_name]
1719
l_0 = wizard.ask_custom_eval(f"At what value of {cv.name} should the "
1820
"Gaussian be centered?")
1921
std = wizard.ask_custom_eval("What should be the standard deviation of "
@@ -45,7 +47,7 @@ def gaussian_selector(wizard):
4547
}
4648

4749

48-
def _get_selector(wizard, selectors):
50+
def _get_selector(wizard, selectors=None):
4951
if selectors is None:
5052
selectors = SHOOTING_SELECTORS
5153
selector = None
@@ -61,7 +63,8 @@ def one_way_shooting(wizard, selectors=None, engine=None):
6163
engines)
6264

6365
selector = _get_selector(wizard, selectors)
64-
strat = strategies.OneWayShootingStrategy(selector=selector)
66+
strat = strategies.OneWayShootingStrategy(selector=selector,
67+
engine=engine)
6568
return strat
6669

6770
# def two_way_shooting(wizard, selectors=None, modifiers=None):
@@ -78,8 +81,9 @@ def spring_shooting(wizard, engine=None):
7881
)
7982
k_spring = wizard.ask_custom_eval("What is the spring constant k?",
8083
type_=float)
81-
strat = strategies.SpringShootingStrategy(delta_max=delta_max,
82-
k_spring=k_spring)
84+
strat = strategies.SpringShootingMoveScheme(
85+
delta_max=delta_max, k_spring=k_spring, engine=engine
86+
)
8387
return strat
8488

8589

‎paths_cli/wizard/tps.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
from paths_cli.wizard.shooting import shooting
44
from functools import partial
55

6+
67
def tps_scheme(wizard, network=None):
78
import openpathsampling as paths
89
from openpathsampling import strategies
910
if network is None:
1011
network = get_missing_object(wizard, wizard.networks, 'network',
1112
tps_network)
1213

13-
shooting_strategy = shooting(wizard)
14+
shooting_strategy = shooting(wizard, network)
15+
16+
if isinstance(shooting_strategy, paths.MoveScheme):
17+
# this means we got a fixed scheme and can't do strategies
18+
return shooting_strategy
19+
1420
# TODO: add an option for shifting maybe?
1521
global_strategy = strategies.OrganizeByMoveGroupStrategy()
1622
scheme = paths.MoveScheme(network)

0 commit comments

Comments
 (0)