Class Integrator#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Derived Types#

Class Documentation#

class Integrator : public Karana::Core::BaseWithVars#

Base class for numerical integrators.

Subclassed by Karana::Integrators::EulerIntegrator, Karana::Integrators::IdaIntegrator, Karana::Integrators::NoopIntegrator, Karana::Integrators::PartitionedIntegrator, Karana::Integrators::RK4Integrator, Karana::Integrators::SundialsIntegrator

Public Functions

Integrator(const IntegratorType &integrator_type, size_t num_states, size_t num_q_states, DerivativeFunction deriv_fn, const IntegratorOptions *options = nullptr)#

Constructor.

Parameters:
  • integrator_type – the type of this integrator

  • num_states – the length of the states vector

  • num_q_states – Number of leading Q states; zero means no partition is specified.

  • deriv_fn – the derivative function

  • options – options for the integrator

virtual ~Integrator()#

Destructor.

void _discard(kc::ks_ptr<kc::Base> &base) override#

Discard the Integrator.

Parameters:

base – A base pointer to the Integrator to discard.

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

Method to advance the system state to a specified time.

Parameters:

to_t – the desired end time

Returns:

the actual end time

virtual void softReset(const km::Ktime &new_t, const km::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 num_states, size_t num_q_states)#

Replace the state size and Q partition count.

Parameters:
  • num_states – the new state size

  • num_q_states – Number of leading Q states; zero means no partition is specified.

const km::Vec &getX() const#

Return the current integrator state.

Returns:

the integrator state vector

km::Ktime getTime() const#

Return the current integrator time.

Returns:

the integrator state time

virtual const kc::ks_ptr<IntegratorOptions> getOptions() const#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

IntegratorType getIntegratorType() const#

Get the IntegratorType for this integrator.

Returns:

The IntegratorType for this integrator.

DerivativeFunction derivFunction() const#

Return the derivative function.

Returns:

the derivative function

virtual void updateJacobian(const km::Mat &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

size_t nStates() const#

Return the state size.

Returns:

the integrator state size

size_t nQ() const#

Return the number of leading Q states, or zero for an unspecified partition.

Returns:

The Q partition size supplied at construction or hard reset.

virtual void setVerboseTracing(bool verbose)#

Tell the integrator to be very verbose; mostly used for debugging numerics in a brute-force approach.

Parameters:

verbose –

Protected Functions

void _checkResult(bool result, const km::Ktime &t) const#

Report a rejected derivative evaluation using the integrator type and stage time.

Parameters:
  • result – Success flag returned by the derivative callback.

  • t – Time supplied to that derivative evaluation.

Throws:

std::invalid_argument – When the callback reports failure.

Protected Attributes

bool _verbose_tracing#

Whether to log all integrator stats to a.

km::Ktime _t#

current time

km::Vec _x#

current state

size_t _num_states = 0#

The number of states the integrator has.

size_t _num_q_states = 0#

Number of leading Q states; ordinary integrators do not use this partition.

DerivativeFunction _deriv_fn = nullptr#

The derivative function used to calculate the derivative of the states.

IntegratorType _integrator_type#

The integrator type.

struct IntegratorOptions#

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

Subclassed by Karana::Integrators::IdaIntegrator::IntegratorOptions, Karana::Integrators::SundialsIntegrator::IntegratorOptions

Public Functions

IntegratorOptions() = default#

Constructor

IntegratorOptions(const IntegratorOptions&) = default#

Copy constructor

IntegratorOptions &operator=(const IntegratorOptions &p) = default#

Assignment operator.

Parameters:

p – The IntegratorOptions to assign from.

Returns:

A reference to the IntegratorOptions assigned to.

virtual ~IntegratorOptions() = default#