All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
CustomIntegrator.h
#ifndef OPENMM_CUSTOMINTEGRATOR_H_
#define OPENMM_CUSTOMINTEGRATOR_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2011-2012 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "Integrator.h"
#include "Vec3.h"
#include "openmm/Kernel.h"
#include "internal/windowsExport.h"
#include <string>
#include <vector>
namespace OpenMM {
class OPENMM_EXPORT CustomIntegrator : public Integrator {
public:
enum ComputationType {
ComputeGlobal = 0,
ComputePerDof = 1,
ComputeSum = 2,
ConstrainPositions = 3,
ConstrainVelocities = 4,
UpdateContextState = 5
};
CustomIntegrator(double stepSize);
int getNumGlobalVariables() const {
return globalNames.size();
}
int getNumPerDofVariables() const {
return perDofNames.size();
}
int getNumComputations() const {
return computations.size();
}
int addGlobalVariable(const std::string& name, double initialValue);
const std::string& getGlobalVariableName(int index) const;
int addPerDofVariable(const std::string& name, double initialValue);
const std::string& getPerDofVariableName(int index) const;
double getGlobalVariable(int index) const;
double getGlobalVariableByName(const std::string& name) const;
void setGlobalVariable(int index, double value);
void setGlobalVariableByName(const std::string& name, double value);
void getPerDofVariable(int index, std::vector<Vec3>& values) const;
void getPerDofVariableByName(const std::string& name, std::vector<Vec3>& values) const;
void setPerDofVariable(int index, const std::vector<Vec3>& values);
void setPerDofVariableByName(const std::string& name, const std::vector<Vec3>& values);
int addComputeGlobal(const std::string& variable, const std::string& expression);
int addComputePerDof(const std::string& variable, const std::string& expression);
int addComputeSum(const std::string& variable, const std::string& expression);
int addConstrainPositions();
int addConstrainVelocities();
int addUpdateContextState();
void getComputationStep(int index, ComputationType& type, std::string& variable, std::string& expression) const;
const std::string& getKineticEnergyExpression() const;
void setKineticEnergyExpression(const std::string& expression);
int getRandomNumberSeed() const {
return randomNumberSeed;
}
void setRandomNumberSeed(int seed) {
randomNumberSeed = seed;
}
void step(int steps);
protected:
void initialize(ContextImpl& context);
void cleanup();
void stateChanged(State::DataType changed);
std::vector<std::string> getKernelNames();
double computeKineticEnergy();
private:
class ComputationInfo;
std::vector<std::string> globalNames;
std::vector<std::string> perDofNames;
mutable std::vector<double> globalValues;
std::vector<std::vector<Vec3> > perDofValues;
std::vector<ComputationInfo> computations;
std::string kineticEnergy;
mutable bool globalsAreCurrent;
int randomNumberSeed;
bool forcesAreValid;
Kernel kernel;
};
class CustomIntegrator::ComputationInfo {
public:
ComputationType type;
std::string variable, expression;
ComputationInfo() {
}
ComputationInfo(ComputationType type, const std::string& variable, const std::string& expression) :
type(type), variable(variable), expression(expression) {
}
};
} // namespace OpenMM
#endif /*OPENMM_CUSTOMINTEGRATOR_H_*/
OpenMM::CustomIntegrator::getNumPerDofVariables
int getNumPerDofVariables() const
Get the number of per-DOF variables that have been defined.
Definition: CustomIntegrator.h:258
OpenMM::CustomIntegrator
This is an Integrator that can be used to implemented arbitrary, user defined integration algorithms...
Definition: CustomIntegrator.h:212
OpenMM::CustomIntegrator::getNumGlobalVariables
int getNumGlobalVariables() const
Get the number of global variables that have been defined.
Definition: CustomIntegrator.h:252
OpenMM::CustomIntegrator::setRandomNumberSeed
void setRandomNumberSeed(int seed)
Set the random number seed.
Definition: CustomIntegrator.h:452
OpenMM::CustomIntegrator::getRandomNumberSeed
int getRandomNumberSeed() const
Get the random number seed.
Definition: CustomIntegrator.h:437
OpenMM::Integrator
An Integrator defines a method for simulating a System by integrating the equations of motion...
Definition: Integrator.h:54
OpenMM::State::DataType
DataType
This is an enumeration of the types of data which may be stored in a State.
Definition: State.h:61
OpenMM::CustomIntegrator::getNumComputations
int getNumComputations() const
Get the number of computation steps that have been added.
Definition: CustomIntegrator.h:264
OpenMM::Kernel
A Kernel encapsulates a particular implementation of a calculation that can be performed on the data ...
Definition: Kernel.h:58
OpenMM
Definition: AndersenThermostat.h:40
OpenMM::CustomIntegrator::ComputationType
ComputationType
This is an enumeration of the different types of computations that may appear in an integration algor...
Definition: CustomIntegrator.h:217