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.

virtual std::string_view 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 system 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

const Vec &getX() const#

Return the current integrator state.

Returns:

the integrator state vector

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.

DerivativeFunction derivFunction() const#

Return the derivative function.

Returns:

the derivative function

virtual void updateJacobian(const 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

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 ODE 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 ODE Integrator instance

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

Factory method for creating a DAE Integrator instances.

Parameters:
  • integrator_type – the type of integrator to create

  • nstates – the length of the states vector (continuous+algebraic)

  • nalgebraic – the number of algebraic values

  • residuals_fn – the residuals function

  • options – options for the integrator

Returns:

a new DAE Integrator instance

Protected Attributes

Ktime _t#

current time

Vec _x#

current state

size_t _nstates = 0#

The number of states the integrator has.

DerivativeFunction _deriv_fn = nullptr#

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

std::unique_ptr<IntegratorOptions> _opts = nullptr#

The integrator options.

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

IntegratorOptions(const IntegratorOptions&) = default#

Copy constructor

IntegratorOptions &operator=(const IntegratorOptions &p)#

Assignment operator.

Parameters:

p – The IntegratorOptions to assign from.

Returns:

A reference to the IntegratorOptions assigned to.

virtual ~IntegratorOptions()#