Karana.Integrators
==================

.. py:module:: Karana.Integrators

.. autoapi-nested-parse::

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

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



Submodules
----------

.. toctree::
   :maxdepth: 1

   /generated/python_api/Karana/Integrators/Integrator_types/index


Attributes
----------

.. autoapisummary::

   Karana.Integrators.ArkExplicitIntegratorOptions


Classes
-------

.. autoapisummary::

   Karana.Integrators.ArkExplicitIntegrator
   Karana.Integrators.ArkExplicitIntegratorVars
   Karana.Integrators.ArkImplicitIntegrator
   Karana.Integrators.ArkImplicitIntegratorOptions
   Karana.Integrators.ArkImplicitIntegratorVars
   Karana.Integrators.CVodeIntegrator
   Karana.Integrators.CVodeIntegratorOptions
   Karana.Integrators.CVodeIntegratorVars
   Karana.Integrators.EulerIntegrator
   Karana.Integrators.ExplicitVerletIntegrator
   Karana.Integrators.Integrator
   Karana.Integrators.IntegratorOptions
   Karana.Integrators.IntegratorType
   Karana.Integrators.PartitionedIntegrator
   Karana.Integrators.RK4Integrator
   Karana.Integrators.SundialsImplicitIntegrator
   Karana.Integrators.SundialsImplicitIntegratorOptions
   Karana.Integrators.SundialsImplicitIntegratorVars
   Karana.Integrators.SundialsIntegrator
   Karana.Integrators.SundialsIntegratorOptions
   Karana.Integrators.SundialsIntegratorVars


Functions
---------

.. autoapisummary::

   Karana.Integrators.createIntegrator
   Karana.Integrators.strToIntegratorType


Package Contents
----------------

.. py:class:: ArkExplicitIntegrator

   Bases: :py:obj:`SundialsIntegrator`, :py:obj:`Integrator`


   The multistep ArkODE explicit integrator from the SUNDIALS suite


   .. py:method:: getAdaptiveStepping() -> bool

      Report whether adaptive step-size control is enabled.

      :returns: True when ARKODE controls the step size adaptively.



   .. py:method:: 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.



   .. py:method:: getOptions() -> SundialsIntegratorOptions

      Get the options associated with the integrator.

      :returns: The options associated with the integrator.



   .. py:method:: getVars() -> ArkExplicitIntegratorVars


   .. py:method:: setAdaptiveStepping(use_adaptive_steps: bool) -> None

      Select adaptive or fixed-step integration.

      :param use_adaptive_steps: True for adaptive stepping; false for fixed
                                 stepping.



   .. py:method:: 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.

      :param fixed_step_size: Positive fixed step size in seconds.



.. py:data:: ArkExplicitIntegratorOptions

.. py:class:: ArkExplicitIntegratorVars

   Bases: :py:obj:`SundialsIntegratorVars`


   The Vars for the ArkExplicitIntegrator class.


