Functions

Model Timestep and Integration

dsim_model member functions that handle timestep updates. More...

Functions

virtual void dsim_model::initialize_timestep ()
 Overridden by subclasses to prepare for the timestep.
virtual void dsim_model::pre_calculate ()
 Overridden by subclasses to do any single-time calculations necessary before integration.
virtual void dsim_model::post_calculate ()
 Overridden by subclasses to do any single-time calculations necessary after integration.
virtual void dsim_model::complete_timestep ()
 Overridden by subclasses to do any necessary post-timestep cleanup.
virtual void dsim_model::rhs (double t, double jd)
 Overridden by subclasses to set the derivatives of integrated states.
void dsim_model::configure_timestep (bool call_pre, bool call_rhs, bool call_post)
 Called to set which functions are called during a timestep.

Detailed Description

dsim_model member functions that handle timestep updates.

These methods handle the updating of the object at each timestep. Timesteps are managed by the simulation in a strict order. Within each step, the order in which the associated function is called on each object is determined by the dependencies between objects that are provided in the simulation setup file. The order of calls is:

  1. initialize_timestep()
  2. pre_calculate() is called if it has been enabled via configure_timestep()
  3. rhs() is called as many times as the object's integrator demands. rhs() is only called on an object if the object has integrated states or has enabled it via configure_timestep()
  4. post_calculate() is called if it has been enabled via configure_timestep()
  5. complete_timestep()

Function Documentation

void dsim_model::complete_timestep (  ) [virtual, inherited]

Overridden by subclasses to do any necessary post-timestep cleanup.

Called on all objects, in an order determined by dependencies specified in the simulation setup file, at the end of each timestep. Models that override this function must take care to call their superclass's implementation as well.

Reimplemented in dsim_rigid_body, and dsim_second_order.

void dsim_model::configure_timestep ( bool  call_pre,
bool  call_rhs,
bool  call_post 
) [protected, inherited]

Called to set which functions are called during a timestep.

Specify which timestep functions should be called on the object. By default, neither pre_calculate() nor post_calculate() will be called on the object, and rhs() will be called only if the object has at least one integrated state variable. Models can call configure_timestep() to turn on or off calls to these three functions.

Parameters:
call_preWhether or not pre_calculate() should be called on this object.
call_rhsWhether or not rhs() should be called on this object.
call_postWhether or not post_calculate() should be called on this object.
void dsim_model::initialize_timestep (  ) [virtual, inherited]

Overridden by subclasses to prepare for the timestep.

Called on all objects, in an order determined by dependencies specified in the simulation setup file, at the beginning of each timestep. Models that override this function must take care to call their superclass's implementation as well.

Reimplemented in dsim_rigid_body, and dsim_second_order.

void dsim_model::post_calculate (  ) [virtual, inherited]

Overridden by subclasses to do any single-time calculations necessary after integration.

Optionally called on objects, in order determined by dependencies specified in the simulation file, after the intra-timestep integration loop ends. Models may opt-in to having post_calculate() called on them by passing true as the third parameter to a call to configure_timestep(), usually in their initialize_data() or initialization_complete() methods. Models that override this function must take care to call their superclass's implementation as well.

void dsim_model::pre_calculate (  ) [virtual, inherited]

Overridden by subclasses to do any single-time calculations necessary before integration.

Optionally called on objects, in order determined by dependencies specified in the simulation file, prior to the intra-timestep integration loop beginning. Models may opt-in to having pre_calculate() called on them by passing true as the first parameter to a call to configure_timestep(), usually in their initialize_data() or initialization_complete() methods. Models that override this function must take care to call their superclass's implementation as well.

void dsim_model::rhs ( double  t,
double  jd 
) [virtual, inherited]

Overridden by subclasses to set the derivatives of integrated states.

The rhs() function is where all integration occurs. Model implementations of rhs() should calculate and store the derivatives for any integrated states by calling dsim_variable::set_derivative() on the appropriate variables. Models may also implement rhs() to perform co-integration message passing- for instance, sending messages to apply forces and torques that other objects need to integrate.

Objects have rhs() called on them in an order determined by dependencies specified in the simulation, and will generally have it called on them multiple times per timestep. How many times is determined by the object's assigned integrator.

All objects that have integrated states will have rhs() called on them. In addition, models may opt-in to having rhs() called on them by passing true as the second parameter to a call to configure_timestep().

Parameters:
tThe simulation time that should be used for any time-dependent calculations for derivatives.
jdThe Julian Date matching the simulation time.

Reimplemented in dsim_ideal_gravity, dsim_ideal_spring, dsim_rigid_body, and dsim_second_order.

 All Classes Files Functions Typedefs Enumerations Enumerator