Class Integrator#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Derived Types#

Class Documentation#

class Integrator#

Base class for numerical integrators.

Subclassed by Karana::Math::ArkExplicitIntegrator, Karana::Math::CVodeIntegrator, Karana::Math::EulerIntegrator, Karana::Math::IdaIntegrator, Karana::Math::NoopIntegrator, Karana::Math::RK4Integrator

Public Functions

Integrator(size_t nstates, DerivativeFunction deriv_fn, const IntegratorOptions *options = nullptr)#

Constructor.

Parameters:
  • nstates – the length of the states vector

  • deriv_fn – the derivative function

  • options – options for the integrator

virtual ~Integrator()#

Destructor.

inline virtual const std::string &typeString() const#

Return the integrator type as a string.

Returns:

the integrator type

virtual Ktime advanceTo(const Ktime &to_t) = 0#

Method to advance the sytem state to a specified time.

Parameters:

to_t – the desired end time

Returns:

the actual end time

virtual void softReset(const Ktime &new_t, const Vec &new_x)#

Reset the cached time and state and to the new values going forward.

Parameters:
  • new_t – the new time

  • new_x – the new state

virtual void hardReset(size_t nstates)#

Reset the state size.

Parameters:

nstates – the new state size

inline const Vec &getX() const#

Return the current integrator state.

Returns:

the integrator state vector

inline Ktime getTime() const#

Return the current integrator time.

Returns:

the integrator state time

virtual std::unique_ptr<IntegratorOptions> getOptions() = 0#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

virtual IntegratorType getIntegratorType() const = 0#

Get the IntegratorType for this integrator.

Returns:

The IntegratorType for this integrator.

inline DerivativeFunction derivFunction() const#

Return the derivative function.

Returns:

the derivative function

inline virtual void updateJacobian(const Mat&)#

Update the stored Jacobian matrix with the provided one.

This is currently an experimental feature - and not all integrators support the use of Jacobians.

Parameters:

mat – the new Jacobian matrix

inline size_t nStates() const#

Return the state size.

Returns:

the integrator state size

Public Static Functions

static kc::ks_ptr<Integrator> create(const IntegratorType &integrator_type, size_t nstates, DerivativeFunction deriv_fn, const IntegratorOptions *options = nullptr)#

Factory method for creating an Integrator instances.

Parameters:
  • integrator_type – the type of integrator to create

  • nstates – the length of the states vector

  • deriv_fn – the derivative function

  • options – options for the integrator

Returns:

a new Integrator instance

Protected Attributes

Ktime _t#

current time

Vec _x#

current state

size_t _nstates = 0#

current state derivative

DerivativeFunction _deriv_fn#
std::unique_ptr<IntegratorOptions> _opts = nullptr#
struct IntegratorOptions#

A struct with integrator options. This struct can be sub-classed by specialized classes to add custom options.

Subclassed by Karana::Math::ArkExplicitIntegrator::IntegratorOptions, Karana::Math::CVodeIntegrator::IntegratorOptions, Karana::Math::IdaIntegrator::IntegratorOptions

Public Functions

IntegratorOptions() = default#

Constructor

inline IntegratorOptions(const IntegratorOptions&)#

Copy constructor

inline IntegratorOptions &operator=(const IntegratorOptions&)#
inline virtual ~IntegratorOptions()#