ostk.mathematics.solver.NumericalSolver¶
- class NumericalSolver(
- self: ostk.mathematics.solver.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,
- log_type: ostk::mathematics::solver::NumericalSolver::LogType,
Bases:
pybind11_object
Create a numerical solver with specified parameters.
- Parameters:
log_type (NumericalSolver.LogType) -- The logging type for the solver.
stepper_type (NumericalSolver.StepperType) -- The stepper algorithm to use.
time_step (float) -- The time step for integration.
relative_tolerance (float) -- The relative tolerance for adaptive steppers.
absolute_tolerance (float) -- The absolute tolerance for adaptive steppers.
Example
>>> solver = NumericalSolver( ... NumericalSolver.LogType.NoLog, ... NumericalSolver.StepperType.RungeKutta4, ... 1.0, 1e-12, 1e-12 ... )
Methods
Create a default numerical solver.
Get the absolute tolerance of the solver.
Get the log type of the solver.
Get the observed state vectors from the last integration.
Get the relative tolerance of the solver.
Get the stepper type of the solver.
Get the time step of the solver.
Overloaded function.
Overloaded function.
Check if the numerical solver is defined.
Get string representation of a log type.
Get string representation of a stepper type.
Create an undefined numerical solver.
- 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 default() ostk.mathematics.solver.NumericalSolver ¶
Create a default numerical solver.
- Returns:
A solver with default settings.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> solver.is_defined() # True
- get_absolute_tolerance( ) ostk.core.type.Real ¶
Get the absolute tolerance of the solver.
- Returns:
The absolute tolerance value.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> abs_tol = solver.get_absolute_tolerance()
- get_log_type( ) ostk::mathematics::solver::NumericalSolver::LogType ¶
Get the log type of the solver.
- Returns:
The log type.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> log_type = solver.get_log_type()
- get_observed_state_vectors( ) 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:
Example
>>> solver = NumericalSolver.default() >>> # After performing integration... >>> states = solver.get_observed_state_vectors()
- get_relative_tolerance( ) ostk.core.type.Real ¶
Get the relative tolerance of the solver.
- Returns:
The relative tolerance value.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> rel_tol = solver.get_relative_tolerance()
- get_stepper_type( ) ostk::mathematics::solver::NumericalSolver::StepperType ¶
Get the stepper type of the solver.
- Returns:
The stepper type.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> stepper_type = solver.get_stepper_type()
- get_time_step( ) ostk.core.type.Real ¶
Get the time step of the solver.
- Returns:
The time step value.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> time_step = solver.get_time_step()
- integrate_duration(*args, **kwargs)¶
Overloaded function.
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)
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.
integrate_time(self: ostk.mathematics.solver.NumericalSolver, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: ostk.core.type.Real, arg2: ostk.core.type.Real, arg3: object) -> tuple[numpy.ndarray[numpy.float64[m, 1]], float]
Integrate a system of differential equations from start to end time.
- Args:
state_vector (StateVector): Initial state vector. start_time (float): Integration start time. end_time (float): Integration end time. system_of_equations (callable): Function defining the system of ODEs.
Signature: f(x, dxdt, t) -> StateVector
- Returns:
StateVector: Final state vector at end time.
- 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] >>> final_state = solver.integrate_time(initial_state, 0.0, 2.0, equations)
integrate_time(self: ostk.mathematics.solver.NumericalSolver, arg0: numpy.ndarray[numpy.float64[m, 1]], arg1: ostk.core.type.Real, arg2: list[ostk.core.type.Real], arg3: object) -> list[tuple[numpy.ndarray[numpy.float64[m, 1]], float]]
Integrate a system of differential equations at specified time points.
- Args:
state_vector (StateVector): Initial state vector. start_time (float): Integration start time. time_array (list): Array of time points to evaluate at. system_of_equations (callable): Function defining the system of ODEs.
Signature: f(x, dxdt, t) -> StateVector
- Returns:
list: State vectors at each time 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] >>> times = [0.5, 1.0, 1.5, 2.0] >>> states = solver.integrate_time(initial_state, 0.0, times, equations)
- is_defined(self: ostk.mathematics.solver.NumericalSolver) bool ¶
Check if the numerical solver is defined.
- Returns:
True if the solver is defined, False otherwise.
- Return type:
Example
>>> solver = NumericalSolver.default() >>> solver.is_defined() # True
- static string_from_log_type(
- log_type: ostk::mathematics::solver::NumericalSolver::LogType,
Get string representation of a log type.
- Parameters:
log_type (NumericalSolver.LogType) -- The log type.
- Returns:
String representation of the log type.
- Return type:
Example
>>> NumericalSolver.string_from_log_type(NumericalSolver.LogType.NoLog)
- static string_from_stepper_type(
- stepper_type: ostk::mathematics::solver::NumericalSolver::StepperType,
Get string representation of a stepper type.
- Parameters:
stepper_type (NumericalSolver.StepperType) -- The stepper type.
- Returns:
String representation of the stepper type.
- Return type:
Example
>>> NumericalSolver.string_from_stepper_type(NumericalSolver.StepperType.RungeKutta4)
- static undefined() ostk.mathematics.solver.NumericalSolver ¶
Create an undefined numerical solver.
- Returns:
An undefined solver.
- Return type:
Example
>>> solver = NumericalSolver.undefined() >>> solver.is_defined() # False