ostk.astrodynamics.trajectory.state.NumericalSolver

class NumericalSolver(
self: ostk.astrodynamics.trajectory.state.NumericalSolver,
log_type: ostk.mathematics.solver.NumericalSolver.LogType,
stepper_type: ostk.mathematics.solver.NumericalSolver.StepperType,
time_step: ostk.core.type.Real,
relative_tolerance: ostk.core.type.Real,
absolute_tolerance: ostk.core.type.Real,
root_solver: ostk.astrodynamics.RootSolver = RootSolver.default(),
)

Bases: NumericalSolver

A numerical solver is used to integrate the trajectory of a dynamical system.

The numerical solver can be used to integrate the trajectory of a dynamical system to a given instant, or to a set of instants, or until an Event Condition is met.

Constructor.

Parameters:

Methods

conditional

Return a conditional numerical solver.

default

Return the default numerical solver.

default_conditional

Return the default conditional numerical solver.

fixed_step_size

Return a Numerical Solver using a fixed stepper.

get_absolute_tolerance

Get the absolute tolerance of the solver.

get_log_type

Get the log type of the solver.

get_observed_state_vectors

Get the observed state vectors from the last integration.

get_observed_states

Get the observed states.

get_relative_tolerance

Get the relative tolerance of the solver.

get_root_solver

Get the root solver.

get_stepper_type

Get the stepper type of the solver.

get_time_step

Get the time step of the solver.

integrate_duration

Overloaded function.

integrate_time

Overloaded function.

is_defined

Check if the numerical solver is defined.

string_from_log_type

Get string representation of a log type.

string_from_stepper_type

Get string representation of a stepper type.

undefined

Return an undefined numerical solver.

class ConditionSolution

Bases: pybind11_object

The solution to an event condition.

property condition_is_satisfied

Whether the event condition is satisfied.

Type:

bool

property iteration_count

The number of iterations required to find the solution.

Type:

int

property root_solver_has_converged

Whether the root solver has converged.

Type:

bool

property state

The state of the trajectory.

Type:

State

class LogType(
self: ostk.mathematics.solver.NumericalSolver.LogType,
value: int,
)

Bases: pybind11_object

Members:

NoLog

LogConstant

LogAdaptive

property name
class StepperType(
self: ostk.mathematics.solver.NumericalSolver.StepperType,
value: int,
)

Bases: pybind11_object

Members:

RungeKutta4

RungeKuttaCashKarp54

RungeKuttaFehlberg78

RungeKuttaDopri5

property name
static conditional(
arg0: ostk.core.type.Real,
arg1: ostk.core.type.Real,
arg2: ostk.core.type.Real,
arg3: Callable[[ostk.astrodynamics.trajectory.State], None],
) ostk.astrodynamics.trajectory.state.NumericalSolver

Return a conditional numerical solver.

Returns:

The conditional numerical solver.

Return type:

NumericalSolver

static default() ostk.astrodynamics.trajectory.state.NumericalSolver

Return the default numerical solver.

Returns:

The default numerical solver.

Return type:

NumericalSolver

static default_conditional(
state_logger: Callable[[ostk.astrodynamics.trajectory.State], None] = None,
) ostk.astrodynamics.trajectory.state.NumericalSolver

Return the default conditional numerical solver.

Parameters:

state_logger (StateLogger, optional) -- The state logger. Defaults to None.

Returns:

The default conditional numerical solver.

Return type:

NumericalSolver

static fixed_step_size(
stepper_type: ostk.mathematics.solver.NumericalSolver.StepperType,
time_step: ostk.core.type.Real,
) ostk.astrodynamics.trajectory.state.NumericalSolver

Return a Numerical Solver using a fixed stepper.

Returns:

The numerical solver.

Return type:

NumericalSolver

get_absolute_tolerance(
self: ostk.mathematics.solver.NumericalSolver,
) ostk.core.type.Real

Get the absolute tolerance of the solver.

Returns:

The absolute tolerance value.

Return type:

float

Example

>>> solver = NumericalSolver.default()
>>> abs_tol = solver.get_absolute_tolerance()
get_log_type(
self: ostk.mathematics.solver.NumericalSolver,
) ostk::mathematics::solver::NumericalSolver::LogType

Get the log type of the solver.

Returns:

The log type.

Return type:

NumericalSolver.LogType

Example

>>> solver = NumericalSolver.default()
>>> log_type = solver.get_log_type()
get_observed_state_vectors(
self: ostk.mathematics.solver.NumericalSolver,
) list[tuple[numpy.ndarray[numpy.float64[m, 1]], float]]

Get the observed state vectors from the last integration.

Returns:

List of observed state vectors during integration.

Return type:

list

Example

>>> solver = NumericalSolver.default()
>>> # After performing integration...
>>> states = solver.get_observed_state_vectors()
get_observed_states(
self: ostk.astrodynamics.trajectory.state.NumericalSolver,
) list[ostk.astrodynamics.trajectory.State]

Get the observed states.

Returns:

The observed states.

Return type:

list[State]

get_relative_tolerance(
self: ostk.mathematics.solver.NumericalSolver,
) ostk.core.type.Real

Get the relative tolerance of the solver.

Returns:

The relative tolerance value.

Return type:

float

Example

>>> solver = NumericalSolver.default()
>>> rel_tol = solver.get_relative_tolerance()
get_root_solver(
self: ostk.astrodynamics.trajectory.state.NumericalSolver,
) ostk.astrodynamics.RootSolver

Get the root solver.

Returns:

The root solver.

Return type:

RootSolver

get_stepper_type(
self: ostk.mathematics.solver.NumericalSolver,
) ostk::mathematics::solver::NumericalSolver::StepperType

Get the stepper type of the solver.

Returns:

The stepper type.

Return type:

NumericalSolver.StepperType

Example

>>> solver = NumericalSolver.default()
>>> stepper_type = solver.get_stepper_type()
get_time_step(
self: ostk.mathematics.solver.NumericalSolver,
) ostk.core.type.Real

Get the time step of the solver.

Returns:

The time step value.

Return type:

float

Example

>>> solver = NumericalSolver.default()
>>> time_step = solver.get_time_step()
integrate_duration(*args, **kwargs)

Overloaded function.

  1. integrate_duration(self: ostk.mathematics.solver.NumericalSolver, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: ostk.core.type.Real, arg2: object) -> tuple[numpy.ndarray[numpy.float64[m, 1]], float]

    Integrate a system of differential equations for a specified duration.

    Args:

    state_vector (StateVector): Initial state vector. duration_in_seconds (float): Integration duration in seconds. system_of_equations (callable): Function defining the system of ODEs.

    Signature: f(x, dxdt, t) -> StateVector

    Returns:

    StateVector: Final state vector after integration.

    Example:
    >>> def equations(x, dxdt, t):
    ...     dxdt[0] = x[1]  # dx/dt = v
    ...     dxdt[1] = -x[0]  # dv/dt = -x (harmonic oscillator)
    ...     return dxdt
    >>> solver = NumericalSolver.default()
    >>> initial_state = [1.0, 0.0]  # x=1, v=0
    >>> final_state = solver.integrate_duration(initial_state, 1.0, equations)
    
  2. integrate_duration(self: ostk.mathematics.solver.NumericalSolver, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: list[ostk.core.type.Real], arg2: object) -> list[tuple[numpy.ndarray[numpy.float64[m, 1]], float]]

    Integrate a system of differential equations at multiple duration points.

    Args:

    state_vector (StateVector): Initial state vector. duration_array (list): Array of duration values in seconds. system_of_equations (callable): Function defining the system of ODEs.

    Signature: f(x, dxdt, t) -> StateVector

    Returns:

    list: State vectors at each duration point.

    Example:
    >>> def equations(x, dxdt, t):
    ...     dxdt[0] = x[1]  # dx/dt = v
    ...     dxdt[1] = -x[0]  # dv/dt = -x (harmonic oscillator)
    ...     return dxdt
    >>> solver = NumericalSolver.default()
    >>> initial_state = [1.0, 0.0]
    >>> durations = [0.5, 1.0, 1.5]
    >>> states = solver.integrate_duration(initial_state, durations, equations)
    
integrate_time(*args, **kwargs)

Overloaded function.

  1. integrate_time(self: ostk.astrodynamics.trajectory.state.NumericalSolver, state: ostk.astrodynamics.trajectory.State, instant: ostk.physics.time.Instant, system_of_equations: object) -> ostk.astrodynamics.trajectory.State

    Integrate the trajectory to a given instant.

    Args:

    state (State): The initial state of the trajectory. instant (Instant): The instant to integrate to. system_of_equations (callable): The system of equations.

    Returns:

    State: The state at the requested time.

  2. integrate_time(self: ostk.astrodynamics.trajectory.state.NumericalSolver, state: ostk.astrodynamics.trajectory.State, instants: list[ostk.physics.time.Instant], system_of_equations: object) -> list[ostk.astrodynamics.trajectory.State]

    Integrate the trajectory to a set of instants.

    Args:

    state (State): The initial state of the trajectory. instants (list[Instant]): The instants to integrate to. system_of_equations (callable): The system of equations.

    Returns:

    list[State]: The states at the requested times.

  3. integrate_time(self: ostk.astrodynamics.trajectory.state.NumericalSolver, state: ostk.astrodynamics.trajectory.State, instant: ostk.physics.time.Instant, system_of_equations: object, event_condition: ostk::astrodynamics::EventCondition) -> ostk.astrodynamics.trajectory.state.NumericalSolver.ConditionSolution

    Integrate the trajectory to a given instant, with an event condition.

    Args:

    state (State): The initial state of the trajectory. instant (Instant): The instant to integrate to. system_of_equations (callable): The system of equations. event_condition (EventCondition): The event condition.

    Returns:

    ConditionSolution: The solution to the event condition.

is_defined(
self: ostk.astrodynamics.trajectory.state.NumericalSolver,
) bool

Check if the numerical solver is defined.

Returns:

True if the numerical solver is defined, False otherwise.

Return type:

bool

static string_from_log_type(
log_type: ostk::mathematics::solver::NumericalSolver::LogType,
) ostk.core.type.String

Get string representation of a log type.

Parameters:

log_type (NumericalSolver.LogType) -- The log type.

Returns:

String representation of the log type.

Return type:

str

Example

>>> NumericalSolver.string_from_log_type(NumericalSolver.LogType.NoLog)
static string_from_stepper_type(
stepper_type: ostk::mathematics::solver::NumericalSolver::StepperType,
) ostk.core.type.String

Get string representation of a stepper type.

Parameters:

stepper_type (NumericalSolver.StepperType) -- The stepper type.

Returns:

String representation of the stepper type.

Return type:

str

Example

>>> NumericalSolver.string_from_stepper_type(NumericalSolver.StepperType.RungeKutta4)
static undefined() ostk.astrodynamics.trajectory.state.NumericalSolver

Return an undefined numerical solver.

Returns:

The undefined numerical solver.

Return type:

NumericalSolver