Karana.Integrators

Contents

Karana.Integrators#

Collection of classes to represent mathematical object used in Karana Dynamics simulations.

Examples include unit quaternions, homogeneous transforms, and spatial vectors.

Submodules#

Attributes#

Classes#

ArkExplicitIntegrator

The multistep ArkODE explicit integrator from the SUNDIALS suite

ArkExplicitIntegratorVars

The Vars for the ArkExplicitIntegrator class.

ArkImplicitIntegrator

The (implicit) Adaptive Runge-Kutta integrator from the SUNDIALS suite

ArkImplicitIntegratorOptions

Options specific to the implicit ARKODE integrator.

ArkImplicitIntegratorVars

The Vars for the ArkImplicitIntegrator class.

CVodeIntegrator

The multistep CVode integrator from the SUNDIALS suite

CVodeIntegratorOptions

CVODE multistep controls shared by its Adams and BDF presets.

CVodeIntegratorVars

The Vars for the CVodeIntegrator class.

EulerIntegrator

The fixed-step Euler one step integrator.

ExplicitVerletIntegrator

Explicit kick-drift-kick Verlet for separable Q/U equations.

Integrator

Base class for numerical integrators

IntegratorOptions

A struct with integrator options. This struct can be

IntegratorType

Enum of integrator types.

PartitionedIntegrator

Abstract integrator for states packed as [Q, U].

RK4Integrator

Fixed-step Runge-Kutta 4th order integrator

SundialsImplicitIntegrator

Abstract base class for implicit Sundials integrators (CVode/ARKStep).

SundialsImplicitIntegratorOptions

Struct with options for this integrator

SundialsImplicitIntegratorVars

The Vars for the SundialsImplicitIntegrator class.

SundialsIntegrator

Abstract base class for Sundials-related integrators.

SundialsIntegratorOptions

Struct with options for this integrator

SundialsIntegratorVars

The Vars for the SundialsIntegrator class.

Functions#

createIntegrator(…)

Factory method for creating DAE Integrator instances

strToIntegratorType(→ IntegratorType)

Convert string to IntegratorType enum.

Package Contents#

class Karana.Integrators.ArkExplicitIntegrator#

Bases: SundialsIntegrator, Integrator

The multistep ArkODE explicit integrator from the SUNDIALS suite

getAdaptiveStepping() → bool#

Report whether adaptive step-size control is enabled.

Returns:

True when ARKODE controls the step size adaptively.

getErrorContributions() → Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#

Get the error contribution for each state.

Returns:

A vector with the error contribution for each state.

getOptions() → SundialsIntegratorOptions#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

getVars() → ArkExplicitIntegratorVars#
setAdaptiveStepping(use_adaptive_steps: bool) → None#

Select adaptive or fixed-step integration.

Parameters:

use_adaptive_steps – True for adaptive stepping; false for fixed stepping.

setFixedStepSize(fixed_step_size: SupportsFloat | SupportsIndex) → None#

Set a fixed step size in fixed-step mode.

Call setAdaptiveStepping(false) to enable fixed stepping. ARKODE may take a smaller final step only to reach the requested target time exactly.

Parameters:

fixed_step_size – Positive fixed step size in seconds.

Karana.Integrators.ArkExplicitIntegratorOptions#
class Karana.Integrators.ArkExplicitIntegratorVars#

Bases: SundialsIntegratorVars

The Vars for the ArkExplicitIntegrator class.

class Karana.Integrators.ArkImplicitIntegrator#

Bases: SundialsImplicitIntegrator

The (implicit) Adaptive Runge-Kutta integrator from the SUNDIALS suite

class PredictorMethod(*args, **kwds)#

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

CUTOFF_ORDER: ClassVar[ArkImplicitIntegrator]#
MAXIMUM_ORDER: ClassVar[ArkImplicitIntegrator]#
TRIVIAL: ClassVar[ArkImplicitIntegrator]#
VARIABLE_ORDER: ClassVar[ArkImplicitIntegrator]#
getAdaptiveStepping() → bool#

Return whether adaptive stepping is enabled.

