Commit 047934e2 authored by Rafal P. Wiewiora's avatar Rafal P. Wiewiora
Browse files

Merge remote-tracking branch 'upstream/master'

parents ce3a5dc0 d12c9bd1
...@@ -517,3 +517,15 @@ ...@@ -517,3 +517,15 @@
year = {2014}, year = {2014},
type = {Journal Article} type = {Journal Article}
} }
@article{Wennberg2015
author = {Wennberg, Christian L. and Murtola, Teemu and Páll, Szilárd and Abraham, Mark J. and Hess, Berk and Lindahl, Erik},
title = {Direct-Space Corrections Enable Fast and Accurate {Lorentz–Berthelot} Combination Rule {Lennard-Jones} Lattice Summation},
journal = {Journal of Chemical Theory and Computation},
volume = {11},
number = {12},
pages = {5737-5746},
year = {2015},
type = {Journal Article}
}
...@@ -48,15 +48,15 @@ Angstroms or nm, and angles may be in degrees or radians. OpenMM uses the ...@@ -48,15 +48,15 @@ Angstroms or nm, and angles may be in degrees or radians. OpenMM uses the
following units everywhere. following units everywhere.
=========== ================= =========== =================
Quantity Units Quantity Units
=========== ================= =========== =================
distance nm distance nm
time ps time ps
mass atomic mass units mass atomic mass units
charge proton charge charge proton charge
temperature Kelvin temperature Kelvin
angle radians angle radians
energy kJ/mol energy kJ/mol
=========== ================= =========== =================
These units have the important feature that they form an internally consistent These units have the important feature that they form an internally consistent
...@@ -373,7 +373,7 @@ where *d* is the width of the periodic box, and selects the smallest value ...@@ -373,7 +373,7 @@ where *d* is the width of the periodic box, and selects the smallest value
for k\ :sub:`max` which gives *error* < :math:`\delta`\ . (If the box is not square, for k\ :sub:`max` which gives *error* < :math:`\delta`\ . (If the box is not square,
k\ :sub:`max` will have a different value along each axis.) k\ :sub:`max` will have a different value along each axis.)
This means that the accuracy of the calculation is determined by :math:`\delta`\ . This means that the accuracy of the calculation is determined by :math:`\delta`\ .
:math:`r_\mathit{cutoff}` does not affect the accuracy of the result, but does affect the speed :math:`r_\mathit{cutoff}` does not affect the accuracy of the result, but does affect the speed
of the calculation by changing the relative costs of the direct space and of the calculation by changing the relative costs of the direct space and
reciprocal space sums. You therefore should test different cutoffs to find the reciprocal space sums. You therefore should test different cutoffs to find the
...@@ -412,7 +412,7 @@ and the number of nodes in the mesh along each dimension as ...@@ -412,7 +412,7 @@ and the number of nodes in the mesh along each dimension as
.. math:: .. math::
n_\mathit{mesh}=\frac{2\alpha d}{{3d}^{1/5}} n_\mathit{mesh}=\frac{2\alpha d}{{3\delta}^{1/5}}
where *d* is the width of the periodic box along that dimension. Alternatively, where *d* is the width of the periodic box along that dimension. Alternatively,
...@@ -432,6 +432,38 @@ to numerical round-off error than Ewald summation. For Platforms that do ...@@ -432,6 +432,38 @@ to numerical round-off error than Ewald summation. For Platforms that do
calculations in single precision, making :math:`\delta` too small (typically below about calculations in single precision, making :math:`\delta` too small (typically below about
5·10\ :sup:`-5`\ ) can actually cause the error to increase. 5·10\ :sup:`-5`\ ) can actually cause the error to increase.
Lennard-Jones Interaction With Particle Mesh Ewald
==================================================
The PME algorithm can also be used for Lennard-Jones interactions. Usually this
is not necessary, since Lennard-Jones forces are short ranged, but there are
situations (such as membrane simulations) where neglecting interactions beyond
the cutoff can measurably affect results.
For computational efficiency, certain approximations are made\ :cite:`Wennberg2015`.
Interactions beyond the cutoff distance include only the attractive :math:`1/r^6`
term, not the repulsive :math:`1/r^{12}` term. Since the latter is much smaller
than the former at long distances, this usually has negligible effect. Also,
the interaction between particles farther apart than the cutoff distance is
computed using geometric combination rules:
.. math::
\sigma=\sqrt{\sigma_1 \sigma_2}
The effect of this approximation is also quite small, and it is still far more
accurate than ignoring the interactions altogether (which is what would happen
with PME).
The formula used to compute the number of nodes along each dimension of the mesh
is slightly different from the one used for Coulomb interactions:
.. math::
n_\mathit{mesh}=\frac{\alpha d}{{3\delta}^{1/5}}
As before, this is an empirical formula. It will usually produce an average
relative error in the forces less than or similar to :math:`\delta`\ , but that
is not guaranteed.
.. _gbsaobcforce: .. _gbsaobcforce:
GBSAOBCForce GBSAOBCForce
...@@ -520,7 +552,7 @@ and :math:`\mathbf{S}_2` be diagonal matrices containing the three radii of each ...@@ -520,7 +552,7 @@ and :math:`\mathbf{S}_2` be diagonal matrices containing the three radii of each
The energy is computed as a product of three terms: The energy is computed as a product of three terms:
.. math:: .. math::
E=U_r(\mathbf{A}_1, \mathbf{A}_2, \mathbf{r}_{12}) \cdot \eta_{12}(\mathbf{A}_1, \mathbf{A}_2) \cdot \chi_{12}(\mathbf{A}_1, \mathbf{A}_2, \hat{\mathbf{r}}_{12}) E=U_r(\mathbf{A}_1, \mathbf{A}_2, \mathbf{r}_{12}) \cdot \eta_{12}(\mathbf{A}_1, \mathbf{A}_2) \cdot \chi_{12}(\mathbf{A}_1, \mathbf{A}_2, \hat{\mathbf{r}}_{12})
The first term describes the distance dependence, and is very similar in form to The first term describes the distance dependence, and is very similar in form to
the Lennard-Jones interaction: the Lennard-Jones interaction:
...@@ -920,7 +952,8 @@ of four particles. That is, the interaction energy of each bond is given by ...@@ -920,7 +952,8 @@ of four particles. That is, the interaction energy of each bond is given by
where *f*\ (\ *...*\ ) is a user defined mathematical expression. It may where *f*\ (\ *...*\ ) is a user defined mathematical expression. It may
depend on an arbitrary set of positions {\ :math:`x_i`\ }, distances {\ :math:`r_i`\ }, depend on an arbitrary set of positions {\ :math:`x_i`\ }, distances {\ :math:`r_i`\ },
angles {\ :math:`\theta_i`\ }, and dihedral angles {\ :math:`\phi_i`\ }. angles {\ :math:`\theta_i`\ }, and dihedral angles {\ :math:`\phi_i`\ }
guaranteed to be in the range [-π, π].
Each distance, angle, or dihedral is defined by specifying a sequence of Each distance, angle, or dihedral is defined by specifying a sequence of
particles chosen from among the particles that make up the bond. A distance particles chosen from among the particles that make up the bond. A distance
...@@ -995,7 +1028,7 @@ Parameters may be specified in two ways: ...@@ -995,7 +1028,7 @@ Parameters may be specified in two ways:
* Per-particle parameters are defined by specifying a value for each particle. * Per-particle parameters are defined by specifying a value for each particle.
The energy function is evaluated one or more times for every unique set of The energy function is evaluated one or more times for every unique set of
:math:`N` particles in the system. The exact number of times depends on the :math:`N` particles in the system. The exact number of times depends on the
*permutation mode*\ . A set of :math:`N` particles has :math:`N!` possible *permutation mode*\ . A set of :math:`N` particles has :math:`N!` possible
permutations. In :code:`SinglePermutation` mode, the function is evaluated permutations. In :code:`SinglePermutation` mode, the function is evaluated
for a single arbitrarily chosen one of those permutations. In for a single arbitrarily chosen one of those permutations. In
......
...@@ -63,11 +63,13 @@ def runOneTest(testName, options): ...@@ -63,11 +63,13 @@ def runOneTest(testName, options):
else: else:
method = app.CutoffPeriodic method = app.CutoffPeriodic
cutoff = 1*unit.nanometers cutoff = 1*unit.nanometers
friction = 1*(1/unit.picoseconds)
else: else:
ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml') ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml')
pdb = app.PDBFile('5dfr_minimized.pdb') pdb = app.PDBFile('5dfr_minimized.pdb')
method = app.CutoffNonPeriodic method = app.CutoffNonPeriodic
cutoff = 2*unit.nanometers cutoff = 2*unit.nanometers
friction = 91*(1/unit.picoseconds)
if options.heavy: if options.heavy:
dt = 0.005*unit.picoseconds dt = 0.005*unit.picoseconds
constraints = app.AllBonds constraints = app.AllBonds
...@@ -77,7 +79,7 @@ def runOneTest(testName, options): ...@@ -77,7 +79,7 @@ def runOneTest(testName, options):
constraints = app.HBonds constraints = app.HBonds
hydrogenMass = None hydrogenMass = None
system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass) system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass)
integ = mm.LangevinIntegrator(300*unit.kelvin, 91*(1/unit.picoseconds), dt) integ = mm.LangevinIntegrator(300*unit.kelvin, friction, dt)
print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds)) print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds))
properties = {} properties = {}
initialSteps = 5 initialSteps = 5
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
Sparse_Matrix_CompRow(const Sparse_Matrix_CompRow &S); Sparse_Matrix_CompRow(const Sparse_Matrix_CompRow &S);
Sparse_Matrix_CompRow(int M, int N, int nz, const T *val, Sparse_Matrix_CompRow(int M, int N, int nz, const T *val,
const int *r, const int *c); int *r, int *c);
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
*/ */
template <class T> template <class T>
Sparse_Matrix_CompRow<T>::Sparse_Matrix_CompRow(int M, int N, int nz, Sparse_Matrix_CompRow<T>::Sparse_Matrix_CompRow(int M, int N, int nz,
const T *val, const int *r, const int *c) : val_(nz,val), const T *val, int *r, int *c) : val_(nz,val),
rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {} rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
......
...@@ -408,210 +408,231 @@ int lbfgs( ...@@ -408,210 +408,231 @@ int lbfgs(
pf = (lbfgsfloatval_t*)vecalloc(param.past * sizeof(lbfgsfloatval_t)); pf = (lbfgsfloatval_t*)vecalloc(param.past * sizeof(lbfgsfloatval_t));
} }
/* Evaluate the function value and its gradient. */ try {
fx = cd.proc_evaluate(cd.instance, x, g, cd.n, 0); /* Evaluate the function value and its gradient. */
if (0. != param.orthantwise_c) { fx = cd.proc_evaluate(cd.instance, x, g, cd.n, 0);
/* Compute the L1 norm of the variable and add it to the object value. */ if (0. != param.orthantwise_c) {
xnorm = owlqn_x1norm(x, param.orthantwise_start, param.orthantwise_end); /* Compute the L1 norm of the variable and add it to the object value. */
fx += xnorm * param.orthantwise_c; xnorm = owlqn_x1norm(x, param.orthantwise_start, param.orthantwise_end);
owlqn_pseudo_gradient( fx += xnorm * param.orthantwise_c;
pg, x, g, n,
param.orthantwise_c, param.orthantwise_start, param.orthantwise_end
);
}
/* Store the initial value of the objective function. */
if (pf != NULL) {
pf[0] = fx;
}
/*
Compute the direction;
we assume the initial hessian matrix H_0 as the identity matrix.
*/
if (param.orthantwise_c == 0.) {
vecncpy(d, g, n);
} else {
vecncpy(d, pg, n);
}
/*
Make sure that the initial variables are not a minimizer.
*/
vec2norm(&xnorm, x, n);
if (param.orthantwise_c == 0.) {
vec2norm(&gnorm, g, n);
} else {
vec2norm(&gnorm, pg, n);
}
if (xnorm < 1.0) xnorm = 1.0;
if (gnorm / xnorm <= param.epsilon) {
ret = LBFGS_ALREADY_MINIMIZED;
goto lbfgs_exit;
}
/* Compute the initial step:
step = 1.0 / sqrt(vecdot(d, d, n))
*/
vec2norminv(&step, d, n);
k = 1;
end = 0;
for (;;) {
/* Store the current position and gradient vectors. */
veccpy(xp, x, n);
veccpy(gp, g, n);
/* Search for an optimal step. */
if (param.orthantwise_c == 0.) {
ls = linesearch(n, x, &fx, g, d, &step, xp, gp, w, &cd, &param);
} else {
ls = linesearch(n, x, &fx, g, d, &step, xp, pg, w, &cd, &param);
owlqn_pseudo_gradient( owlqn_pseudo_gradient(
pg, x, g, n, pg, x, g, n,
param.orthantwise_c, param.orthantwise_start, param.orthantwise_end param.orthantwise_c, param.orthantwise_start, param.orthantwise_end
); );
} }
if (ls < 0) {
/* Revert to the previous point. */ /* Store the initial value of the objective function. */
veccpy(x, xp, n); if (pf != NULL) {
veccpy(g, gp, n); pf[0] = fx;
ret = ls;
goto lbfgs_exit;
} }
/* Compute x and g norms. */ /*
vec2norm(&xnorm, x, n); Compute the direction;
we assume the initial hessian matrix H_0 as the identity matrix.
*/
if (param.orthantwise_c == 0.) { if (param.orthantwise_c == 0.) {
vec2norm(&gnorm, g, n); vecncpy(d, g, n);
} else { } else {
vec2norm(&gnorm, pg, n); vecncpy(d, pg, n);
}
/* Report the progress. */
if (cd.proc_progress) {
if (ret = cd.proc_progress(cd.instance, x, g, fx, xnorm, gnorm, step, cd.n, k, ls)) {
goto lbfgs_exit;
}
} }
/* /*
Convergence test. Make sure that the initial variables are not a minimizer.
The criterion is given by the following formula:
|g(x)| / \max(1, |x|) < \epsilon
*/ */
vec2norm(&xnorm, x, n);
if (param.orthantwise_c == 0.) {
vec2norm(&gnorm, g, n);
} else {
vec2norm(&gnorm, pg, n);
}
if (xnorm < 1.0) xnorm = 1.0; if (xnorm < 1.0) xnorm = 1.0;
if (gnorm / xnorm <= param.epsilon) { if (gnorm / xnorm <= param.epsilon) {
/* Convergence. */ ret = LBFGS_ALREADY_MINIMIZED;
ret = LBFGS_SUCCESS; goto lbfgs_exit;
break;
} }
/* /* Compute the initial step:
Test for stopping criterion. step = 1.0 / sqrt(vecdot(d, d, n))
The criterion is given by the following formula:
(f(past_x) - f(x)) / f(x) < \delta
*/ */
if (pf != NULL) { vec2norminv(&step, d, n);
/* We don't test the stopping criterion while k < past. */
if (param.past <= k) { k = 1;
/* Compute the relative improvement from the past. */ end = 0;
rate = (pf[k % param.past] - fx) / fx; for (;;) {
/* Store the current position and gradient vectors. */
/* The stopping criterion. */ veccpy(xp, x, n);
if (rate < param.delta) { veccpy(gp, g, n);
ret = LBFGS_STOP;
break; /* Search for an optimal step. */
if (param.orthantwise_c == 0.) {
ls = linesearch(n, x, &fx, g, d, &step, xp, gp, w, &cd, &param);
} else {
ls = linesearch(n, x, &fx, g, d, &step, xp, pg, w, &cd, &param);
owlqn_pseudo_gradient(
pg, x, g, n,
param.orthantwise_c, param.orthantwise_start, param.orthantwise_end
);
}
if (ls < 0) {
/* Revert to the previous point. */
veccpy(x, xp, n);
veccpy(g, gp, n);
ret = ls;
goto lbfgs_exit;
}
/* Compute x and g norms. */
vec2norm(&xnorm, x, n);
if (param.orthantwise_c == 0.) {
vec2norm(&gnorm, g, n);
} else {
vec2norm(&gnorm, pg, n);
}
/* Report the progress. */
if (cd.proc_progress) {
if (ret = cd.proc_progress(cd.instance, x, g, fx, xnorm, gnorm, step, cd.n, k, ls)) {
goto lbfgs_exit;
} }
} }
/* Store the current value of the objective function. */ /*
pf[k % param.past] = fx; Convergence test.
} The criterion is given by the following formula:
|g(x)| / \max(1, |x|) < \epsilon
*/
if (xnorm < 1.0) xnorm = 1.0;
if (gnorm / xnorm <= param.epsilon) {
/* Convergence. */
ret = LBFGS_SUCCESS;
break;
}
if (param.max_iterations != 0 && param.max_iterations < k+1) { /*
/* Maximum number of iterations. */ Test for stopping criterion.
ret = LBFGSERR_MAXIMUMITERATION; The criterion is given by the following formula:
break; (f(past_x) - f(x)) / f(x) < \delta
} */
if (pf != NULL) {
/* We don't test the stopping criterion while k < past. */
if (param.past <= k) {
/* Compute the relative improvement from the past. */
rate = (pf[k % param.past] - fx) / fx;
/* The stopping criterion. */
if (rate < param.delta) {
ret = LBFGS_STOP;
break;
}
}
/* /* Store the current value of the objective function. */
Update vectors s and y: pf[k % param.past] = fx;
s_{k+1} = x_{k+1} - x_{k} = \step * d_{k}. }
y_{k+1} = g_{k+1} - g_{k}.
*/
it = &lm[end];
vecdiff(it->s, x, xp, n);
vecdiff(it->y, g, gp, n);
/* if (param.max_iterations != 0 && param.max_iterations < k+1) {
Compute scalars ys and yy: /* Maximum number of iterations. */
ys = y^t \cdot s = 1 / \rho. ret = LBFGSERR_MAXIMUMITERATION;
yy = y^t \cdot y. break;
Notice that yy is used for scaling the hessian matrix H_0 (Cholesky factor). }
*/
vecdot(&ys, it->y, it->s, n);
vecdot(&yy, it->y, it->y, n);
it->ys = ys;
/* /*
Recursive formula to compute dir = -(H \cdot g). Update vectors s and y:
This is described in page 779 of: s_{k+1} = x_{k+1} - x_{k} = \step * d_{k}.
Jorge Nocedal. y_{k+1} = g_{k+1} - g_{k}.
Updating Quasi-Newton Matrices with Limited Storage. */
Mathematics of Computation, Vol. 35, No. 151, it = &lm[end];
pp. 773--782, 1980. vecdiff(it->s, x, xp, n);
*/ vecdiff(it->y, g, gp, n);
bound = (m <= k) ? m : k;
++k;
end = (end + 1) % m;
/* Compute the steepest direction. */ /*
if (param.orthantwise_c == 0.) { Compute scalars ys and yy:
/* Compute the negative of gradients. */ ys = y^t \cdot s = 1 / \rho.
vecncpy(d, g, n); yy = y^t \cdot y.
} else { Notice that yy is used for scaling the hessian matrix H_0 (Cholesky factor).
vecncpy(d, pg, n); */
} vecdot(&ys, it->y, it->s, n);
vecdot(&yy, it->y, it->y, n);
it->ys = ys;
j = end; /*
for (i = 0;i < bound;++i) { Recursive formula to compute dir = -(H \cdot g).
j = (j + m - 1) % m; /* if (--j == -1) j = m-1; */ This is described in page 779 of:
it = &lm[j]; Jorge Nocedal.
/* \alpha_{j} = \rho_{j} s^{t}_{j} \cdot q_{k+1}. */ Updating Quasi-Newton Matrices with Limited Storage.
vecdot(&it->alpha, it->s, d, n); Mathematics of Computation, Vol. 35, No. 151,
it->alpha /= it->ys; pp. 773--782, 1980.
/* q_{i} = q_{i+1} - \alpha_{i} y_{i}. */ */
vecadd(d, it->y, -it->alpha, n); bound = (m <= k) ? m : k;
} ++k;
end = (end + 1) % m;
/* Compute the steepest direction. */
if (param.orthantwise_c == 0.) {
/* Compute the negative of gradients. */
vecncpy(d, g, n);
} else {
vecncpy(d, pg, n);
}
vecscale(d, ys / yy, n); j = end;
for (i = 0;i < bound;++i) {
j = (j + m - 1) % m; /* if (--j == -1) j = m-1; */
it = &lm[j];
/* \alpha_{j} = \rho_{j} s^{t}_{j} \cdot q_{k+1}. */
vecdot(&it->alpha, it->s, d, n);
it->alpha /= it->ys;
/* q_{i} = q_{i+1} - \alpha_{i} y_{i}. */
vecadd(d, it->y, -it->alpha, n);
}
for (i = 0;i < bound;++i) { vecscale(d, ys / yy, n);
it = &lm[j];
/* \beta_{j} = \rho_{j} y^t_{j} \cdot \gamma_{i}. */
vecdot(&beta, it->y, d, n);
beta /= it->ys;
/* \gamma_{i+1} = \gamma_{i} + (\alpha_{j} - \beta_{j}) s_{j}. */
vecadd(d, it->s, it->alpha - beta, n);
j = (j + 1) % m; /* if (++j == m) j = 0; */
}
/* for (i = 0;i < bound;++i) {
Constrain the search direction for orthant-wise updates. it = &lm[j];
*/ /* \beta_{j} = \rho_{j} y^t_{j} \cdot \gamma_{i}. */
if (param.orthantwise_c != 0.) { vecdot(&beta, it->y, d, n);
for (i = param.orthantwise_start;i < param.orthantwise_end;++i) { beta /= it->ys;
if (d[i] * pg[i] >= 0) { /* \gamma_{i+1} = \gamma_{i} + (\alpha_{j} - \beta_{j}) s_{j}. */
d[i] = 0; vecadd(d, it->s, it->alpha - beta, n);
j = (j + 1) % m; /* if (++j == m) j = 0; */
}
/*
Constrain the search direction for orthant-wise updates.
*/
if (param.orthantwise_c != 0.) {
for (i = param.orthantwise_start;i < param.orthantwise_end;++i) {
if (d[i] * pg[i] >= 0) {
d[i] = 0;
}
} }
} }
}
/* /*
Now the search direction d is ready. We try step = 1 first. Now the search direction d is ready. We try step = 1 first.
*/ */
step = 1.0; step = 1.0;
}
}
catch (...) {
vecfree(pf);
/* Free memory blocks used by this function. */
if (lm != NULL) {
for (i = 0;i < m;++i) {
vecfree(lm[i].s);
vecfree(lm[i].y);
}
vecfree(lm);
}
vecfree(pg);
vecfree(w);
vecfree(d);
vecfree(gp);
vecfree(g);
vecfree(xp);
throw;
} }
lbfgs_exit: lbfgs_exit:
......
...@@ -555,7 +555,8 @@ public: ...@@ -555,7 +555,8 @@ public:
CutoffNonPeriodic = 1, CutoffNonPeriodic = 1,
CutoffPeriodic = 2, CutoffPeriodic = 2,
Ewald = 3, Ewald = 3,
PME = 4 PME = 4,
LJPME = 5
}; };
static std::string Name() { static std::string Name() {
return "CalcNonbondedForce"; return "CalcNonbondedForce";
...@@ -589,13 +590,22 @@ public: ...@@ -589,13 +590,22 @@ public:
virtual void copyParametersToContext(ContextImpl& context, const NonbondedForce& force) = 0; virtual void copyParametersToContext(ContextImpl& context, const NonbondedForce& force) = 0;
/** /**
* Get the parameters being used for PME. * Get the parameters being used for PME.
* *
* @param alpha the separation parameter * @param alpha the separation parameter
* @param nx the number of grid points along the X axis * @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis * @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis * @param nz the number of grid points along the Z axis
*/ */
virtual void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0; virtual void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0;
/**
* Get the parameters being used for the dispersion terms in LJPME.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
virtual void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0;
}; };
/** /**
...@@ -1335,6 +1345,57 @@ public: ...@@ -1335,6 +1345,57 @@ public:
}; };
/**
* This kernel performs the dispersion reciprocal space calculation for LJPME. In most cases, this
* calculation is done directly by CalcNonbondedForceKernel so this kernel is unneeded.
* In some cases it may want to outsource the work to a different kernel. In particular,
* GPU based platforms sometimes use a CPU based implementation provided by a separate
* plugin.
*/
class CalcDispersionPmeReciprocalForceKernel : public KernelImpl {
public:
class IO;
static std::string Name() {
return "CalcDispersionPmeReciprocalForce";
}
CalcDispersionPmeReciprocalForceKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
}
/**
* Initialize the kernel.
*
* @param gridx the x size of the PME grid
* @param gridy the y size of the PME grid
* @param gridz the z size of the PME grid
* @param numParticles the number of particles in the system
* @param alpha the Ewald blending parameter
*/
virtual void initialize(int gridx, int gridy, int gridz, int numParticles, double alpha) = 0;
/**
* Begin computing the force and energy.
*
* @param io an object that coordinates data transfer
* @param periodicBoxVectors the vectors defining the periodic box (measured in nm)
* @param includeEnergy true if potential energy should be computed
*/
virtual void beginComputation(IO& io, const Vec3* periodicBoxVectors, bool includeEnergy) = 0;
/**
* Finish computing the force and energy.
*
* @param io an object that coordinates data transfer
* @return the potential energy due to the PME reciprocal space interactions
*/
virtual double finishComputation(IO& io) = 0;
/**
* Get the parameters being used for PME.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
virtual void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const = 0;
};
} // namespace OpenMM } // namespace OpenMM
#endif /*OPENMM_KERNELS_H_*/ #endif /*OPENMM_KERNELS_H_*/
...@@ -104,7 +104,7 @@ void Platform::setPropertyDefaultValue(const string& property, const string& val ...@@ -104,7 +104,7 @@ void Platform::setPropertyDefaultValue(const string& property, const string& val
propertyName = deprecatedPropertyReplacements.find(property)->second; propertyName = deprecatedPropertyReplacements.find(property)->second;
for (int i = 0; i < (int) platformProperties.size(); i++) for (int i = 0; i < (int) platformProperties.size(); i++)
if (platformProperties[i] == propertyName) { if (platformProperties[i] == propertyName) {
defaultProperties[property] = value; defaultProperties[propertyName] = value;
return; return;
} }
throw OpenMMException("setPropertyDefaultValue: Illegal property name"); throw OpenMMException("setPropertyDefaultValue: Illegal property name");
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2015 Stanford University and the Authors. * * Portions copyright (c) 2015-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -171,6 +171,16 @@ protected: ...@@ -171,6 +171,16 @@ protected:
* The implementation returns the union of all kernel names required by all Integrators that have been added. * The implementation returns the union of all kernel names required by all Integrators that have been added.
*/ */
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
/**
* This will be called by the Context when the user modifies aspects of the context state, such
* as positions, velocities, or parameters. This gives the Integrator a chance to discard cached
* information. This is <i>only</i> called when the user modifies information using methods of the Context
* object. It is <i>not</i> called when a ForceImpl object modifies state information in its updateContextState()
* method (unless the ForceImpl calls a Context method to perform the modification).
*
* @param changed this specifies what aspect of the Context was changed
*/
void stateChanged(State::DataType changed);
/** /**
* Compute the kinetic energy of the system at the current time. * Compute the kinetic energy of the system at the current time.
* *
......
...@@ -57,7 +57,7 @@ namespace OpenMM { ...@@ -57,7 +57,7 @@ namespace OpenMM {
* <li>distance(p1, p2): the distance between particles p1 and p2 (where "p1" and "p2" may be replaced by the names * <li>distance(p1, p2): the distance between particles p1 and p2 (where "p1" and "p2" may be replaced by the names
* of whichever particles you want to calculate the distance between).</li> * of whichever particles you want to calculate the distance between).</li>
* <li>angle(p1, p2, p3): the angle formed by the three specified particles.</li> * <li>angle(p1, p2, p3): the angle formed by the three specified particles.</li>
* <li>dihedral(p1, p2, p3, p4): the dihedral angle formed by the four specified particles.</li> * <li>dihedral(p1, p2, p3, p4): the dihedral angle formed by the four specified particles, guaranteed to be in the range [-pi,+pi].</li>
* </ul> * </ul>
* *
* The expression also may involve tabulated functions, and may depend on arbitrary * The expression also may involve tabulated functions, and may depend on arbitrary
...@@ -87,7 +87,7 @@ namespace OpenMM { ...@@ -87,7 +87,7 @@ namespace OpenMM {
* force->addPerBondParameter("theta0"); * force->addPerBondParameter("theta0");
* force->addPerBondParameter("r0"); * force->addPerBondParameter("r0");
* </pre></tt> * </pre></tt>
* *
* This class also has the ability to compute derivatives of the potential energy with respect to global parameters. * This class also has the ability to compute derivatives of the potential energy with respect to global parameters.
* Call addEnergyParameterDerivative() to request that the derivative with respect to a particular parameter be * Call addEnergyParameterDerivative() to request that the derivative with respect to a particular parameter be
* computed. You can then query its value in a Context by calling getState() on it. * computed. You can then query its value in a Context by calling getState() on it.
......
...@@ -52,6 +52,7 @@ namespace OpenMM { ...@@ -52,6 +52,7 @@ namespace OpenMM {
* part of the system definition, while values of global parameters may be modified during a simulation by calling Context::setParameter(). * part of the system definition, while values of global parameters may be modified during a simulation by calling Context::setParameter().
* Finally, call addTorsion() once for each torsion. After an torsion has been added, you can modify its parameters by calling setTorsionParameters(). * Finally, call addTorsion() once for each torsion. After an torsion has been added, you can modify its parameters by calling setTorsionParameters().
* This will have no effect on Contexts that already exist unless you call updateParametersInContext(). * This will have no effect on Contexts that already exist unless you call updateParametersInContext().
* theta is guaranteed to be in the range [-pi,+pi]
* *
* As an example, the following code creates a CustomTorsionForce that implements a harmonic potential: * As an example, the following code creates a CustomTorsionForce that implements a harmonic potential:
* *
...@@ -63,7 +64,7 @@ namespace OpenMM { ...@@ -63,7 +64,7 @@ namespace OpenMM {
* force->addPerTorsionParameter("k"); * force->addPerTorsionParameter("k");
* force->addPerTorsionParameter("theta0"); * force->addPerTorsionParameter("theta0");
* </pre></tt> * </pre></tt>
* *
* This class also has the ability to compute derivatives of the potential energy with respect to global parameters. * This class also has the ability to compute derivatives of the potential energy with respect to global parameters.
* Call addEnergyParameterDerivative() to request that the derivative with respect to a particular parameter be * Call addEnergyParameterDerivative() to request that the derivative with respect to a particular parameter be
* computed. You can then query its value in a Context by calling getState() on it. * computed. You can then query its value in a Context by calling getState() on it.
......
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
* @returns true if force uses PBC and false otherwise * @returns true if force uses PBC and false otherwise
*/ */
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return true; return false;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
......
...@@ -147,7 +147,7 @@ public: ...@@ -147,7 +147,7 @@ public:
* @returns true if force uses PBC and false otherwise * @returns true if force uses PBC and false otherwise
*/ */
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return true; return false;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
......
...@@ -244,7 +244,7 @@ public: ...@@ -244,7 +244,7 @@ public:
* @returns true if force uses PBC and false otherwise * @returns true if force uses PBC and false otherwise
*/ */
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return true; return false;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
......
...@@ -101,15 +101,20 @@ public: ...@@ -101,15 +101,20 @@ public:
*/ */
CutoffPeriodic = 2, CutoffPeriodic = 2,
/** /**
* Periodic boundary conditions are used, and Ewald summation is used to compute the interaction of each particle * Periodic boundary conditions are used, and Ewald summation is used to compute the Coulomb interaction of each particle
* with all periodic copies of every other particle. * with all periodic copies of every other particle.
*/ */
Ewald = 3, Ewald = 3,
/** /**
* Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the interaction of each particle * Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the Coulomb interaction of each particle
* with all periodic copies of every other particle. * with all periodic copies of every other particle.
*/ */
PME = 4 PME = 4,
/**
* Periodic boundary conditions are used, and Particle-Mesh Ewald (PME) summation is used to compute the interaction of each particle
* with all periodic copies of every other particle for both Coulomb and Lennard-Jones. No switching is used for either interaction.
*/
LJPME = 5
}; };
/** /**
* Create a NonbondedForce. * Create a NonbondedForce.
...@@ -207,6 +212,16 @@ public: ...@@ -207,6 +212,16 @@ public:
* @param[out] nz the number of grid points along the Z axis * @param[out] nz the number of grid points along the Z axis
*/ */
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const; void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/**
* Get the parameters to use for dispersion term in LJ-PME calculations. If alpha is 0 (the default),
* these parameters are ignored and instead their values are chosen based on the Ewald error tolerance.
*
* @param[out] alpha the separation parameter
* @param[out] nx the number of dispersion grid points along the X axis
* @param[out] ny the number of dispersion grid points along the Y axis
* @param[out] nz the number of dispersion grid points along the Z axis
*/
void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are * Set the parameters to use for PME calculations. If alpha is 0 (the default), these parameters are
* ignored and instead their values are chosen based on the Ewald error tolerance. * ignored and instead their values are chosen based on the Ewald error tolerance.
...@@ -217,6 +232,16 @@ public: ...@@ -217,6 +232,16 @@ public:
* @param nz the number of grid points along the Z axis * @param nz the number of grid points along the Z axis
*/ */
void setPMEParameters(double alpha, int nx, int ny, int nz); void setPMEParameters(double alpha, int nx, int ny, int nz);
/**
* Set the parameters to use for the dispersion term in LJPME calculations. If alpha is 0 (the default),
* these parameters are ignored and instead their values are chosen based on the Ewald error tolerance.
*
* @param alpha the separation parameter
* @param nx the number of grid points along the X axis
* @param ny the number of grid points along the Y axis
* @param nz the number of grid points along the Z axis
*/
void setLJPMEParameters(double alpha, int nx, int ny, int nz);
/** /**
* Get the parameters being used for PME in a particular Context. Because some platforms have restrictions * Get the parameters being used for PME in a particular Context. Because some platforms have restrictions
* on the allowed grid sizes, the values that are actually used may be slightly different from those * on the allowed grid sizes, the values that are actually used may be slightly different from those
...@@ -230,6 +255,19 @@ public: ...@@ -230,6 +255,19 @@ public:
* @param[out] nz the number of grid points along the Z axis * @param[out] nz the number of grid points along the Z axis
*/ */
void getPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const; void getPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const;
/**
* Get the PME parameters being used for the dispersion term for LJPME in a particular Context. Because some
* platforms have restrictions on the allowed grid sizes, the values that are actually used may be slightly different
* from those specified with setPMEParameters(), or the standard values calculated based on the Ewald error tolerance.
* See the manual for details.
*
* @param context the Context for which to get the parameters
* @param[out] alpha the separation parameter
* @param[out] nx the number of grid points along the X axis
* @param[out] ny the number of grid points along the Y axis
* @param[out] nz the number of grid points along the Z axis
*/
void getLJPMEParametersInContext(const Context& context, double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* Add the nonbonded force parameters for a particle. This should be called once for each particle * Add the nonbonded force parameters for a particle. This should be called once for each particle
* in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle. * in the System. When it is called for the i'th time, it specifies the parameters for the i'th particle.
...@@ -374,7 +412,8 @@ public: ...@@ -374,7 +412,8 @@ public:
bool usesPeriodicBoundaryConditions() const { bool usesPeriodicBoundaryConditions() const {
return nonbondedMethod == NonbondedForce::CutoffPeriodic || return nonbondedMethod == NonbondedForce::CutoffPeriodic ||
nonbondedMethod == NonbondedForce::Ewald || nonbondedMethod == NonbondedForce::Ewald ||
nonbondedMethod == NonbondedForce::PME; nonbondedMethod == NonbondedForce::PME ||
nonbondedMethod == NonbondedForce::LJPME;
} }
protected: protected:
ForceImpl* createImpl() const; ForceImpl* createImpl() const;
...@@ -382,9 +421,9 @@ private: ...@@ -382,9 +421,9 @@ private:
class ParticleInfo; class ParticleInfo;
class ExceptionInfo; class ExceptionInfo;
NonbondedMethod nonbondedMethod; NonbondedMethod nonbondedMethod;
double cutoffDistance, switchingDistance, rfDielectric, ewaldErrorTol, alpha; double cutoffDistance, switchingDistance, rfDielectric, ewaldErrorTol, alpha, dalpha;
bool useSwitchingFunction, useDispersionCorrection; bool useSwitchingFunction, useDispersionCorrection;
int recipForceGroup, nx, ny, nz; int recipForceGroup, nx, ny, nz, dnx, dny, dnz;
void addExclusionsToSet(const std::vector<std::set<int> >& bonded12, std::set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const; void addExclusionsToSet(const std::vector<std::set<int> >& bonded12, std::set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const;
std::vector<ParticleInfo> particles; std::vector<ParticleInfo> particles;
std::vector<ExceptionInfo> exceptions; std::vector<ExceptionInfo> exceptions;
......
...@@ -59,6 +59,9 @@ class OPENMM_EXPORT TabulatedFunction { ...@@ -59,6 +59,9 @@ class OPENMM_EXPORT TabulatedFunction {
public: public:
virtual ~TabulatedFunction() { virtual ~TabulatedFunction() {
} }
/**
* @deprecated This will be removed in a future release.
*/
virtual TabulatedFunction* Copy() const = 0; virtual TabulatedFunction* Copy() const = 0;
}; };
...@@ -99,6 +102,8 @@ public: ...@@ -99,6 +102,8 @@ public:
void setFunctionParameters(const std::vector<double>& values, double min, double max); void setFunctionParameters(const std::vector<double>& values, double min, double max);
/** /**
* Create a deep copy of the tabulated function. * Create a deep copy of the tabulated function.
*
* @deprecated This will be removed in a future release.
*/ */
Continuous1DFunction* Copy() const; Continuous1DFunction* Copy() const;
private: private:
...@@ -158,6 +163,8 @@ public: ...@@ -158,6 +163,8 @@ public:
void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax); void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Continuous2DFunction* Copy() const; Continuous2DFunction* Copy() const;
private: private:
...@@ -233,6 +240,8 @@ public: ...@@ -233,6 +240,8 @@ public:
void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax); void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Continuous3DFunction* Copy() const; Continuous3DFunction* Copy() const;
private: private:
...@@ -268,6 +277,8 @@ public: ...@@ -268,6 +277,8 @@ public:
void setFunctionParameters(const std::vector<double>& values); void setFunctionParameters(const std::vector<double>& values);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Discrete1DFunction* Copy() const; Discrete1DFunction* Copy() const;
private: private:
...@@ -310,6 +321,8 @@ public: ...@@ -310,6 +321,8 @@ public:
void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values); void setFunctionParameters(int xsize, int ysize, const std::vector<double>& values);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Discrete2DFunction* Copy() const; Discrete2DFunction* Copy() const;
private: private:
...@@ -356,6 +369,8 @@ public: ...@@ -356,6 +369,8 @@ public:
void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values); void setFunctionParameters(int xsize, int ysize, int zsize, const std::vector<double>& values);
/** /**
* Create a deep copy of the tabulated function * Create a deep copy of the tabulated function
*
* @deprecated This will be removed in a future release.
*/ */
Discrete3DFunction* Copy() const; Discrete3DFunction* Copy() const;
private: private:
......
...@@ -252,6 +252,10 @@ public: ...@@ -252,6 +252,10 @@ public:
void integratorDeleted() { void integratorDeleted() {
integratorIsDeleted = true; integratorIsDeleted = true;
} }
/**
* Notify the integrator that some aspect of the system has changed, and cached information should be discarded.
*/
void systemChanged();
/** /**
* This is the routine that actually computes the list of molecules returned by getMolecules(). Normally * This is the routine that actually computes the list of molecules returned by getMolecules(). Normally
* you should never call it. It is exposed here because the same logic is useful to other classes too. * you should never call it. It is exposed here because the same logic is useful to other classes too.
......
...@@ -65,6 +65,7 @@ public: ...@@ -65,6 +65,7 @@ public:
std::vector<std::string> getKernelNames(); std::vector<std::string> getKernelNames();
void updateParametersInContext(ContextImpl& context); void updateParametersInContext(ContextImpl& context);
void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const; void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
void getLJPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
/** /**
* This is a utility routine that calculates the values to use for alpha and kmax when using * This is a utility routine that calculates the values to use for alpha and kmax when using
* Ewald summation. * Ewald summation.
...@@ -74,7 +75,7 @@ public: ...@@ -74,7 +75,7 @@ public:
* This is a utility routine that calculates the values to use for alpha and grid size when using * This is a utility routine that calculates the values to use for alpha and grid size when using
* Particle Mesh Ewald. * Particle Mesh Ewald.
*/ */
static void calcPMEParameters(const System& system, const NonbondedForce& force, double& alpha, int& xsize, int& ysize, int& zsize); static void calcPMEParameters(const System& system, const NonbondedForce& force, double& alpha, int& xsize, int& ysize, int& zsize, bool lj);
/** /**
* Compute the coefficient which, when divided by the periodic box volume, gives the * Compute the coefficient which, when divided by the periodic box volume, gives the
* long range dispersion correction to the energy. * long range dispersion correction to the energy.
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2013 Stanford University and the Authors. * * Portions copyright (c) 2013-2017 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define NOMINMAX #define NOMINMAX
#include "windowsExport.h" #include "windowsExport.h"
#include <functional>
#include <pthread.h> #include <pthread.h>
#include <vector> #include <vector>
...@@ -69,6 +70,10 @@ public: ...@@ -69,6 +70,10 @@ public:
* Execute a Task in parallel on the worker threads. * Execute a Task in parallel on the worker threads.
*/ */
void execute(Task& task); void execute(Task& task);
/**
* Execute a function in parallel on the worker threads.
*/
void execute(std::function<void (ThreadPool&, int)> task);
/** /**
* This is called by the worker threads to block until all threads have reached the same point * This is called by the worker threads to block until all threads have reached the same point
* and the master thread instructs them to continue by calling resumeThreads(). * and the master thread instructs them to continue by calling resumeThreads().
...@@ -90,6 +95,8 @@ private: ...@@ -90,6 +95,8 @@ private:
std::vector<ThreadData*> threadData; std::vector<ThreadData*> threadData;
pthread_cond_t startCondition, endCondition; pthread_cond_t startCondition, endCondition;
pthread_mutex_t lock; pthread_mutex_t lock;
Task* currentTask;
std::function<void (ThreadPool& pool, int)> currentFunction;
}; };
/** /**
......
...@@ -158,4 +158,5 @@ void CMAPTorsionForceImpl::calcMapDerivatives(int size, const vector<double>& en ...@@ -158,4 +158,5 @@ void CMAPTorsionForceImpl::calcMapDerivatives(int size, const vector<double>& en
void CMAPTorsionForceImpl::updateParametersInContext(ContextImpl& context) { void CMAPTorsionForceImpl::updateParametersInContext(ContextImpl& context) {
kernel.getAs<CalcCMAPTorsionForceKernel>().copyParametersToContext(context, owner); kernel.getAs<CalcCMAPTorsionForceKernel>().copyParametersToContext(context, owner);
context.systemChanged();
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2015 Stanford University and the Authors. * * Portions copyright (c) 2015-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -120,6 +120,11 @@ vector<string> CompoundIntegrator::getKernelNames() { ...@@ -120,6 +120,11 @@ vector<string> CompoundIntegrator::getKernelNames() {
return kernels; return kernels;
} }
void CompoundIntegrator::stateChanged(State::DataType changed) {
for (int i = 0; i < integrators.size(); i++)
integrators[i]->stateChanged(changed);
}
double CompoundIntegrator::computeKineticEnergy() { double CompoundIntegrator::computeKineticEnergy() {
return integrators[currentIntegrator]->computeKineticEnergy(); return integrators[currentIntegrator]->computeKineticEnergy();
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment