gemseo.algos.ode.ode_problem module#
ODE problem.
- class DifferentiationFunctions(desvar, state, time_state=None)[source]#
Bases:
NamedTuple
Functions to differentiate the right-hand side (RHS) of the ODE.
Either a constant matrix or a function to compute it at a given time and state.
If
None
, it will be approximated.Create new instance of DifferentiationFunctions(desvar, state, time_state)
- Parameters:
desvar (Callable[[ndarray[Any, dtype[floating[Any]]] | float, ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]] | ndarray[Any, dtype[floating[Any]]] | None)
state (Callable[[ndarray[Any, dtype[floating[Any]]] | float, ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]] | ndarray[Any, dtype[floating[Any]]] | None)
time_state (Callable[[ndarray[Any, dtype[floating[Any]]] | float, ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]] | ndarray[Any, dtype[floating[Any]]] | None)
- desvar: Callable[[ndarray[Any, dtype[floating[Any]]] | float, ndarray[Any, dtype[floating[Any]]]], ndarray[Any, dtype[floating[Any]]]] | ndarray[Any, dtype[floating[Any]]] | None#
The function to differentiate the RHS with respect to the design variables.
- class ODEProblem(func, initial_state, times, jac_wrt_time_state=None, jac_wrt_state=None, jac_wrt_desvar=None, adjoint_wrt_state=None, adjoint_wrt_desvar=None, solve_at_algorithm_times=None, event_functions=())[source]#
Bases:
BaseProblem
First-order ordinary differential equation (ODE).
A first-order ODE is written as
\[\frac{ds(t)}{dt} = f(t, s(t)).\]where \(f\) is called the right-hand side (RHS) of the ODE and \(s(t)\) is the state vector at time \(t\).
- Parameters:
func (RHSFuncType | RealArray) -- The RHS function \(f\).
initial_state (RealArray) -- The initial state.
times (ArrayLike) -- Either the initial and final times or the times of interest where the state must be stored, including the initial and final times. When only initial and final times are provided, the times of interest are the instants chosen by the ODE solver to compute the state trajectories.
jac_wrt_time_state (RHSJacType) -- The Jacobian of \(f\) for time and state. Either a constant matrix or a function to compute it at a given time and state. If
None
, it will be approximated.jac_wrt_state (RHSJacType) -- The Jacobian of \(f\) with respect to state. Either a constant matrix or a function to compute it at a given time and state. If
None
, it will be approximated.jac_wrt_desvar (RHSJacType) -- The Jacobian of \(f\) with respect to the design variables. Either a constant matrix or a function to compute it at a given time and state. If
None
, it will be approximated.adjoint_wrt_state (RHSJacType) -- The adjoint relative to the state when using an adjoint-based ODE solver.
adjoint_wrt_desvar (RHSJacType) -- The adjoint relative to the design variables when using an adjoint-based ODE solver.
solve_at_algorithm_times (bool | None) -- Whether to solve the ODE chosen by the algorithm. Otherwise, use times defined in the vector times. If
None
, it is initialized asFalse
if no terminal event is considered, andTrue
otherwise.event_functions (Iterable[RHSFuncType]) --
The event functions, for which the integration stops when they get equal to 0. If empty, the solver will solve the ODE for the entire assigned time interval.
By default it is set to ().
- check()[source]#
Ensure the parameters of the problem are consistent.
- Raises:
ValueError -- If the state and time shapes are inconsistent.
- Return type:
None
- adjoint: DifferentiationFunctions#
The functions to compute the adjoint of \(f\).
- event_functions: Iterable[RHSFuncType]#
The event functions, for which the integration stops when they get equal to 0.
- initial_state: RealArray#
The state at the initial time.
- jac: DifferentiationFunctions#
The functions to compute the Jacobian of \(f\).
- rhs_function: RHSFuncType#
The RHS function \(f\).
- solve_at_algorithm_times: bool#
Whether to solve ODE only at time of interest.
Otherwise, use times chosen by the algorithm.
- time_interval: TimeInterval#
The initial and final times.