Backward Differentiation (BDF) solvers are a family of implicit solvers that perform a single right-hand-side solve per time step and achieve high-order accuracy by storing the solution at several previous time steps.
BDF methods are multi-step solvers and thus require not only an initial condition, but also the solution at the first few time points depending on the order of the method. For example, BDF3 requires the solution at times \(t_0, t_0+k, t_0+2k\) where \(t_0\) is the initial time and \(k\) is the temporal step-size.
This implementation assumes that you only have the solution at \(t_0\) and accepts another time-integrator as a seed. For example, we may use RK4 (a single step method). You must also decide the step-size of the single-step method such that the step-size of the Adams-Moulton solver is an integer multiple.
For example,
solver = BDF5(RK4(), seed_steps_per_step=2)
It is important to ensure that the order of the seed method and the number of seed steps per step are at least as accurate as the order of the BDF method. For example
solver = BDF5(RK4(), seed_steps_per_step=1)
solver = BDF5(RK4(), seed_steps_per_step=2)
backward_differentiation
BackwardDifferentiationAbstract
Bases: TimeIntegrator
An abstract class for Backward Differentiation (BDF) solvers.
All BDF solvers will inherit these methods. Additionally,
they inherit the methods of time_integrator.TimeIntegrator
as well.
Source code in src/odeiter/backward_differentiation.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 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 | |
__init__(seed, seed_steps_per_step, root_finder=DefaultRootFinder)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
TimeIntegrator
|
another time integrator used to take the first few steps. |
required |
seed_steps_per_step
|
int
|
the number of seed steps taking per step of the AB integrator. |
required |
root_finder
|
RootFinder
|
a function of the form |
DefaultRootFinder
|
Source code in src/odeiter/backward_differentiation.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
name()
Returns:
| Type | Description |
|---|---|
str
|
The name of the method |
Source code in src/odeiter/backward_differentiation.py
40 41 42 43 44 45 46 | |
order()
Returns:
| Type | Description |
|---|---|
int
|
The order of the method |
Source code in src/odeiter/backward_differentiation.py
48 49 50 51 52 53 54 | |
us_coeffs()
Returns:
| Type | Description |
|---|---|
list[float]
|
The solution interpolation coefficients of the method. |
Source code in src/odeiter/backward_differentiation.py
56 57 58 59 60 61 62 | |
f_coeff()
Returns:
| Type | Description |
|---|---|
float
|
The derivative interpolation coefficient of the method. |
Source code in src/odeiter/backward_differentiation.py
64 65 66 67 68 69 70 | |
update(t, us, rhs, delta_t)
Compute the next time step. You probably want solution_generator instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
The current time. |
required |
us
|
ndarray[float]
|
The solution at the current time-step and several previous time-steps. |
required |
rhs
|
Callable[[float, ndarray[float]], ndarray[float]]
|
The right-hand-side of the system as a function |
required |
delta_t
|
float
|
the temporal step-size. |
required |
Returns:
| Type | Description |
|---|---|
ndarray[float]
|
The solution at the next time step. |
Source code in src/odeiter/backward_differentiation.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
solution_generator(u0, rhs, time)
Create a generator that yields the solution for each time in time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u0
|
ndarray[float]
|
The initial condition of the system. Must be the same size as the system. |
required |
rhs
|
Callable[[float, ndarray[float]], ndarray[float]]
|
The right-hand-side as a function with signature |
required |
time
|
TimeDomain
|
The discretized time domain from. |
required |
Returns:
| Type | Description |
|---|---|
None
|
A generator that yields the solution at each time in |
Source code in src/odeiter/backward_differentiation.py
98 99 100 101 102 103 104 105 106 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 | |
BDF2
Bases: BackwardDifferentiationAbstract
Backward Differentiation of order 2.
Source code in src/odeiter/backward_differentiation.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
BDF3
Bases: BackwardDifferentiationAbstract
Backward Differentiation of order 3.
Source code in src/odeiter/backward_differentiation.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
BDF4
Bases: BackwardDifferentiationAbstract
Backward Differentiation of order 4.
Source code in src/odeiter/backward_differentiation.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
BDF5
Bases: BackwardDifferentiationAbstract
Backward Differentiation of order 5.
Source code in src/odeiter/backward_differentiation.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |