cds2.integrate
Numerical integration and ODE solving on scipy.integrate.
Quadrature and ODE — convenience re-export of scipy.integrate; see cds2.sde for SDE companion.
QuadResult
dataclass
Integral estimate with its absolute error bound.
Source code in src/cds2/integrate.py
26 27 28 29 30 31 | |
OdeResult
dataclass
Trajectory produced by an initial-value-problem solver.
Source code in src/cds2/integrate.py
34 35 36 37 38 39 40 41 42 43 | |
BVPResult
dataclass
Solution of a two-point boundary value problem on the output mesh.
Source code in src/cds2/integrate.py
46 47 48 49 50 51 52 53 | |
solve_bvp(func, bc, initial_mesh, initial_guess, tol=0.001, max_nodes=1000)
Solve a two-point boundary value problem y' = func(t, y), bc(ya, yb) = 0.
initial_mesh is the starting node grid; initial_guess is a
(n_states, len(mesh)) array of starting values for the collocation
solver (4th-order collocation with residual control).
Source code in src/cds2/integrate.py
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 | |
quad(func, a, b)
Adaptive definite integral of a scalar function over [a, b].
Source code in src/cds2/integrate.py
86 87 88 89 | |
integrate_2d(func, xa, xb, ya, yb)
Double integral of func(x, y) over the rectangle [xa, xb] x [ya, yb].
Source code in src/cds2/integrate.py
92 93 94 95 96 97 98 99 100 101 | |
integrate_3d(func, xa, xb, ya, yb, za, zb)
Triple integral of func(x, y, z) over the axis-aligned box.
Source code in src/cds2/integrate.py
104 105 106 107 108 109 110 111 112 113 114 115 | |
solve_ivp(func, t_span, y0, t_eval=None, method='RK45', events=None, **kwargs)
Integrate an initial-value problem dy/dt = func(t, y).
Backward integration works naturally when t_span[1] < t_span[0].
Pass events (callables g(t, y) -> float; zero crossings trigger
them, set terminal = True on a callable to stop integration) to
receive t_events / y_events on the result. For stiff problems
use method="Radau", "BDF" or "LSODA".
Source code in src/cds2/integrate.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
trapezoid(y, x=None, dx=1.0)
Composite trapezoidal integral of sampled values.
Source code in src/cds2/integrate.py
159 160 161 | |
cumulative_trapezoid(y, x=None, dx=1.0)
Running trapezoidal integral, returned with the same length as y.
Source code in src/cds2/integrate.py
164 165 166 167 168 169 170 171 | |
simpson(y, x=None, dx=1.0)
Composite Simpson-rule integral of sampled values.
Source code in src/cds2/integrate.py
174 175 176 | |