def construct_simulator(name, top, sys, pos, timestep=default_timestep, thinning_interval=default_thinning): return EquilibriumSimulator(platform=configure_platform("CUDA"), topology=top, system=sys, positions=pos, temperature=temperature, timestep=timestep, burn_in_length=burn_in_length, n_samples=n_samples, thinning_interval=thinning_interval, name=name)
def simulation_factory(scheme, system_loader, constrained=True): """Create and return a simulation that includes: * Langevin integrator with the prescribed operator splitting * AlanineDipeptideVacuum with or without restraints.""" platform = configure_platform("Reference") temperature = simulation_parameters["temperature"] topology, system, positions = system_loader(constrained) lsi = LangevinSplittingIntegrator(scheme, temperature=temperature, timestep=2.0 * unit.femtosecond, measure_heat=True, measure_shadow_work=True) simulation = app.Simulation(topology, system, lsi, platform) simulation.context.setPositions(positions) simulation.context.setVelocitiesToTemperature(temperature) return simulation
def oscillator_factory(coupling_strength=0.0): testsystem = CoupledPowerOscillators( nx=10, ny=10, nz=10, K=10000, b=12.0, well_radius=0.5, # bond_well_radius=1.0 / (1 + coupling_strength), coupling_strength=coupling_strength * unit.kilocalories_per_mole / unit.angstrom) top, sys, pos = testsystem.topology, testsystem.system, testsystem.positions coupled_power_oscillators = EquilibriumSimulator( platform=configure_platform("CPU"), topology=top, system=sys, positions=pos, temperature=temperature, ghmc_timestep=0.5 * unit.femtosecond, burn_in_length=1000, n_samples=1000, thinning_interval=10, name="coupled_power_oscillators_{}".format(coupling_strength)) return coupled_power_oscillators
from benchmark import simulation_parameters from benchmark.integrators import LangevinSplittingIntegrator from benchmark.testsystems.alanine_dipeptide import load_alanine from benchmark.testsystems.bookkeepers import NonequilibriumSimulator from benchmark.testsystems.configuration import configure_platform import numpy as np n_samples = 100 thinning_interval = 100 temperature = simulation_parameters["temperature"] from benchmark.testsystems.bookkeepers import EquilibriumSimulator top, sys, pos = load_alanine(constrained=True) alanine_constrained = EquilibriumSimulator( platform=configure_platform("Reference"), topology=top, system=sys, positions=pos, temperature=temperature, timestep=1.0 * unit.femtosecond, burn_in_length=500, n_samples=n_samples, thinning_interval=thinning_interval, name="alanine_constrained_test") print("Sample from cache: \n", alanine_constrained.sample_x_from_equilibrium()) sim = NonequilibriumSimulator( alanine_constrained, LangevinSplittingIntegrator("O V R V O", timestep=4.5 * unit.femtoseconds)) result = sim.collect_protocol_samples(100,
def load_waterbox(constrained=True): """Load WaterBox test system""" testsystem = WaterBox(constrained=constrained) (topology, system, positions) = testsystem.topology, testsystem.system, testsystem.positions add_barostat(system) return topology, system, positions temperature = simulation_parameters["temperature"] from benchmark.testsystems.bookkeepers import EquilibriumSimulator top, sys, pos = load_waterbox(constrained=True) waterbox_constrained = EquilibriumSimulator( platform=configure_platform("CUDA"), topology=top, system=sys, positions=pos, temperature=temperature, timestep=1.0 * unit.femtosecond, burn_in_length=100000, n_samples=1000, thinning_interval=10000, name="waterbox_constrained") top, sys, pos = load_waterbox(constrained=False) flexible_waterbox = EquilibriumSimulator(platform=configure_platform("CUDA"), topology=top, system=sys, positions=pos,
force.addBond(int(bond[0]), int(bond[1]), grid_spacing, coupling_strength) system.addForce(force) # Create topology. topology = app.Topology() element = app.Element.getBySymbol('Ar') chain = topology.addChain() for particle in range(system.getNumParticles()): residue = topology.addResidue('Ar', chain) topology.addAtom('Ar', element, residue) # Set topology, positions, system as instance attributes self.topology = topology self.positions = positions self.system = system n_samples = 1000 # number of samples to collect if 'TRAVIS' in os.environ: n_samples = 20 # reduce sampling for travis temperature = simulation_parameters["temperature"] testsystem = CoupledPowerOscillators(nx=5, ny=5, nz=5) top, sys, pos = testsystem.topology, testsystem.system, testsystem.positions coupled_power_oscillators = EquilibriumSimulator(platform=configure_platform("CPU"), topology=top, system=sys, positions=pos, temperature=temperature, timestep=1.0 * unit.femtosecond, burn_in_length=1000, n_samples=n_samples, thinning_interval=10, name="coupled_power_oscillators")
if constrained: testsystem = AlanineDipeptideExplicit(constraints=app.HBonds, rigid_water=True) else: testsystem = AlanineDipeptideExplicit(constraints=None, rigid_water=False) topology, system, positions = testsystem.topology, testsystem.system, testsystem.positions add_barostat(system) return topology, system, positions n_samples = 1000 # number of samples to collect if 'TRAVIS' in os.environ: n_samples = 20 # reduce sampling for travis temperature = simulation_parameters["temperature"] from benchmark.testsystems.bookkeepers import EquilibriumSimulator top, sys, pos = load_alanine(constrained=True) alanine_constrained = EquilibriumSimulator(platform=configure_platform("Reference"), topology=top, system=sys, positions=pos, temperature=temperature, timestep=1.0 * unit.femtosecond, burn_in_length=50000, n_samples=n_samples, thinning_interval=10000, name="alanine_constrained") top, sys, pos = load_alanine(constrained=False) alanine_unconstrained = EquilibriumSimulator(platform=configure_platform("Reference"), topology=top, system=sys, positions=pos, temperature=temperature, timestep=1.0 * unit.femtosecond, burn_in_length=50000, n_samples=n_samples, thinning_interval=10000, name="alanine_unconstrained") top, sys, pos = load_solvated_alanine(constrained=False)