.. py:class:: ArkImplicitIntegrator

   Bases: :py:obj:`SundialsImplicitIntegrator`


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


   .. py:class:: PredictorMethod(*args, **kwds)

      Bases: :py:obj:`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.


      .. py:attribute:: CUTOFF_ORDER
         :type:  ClassVar[ArkImplicitIntegrator]


      .. py:attribute:: MAXIMUM_ORDER
         :type:  ClassVar[ArkImplicitIntegrator]


      .. py:attribute:: TRIVIAL
         :type:  ClassVar[ArkImplicitIntegrator]


      .. py:attribute:: VARIABLE_ORDER
         :type:  ClassVar[ArkImplicitIntegrator]



   .. py:method:: getAdaptiveStepping() -> bool

      Return whether adaptive stepping is enabled.



   .. py:method:: 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.



   .. py:method:: getOptions() -> ArkImplicitIntegratorOptions

      Get the options associated with the integrator.

      :returns: The options associated with the integrator.



   .. py:method:: getVars() -> ArkImplicitIntegratorVars


   .. py:method:: setAdaptiveStepping(use_adaptive_steps: bool) -> None

      Enable or disable adaptive stepping.



   .. py:method:: setFixedStepSize(fixed_step_size: SupportsFloat | SupportsIndex) -> None

      Set the fixed step size in seconds.



.. py:class:: ArkImplicitIntegratorOptions

   Bases: :py:obj:`SundialsImplicitIntegratorOptions`


   Options specific to the implicit ARKODE integrator.


   .. py:property:: predictor_method
      :type: ArkImplicitIntegrator


      Implicit-stage predictor used by ARK implicit.


.. py:class:: ArkImplicitIntegratorVars

   Bases: :py:obj:`SundialsImplicitIntegratorVars`


   The Vars for the ArkImplicitIntegrator class.


.. py:class:: CVodeIntegrator

   Bases: :py:obj:`SundialsImplicitIntegrator`


   The multistep CVode integrator from the SUNDIALS suite


   .. py:method:: 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.



   .. py:method:: getDetectStalls() -> bool

      Return whether automatic stall monitoring and tracing are enabled.



   .. py:method:: 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.



   .. py:method:: getLastAdvanceErrorTestFailures() -> int

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



   .. py:method:: getLastAdvanceRhsEvals() -> int

      Return RHS evaluations in the most recent monitored CVODE advance.



   .. py:method:: getLastAdvanceSteps() -> int

      Return accepted steps in the most recent monitored CVODE advance.



   .. py:method:: getOptions() -> CVodeIntegratorOptions

      Get the options associated with the integrator.

      :returns: The options associated with the integrator.



   .. py:method:: getStallCount() -> int

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



   .. py:method:: getStallLogFile() -> str

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



   .. py:method:: getVars() -> CVodeIntegratorVars


   .. py:method:: setDetectStalls(enabled: bool) -> None

      Toggle automatic stall monitoring and its timestamped trace file.



   .. py:method:: setEtaFixedStepBounds(eta_min_fx: SupportsFloat | SupportsIndex, eta_max_fx: SupportsFloat | SupportsIndex) -> None

      Experimental: retain step size for proposed ratios strictly between
                    the bounds.

      :param lower: Finite lower bound in [0, 1]; raising it permits more
                    decreases.
      :param upper: Finite upper bound >= 1 and > lower; raising it suppresses
                    more increases.

      .. seealso::

         https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c
         .CVodeSetEtaFixedStepBounds



   .. py:method:: 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.

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



   .. py:method:: setStabilityLimitDetection(enabled: bool) -> None

      Experimental: toggle BDF stability-limit detection.

      May reset or reduce num_stab_lim_order_reductions.

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

      .. seealso::

         https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c
         .CVodeSetStabLimDet



   .. py:property:: detect_stalls
      :type: bool


      Enable automatic CVODE stall detection and timestamped HDF5 tracing.


   .. py:property:: stall_log_file
      :type: str


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


.. py:class:: CVodeIntegratorOptions

   Bases: :py:obj:`SundialsImplicitIntegratorOptions`


   CVODE multistep controls shared by its Adams and BDF presets.


   .. py:property:: eta_max_fx
      :type: float


      



      upper bound of the step-size ratio deadband after
                    successful
      integration steps.

      .. seealso::

         https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c
         .CVodeSetEtaFixedStepBounds

      :type: Experimental


   .. py:property:: eta_min_fx
      :type: float


      



      lower bound of the step-size ratio deadband after
                    successful
      integration steps.

      .. seealso::

         https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c
         .CVodeSetEtaFixedStepBounds

      :type: Experimental


   .. py:property:: max_order
      :type: int


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

      .. seealso::

         https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c
         .CVodeSetMaxOrd


   .. py:property:: stability_limit_detection
      :type: bool


      



      reduce BDF order when a stability limit is detected (BDF
                    only).
      Toggling may reset or reduce num_stab_lim_order_reductions.

      .. seealso::

         https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c
         .CVodeSetStabLimDet

      :type: Experimental


.. py:class:: CVodeIntegratorVars

   Bases: :py:obj:`SundialsImplicitIntegratorVars`


   The Vars for the CVodeIntegrator class.


   .. py:property:: curr_gamma
      :type: 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.


   .. py:property:: curr_order
      :type: Karana.Core._KCore_pybind11_Py._VarInt


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


   .. py:property:: last_advance_error_test_failures
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: last_advance_rhs_evals
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: last_advance_steps
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: last_order
      :type: Karana.Core._KCore_pybind11_Py._VarInt


      Integration method order used during last step


   .. py:property:: num_quasi_full_refreshes
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: num_quasi_partial_refreshes
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: num_quasi_probes
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: num_quasi_refreshed_columns
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: num_quasi_rhs_evals
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: num_stab_lim_order_reductions
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: stall_count
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


.. py:class:: EulerIntegrator

   Bases: :py:obj:`Integrator`


   The fixed-step Euler one step integrator.


.. py:class:: ExplicitVerletIntegrator

   Bases: :py:obj:`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.


.. py:class:: Integrator

   Bases: :py:obj:`Karana.Core.BaseWithVars`


   Base class for numerical integrators


   .. py:method:: create() -> None
      :staticmethod:



   .. py:method:: advanceTo(to_t: SupportsFloat | SupportsIndex | numpy.timedelta64) -> numpy.timedelta64

      Method to advance the system state to a specified time

      :param to_t: the desired end time

      :returns: the actual end time



   .. py:method:: 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



   .. py:method:: getIntegratorType() -> IntegratorType

      Get the IntegratorType for this integrator.

      :returns: The IntegratorType for this integrator.



   .. py:method:: getOptions() -> IntegratorOptions

      Get the options associated with the integrator.

      :returns: The options associated with the integrator.



   .. py:method:: getTime() -> numpy.timedelta64

      Return the current integrator time

      :returns: the integrator state time



   .. py:method:: getX() -> Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]

      Return the current integrator state

      :returns: the integrator state vector



   .. py:method:: hardReset(num_states: SupportsInt | SupportsIndex, num_q_states: SupportsInt | SupportsIndex) -> None

      Replace the state size and Q partition count

      :param num_states: the new state size
      :param num_q_states: Number of leading Q states; zero means no partition
                           is specified.



   .. py:method:: 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.



   .. py:method:: nStates() -> int

      Return the state size

      :returns: the integrator state size



   .. py:method:: setVerboseTracing(verbose: bool) -> None

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

      :param verbose:



   .. py:method:: 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

      :param new_t: the new time
      :param new_x: the new state



   .. py:method:: 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.

      :param mat: the new Jacobian matrix



.. py:class:: IntegratorOptions

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


.. py:class:: IntegratorType(*args, **kwds)

   Bases: :py:obj:`enum.Enum`


   Enum of integrator types.


   .. py:attribute:: ARKEXPLICIT
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKEXPLICIT_CASH
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKEXPLICIT_DOPRI
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKEXPLICIT_FEHLBERG78
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKEXPLICIT_HUEN_EULER
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKIMPLICIT
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKIMPLICIT_DIRK23
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKIMPLICIT_ESDIRK45
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKIMPLICIT_SDIRK12
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: ARKIMPLICIT_SDIRK34
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: CVODE
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: CVODE_NEWTON
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: CVODE_NEWTON_QUASI_NEWTON
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: CVODE_STIFF
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: CVODE_STIFF_JFNK
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: CVODE_STIFF_QUASI_NEWTON
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: EULER
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: EXPLICIT_VERLET
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: IDA
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: NO_OP
      :type:  ClassVar[IntegratorType]


   .. py:attribute:: RK4
      :type:  ClassVar[IntegratorType]


   .. py:method:: to_yaml(representer, node)
      :classmethod:


      Class method used to represent IntegratorType in a yaml file.



   .. py:method:: from_yaml(_, node) -> Self
      :classmethod:


      Construct a IntegratorType from yaml file data.



   .. py:method:: to_json(o: IntegratorType) -> dict[str, Any]
      :staticmethod:


      Class method used to represent IntegratorType in a json file.



   .. py:method:: from_json(d: dict[str, Any]) -> Self
      :classmethod:


      Construct a IntegratorType from json file data.



.. py:class:: PartitionedIntegrator

   Bases: :py:obj:`Integrator`


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

   This class provides validation checks used by child classes.


.. py:class:: RK4Integrator

   Bases: :py:obj:`Integrator`


   Fixed-step Runge-Kutta 4th order integrator


