CompoundIntegrator¶
-
class
OpenMM::
CompoundIntegrator
¶ This class allows you to use multiple integration algorithms within a single simulation, switching back and forth between them. To use it, create whatever other Integrators you need, then add all of them to a
CustomIntegrator
:CompoundIntegrator compoundIntegrator; compoundIntegrator.addIntegrator(new VerletIntegrator(0.001)); compoundIntegrator.addIntegrator(new LangevinIntegrator(300.0, 1.0, 0.001));
Next create a
Context
, specifying theCompoundIntegrator
as theIntegrator
to use for theContext
:Context context(system, compoundIntegrator);
Finally, call
setCurrentIntegrator()
to set whichIntegrator
is active. That one will be used for all calls tostep()
until the next time you change it.compoundIntegrator.setCurrentIntegrator(0); compoundIntegrator.step(1000); // Take 1000 steps of Verlet dynamics compoundIntegrator.setCurrentIntegrator(1); compoundIntegrator.step(1000); // Take 1000 steps of Langevin dynamics
When switching between integrators, it is important to make sure they are compatible with each other, and that they will interpret the positions and velocities in the same way. Remember that leapfrog style integrators assume the positions and velocities are offset from each other by half a time step. When switching between a leapfrog and non-leapfrog integrator, you must first adjust the velocities to avoid introducing error. This is also true when switching between two leapfrog integrators that use different step sizes, since they will interpret the velocities as corresponding to different times.
Methods
CompoundIntegrator
Create a CompoundIntegrator
.~CompoundIntegrator
getNumIntegrators
Get the number of Integrators that have been added to this CompoundIntegrator
.addIntegrator
Add an Integrator
to thisCompoundIntegrator
.getIntegrator
Get a reference to one of the Integrators that have been added to this CompoundIntegrator
.getIntegrator
Get a const reference to one of the Integrators that have been added to this CompoundIntegrator
.getCurrentIntegrator
Get the index of the current Integrator
.setCurrentIntegrator
Set the current Integrator
.getStepSize
Get the size of each time step, in picoseconds. setStepSize
Set the size of each time step, in picoseconds. getConstraintTolerance
Get the distance tolerance within which constraints are maintained, as a fraction of the constrained distance. setConstraintTolerance
Set the distance tolerance within which constraints are maintained, as a fraction of the constrained distance. step
Advance a simulation through time by taking a series of time steps. -
CompoundIntegrator
()¶ Create a
CompoundIntegrator()
.
-
~CompoundIntegrator
()¶
-
int
getNumIntegrators
() const¶ Get the number of Integrators that have been added to this
CompoundIntegrator
.
-
int
addIntegrator
(Integrator *integrator)¶ Add an
Integrator
to thisCompoundIntegrator
. TheIntegrator
object should have been created on the heap with the “new” operator. TheCompoundIntegrator
takes over ownership of it, and deletes it when theCompoundIntegrator
itself is deleted. All Integrators must be added before theContext
is created.Parameters: - integrator – the
Integrator
to add
Returns: the index of the Integrator
that was added- integrator – the
-
Integrator &
getIntegrator
(int index)¶ Get a reference to one of the Integrators that have been added to this
CompoundIntegrator
.Parameters: - index – the index of the
Integrator
to get
- index – the index of the
-
const Integrator &
getIntegrator
(int index) const¶ Get a const reference to one of the Integrators that have been added to this
CompoundIntegrator
.Parameters: - index – the index of the
Integrator
to get
- index – the index of the
-
int
getCurrentIntegrator
() const¶ Get the index of the current
Integrator
.
-
void
setCurrentIntegrator
(int index)¶ Set the current
Integrator
.Parameters: - index – the index of the
Integrator
to use
- index – the index of the
-
double
getStepSize
() const¶ Get the size of each time step, in picoseconds. This method calls
getStepSize()
on whicheverIntegrator
has been set as current.Returns: the step size, measured in ps
-
void
setStepSize
(double size)¶ Set the size of each time step, in picoseconds. This method calls
setStepSize()
on whicheverIntegrator
has been set as current.Parameters: - size – the step size, measured in ps
-
double
getConstraintTolerance
() const¶ Get the distance tolerance within which constraints are maintained, as a fraction of the constrained distance. This method calls
getConstraintTolerance()
on whicheverIntegrator
has been set as current.
-
void
setConstraintTolerance
(double tol)¶ Set the distance tolerance within which constraints are maintained, as a fraction of the constrained distance. This method calls
setConstraintTolerance()
on whicheverIntegrator
has been set as current.
-
void
step
(int steps)¶ Advance a simulation through time by taking a series of time steps. This method calls
step()
on whicheverIntegrator
has been set as current.Parameters: - steps – the number of time steps to take
-