ode_environment
IntegrationError()
Bases: Exception
Error while integrating an ODE.
This exception is raised when an error occurs while integrating an ordinary differential equation.
Initialize the exception.
Source code in src/flowcean/environments/ode_environment.py
20 21 22 |
|
State
Bases: ABC
State of a differential equation.
This class represents the state of a differential equation. It provides methods to convert the state to and from a numpy array for integration.
as_numpy()
abstractmethod
Convert the state to a numpy array.
Returns:
Type | Description |
---|---|
NDArray[float64]
|
State as a numpy array. |
Source code in src/flowcean/environments/ode_environment.py
32 33 34 35 36 37 38 |
|
from_numpy(state)
abstractmethod
classmethod
Create a state from a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
NDArray[float64]
|
State as a numpy array. |
required |
Returns:
Type | Description |
---|---|
Self
|
State instance. |
Source code in src/flowcean/environments/ode_environment.py
40 41 42 43 44 45 46 47 48 49 50 |
|
OdeSystem(t, state)
Bases: ABC
System governed by an ordinary differential equation.
This class represents a continuous system. The system is defined by a differential flow function \(f\) that governs the evolution of the state \(x\).
The system can be integrated to obtain the state at a future time.
Attributes:
Name | Type | Description |
---|---|---|
t |
float
|
Current time. |
state |
X
|
Current state. |
Initialize the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
float
|
Initial time. |
required |
state
|
X
|
Initial state. |
required |
Source code in src/flowcean/environments/ode_environment.py
75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
flow(t, state)
abstractmethod
Ordinary differential equation.
Compute the derivative of the state \(x\) at time \(t\).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
float
|
Time. |
required |
state
|
NDArray[float64]
|
State. |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Derivative of the state. |
Source code in src/flowcean/environments/ode_environment.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
step(dt)
Step the mode forward in time.
Step the mode forward in time by integrating the differential equation for a time step of dt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dt
|
float
|
Time step. |
required |
Returns:
Type | Description |
---|---|
tuple[Sequence[float], Sequence[X]]
|
Tuple of times and states of the integration. |
Source code in src/flowcean/environments/ode_environment.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
OdeEnvironment(system, *, dt=1.0, map_to_dataframe)
Bases: IncrementalEnvironment
Environment governed by an ordinary differential equation.
This environment integrates an OdeSystem to generate a sequence of states.
Initialize the environment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
system
|
OdeSystem[X]
|
ODE system. |
required |
dt
|
float
|
Time step. |
1.0
|
map_to_dataframe
|
Callable[[Sequence[float], Sequence[X]], DataFrame]
|
Function to map states to a DataFrame. |
required |
Source code in src/flowcean/environments/ode_environment.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|