Expose reference position of HarmonicOscillator as a context parameter
@@ -627,7 +627,7 @@ class HarmonicOscillator(TestSystem):
Parameters
----------
- K : simtk.unit.Quantity, optional, default=90.0 * unit.kilocalories_per_mole/unit.angstrom**2
+ K : simtk.unit.Quantity, optional, default=100.0 * unit.kilocalories_per_mole/unit.angstrom**2
harmonic restraining potential
mass : simtk.unit.Quantity, optional, default=39.948 * unit.amu
particle mass
@@ -639,6 +639,13 @@ class HarmonicOscillator(TestSystem):
positions : list
positions of harmonic oscillator
+ Context parameters
+ ------------------
+ testsystems_HarmonicOscillator_K
+ Spring constant of harmonic oscillator
+ testsystems_HarmonicOscillator_x0
+ Reference x position for harmonic oscillator
+
Notes
-----
@@ -696,10 +703,12 @@ class HarmonicOscillator(TestSystem):
system.setDefaultPeriodicBoxVectors([edge,0,0], [0,edge,0], [0,0,edge])
# Add a restrining potential centered at the origin.
- energy_expression = '(K/2.0) * (x^2 + y^2 + z^2);'
+ energy_expression = '(K/2.0) * ((x-x0)^2 + y^2 + z^2);'
energy_expression += 'K = testsystems_HarmonicOscillator_K;'
+ energy_expression += 'x0 = testsystems_HarmonicOscillator_x0;'
force = openmm.CustomExternalForce(energy_expression)
force.addGlobalParameter('testsystems_HarmonicOscillator_K', K)
+ force.addGlobalParameter('testsystems_HarmonicOscillator_x0', 0.0)
force.addParticle(0, [])
system.addForce(force)
