Continuing a Path Sampling Simulation
You’ll often want to continue a simulation – either because there was a problem with a previous simulation, or because you’d decided you need more data than was captured in an initial run.
Like most codes, OpenPathSampling makes it easy for you to continue from a previous simulation. The example we show here is based on the alanine dipeptide MSTIS example.
Restart from existing production file and continue¶
Restarting to generate more data¶
We obviously need OPS
import openpathsampling as paths
Open the storage with mode a
for appendable.
storage = paths.Storage("ala_mstis_production.nc", "a")
Next, we load the pathsimulator. Note, that this object is not really immutable and it has a state. What you actually save are all the immutable options like root sampleset and the move scheme that is used.
Loading a Pathsimulator will automatically set its storage to the one you loaded from. You can of course change this manually.
As a remark! The MoveScheme is also not immutable and depends on the time when you save it. This is currently acceptable from a useability standpoint. It should not affect you but you might keep it in mind.
mstis_calc = storage.pathsimulators[0]
Since the PathSimulator is hollow in the sense described above we still need to initialize it with the actual initial sampleset we want to use. If you really want to continue you can use the restart_at_step
function and it will setup the PathSimulator in a way the it continues from the given step without creating the initial step and resetting Samples etc.
mstis_calc.restart_at_step(storage.steps[-1])
After that we are good to continue at the last (or any other) step of the simulation. This restarting will keep references to the original PathSimulation object so you can better find step that are generated from the same PathSimulator object.
mstis_calc.run(2)
Check the current file size
storage.file_size_str
And close the file. We can continue later...
storage.close()