Adams-Bashforth solvers are a family of explicit solvers that perform a single right-hand-side evaluation per time step and achieve high-order accuracy by storing the derivative at several previous time steps. This makes them computationally efficient at the cost of some memory.
Adams-Bashforth 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, AB3 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-Bashforth solver is an integer multiple.
For example,
solver = AB5(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 Adams-Bashforth method. For example
solver = AB5(RK4(), seed_steps_per_step=1)
solver = AB5(RK4(), seed_steps_per_step=2)
adams_bashforth
A module containing Adams-Bashforth solvers of several orders.
AdamsBashforthAbstract
Bases: TimeIntegrator
An abstract class for Adams-Bashforth (AB) solvers. All AB solvers will inherit these methods.
Source code in src/odeiter/adams_bashforth.py
11 12 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 | |
__init__(seed, seed_steps_per_step)
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 |
Source code in src/odeiter/adams_bashforth.py
17 18 19 20 21 22 23 24 25 26 | |
name()
Returns:
| Type | Description |
|---|---|
str
|
The name of the method |
Source code in src/odeiter/adams_bashforth.py
28 29 30 31 32 33 34 | |
order()
Returns:
| Type | Description |
|---|---|
int
|
The order of the method |
Source code in src/odeiter/adams_bashforth.py
36 37 38 39 40 41 42 | |
fs_coeffs()
Returns:
| Type | Description |
|---|---|
list[float]
|
The interpolation coefficients of the method. |
Source code in src/odeiter/adams_bashforth.py
44 45 46 47 48 49 50 | |
update(u, fs, delta_t)
Compute the next time step. You probably want solution_generator instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
ndarray[float]
|
The solution at the current time-step. |
required |
fs
|
ndarray[float]
|
the right-hand-side at several previous time-steps. |
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/adams_bashforth.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
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/adams_bashforth.py
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 | |
AB2
Bases: AdamsBashforthAbstract
Adams-Bashforth 2.
Source code in src/odeiter/adams_bashforth.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
AB3
Bases: AdamsBashforthAbstract
Adams-Bashforth 3.
Source code in src/odeiter/adams_bashforth.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
AB4
Bases: AdamsBashforthAbstract
Adams-Bashforth 4.
Source code in src/odeiter/adams_bashforth.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
AB5
Bases: AdamsBashforthAbstract
Adams-Bashforth 5.
Source code in src/odeiter/adams_bashforth.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |