Exemple #1
0
    def __init__(self):

        # must set this here since we need it to generate the state,
        # will get called again in the superclass method
        self.getState_kwargs = dict(GET_STATE_KWARG_DEFAULTS)
        if self.GET_STATE_KWARGS is not None:
            self.getState_kwargs.update(self.GET_STATE_KWARGS)

        test_sys = LennardJonesPair()

        init_state = self.make_state(test_sys.system, test_sys.positions)

        super().__init__(
            distance=PairDistance(),
            init_state=init_state,
            system=test_sys.system,
            topology=test_sys.topology,
        )
Exemple #2
0
hdf5_filename = 'results.wepy.h5'
setup_state_filename = 'setup.pkl'
restart_state_filename = 'restart.pkl'

# normalize the input paths
json_top_path = osp.join(inputs_dir, json_top_filename)

# normalize the output paths
hdf5_path = osp.join(outputs_dir, hdf5_filename)
setup_state_path = osp.join(outputs_dir, setup_state_filename)
restart_state_path = osp.join(outputs_dir, restart_state_filename)

## System and OpenMMRunner

# make the test system from openmmtools
test_sys = LennardJonesPair()

# make the integrator
integrator = omm.LangevinIntegrator(TEMPERATURE, FRICTION_COEFFICIENT,
                                    STEP_SIZE)

# make a context and set the positions
context = omm.Context(test_sys.system, copy(integrator))
context.setPositions(test_sys.positions)

# get the data from this context so we have a state to start the
# simulation with
get_state_kwargs = dict(GET_STATE_KWARG_DEFAULTS)
init_sim_state = context.getState(**get_state_kwargs)
init_state = OpenMMState(init_sim_state)
from simtk.openmm import *
from openmmtools.testsystems import  LennardJonesPair
from openmmtools import alchemy
import numpy as np
from simtk.openmm.vec3 import Vec3
from openforcefield.topology import Molecule, Topology
from openmmforcefields.generators import SystemGenerator

platform = openmm.Platform.getPlatformByName('CPU')
# platform.setPropertyDefaultValue('Precision', 'double')

'''
---SYSTEM PREPARATION---
'''

test_system = LennardJonesPair()
[system, topology, positions] = [test_system.system, test_system.topology , test_system.positions]

reference_force = system.getForces()[0]

sterics_mixing_rules = ()

expression = ('U_sterics;'
              'U_sterics = (1.0-lambda)*4*epsilon*x*(x-1.0);'
              'x = (sigma/reff_sterics)^6;'
              'reff_sterics = (softcore_alpha*lambda*(sigma^softcore_n) + r^softcore_n)^(1.0/softcore_n);'
              'epsilon = sqrt(epsilon1*epsilon2);'
              'sigma = 0.5*(sigma1 + sigma2);')

force = openmm.CustomNonbondedForce(expression)