Adams-Moulton 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 derivative at several previous time steps.
Adams-Moulton 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, AM3 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 = AM4(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-Moulton method. For example
solver = AM4(RK4(), seed_steps_per_step=1)
solver = AM5(RK4(), seed_steps_per_step=2)
adams_moulton
A module containing Adams-Moulton solvers of several orders.
AdamsMoultonAbstract
Bases: TimeIntegrator
An abstract class for Adams-Moulton (AM) solvers.
All AM solvers will inherit these methods. Additionally,
they inherit the methods of time_integrator.TimeIntegrator
as well.
Source code in src/odeiter/adams_moulton.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 | |
__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/adams_moulton.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/adams_moulton.py
40 41 42 43 44 45 46 | |
order()
Returns:
| Type | Description |
|---|---|
int
|
The order of the method |
Source code in src/odeiter/adams_moulton.py
48 49 50 51 52 53 54 | |
fs_coeffs()
Returns:
| Type | Description |
|---|---|
list[float]
|
The interpolation coefficients of the method. |
Source code in src/odeiter/adams_moulton.py
56 57 58 59 60 61 62 | |
update(t, u, rhs, fs, delta_t)
Compute the next time step. You probably want solution_generator instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
The current time. |
required |
u
|
ndarray[float]
|
The solution at the current time-step. |
required |
rhs
|
Callable[[float, ndarray[float]], ndarray[float]]
|
The right-hand-side of the system as a function |
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_moulton.py
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 | |
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_moulton.py
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 | |
AM2
Bases: AdamsMoultonAbstract
Adams Moulton of order 3.
Source code in src/odeiter/adams_moulton.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
AM3
Bases: AdamsMoultonAbstract
Adams Moulton of order 4.
Source code in src/odeiter/adams_moulton.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
AM4
Bases: AdamsMoultonAbstract
Adams Moulton of order 5.
Source code in src/odeiter/adams_moulton.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |