Skip to content

History

stephenberry edited this page May 2, 2016 · 2 revisions

Module history() method

All Ascent modules inherit a history() method that allows the history of a tracked variable to be accessed.
For example:
module.track("x"); - Specify x variable to be tracked

std::deque<double>& x_hist = module.history<double>("x"); - Access the current time history of variable x

New history states for tracked variables are pushed back after report, and x_hist will only have full time step results for the x variable. In some cases the internal integration values of x are desirable or computations based on updated x values need to be made at specific points in the integration cycle, for these cases the asc::History class should be used.

If you are already tracking a variable, then often program memory can be saved by using the history() method rather than the History class, but the History class is more flexible in its use.

History class

The asc::History class makes it easy to handle time dependent computations.

In order to save history of a variable's state, the push_back method must be used. An error will be produced if push_back is called when the simulation time hasn't progressed (this is enforced for time dependent algorithms, which would explode if the time difference were zero).

If you want to use push_back in update() then be sure to put it inside a an if (time_advanced) block, because some integration algorithms call update() multiple times for the same simulation time (e.g. Runge Kutta 4th Order).

Values can be pushed back in an if(sample()) block within update(), but if(sample()) causes push_back at the beginning of the time step and not the end. Keep this in mind.

History has built in commonly used algorithms:

  • fit2D (two dimensional curve fitting to a generic Function)
  • derivative
  • extrapolate (extrapolate parameter history given a generic Function)
  • extrapParabolic (parabolic extrapolation curve fit to the function: x(t) = A + Bt + Ct*t)
  • integral
  • mean
  • stdDeviation (standard deviation)

If you want to expand algorithms available to History, then inherit from the class. History's time history (th) and parameter history (x) deques are protected and not private for this purpose.

HistoryVector

The HistoryVector class behaves just like History, except that it keeps track of Eigen vectors (e.g. Eigen::Vector3d). It also provides vectorwise computations.

HistorySparse

Filter out old history data so that real time graphing can more quickly plot a significant time history of a variable.

Clone this wiki locally