Simbody
3.5
|
This is a stripped-down numerical integrator for small ODE or DAE problems whose size is known at compile time, with no provision for discrete variables, event detection, or interpolation. More...
Public Types | |
enum | { NQ = Eqn::NQ, NC = Eqn::NC, N = 2*NQ } |
Public Member Functions | |
GeodesicIntegrator (const Eqn &eqn, Real accuracy, Real constraintTol) | |
Construct an integrator for the given set of equations eqn, which are to be solved to the given accuracy, with constraints maintained to within the given constraintTol. More... | |
void | initialize (Real t, const Vec< N > &y) |
Call this once before taking a series of steps. More... | |
void | setTimeAndState (Real t, const Vec< N > &y) |
Set initial time and state prior to integrating. More... | |
void | setNextStepSizeToTry (Real h) |
Use this if you think you know a better initial step size to try than the default. More... | |
Real | getNextStepSizeToTry () const |
Return the size of the next time step the integrator will attempt on the next call to takeOneStep(). More... | |
Real | getRequiredAccuracy () const |
Return the accuracy requirement as set in the constructor. More... | |
Real | getConstraintTolerance () const |
Return the constraint tolerance as set in the constructor. More... | |
Real | getActualInitialStepSizeTaken () const |
Return the size of the first accepted step to be taken after the most recent initialize() call. More... | |
int | getNumStepsTaken () const |
Return the number of successful time steps taken since the most recent initialize() call. More... | |
int | getNumStepsAttempted () const |
Return the total number of steps that were attempted since the most recent initialize() call. More... | |
int | getNumErrorTestFailures () const |
How many steps were rejected because they did not satisfy the accuracy requirement, since the most recent initalize() call. More... | |
int | getNumProjectionFailures () const |
How many steps were rejected because the projectIfNeeded() method was unable to satisfy the constraint tolerance (since the most recent initialize() call). More... | |
int | getNumInitializations () const |
Return the number of calls to initialize() since construction of this integrator object. More... | |
void | takeOneStep (Real tStop) |
Advance time and state by one error-controlled step and return, but in no case advance past t=tStop. More... | |
const Real & | getTime () const |
Return the current time. More... | |
const Vec< N > & | getY () const |
Return the complete current state as a Vec<N>. More... | |
const Vec< NQ > & | getQ () const |
Return just the "position" variables q from the current state. More... | |
const Vec< NQ > & | getU () const |
Return just the "velocity" variables u from the current state. More... | |
const Vec< N > & | getYDot () const |
Return the complete set of time derivatives of the current state. More... | |
const Vec< NQ > & | getQDot () const |
Return just the derivatives qdot of the "position" variables q. More... | |
const Vec< NQ > & | getUDot () const |
Return just the derivatives udot of the "velocity" variables u. More... | |
Static Public Member Functions | |
template<int Z> | |
static Real | calcNormInf (const Vec< Z > &v) |
This is a utility routine that returns the infinity norm (maximum absolute value) contained in a fixed-size, scalar Vec. More... | |
template<int Z> | |
static Real | calcNormRMS (const Vec< Z > &v) |
This is a utility routine that returns the RMS norm of a fixed-size, scalar Vec. More... | |
This is a stripped-down numerical integrator for small ODE or DAE problems whose size is known at compile time, with no provision for discrete variables, event detection, or interpolation.
You cannot use this integrator to advance a Simbody System; see Integrator instead. Everything is defined in this header file so that the integration can proceed with virtually no overhead. Templates are used rather than run-time polymorphism, so there are no virtual function calls. The system of equations is given as a template object that must implement particular methods which the compiler may inline if they are simple enough.
This integrator is instantiated with a class that encapsulates the system of equations to be solved, and must provide compile time constants and methods with the following signatures:
This is an explicit, variable-step integrator solving a 2nd-order DAE structured as an ODE-on-a-manifold system[1] like this:
(1) udot = f(t,q,u) NQ dynamic differential equations (2) qdot = u NQ kinematic differential equations (3) 0 = c(t,q,u) NC constraints
Here the "dot" suffix indicates differentiation with respect to the independent variable t which we'll refer to as time here although it can be anything (for geodesic calculations it is arc length). We'll call the second order variables q the "position variables", and their time derivatives u the "velocity variables". Collected together we call the state y={q,u}. At the beginning of a step, we expect to have been given initial conditions t0,q0,u0 such that |c(t0,q0,u0)|<=tol. The user provides the accuracy requirement and constraint tolerance. We solve the system to that accuracy while keeping the constraints within tolerance. The integrator returns after taking a successful step which may involve trial evaluations that are retracted.
By "ODE on a manifold" we mean that the ODE (1,2) automatically satisfies the condition that IF c==0, THEN cdot=0, where
cdot=Dc/Dt + Dc/Dq*qdot + Dc/Du*udot
This means that satisfaction of the acceleration-level constraints is built into the dynamic differential equations (1) so that we need only deal with relatively slow drift of the solution away from the position and velocity constraint manifolds.
To handle the constraint drift we use the method of coordinate projection and expect the supplied Equations object to be able to perform a least-squares projection of a state (q,u) to move it onto the constraint manifolds.
[1] Hairer, Lubich, Wanner, "Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations", 2nd ed., section IV.4, pg 109ff, Springer, 2006.
|
inline |
Construct an integrator for the given set of equations eqn, which are to be solved to the given accuracy, with constraints maintained to within the given constraintTol.
|
inline |
Call this once before taking a series of steps.
This sets the initial conditions, and calculates the starting derivatives and constraint errors. The constraints must be satisfied already by the given state; an error is thrown if not.
|
inline |
Set initial time and state prior to integrating.
State derivatives and constraint errors are calculated and an error is thrown if the constraints are not already satisifed to the required tolerance.
|
inline |
Use this if you think you know a better initial step size to try than the default.
|
inline |
Return the size of the next time step the integrator will attempt on the next call to takeOneStep().
|
inline |
Return the accuracy requirement as set in the constructor.
|
inline |
Return the constraint tolerance as set in the constructor.
|
inline |
Return the size of the first accepted step to be taken after the most recent initialize() call.
|
inline |
Return the number of successful time steps taken since the most recent initialize() call.
|
inline |
Return the total number of steps that were attempted since the most recent initialize() call.
In general this will be more than the number of steps taken since some will be rejected.
|
inline |
How many steps were rejected because they did not satisfy the accuracy requirement, since the most recent initalize() call.
This is common but for non-stiff systems should be only a modest fraction of the number of steps taken.
|
inline |
How many steps were rejected because the projectIfNeeded() method was unable to satisfy the constraint tolerance (since the most recent initialize() call).
This should be very rare.
|
inline |
Return the number of calls to initialize() since construction of this integrator object.
void SimTK::GeodesicIntegrator< Eqn >::takeOneStep | ( | Real | tStop | ) |
Advance time and state by one error-controlled step and return, but in no case advance past t=tStop.
The integrator's internal time, state, and state derivatives are advanced to the end of the step. If this step reaches tStop, the returned time will be exactly tStop.
|
inline |
Return the current time.
|
inline |
Return the complete current state as a Vec<N>.
|
inline |
Return just the "position" variables q from the current state.
|
inline |
Return just the "velocity" variables u from the current state.
|
inline |
Return the complete set of time derivatives of the current state.
|
inline |
Return just the derivatives qdot of the "position" variables q.
|
inline |
Return just the derivatives udot of the "velocity" variables u.
|
inlinestatic |
This is a utility routine that returns the infinity norm (maximum absolute value) contained in a fixed-size, scalar Vec.
|
inlinestatic |
This is a utility routine that returns the RMS norm of a fixed-size, scalar Vec.