.. py:class:: SundialsImplicitIntegrator

   Bases: :py:obj:`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.


   .. py:method:: getOptions() -> SundialsImplicitIntegratorOptions

      Get the options associated with the integrator.

      :returns: The options associated with the integrator.



   .. py:method:: 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.

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



   .. py:method:: setAndersonLength(length: SupportsInt | SupportsIndex) -> None

      Set the subspace size to use for Anderson acceleration.

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



   .. py:method:: setJacobianEvalFrequency(frequency: SupportsInt | SupportsIndex) -> None

      Set the number of integration steps between Jacobian evaluations.

      :param frequency: Evaluation frequency; zero selects the SUNDIALS
                        default.



   .. py:method:: setLinearSetupFrequency(frequency: SupportsInt | SupportsIndex) -> None

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

      :param frequency: Setup frequency; zero selects the SUNDIALS default.



   .. py:method:: setMaxNLIters(iters: SupportsInt | SupportsIndex) -> None

      Set the maximum nonlinear iterations.

      :param iters: Max iters to take before trying a smaller timestep.



.. py:class:: SundialsImplicitIntegratorOptions

   Bases: :py:obj:`SundialsIntegratorOptions`


   Struct with options for this integrator


   .. py:property:: anderson_damping
      :type: 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.


   .. py:property:: anderson_length
      :type: int


      Number of past iterates to consider with Anderson acceleration.


   .. py:property:: jacobian_eval_frequency
      :type: 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.


   .. py:property:: linear_setup_frequency
      :type: 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.


   .. py:property:: max_nl_iters
      :type: int


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


   .. py:property:: use_jacobian
      :type: bool


      



      the application must keep the stored Jacobian current
                    with
      updateJacobian(); kdFlex does not compute or refresh it automatically.

      :type: Experimental


.. py:class:: SundialsImplicitIntegratorVars

   Bases: :py:obj:`SundialsIntegratorVars`


   The Vars for the SundialsImplicitIntegrator class.


   .. py:property:: num_jac_evals
      :type: 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.


   .. py:property:: num_lin_conv_fails
      :type: 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.


   .. py:property:: num_lin_iters
      :type: 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.


   .. py:property:: num_lin_rhs_evals
      :type: 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.


   .. py:property:: num_lin_solver_setups
      :type: 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.


   .. py:property:: num_nonlin_conv_fails
      :type: 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.


   .. py:property:: num_nonlin_iters
      :type: 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.


   .. py:property:: num_step_solve_fails
      :type: 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.


.. py:class:: SundialsIntegrator

   Bases: :py:obj:`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.


   .. py:method:: getOptions() -> SundialsIntegratorOptions

      Get the options associated with the integrator.

      :returns: The options associated with the integrator.



   .. py:method:: setAtol(atol: SupportsFloat | SupportsIndex) -> None

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

      :param atol: The scalar atol to use for all state variables.



   .. py:method:: setRtol(rtol: SupportsFloat | SupportsIndex) -> None

      Set the relative tolerance used for controlling error vs runtime.

      :param rtol: The rtol to use for all state variables.



   .. py:method:: 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.

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



.. py:class:: SundialsIntegratorOptions

   Bases: :py:obj:`IntegratorOptions`


   Struct with options for this integrator


   .. py:property:: atol
      :type: float


      The desired absolute tolerance used to control the integrator error


   .. py:property:: atol_vec
      :type: 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.


   .. py:property:: max_num_steps
      :type: int


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


   .. py:property:: min_step_size
      :type: float


      Minimum acceptable step size before we error out.


   .. py:property:: rtol
      :type: float


      The desired relative tolerance used to control the integrator error


.. py:class:: SundialsIntegratorVars

   Bases: :py:obj:`Karana.Core.BaseVars`


   The Vars for the SundialsIntegrator class.


   .. py:property:: curr_step
      :type: Karana.Core._KCore_pybind11_Py._VarDouble


      Current step size to try on next advance call


   .. py:property:: last_step
      :type: Karana.Core._KCore_pybind11_Py._VarDouble


      Last successful step size


   .. py:property:: num_err_test_fails
      :type: Karana.Core._KCore_pybind11_Py._VarLong


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


   .. py:property:: num_q_states
      :type: Karana.Core._KCore_pybind11_Py._VarSizeT


      Current number of leading Q states; zero means unspecified.


   .. py:property:: num_rhs_evals
      :type: Karana.Core._KCore_pybind11_Py._VarLong


      Cumulative number of RHS calls taken by the solver


   .. py:property:: num_states
      :type: Karana.Core._KCore_pybind11_Py._VarSizeT


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


   .. py:property:: num_steps
      :type: Karana.Core._KCore_pybind11_Py._VarLong


      Cumulative number of internal steps taken by the solver


.. py:function:: createIntegrator(integrator_type: IntegratorType, num_states: SupportsInt | SupportsIndex, num_q_states: SupportsInt | SupportsIndex, deriv_fn: collections.abc.Callable, options: IntegratorOptions = None) -> Integrator
                 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

   :param integrator_type: the type of integrator to create
   :param num_states: the length of the states vector (continuous+algebraic)
   :param num_q_states: Number of leading Q states; zero means no partition
                        is specified.
   :param num_algebraic: the number of algebraic values
   :param residuals_fn: the residuals function
   :param options: options for the integrator

   :returns: a new DAE Integrator instance


.. py:function:: strToIntegratorType(arg0: str) -> IntegratorType

   Convert string to IntegratorType enum.

   :param str: The name of the integrator type.

   :returns: The IntegratorType associated with the string.


