core.interpolation¶
Generic interpolation utilities for tabulated curves used across machwave.
BoundedCubicSpline¶
Many parts of machwave consume property curves as small tables — pump head versus volumetric flow, burn rate versus pressure, nozzle area versus axial station. BoundedCubicSpline wraps such a table in a cubic spline that:
- Interpolates between knots with a cubic spline. Smooth derivatives matter when the curve is composed with downstream solvers (RK4 step, root-finder on injector–chamber balance, etc.).
- Refuses to extrapolate.
scipy.interpolate.CubicSplineis constructed withextrapolate=False, and the class additionally raisesValueErrorfor any input outside[x_points[0], x_points[-1]]. A simulation that drifts off the calibrated domain fails loudly rather than producing fabricated values.
The constructor rejects malformed tables eagerly: the two sequences must be one-dimensional, the same length, contain at least two knots, and x_points must be strictly increasing. The inclusive domain bounds are exposed via the domain property.
Example¶
from machwave.core.interpolation import BoundedCubicSpline
efficiency_curve = BoundedCubicSpline(
x_points=[0.5, 1.0, 1.5, 2.0],
y_points=[0.55, 0.65, 0.62, 0.50],
)
efficiency_curve.domain # → (0.5, 2.0)
efficiency_curve(1.2) # → smooth spline value
efficiency_curve(3.0) # raises ValueError — outside [0.5, 2.0]
machwave.core.interpolation
¶
BoundedCubicSpline
¶
Cubic spline interpolant that does not extrapolate outside its domain.
Source code in machwave/core/interpolation.py
domain
property
¶
Return the inclusive (minimum, maximum) bounds of the spline.
__call__(value)
¶
Return the interpolated value at value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Independent-axis input at which to evaluate the spline. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Interpolated dependent value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in machwave/core/interpolation.py
__init__(x_points, y_points)
¶
Construct the spline from a table of knots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_points
|
Sequence[float]
|
Strictly increasing knot locations along the independent axis. Must contain at least two entries. |
required |
y_points
|
Sequence[float]
|
Dependent values at each knot. Must have the same length
as |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the inputs are not one-dimensional sequences of
equal length, if fewer than two knots are supplied, or if
|