Commit 4a30156a authored by peastman's avatar peastman
Browse files

Added Integrator.setIntegrationForceGroups()

parent f902295b
...@@ -1623,7 +1623,8 @@ Force Groups ...@@ -1623,7 +1623,8 @@ Force Groups
************ ************
It is possible to split the Force objects in a System into groups. Those groups It is possible to split the Force objects in a System into groups. Those groups
can then be evaluated independently of each other. Some Force classes also can then be evaluated independently of each other. This is done by calling
:code:`setForceGroup()` on the Force. Some Force classes also
provide finer grained control over grouping. For example, NonbondedForce allows provide finer grained control over grouping. For example, NonbondedForce allows
direct space computations to be in one group and reciprocal space computations direct space computations to be in one group and reciprocal space computations
in a different group. in a different group.
...@@ -1631,8 +1632,15 @@ in a different group. ...@@ -1631,8 +1632,15 @@ in a different group.
The most important use of force groups is for implementing multiple time step The most important use of force groups is for implementing multiple time step
algorithms with CustomIntegrator. For example, you might evaluate the slowly algorithms with CustomIntegrator. For example, you might evaluate the slowly
changing nonbonded interactions less frequently than the quickly changing bonded changing nonbonded interactions less frequently than the quickly changing bonded
ones. It also is useful if you want the ability to query a subset of the forces ones. This can be done by putting the slow and fast forces into separate
acting on the system. groups, then using a :class:`MTSIntegrator` or :class:`MTSLangevinIntegrator`
that evaluates the groups at different frequencies.
Another important use is to define forces that are not used when integrating
the equations of motion, but can still be queried efficiently. To do this,
call :code:`setIntegrationForceGroups()` on the :class:`Integrator`. Any groups
omitted will be ignored during simulation, but can be queried at any time by
calling :code:`getState()`.
Virtual Sites Virtual Sites
************* *************
......
...@@ -85,6 +85,18 @@ public: ...@@ -85,6 +85,18 @@ public:
* @param steps the number of time steps to take * @param steps the number of time steps to take
*/ */
virtual void step(int steps) = 0; virtual void step(int steps) = 0;
/**
* Get which force groups to use for integration. By default, all force groups
* are included. This is interpreted as a set if bit flags: the forces from group i
* will be included if (groups&(1<<i)) != 0.
*/
virtual int getIntegrationForceGroups() const;
/**
* Set which force groups to use for integration. By default, all force groups
* are included. This is interpreted as a set if bit flags: the forces from group i
* will be included if (groups&(1<<i)) != 0.
*/
virtual void setIntegrationForceGroups(int groups);
protected: protected:
friend class Context; friend class Context;
friend class ContextImpl; friend class ContextImpl;
...@@ -166,6 +178,7 @@ protected: ...@@ -166,6 +178,7 @@ protected:
} }
private: private:
double stepSize, constraintTol; double stepSize, constraintTol;
int forceGroups;
}; };
} // namespace OpenMM } // namespace OpenMM
......
...@@ -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) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -80,7 +80,7 @@ void BrownianIntegrator::step(int steps) { ...@@ -80,7 +80,7 @@ void BrownianIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateBrownianStepKernel>().execute(*context, *this); kernel.getAs<IntegrateBrownianStepKernel>().execute(*context, *this);
} }
} }
...@@ -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) 2013-2015 Stanford University and the Authors. * * Portions copyright (c) 2013-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
using namespace OpenMM; using namespace OpenMM;
Integrator::Integrator() : owner(NULL), context(NULL) { Integrator::Integrator() : owner(NULL), context(NULL), forceGroups(0xFFFFFFFF) {
} }
Integrator::~Integrator() { Integrator::~Integrator() {
...@@ -69,6 +69,14 @@ void Integrator::setConstraintTolerance(double tol) { ...@@ -69,6 +69,14 @@ void Integrator::setConstraintTolerance(double tol) {
constraintTol = tol; constraintTol = tol;
} }
int Integrator::getIntegrationForceGroups() const {
return forceGroups;
}
void Integrator::setIntegrationForceGroups(int groups) {
forceGroups = groups;
}
std::vector<Vec3> Integrator::getVelocitiesForTemperature(const System &system, double temperature, int randomSeed) const { std::vector<Vec3> Integrator::getVelocitiesForTemperature(const System &system, double temperature, int randomSeed) const {
// Generate the list of Gaussian random numbers. // Generate the list of Gaussian random numbers.
OpenMM_SFMT::SFMT sfmt; OpenMM_SFMT::SFMT sfmt;
......
...@@ -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) 2008-2012 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -76,7 +76,7 @@ void LangevinIntegrator::step(int steps) { ...@@ -76,7 +76,7 @@ void LangevinIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateLangevinStepKernel>().execute(*context, *this); kernel.getAs<IntegrateLangevinStepKernel>().execute(*context, *this);
} }
} }
...@@ -80,7 +80,7 @@ void LangevinMiddleIntegrator::step(int steps) { ...@@ -80,7 +80,7 @@ void LangevinMiddleIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateLangevinMiddleStepKernel>().execute(*context, *this); kernel.getAs<IntegrateLangevinMiddleStepKernel>().execute(*context, *this);
} }
} }
...@@ -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) 2010-2016 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -79,7 +79,7 @@ struct MinimizerData { ...@@ -79,7 +79,7 @@ struct MinimizerData {
static double computeForcesAndEnergy(Context& context, const vector<Vec3>& positions, lbfgsfloatval_t *g) { static double computeForcesAndEnergy(Context& context, const vector<Vec3>& positions, lbfgsfloatval_t *g) {
context.setPositions(positions); context.setPositions(positions);
context.computeVirtualSites(); context.computeVirtualSites();
State state = context.getState(State::Forces | State::Energy); State state = context.getState(State::Forces | State::Energy, false, context.getIntegrator().getIntegrationForceGroups());
const vector<Vec3>& forces = state.getForces(); const vector<Vec3>& forces = state.getForces();
const System& system = context.getSystem(); const System& system = context.getSystem();
for (int i = 0; i < forces.size(); i++) { for (int i = 0; i < forces.size(); i++) {
......
...@@ -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) 2010-2019 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang * * Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: * * Contributors: *
* * * *
...@@ -72,7 +72,8 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) ...@@ -72,7 +72,8 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
// Compute the current potential energy. // Compute the current potential energy.
double initialEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); int groups = context.getIntegrator().getIntegrationForceGroups();
double initialEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double pressure; double pressure;
// Choose which axis to modify at random. // Choose which axis to modify at random.
...@@ -114,7 +115,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) ...@@ -114,7 +115,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double kT = BOLTZ*context.getParameter(MonteCarloAnisotropicBarostat::Temperature()); double kT = BOLTZ*context.getParameter(MonteCarloAnisotropicBarostat::Temperature());
double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume);
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) { if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) {
......
...@@ -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) 2010-2019 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -68,7 +68,8 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc ...@@ -68,7 +68,8 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc
// Compute the current potential energy. // Compute the current potential energy.
double initialEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); int groups = context.getIntegrator().getIntegrationForceGroups();
double initialEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
// Modify the periodic box size. // Modify the periodic box size.
...@@ -83,7 +84,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc ...@@ -83,7 +84,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double pressure = context.getParameter(MonteCarloBarostat::Pressure())*(AVOGADRO*1e-25); double pressure = context.getParameter(MonteCarloBarostat::Pressure())*(AVOGADRO*1e-25);
double kT = BOLTZ*context.getParameter(MonteCarloBarostat::Temperature()); double kT = BOLTZ*context.getParameter(MonteCarloBarostat::Temperature());
double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume);
......
...@@ -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) 2010-2019 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang * * Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: * * Contributors: *
* * * *
...@@ -70,7 +70,8 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) { ...@@ -70,7 +70,8 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
// Compute the current potential energy. // Compute the current potential energy.
double initialEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); int groups = context.getIntegrator().getIntegrationForceGroups();
double initialEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double pressure = context.getParameter(MonteCarloMembraneBarostat::Pressure())*(AVOGADRO*1e-25); double pressure = context.getParameter(MonteCarloMembraneBarostat::Pressure())*(AVOGADRO*1e-25);
double tension = context.getParameter(MonteCarloMembraneBarostat::SurfaceTension())*(AVOGADRO*1e-25); double tension = context.getParameter(MonteCarloMembraneBarostat::SurfaceTension())*(AVOGADRO*1e-25);
...@@ -115,7 +116,7 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) { ...@@ -115,7 +116,7 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double kT = BOLTZ*context.getParameter(MonteCarloMembraneBarostat::Temperature()); double kT = BOLTZ*context.getParameter(MonteCarloMembraneBarostat::Temperature());
double w = finalEnergy-initialEnergy + pressure*deltaVolume - tension*deltaArea - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - tension*deltaArea - context.getMolecules().size()*kT*std::log(newVolume/volume);
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) { if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) {
......
...@@ -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) 2019 Stanford University and the Authors. * * Portions copyright (c) 2019-2020 Stanford University and the Authors. *
* Authors: Andreas Krämer and Andrew C. Simmonett * * Authors: Andreas Krämer and Andrew C. Simmonett *
* Contributors: * * Contributors: *
* * * *
...@@ -337,7 +337,7 @@ void NoseHooverIntegrator::step(int steps) { ...@@ -337,7 +337,7 @@ void NoseHooverIntegrator::step(int steps) {
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
if(context->updateContextState()) if(context->updateContextState())
forcesAreValid = false; forcesAreValid = false;
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateNoseHooverStepKernel>().execute(*context, *this, forcesAreValid); kernel.getAs<IntegrateNoseHooverStepKernel>().execute(*context, *this, forcesAreValid);
} }
} }
......
...@@ -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) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -80,7 +80,7 @@ void VariableLangevinIntegrator::step(int steps) { ...@@ -80,7 +80,7 @@ void VariableLangevinIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity())); setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity()));
} }
} }
...@@ -90,7 +90,7 @@ void VariableLangevinIntegrator::stepTo(double time) { ...@@ -90,7 +90,7 @@ void VariableLangevinIntegrator::stepTo(double time) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
while (time > context->getTime()) { while (time > context->getTime()) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, time)); setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, time));
} }
} }
...@@ -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) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -74,7 +74,7 @@ void VariableVerletIntegrator::step(int steps) { ...@@ -74,7 +74,7 @@ void VariableVerletIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity())); setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity()));
} }
} }
...@@ -84,7 +84,7 @@ void VariableVerletIntegrator::stepTo(double time) { ...@@ -84,7 +84,7 @@ void VariableVerletIntegrator::stepTo(double time) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
while (time > context->getTime()) { while (time > context->getTime()) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, time)); setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, time));
} }
} }
...@@ -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) 2008-2012 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -73,7 +73,7 @@ void VerletIntegrator::step(int steps) { ...@@ -73,7 +73,7 @@ void VerletIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateVerletStepKernel>().execute(*context, *this); kernel.getAs<IntegrateVerletStepKernel>().execute(*context, *this);
} }
} }
...@@ -5709,7 +5709,7 @@ void CommonIntegrateNoseHooverStepKernel::execute(ContextImpl& context, const No ...@@ -5709,7 +5709,7 @@ void CommonIntegrateNoseHooverStepKernel::execute(ContextImpl& context, const No
// If the atom reordering has occured, the forces from the previous step are permuted and thus invalid. // If the atom reordering has occured, the forces from the previous step are permuted and thus invalid.
// They need to be either sorted or recomputed; here we choose the latter. // They need to be either sorted or recomputed; here we choose the latter.
if (!forcesAreValid || cc.getAtomsWereReordered()) context.calcForcesAndEnergy(true, false); if (!forcesAreValid || cc.getAtomsWereReordered()) context.calcForcesAndEnergy(true, false, integrator.getIntegrationForceGroups());
const auto& atomList = integrator.getAllThermostatedIndividualParticles(); const auto& atomList = integrator.getAllThermostatedIndividualParticles();
const auto& pairList = integrator.getAllThermostatedPairs(); const auto& pairList = integrator.getAllThermostatedPairs();
...@@ -6770,7 +6770,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -6770,7 +6770,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
// Record the variable names and flags for the force and energy in each step. // Record the variable names and flags for the force and energy in each step.
forceGroupFlags.resize(numSteps, -1); forceGroupFlags.resize(numSteps, integrator.getIntegrationForceGroups());
vector<string> forceGroupName; vector<string> forceGroupName;
vector<string> energyGroupName; vector<string> energyGroupName;
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
......
/* Portions copyright (c) 2011-2017 Stanford University and Simbios. /* Portions copyright (c) 2011-2020 Stanford University and Simbios.
* Contributors: Peter Eastman * Contributors: Peter Eastman
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -171,7 +171,7 @@ void ReferenceCustomDynamics::initialize(ContextImpl& context, vector<double>& m ...@@ -171,7 +171,7 @@ void ReferenceCustomDynamics::initialize(ContextImpl& context, vector<double>& m
// Record the force group flags for each step. // Record the force group flags for each step.
forceGroupFlags.resize(numSteps, -1); forceGroupFlags.resize(numSteps, integrator.getIntegrationForceGroups());
for (int i = 0; i < numSteps; i++) for (int i = 0; i < numSteps; i++)
if (forceGroup[i] > -1) if (forceGroup[i] > -1)
forceGroupFlags[i] = 1<<forceGroup[i]; forceGroupFlags[i] = 1<<forceGroup[i];
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "openmm/Integrator.h"
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "SimTKOpenMMUtilities.h" #include "SimTKOpenMMUtilities.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
...@@ -55,7 +56,7 @@ void ReferenceNoseHooverDynamics::step1(OpenMM::ContextImpl &context, const Open ...@@ -55,7 +56,7 @@ void ReferenceNoseHooverDynamics::step1(OpenMM::ContextImpl &context, const Open
double maxPairDistance) { double maxPairDistance) {
// first-time-through initialization // first-time-through initialization
if (!forcesAreValid) context.calcForcesAndEnergy(true, false); if (!forcesAreValid) context.calcForcesAndEnergy(true, false, context.getIntegrator().getIntegrationForceGroups());
if (getTimeStep() == 0) { if (getTimeStep() == 0) {
// invert masses // invert masses
......
...@@ -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) 2008-2018 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs * * Authors: Peter Eastman, Mark Friedrichs *
* Contributors: * * Contributors: *
* * * *
...@@ -1782,7 +1782,7 @@ void CudaCalcAmoebaMultipoleForceKernel::ensureMultipolesValid(ContextImpl& cont ...@@ -1782,7 +1782,7 @@ void CudaCalcAmoebaMultipoleForceKernel::ensureMultipolesValid(ContextImpl& cont
} }
} }
if (!multipolesAreValid) if (!multipolesAreValid)
context.calcForcesAndEnergy(false, false, -1); context.calcForcesAndEnergy(false, false, context.getIntegrator().getIntegrationForceGroups());
} }
...@@ -3650,7 +3650,7 @@ void CudaCalcHippoNonbondedForceKernel::ensureMultipolesValid(ContextImpl& conte ...@@ -3650,7 +3650,7 @@ void CudaCalcHippoNonbondedForceKernel::ensureMultipolesValid(ContextImpl& conte
} }
} }
if (!multipolesAreValid) if (!multipolesAreValid)
context.calcForcesAndEnergy(false, false, -1); context.calcForcesAndEnergy(false, false, context.getIntegrator().getIntegrationForceGroups());
} }
void CudaCalcHippoNonbondedForceKernel::getLabFramePermanentDipoles(ContextImpl& context, vector<Vec3>& dipoles) { void CudaCalcHippoNonbondedForceKernel::getLabFramePermanentDipoles(ContextImpl& context, vector<Vec3>& dipoles) {
......
...@@ -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) 2013-2019 Stanford University and the Authors. * * Portions copyright (c) 2013-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -516,7 +516,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf ...@@ -516,7 +516,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
// Compute the forces and energy for this configuration. // Compute the forces and energy for this configuration.
double energy = context.calcForcesAndEnergy(true, true); double energy = context.calcForcesAndEnergy(true, true, context.getIntegrator().getIntegrationForceGroups());
long long* force = (long long*) cc.getPinnedBuffer(); long long* force = (long long*) cc.getPinnedBuffer();
cc.getLongForceBuffer().download(force); cc.getLongForceBuffer().download(force);
double forceScale = -1.0/0x100000000; double forceScale = -1.0/0x100000000;
......
...@@ -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) 2011-2014 Stanford University and the Authors. * * Portions copyright (c) 2011-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -497,7 +497,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf ...@@ -497,7 +497,7 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
vector<Vec3>& force = extractForces(context); vector<Vec3>& force = extractForces(context);
for (int i = 0; i < numDrudeParticles; i++) for (int i = 0; i < numDrudeParticles; i++)
pos[drudeParticles[i]] = Vec3(x[3*i], x[3*i+1], x[3*i+2]); pos[drudeParticles[i]] = Vec3(x[3*i], x[3*i+1], x[3*i+2]);
double energy = context.calcForcesAndEnergy(true, true); double energy = context.calcForcesAndEnergy(true, true, context.getIntegrator().getIntegrationForceGroups());
for (int i = 0; i < numDrudeParticles; i++) { for (int i = 0; i < numDrudeParticles; i++) {
Vec3 f = force[drudeParticles[i]]; Vec3 f = force[drudeParticles[i]];
g[3*i] = -f[0]; g[3*i] = -f[0];
......
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