Skip to content

Commit

Permalink
adopt example from openmmtools
Browse files Browse the repository at this point in the history
  • Loading branch information
wiederm committed Dec 19, 2023
1 parent b426f28 commit 6af6ef6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
3 changes: 1 addition & 2 deletions chiron/tests/test_minization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
def test_minimization():
from chiron.minimze import minimize_energy
import jax
import jax.numpy as jnp

from chiron.states import SamplerState
Expand Down Expand Up @@ -32,4 +31,4 @@ def test_minimization():

min_x = minimize_energy(sampler_state.x0, lj_potential.compute_energy, nbr_list)
e = lj_potential.compute_energy(min_x, nbr_list)
assert jnp.isclose(e, -12506.332)
assert jnp.isclose(e, -12506.332)
39 changes: 39 additions & 0 deletions chiron/tests/test_multistate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
def test_HO():
import math
from openmm import unit
from openmmtools import testsystems
from chiron.multistate import MultiStateSampler
from chiron.mcmc import LangevinDynamicsMove
from chiron.states import ThermodynamicState

testsystem = testsystems.AlanineDipeptideImplicit()

n_replicas = 3
T_min = 298.0 * unit.kelvin # Minimum temperature.
T_max = 600.0 * unit.kelvin # Maximum temperature.
temperatures = [
T_min
+ (T_max - T_min)
* (math.exp(float(i) / float(n_replicas - 1)) - 1.0)
/ (math.e - 1.0)
for i in range(n_replicas)
]
temperatures = [
T_min
+ (T_max - T_min)
* (math.exp(float(i) / float(n_replicas - 1)) - 1.0)
/ (math.e - 1.0)
for i in range(n_replicas)
]
thermodynamic_states = [
ThermodynamicState(system=testsystem.system, temperature=T)
for T in temperatures
]

# Initialize simulation object with options. Run with a langevin integrator.

move = LangevinDynamicsMove(timestep=2.0 * unit.femtoseconds, n_steps=50)
simulation = MultiStateSampler(mcmc_moves=move, number_of_iterations=2)

# Run the simulation
simulation.run()

0 comments on commit 6af6ef6

Please sign in to comment.