This is file runs the main calculation for the flexible length TPS simulation. It requires the file alanine_dipeptide_tps_equil.nc
, which is written in the notebook alanine_dipeptide_tps_first_traj.ipynb
.
In this file, you will learn:
NB: This is a long calculation. In practice, it would be best to export the Python from this notebook, remove the live_visualizer
, and run non-interactively on a computing node.
In [1]:
from __future__ import print_function
%matplotlib inline
import openpathsampling as paths
In [2]:
from openpathsampling.engines import gromacs as ops_gmx
In [3]:
old_storage = paths.Storage("alanine_dipeptide_tps_equil.nc", mode='r')
In [4]:
options = {
'gmx_executable': 'gmx -nobackup ',
'snapshot_timestep': 0.02,
'n_frames_max': 10000,
}
# we create a new engine because we want to save in new directories
# (prod instead of equil)
engine = ops_gmx.Engine(gro="conf.gro",
mdp="md.mdp",
top="topol.top",
options=options,
base_dir=".",
prefix="prod").named("production")
# make sure we store the calculated versions of phi and psi (enable_diskcache)
phi = old_storage.cvs['phi'].enable_diskcache()
psi = old_storage.cvs['psi'].enable_diskcache()
# load the same network as used for
network = old_storage.networks['tps_network']
final_step = old_storage.steps[-1]
traj = final_step.active[0].trajectory
template = traj[0] # any snapshot is fine
As always, the process for setting up a simulation is:
network
move_scheme
initial_conditions
PathSampling
object and run it.We'll use the same network as before, but because our engine has changed (so that we output to a different directory) we need to create a new move scheme.
In [5]:
scheme = paths.OneWayShootingMoveScheme(network,
selector=paths.UniformSelector(),
engine=engine).named("prod_scheme")
In [6]:
initial_conditions = scheme.initial_conditions_from_trajectories(traj)
In [7]:
storage = paths.Storage("alanine_dipeptide_tps.nc", mode="w")
storage.save(template) # required for diskcache
sampler = paths.PathSampling(storage=storage,
move_scheme=scheme,
sample_set=initial_conditions)
In [8]:
# This sets up debug-level for the engine logging, to provide additional information
# about what is happening
#import logging.config
# set the path to your conf file
#conf_file_loc = "../../openpathsampling/resources/engine_debug.conf"
#logging.config.fileConfig(conf_file_loc, disable_existing_loggers=True)
Note: 1000 steps will take a long time. If you just want to run a little bit, reduce this number.
In [9]:
sampler.run(1000)
In [10]:
# IF YOU HAVE AN ERROR: uncomment and run
# engine.stop(None)
# (this will stop the Gromacs process)
In [11]:
# IF YOU RE-RUN, DELETE EXISTING FILES AND RESTART THE NOTEBOOK
#!rm -rf prod_trr prod_log prod_edr
With this done, you can go on to do the flexible-length parts of the analysis in alanine_dipeptide_tps_analysis.ipynb
.
In [12]:
storage.close()