example_pkg
Type part of a name or a dotted path
A tiny package, so the example site has an API reference to render.
Classes
Functions
| Name | Description |
|---|---|
linspace_midpoints | The midpoints of cells uniform cells on [start, stop]. |
midpoint_integral | The integral of f on [start, stop] by the composite midpoint rule. |
Modules
Driftclass#
example_pkg.schemesView sourceclass Drift(Scheme)Bases: Scheme
Move the position at the current velocity.
Numerics
update
Assumptions:
- velocity constant over the step
Gridclassdataclass#
example_pkg.gridView sourceclass Grid(start: float, stop: float, cells: int)A uniform grid of cells on [start, stop].
Attributes
cellsattributeinstance attribute#
cells: intstartattributeinstance attribute#
start: floatstopattributeinstance attribute#
stop: floatnodesmethod#
def nodes() -> np.ndarrayThe cells + 1 cell boundaries.
Returns
np.ndarray- The node coordinates.
Kickclass#
example_pkg.schemesView sourceclass Kick(Scheme)Bases: Scheme
Change the velocity by the acceleration at the current position.
Numerics
update
Leapfrogclass#
example_pkg.schemesView sourceclass Leapfrog(Scheme)Bases: Scheme
Half a kick, a drift and half a kick: the velocity Verlet scheme.
Numerics
half kick
drift
kick
energy
Order of accuracy: x: 2, v: 2.
Assumptions:
- the acceleration depends on the position only
References:
- Hairer, Lubich and Wanner, Geometric Numerical Integration (2006), section I.1.4
Built from:
example_pkg.schemes.Kickexample_pkg.schemes.Drift
linspace_midpointsfunction#
example_pkg.gridView sourcedef linspace_midpoints(start: float, stop: float, cells: int) -> np.ndarrayThe midpoints of cells uniform cells on [start, stop].
Parameters
Returns
np.ndarray- An array of length
cells.
midpoint_integralfunction#
example_pkg.gridView sourcedef midpoint_integral(f, start: float, stop: float, cells: int) -> floatThe integral of f on [start, stop] by the composite midpoint rule.
Parameters
Returns
float- The approximate integral.
Numerics
rule
error
Order of accuracy: 2.
Assumptions:
- f twice continuously differentiable on [a, b]
References:
- Süli and Mayers, An Introduction to Numerical Analysis (2003), section 7.2