getErrorContributions() → Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#

Get the error contribution for each state.

Returns:

A vector with the error contribution for each state.

getOptions() → ArkImplicitIntegratorOptions#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

getVars() → ArkImplicitIntegratorVars#
setAdaptiveStepping(use_adaptive_steps: bool) → None#

Enable or disable adaptive stepping.

setFixedStepSize(fixed_step_size: SupportsFloat | SupportsIndex) → None#

Set the fixed step size in seconds.

class Karana.Integrators.ArkImplicitIntegratorOptions#

Bases: SundialsImplicitIntegratorOptions

Options specific to the implicit ARKODE integrator.

property predictor_method: ArkImplicitIntegrator#

Implicit-stage predictor used by ARK implicit.

class Karana.Integrators.ArkImplicitIntegratorVars#

Bases: SundialsImplicitIntegratorVars

The Vars for the ArkImplicitIntegrator class.

class Karana.Integrators.CVodeIntegrator#

Bases: SundialsImplicitIntegrator

The multistep CVode integrator from the SUNDIALS suite

estimateDynamicsJacobian() → Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]#

Estimate the current RHS Jacobian; columns identify perturbed state indices. This explicit diagnostic performs extra RHS calls and restores the base state.

getDetectStalls() → bool#

Return whether automatic stall monitoring and tracing are enabled.

getErrorContributions() → Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#

Get the error contribution for each state.

Returns:

A vector with the error contribution for each state.

getLastAdvanceErrorTestFailures() → int#

Return error-test failures in the most recent monitored CVODE advance.

getLastAdvanceRhsEvals() → int#

Return RHS evaluations in the most recent monitored CVODE advance.

getLastAdvanceSteps() → int#

Return accepted steps in the most recent monitored CVODE advance.

getOptions() → CVodeIntegratorOptions#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

getStallCount() → int#

Return the number of flagged advances since the last hard reset.

getStallLogFile() → str#

Return the configured stall log filename, or empty when disabled.

getVars() → CVodeIntegratorVars#
setDetectStalls(enabled: bool) → None#

Toggle automatic stall monitoring and its timestamped trace file.

setEtaFixedStepBounds(eta_min_fx: SupportsFloat | SupportsIndex, eta_max_fx: SupportsFloat | SupportsIndex) → None#
Experimental: retain step size for proposed ratios strictly between

the bounds.

Parameters:
  • lower – Finite lower bound in [0, 1]; raising it permits more decreases.

  • upper – Finite upper bound >= 1 and > lower; raising it suppresses more increases.

setMaxOrder(order: SupportsInt | SupportsIndex) → None#

Set the maximum multistep order; zero restores the method default.

Lowering below active history restarts that history at the current state/time, preserving cumulative work counters. Invalid values leave options unchanged.

Parameters:

order – Zero, or 1..12 for Adams / 1..5 for BDF.

setStabilityLimitDetection(enabled: bool) → None#

Experimental: toggle BDF stability-limit detection.

May reset or reduce num_stab_lim_order_reductions.

Parameters:

enabled – True only for BDF; false is supported for every CVODE preset.

property detect_stalls: bool#

Enable automatic CVODE stall detection and timestamped HDF5 tracing.

property stall_log_file: str#

Automatically generated HDF5 stall-trace filename, or empty while disabled.

class Karana.Integrators.CVodeIntegratorOptions#

Bases: SundialsImplicitIntegratorOptions

CVODE multistep controls shared by its Adams and BDF presets.

property eta_max_fx: float#
upper bound of the step-size ratio deadband after

successful

integration steps.

Type:

Experimental

property eta_min_fx: float#
lower bound of the step-size ratio deadband after

successful

integration steps.

Type:

Experimental

property max_order: int#

Maximum integration order; 0 uses the default (Adams 12, BDF 5).

property stability_limit_detection: bool#
reduce BDF order when a stability limit is detected (BDF

only).

Toggling may reset or reduce num_stab_lim_order_reductions.

Type:

Experimental

class Karana.Integrators.CVodeIntegratorVars#

