-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Hello,
I am trying to run a REST2 simulation to fold/unfold small peptide (chignolin and TrpCage).
It seems that femto is more adequate to study protein ligand system, but it looks anyway doable with femto.
Here is my code :
from openmm import app
from openmm.app import PDBFile
from openmm import unit
import femto.md.config
import femto.md.constants
import femto.md.hremd
import femto.md.utils.openmm
import femto.md.rest
import femto.md.system
import parmed
pdb = PDBFile(f"tmp/test_explicit_equi.pdb")
forcefield_files = ['amber14-all.xml', 'amber14/tip3pfb.xml']
forcefield = app.ForceField(*forcefield_files)
system = forcefield.createSystem(
pdb.topology,
nonbondedMethod=app.PME,
nonbondedCutoff=1.0 * unit.nanometers,
constraints=app.HBonds,
rigidWater=True,
ewaldErrorTolerance=0.0005,
hydrogenMass=3.0,
)
rest_temperatures = [300.0, 310.0, 320.0] * unit.kelvin
rest_betas = [
1.0 / (unit.MOLAR_GAS_CONSTANT_R * rest_temperature)
for rest_temperature in rest_temperatures
]
states = [
{femto.md.rest.REST_CTX_PARAM: rest_beta / rest_betas[0]}
for rest_beta in rest_betas
]
# REST requires both beta_m / beta_0 and sqrt(beta_m / beta_0) to be defined
# we can use a helper to compute the later from the former for each state
states = [
femto.md.utils.openmm.evaluate_ctx_parameters(state, system)
for state in states
]
# create the OpenMM simulation object
intergrator_config = femto.md.config.LangevinIntegrator(
timestep=4.0 * unit.femtosecond,
)
integrator = femto.md.utils.openmm.create_integrator(
intergrator_config, rest_temperatures[0]
)
structure = parmed.openmm.topsystem.load_topology(pdb.topology, system, pdb.positions)
femto.md.system.apply_hmr(system, structure)
solute_indices = [int(i.index) for i in pdb.topology.atoms() if i.residue.chain.id in ['A']]
rest_config = femto.md.config.REST(scale_torsions=True, scale_nonbonded=True)
femto.md.rest.apply_rest(system, solute_indices, rest_config)
print(states)
simulation = femto.md.utils.openmm.create_simulation(
system,
structure,
None, # or None to use the coordinates / box in structure
integrator=integrator,
state=states[0],
platform=femto.md.constants.OpenMMPlatform.CUDA,
)
# define how the HREMD should be run
hremd_config = femto.md.config.HREMD(
# the number of steps to run each replica for before starting to
# propose swaps
n_warmup_steps=150000,
# the number of steps to run before proposing swaps
n_steps_per_cycle=500,
# the number of 'swaps' to propose - the total simulation length
# will be n_warmup_steps + n_steps * n_cycles
n_cycles=2000,
# the frequency with which to store trajectories of each replica.
# set to None to not store trajectories
trajectory_interval=10 # store every 10 * 500 steps.
)
femto.md.hremd.run_hremd(
simulation,
states,
hremd_config,
# the directory to store sampled reduced potentials and trajectories to
output_dir=pathlib.Path('test_hremd')
)Here is the error:
[{'bm_b0': 1.0}, {'bm_b0': 0.967741935483871}, {'bm_b0': 0.9375}]
NaN detected for replica=0 state=0, retrying 1/5
NaN detected for replica=0 state=0, retrying 2/5
NaN detected for replica=0 state=0, retrying 3/5
NaN detected for replica=0 state=0, retrying 4/5
NaN detected for replica=0 state=0 that could not be resolved by retries.
Particle coordinate is NaN. For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#nan
Traceback (most recent call last):
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/femto/md/utils/mpi.py", line 85, in get_mpi_comm
yield comm
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/femto/md/hremd.py", line 640, in run_hremd
_propagate_replicas(
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/femto/md/hremd.py", line 235, in _propagate_replicas
simulation.step(n_steps)
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/openmm/app/simulation.py", line 147, in step
self._simulate(endStep=self.currentStep+steps)
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/openmm/app/simulation.py", line 212, in _simulate
self.integrator.step(10) # Only take 10 steps at a time, to give Python more chances to respond to a control-c.
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/openmm/openmm.py", line 9338, in step
return _openmm.LangevinMiddleIntegrator_step(self, steps)
openmm.OpenMMException: Particle coordinate is NaN. For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#nan
Traceback (most recent call last):
File "/mnt/data_22/REST2_test/test_femto_2.py", line 92, in <module>
femto.md.hremd.run_hremd(
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/femto/md/hremd.py", line 640, in run_hremd
_propagate_replicas(
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/femto/md/hremd.py", line 235, in _propagate_replicas
simulation.step(n_steps)
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/openmm/app/simulation.py", line 147, in step
self._simulate(endStep=self.currentStep+steps)
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/openmm/app/simulation.py", line 212, in _simulate
self.integrator.step(10) # Only take 10 steps at a time, to give Python more chances to respond to a control-c.
File "/home/murail/miniforge3/envs/openmm/lib/python3.10/site-packages/openmm/openmm.py", line 9338, in step
return _openmm.LangevinMiddleIntegrator_step(self, steps)
openmm.OpenMMException: Particle coordinate is NaN. For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#nanIs it something link to my installation of femto or am i doing something wrong ?
Cheers,
Samuel
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels