|
| 1 | +import click |
| 2 | +# import openpathsampling as paths |
| 3 | + |
| 4 | +from paths_cli.parameters import ( |
| 5 | + INPUT_FILE, OUTPUT_FILE, INIT_CONDS, SCHEME |
| 6 | +) |
| 7 | + |
| 8 | +@click.command( |
| 9 | + "equilibrate", |
| 10 | + short_help="Run equilibration for path sampling", |
| 11 | +) |
| 12 | +@INPUT_FILE.clicked(required=True) |
| 13 | +@OUTPUT_FILE.clicked(required=True) |
| 14 | +@SCHEME.clicked(required=False) |
| 15 | +@INIT_CONDS.clicked(required=False) |
| 16 | +@click.option('--multiplier', type=int, default=1, |
| 17 | + help=("run number of steps equal to MULTIPLIER times the " |
| 18 | + + "number of stepss to decorrelate")) |
| 19 | +@click.option("--extra-steps", type=int, default=0, |
| 20 | + help="run EXTRA-STEPS additional steps") |
| 21 | +def equilibrate(input_file, output_file, scheme, init_conds, multiplier, |
| 22 | + extra_steps): |
| 23 | + """Run path sampling equilibration, based on INPUT_FILE. |
| 24 | +
|
| 25 | + This just runs the normal path sampling simulation, but the number of |
| 26 | + steps depends on how long it takes to create a fully decorrelated |
| 27 | + sample set (no frames from the initial trajectories are still active). |
| 28 | +
|
| 29 | + If N_DECORR is the number of steps to fully decorrelate, the total |
| 30 | + number of steps run is: N_DECORR * MULTIPLIER + EXTRA_STEPS |
| 31 | + """ |
| 32 | + storage = INPUT_FILE.get(input_file) |
| 33 | + equilibrate_main( |
| 34 | + output_storage=OUTPUT_FILE.get(output_file), |
| 35 | + scheme=SCHEME.get(storage, scheme), |
| 36 | + init_conds=INIT_CONDS.get(storage, init_conds), |
| 37 | + multiplier=multiplier, |
| 38 | + extra_steps=extra_steps |
| 39 | + ) |
| 40 | + |
| 41 | + |
| 42 | +def equilibrate_main(output_storage, scheme, init_conds, multiplier, |
| 43 | + extra_steps): |
| 44 | + import openpathsampling as paths |
| 45 | + init_conds = scheme.initial_conditions_from_trajectories(init_conds) |
| 46 | + simulation = paths.PathSampling( |
| 47 | + storage=output_storage, |
| 48 | + move_scheme=scheme, |
| 49 | + sample_set=init_conds |
| 50 | + ) |
| 51 | + simulation.run_until_decorrelated() |
| 52 | + n_decorr = simulation.step |
| 53 | + simulation.run(n_decorr * (multiplier - 1) + extra_steps) |
| 54 | + if output_storage: |
| 55 | + output_storage.tags['final_conditions'] = simulation.sample_set |
| 56 | + output_storage.tags['equilibrated'] = simulation.sample_set |
| 57 | + return simulation.sample_set, simulation |
| 58 | + |
| 59 | + |
| 60 | +CLI = equilibrate |
| 61 | +SECTION = "Simulation" |
| 62 | +REQUIRES_OPS = (1, 2) |
0 commit comments