Bases: SundialsImplicitIntegratorVars

The Vars for the CVodeIntegrator class.

property curr_gamma: Karana.Core._KCore_pybind11_Py._VarDouble#

Current CVODE gamma coefficient in I - gamma J. Returns -1.0 (unavailable) before the first accepted step after initialization or reset.

property curr_order: Karana.Core._KCore_pybind11_Py._VarInt#

Order selected for the next CVODE step; zero immediately after initialization/reset.

property last_advance_error_test_failures: Karana.Core._KCore_pybind11_Py._VarLong#

Error-test failures in the last monitored advance; -1 while monitoring is inactive.

property last_advance_rhs_evals: Karana.Core._KCore_pybind11_Py._VarLong#

RHS evaluations in the last monitored advance; -1 while monitoring is inactive.

property last_advance_steps: Karana.Core._KCore_pybind11_Py._VarLong#

Accepted steps in the last monitored advance; -1 while monitoring is inactive.

property last_order: Karana.Core._KCore_pybind11_Py._VarInt#

Integration method order used during last step

property num_quasi_full_refreshes: Karana.Core._KCore_pybind11_Py._VarLong#

Complete finite-difference refreshes performed by quasi-Newton; -1 when not selected.

property num_quasi_partial_refreshes: Karana.Core._KCore_pybind11_Py._VarLong#

Motion-ranked partial refreshes performed by quasi-Newton; -1 when not selected.

property num_quasi_probes: Karana.Core._KCore_pybind11_Py._VarLong#

Fixed-time secant probes performed by quasi-Newton; -1 when not selected.

property num_quasi_refreshed_columns: Karana.Core._KCore_pybind11_Py._VarLong#

Finite-difference columns refreshed by quasi-Newton; -1 when not selected.

property num_quasi_rhs_evals: Karana.Core._KCore_pybind11_Py._VarLong#

Extra RHS evaluations performed by quasi-Newton; -1 when not selected.

property num_stab_lim_order_reductions: Karana.Core._KCore_pybind11_Py._VarLong#

BDF stability-limit order reductions; -1 when detection is disabled. Toggling detection may reset or reduce this count.

property stall_count: Karana.Core._KCore_pybind11_Py._VarLong#

Detected stall advances since hard reset; -1 while monitoring is inactive.

class Karana.Integrators.EulerIntegrator#

Bases: Integrator

The fixed-step Euler one step integrator.

class Karana.Integrators.ExplicitVerletIntegrator#

Bases: PartitionedIntegrator

Explicit kick-drift-kick Verlet for separable Q/U equations.

This implementation assumes that the first num_q_states are Q and the rest U coordinates.

Each advanceTo call takes one step of size h using the full-state callback: f[ U_{1/2}=U_n+frac h2 g(t_n,Q_n),qquad Q_{n+1}=Q_n+h f(U_{1/2}),qquad U_{n+1}=U_{1/2}+frac h2 g(t_{n+1},Q_{n+1}). f] Second-order accuracy requires separable dynamics: Qdot = f(U) and Udot = g(t, Q). If the dynamics are not separable this method falls back to first order, in which case using Euler or RK4 is more appropriate.

Unequal sizes, such as one Q state and two U states, still give second-order accuracy for the smooth separable equations above. Symplecticity is a separate property: standard Hamiltonian position-momentum pairs require equal Q

and U

counts and equations from a separable Hamiltonian. A full three- dimensional state cannot be symplectic. If an extra state is constant or redundant, a reduced even-dimensional system may still be symplectic; this depends on the equations and how the reduced state is defined.

class Karana.Integrators.Integrator#

Bases: Karana.Core.BaseWithVars

Base class for numerical integrators

static create() → None#
advanceTo(to_t: SupportsFloat | SupportsIndex | numpy.timedelta64) → numpy.timedelta64#

Method to advance the system state to a specified time

Parameters:

to_t – the desired end time

Returns:

the actual end time

derivFunction() → collections.abc.Callable[[SupportsFloat | SupportsIndex | numpy.timedelta64, Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]], Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]], bool]#

Return the derivative function

Returns:

the derivative function

getIntegratorType() → IntegratorType#

Get the IntegratorType for this integrator.

Returns:

The IntegratorType for this integrator.

getOptions() → IntegratorOptions#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

getTime() → numpy.timedelta64#

Return the current integrator time

Returns:

the integrator state time

getX() → Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]#

Return the current integrator state

Returns:

the integrator state vector

hardReset(num_states: SupportsInt | SupportsIndex, num_q_states: SupportsInt | SupportsIndex) → None#

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.

nQ() → int#

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

Returns:

The Q partition size supplied at construction or hard reset.

nStates() → int#

Return the state size

Returns:

the integrator state size

setVerboseTracing(verbose: bool) → None#

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

Parameters:

verbose

softReset(new_t: SupportsFloat | SupportsIndex | numpy.timedelta64, new_x: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]) → None#

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

Parameters:
  • new_t – the new time

  • new_x – the new state

updateJacobian(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, n]]) → None#

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

class Karana.Integrators.IntegratorOptions#

A struct with integrator options. This struct can be

sub-classed by specialized classes to add custom options.

class Karana.Integrators.IntegratorType(*args, **kwds)#

Bases: enum.Enum

Enum of integrator types.

ARKEXPLICIT: ClassVar[IntegratorType]#
ARKEXPLICIT_CASH: ClassVar[IntegratorType]#
ARKEXPLICIT_DOPRI: ClassVar[IntegratorType]#
ARKEXPLICIT_FEHLBERG78: ClassVar[IntegratorType]#
ARKEXPLICIT_HUEN_EULER: ClassVar[IntegratorType]#
ARKIMPLICIT: ClassVar[IntegratorType]#
ARKIMPLICIT_DIRK23: ClassVar[IntegratorType]#
ARKIMPLICIT_ESDIRK45: ClassVar[IntegratorType]#
ARKIMPLICIT_SDIRK12: ClassVar[IntegratorType]#
ARKIMPLICIT_SDIRK34: ClassVar[IntegratorType]#
CVODE: ClassVar[IntegratorType]#
CVODE_NEWTON: ClassVar[IntegratorType]#
CVODE_NEWTON_QUASI_NEWTON: ClassVar[IntegratorType]#
CVODE_STIFF: ClassVar[IntegratorType]#
CVODE_STIFF_JFNK: ClassVar[IntegratorType]#
CVODE_STIFF_QUASI_NEWTON: ClassVar[IntegratorType]#
EULER: ClassVar[IntegratorType]#
EXPLICIT_VERLET: ClassVar[IntegratorType]#
IDA: ClassVar[IntegratorType]#
NO_OP: ClassVar[IntegratorType]#
RK4: ClassVar[IntegratorType]#
classmethod to_yaml(representer, node)#

Class method used to represent IntegratorType in a yaml file.

classmethod from_yaml(_, node) → Self#

Construct a IntegratorType from yaml file data.

static to_json(o: IntegratorType) → dict[str, Any]#

Class method used to represent IntegratorType in a json file.

classmethod from_json(d: dict[str, Any]) → Self#

Construct a IntegratorType from json file data.

class Karana.Integrators.PartitionedIntegrator#

Bases: Integrator

Abstract integrator for states packed as [Q, U].

This class provides validation checks used by child classes.

class Karana.Integrators.RK4Integrator#

Bases: Integrator

Fixed-step Runge-Kutta 4th order integrator

class Karana.Integrators.SundialsImplicitIntegrator#

Bases: SundialsIntegrator

Abstract base class for implicit Sundials integrators (CVode/ARKStep).

This class manages linear and nonlinear solvers specifically, and adds options and vars relating to implicit integration.

getOptions() → SundialsImplicitIntegratorOptions#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

setAndersonDamping(damping: SupportsFloat | SupportsIndex) → None#

Set the Anderson damping factor to use for nonlinear solves; must be in (0, 1] and smaller means stronger damping.

Parameters:

damping – Damping factor; pass a value of 1 for no damping.

setAndersonLength(length: SupportsInt | SupportsIndex) → None#

Set the subspace size to use for Anderson acceleration.

Parameters:

length – Damping factor; pass a value of 0 for no damping.

setJacobianEvalFrequency(frequency: SupportsInt | SupportsIndex) → None#

Set the number of integration steps between Jacobian evaluations.

Parameters:

frequency – Evaluation frequency; zero selects the SUNDIALS default.

setLinearSetupFrequency(frequency: SupportsInt | SupportsIndex) → None#

Set the number of integration steps between linear-solver setups.

Parameters:

frequency – Setup frequency; zero selects the SUNDIALS default.

setMaxNLIters(iters: SupportsInt | SupportsIndex) → None#

Set the maximum nonlinear iterations.

Parameters:

iters – Max iters to take before trying a smaller timestep.

class Karana.Integrators.SundialsImplicitIntegratorOptions#

Bases: SundialsIntegratorOptions

Struct with options for this integrator

property anderson_damping: float#

Anderson damping in (0, 1] used for implicit integrators with fixed- point solves.

This is used to potentially speed up internal iterations by reusing past iterates (within the same time step). A value of 1 indicates no damping, and smaller values imply a “stronger” damping.

property anderson_length: int#

Number of past iterates to consider with Anderson acceleration.

property jacobian_eval_frequency: int#

Number of integration steps between implicit Jacobian evaluations.

This option applies to CVODE Newton and ARKODE implicit solvers. A value of zero selects the backend’s SUNDIALS default.

property linear_setup_frequency: int#

Number of integration steps between implicit linear-solver setups.

This option applies to CVODE Newton and ARKODE implicit solvers. A value of zero selects the backend’s SUNDIALS default.

property max_nl_iters: int#

Maximum number of nonlinear iterations before we try a smaller step size

property use_jacobian: bool#
the application must keep the stored Jacobian current

with

updateJacobian(); kdFlex does not compute or refresh it automatically.

Type:

Experimental

class Karana.Integrators.SundialsImplicitIntegratorVars#

Bases: SundialsIntegratorVars

The Vars for the SundialsImplicitIntegrator class.

property num_jac_evals: Karana.Core._KCore_pybind11_Py._VarLong#

Number of calls made to the linear solver interface’s Jacobian function.

Note

Returns -1 when no linear solver is attached.

Note

Before SUNDIALS 7.6, the stale native value is ignored after a soft reset until the next successful advance.

property num_lin_conv_fails: Karana.Core._KCore_pybind11_Py._VarLong#

Number of linear solver convergence failures.

Note

Returns -1 when no linear solver is attached.

Note

Before SUNDIALS 7.6, the stale native value is ignored after a soft reset until the next successful advance.

property num_lin_iters: Karana.Core._KCore_pybind11_Py._VarLong#

Number of linear iterations.

Note

Returns -1 when no linear solver is attached.

Note

Before SUNDIALS 7.6, the stale native value is ignored after a soft reset until the next successful advance.

property num_lin_rhs_evals: Karana.Core._KCore_pybind11_Py._VarLong#

Number of RHS/derivative calls used to estimate Jacobians.

Note

Returns -1 when no linear solver is attached.

Note

Before SUNDIALS 7.6, the stale native value is ignored after a soft reset until the next successful advance.

property num_lin_solver_setups: Karana.Core._KCore_pybind11_Py._VarLong#

Number of times the linear solver setup routine was called.

Note

Returns -1 when no linear solver is attached.

property num_nonlin_conv_fails: Karana.Core._KCore_pybind11_Py._VarLong#

Number of nonlinear solver convergence failures.

Note

In SUNDIALS 6.2 and newer this counts every failed nonlinear solve, not only rejected timesteps. ARKODE accumulates it for the nonlinear solver object’s lifetime, so soft resets do not reset or cache the native counter.

property num_nonlin_iters: Karana.Core._KCore_pybind11_Py._VarLong#

Cumulative number of nonlinear iterations.

Note

ARKODE reports this value for the lifetime of its nonlinear solver object, so soft resets do not reset or cache the native counter.

property num_step_solve_fails: Karana.Core._KCore_pybind11_Py._VarLong#

Number of rejected timesteps due to nonlinear solve failure.

Note

This statistic is distinct from nonlinear convergence failures in SUNDIALS 6.2 and newer. Starting with SUNDIALS 7.6, CVODE excludes inequality-constraint failures.

class Karana.Integrators.SundialsIntegrator#

Bases: Integrator

Abstract base class for Sundials-related integrators.

This class helps manage shared memory, options, and vars. It defines several pure virtual methods for the subclass to override and satisfies all virtual functions of an Integrator.

getOptions() → SundialsIntegratorOptions#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

setAtol(atol: SupportsFloat | SupportsIndex) → None#

Set the scalar absolute tolerance used for controlling error vs runtime.

Parameters:

atol – The scalar atol to use for all state variables.

setRtol(rtol: SupportsFloat | SupportsIndex) → None#

Set the relative tolerance used for controlling error vs runtime.

Parameters:

rtol – The rtol to use for all state variables.

setVectorAtol(atol_vec: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]] | None) → None#

Set the vector absolute tolerance used for controlling error vs runtime, or a null value to fall back to scalar atol.

Parameters:

atol_vec – The optional vector atol to use; must have same length as state vector or be null.

class Karana.Integrators.SundialsIntegratorOptions#

Bases: IntegratorOptions

Struct with options for this integrator

property atol: float#

The desired absolute tolerance used to control the integrator error

property atol_vec: Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]] | None#

The desired absolute tolerance vector used to control the integrator error. This can be used rather than a scalar tolerance to set different values for different states.

property max_num_steps: int#

The maximum number of steps the solver can take before throwing a too much work error.

property min_step_size: float#

Minimum acceptable step size before we error out.

property rtol: float#

The desired relative tolerance used to control the integrator error

class Karana.Integrators.SundialsIntegratorVars#

Bases: Karana.Core.BaseVars

The Vars for the SundialsIntegrator class.

property curr_step: Karana.Core._KCore_pybind11_Py._VarDouble#

Current step size to try on next advance call

property last_step: Karana.Core._KCore_pybind11_Py._VarDouble#

Last successful step size

property num_err_test_fails: Karana.Core._KCore_pybind11_Py._VarLong#

Cumulative number of error test failures due to too large of step size

property num_q_states: Karana.Core._KCore_pybind11_Py._VarSizeT#

Current number of leading Q states; zero means unspecified.

property num_rhs_evals: Karana.Core._KCore_pybind11_Py._VarLong#

Cumulative number of RHS calls taken by the solver

property num_states: Karana.Core._KCore_pybind11_Py._VarSizeT#

Current total state-vector size, updated after hard reset.

property num_steps: Karana.Core._KCore_pybind11_Py._VarLong#

Cumulative number of internal steps taken by the solver

Karana.Integrators.createIntegrator(integrator_type: IntegratorType, num_states: SupportsInt | SupportsIndex, num_q_states: SupportsInt | SupportsIndex, deriv_fn: collections.abc.Callable, options: IntegratorOptions = None) → Integrator#
Karana.Integrators.createIntegrator(integrator_type: IntegratorType, num_states: SupportsInt | SupportsIndex, num_q_states: SupportsInt | SupportsIndex, num_algebraic: SupportsInt | SupportsIndex, residuals_fn: collections.abc.Callable[[SupportsFloat | SupportsIndex | numpy.timedelta64, Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]], Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]], Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]], None], options: IntegratorOptions = None) → Integrator

Factory method for creating DAE Integrator instances

Parameters:
  • integrator_type – the type of integrator to create

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

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

  • num_algebraic – the number of algebraic values

  • residuals_fn – the residuals function

  • options – options for the integrator

Returns:

a new DAE Integrator instance

Karana.Integrators.strToIntegratorType(arg0: str) → IntegratorType#

Convert string to IntegratorType enum.

Parameters:

str – The name of the integrator type.

Returns:

The IntegratorType associated with the string.