Skip to content

pyflightstream.farfield.fields (stable)

Generated from the docstrings at build time: every one of the 7 names in the __all__ of pyflightstream.farfield.fields has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

The containers the far-field core integrates: survey samples on a lattice or a plane.

Pipeline role: the frozen numpy containers that replaced the xarray dataset (FR-457). :class:LatticeFields carries the samples of a cylindrical survey lattice, shaped (station, ring, azimuth), in the shaft-aligned coordinates defined by :mod:pyflightstream.probes.lattice; :class:PlaneFields carries the samples of a rectangular far-field plane, shaped (y, z). Neither reads or writes a file (FR-1004).

Field names: axial velocity u (m/s, +x downstream), transverse Cartesian v (+y) and w (+z), cylindrical v_r and v_theta (derived, see :func:cylindrical_components), pressure perturbation p_prime = p - p_inf (Pa). Radii and stations are nondimensionalized by the lattice tip radius.

Advanced

pyflightstream.farfield.fields.FarfieldInputError

Bases: PyflightstreamError, ValueError

A far-field reduction was given fields it cannot integrate.

Survey fields missing a sample array the ledger needs, a harmonic request the azimuthal sampling cannot resolve, a flux or moment call whose arrays do not agree on shape or frame, a station the lattice does not carry.

Also inherits from ValueError.

pyflightstream.farfield.fields.LatticeFields dataclass

LatticeFields(
    stations: ndarray,
    ring_centers: ndarray,
    ring_edges: ndarray,
    psi: ndarray,
    tip_radius: float,
    values: Mapping[str, ndarray],
    lateral_radius: float | None = None,
    lateral_stations: ndarray = (lambda: np.empty(0))(),
    lateral_values: Mapping[str, ndarray] = _EMPTY,
)

Samples of a cylindrical survey lattice with its coordinates.

Attributes:

Name Type Description
stations ndarray

Axial positions x/R of the annular planes, shape (n_stations,).

ring_centers ndarray

Sampling radii r/R, shape (n_r,).

ring_edges ndarray

Ring edges r/R, shape (n_r + 1,); the quadrature weights come from them.

psi ndarray

Uniform azimuths in radians, shape (n_psi,).

tip_radius float

Reference radius R, in THE LENGTH UNIT OF THE SAMPLES' POSITIONS. No unit conversion is performed by this container or by :func:lattice_fields: every area the balances integrate over is tip_radius squared times a dimensionless weight, so a ledger comes out in the field's units times that length unit squared (N for a momentum flux, W for an energy flux, kg/s for a mass flux, when the fields are in SI) and is SI only when R is given in metres. The post product path gives metres: it builds the lattice from the metre radius the artifact states and turns the exported coordinates into metres by the saved simulation's unit before it reads them. A caller of this library holding R in the simulation's unit (millimetres, say) owns the conversion: pass tip_radius in metres, with the fields in SI.

values mapping of str to numpy.ndarray

Sampled fields, each shaped (n_stations, n_r, n_psi).

lateral_radius float or None

Radius r/R of the lateral closure cylinder; None without one.

lateral_stations ndarray

Axial positions x/R of the lateral rings, shape (n_lateral,).

lateral_values mapping of str to numpy.ndarray

Lateral ring samples, each shaped (n_lateral, n_psi).

shape property

shape: tuple[int, int, int]

The sample shape (n_stations, n_r, n_psi).

with_values

with_values(**arrays: ndarray) -> LatticeFields

Return a copy with fields added or replaced (shapes checked).

with_lateral_values

with_lateral_values(**arrays: ndarray) -> LatticeFields

Return a copy with lateral-ring fields added or replaced.

station_index

station_index(station: float) -> int

Return the index of a station x/R, allowing floating-point roundoff.

An exact match wins; otherwise the one station within 1e-12 (relative and absolute) is taken, so 0.1 * 3 finds the plane at 0.3. A nearby plane is never guessed.

Raises:

Type Description
FarfieldInputError

If no plane, or more than one, lies at station within the roundoff tolerance; the message names the available stations.

points

points() -> tuple[np.ndarray, dict[str, np.ndarray]]

Flatten the survey into the inputs of the point writers.

The replacement of the retired post.dataset_to_points: positions rebuilt from the survey coordinates (x = station R, y = r sin(psi) R, z = r cos(psi) R, the convention of :mod:pyflightstream.probes) and every field flattened in the same station, ring, azimuth order, so the result drops straight into :func:pyflightstream.post.writers.write_vtk_points or :func:pyflightstream.post.writers.write_tecplot_points.

Returns:

Type Description
tuple

(points, fields): positions (n, 3) in the length unit of tip_radius (metres on the post product path) and the flattened scalar fields.

pyflightstream.farfield.fields.PlaneFields dataclass

PlaneFields(
    y: ndarray, z: ndarray, values: Mapping[str, ndarray]
)

Samples of a uniform rectangular far-field plane (Trefftz C, wing).

Attributes:

Name Type Description
y, z ndarray

The grid axes in the plane, in m, uniform and strictly increasing, shapes (n_y,) and (n_z,); y to the right and z up in the wind axes of the point.

values mapping of str to numpy.ndarray

Sampled fields, each shaped (n_y, n_z): u, v, w in wind axes (m/s) and p_prime (Pa) where the analysis needs it.

pyflightstream.farfield.fields.cylindrical_components

cylindrical_components(
    fields: LatticeFields,
) -> LatticeFields

Add the cylindrical velocity components v_r and v_theta.

Convention (fixed here and pinned by a tier-1 test, DLV-006 Sec. 3.1): y = r sin(psi), z = r cos(psi), so the radial unit vector is (0, sin psi, cos psi) and the azimuthal unit vector, in the direction of growing psi (+z toward +y), is (0, cos psi, -sin psi). A right-handed rotation about +x therefore has negative v_theta in this convention. The lateral rings gain the same two components where they carry v and w.

Parameters:

Name Type Description Default
fields LatticeFields

Survey samples carrying v and w (m/s).

required

Returns:

Type Description
LatticeFields

A copy with v_r and v_theta added (m/s).

pyflightstream.farfield.fields.hub_frame_velocities

hub_frame_velocities(
    points: ndarray,
    *,
    velocities: ndarray,
    omega: float,
    axis: ndarray,
    origin: ndarray,
) -> np.ndarray

Convert velocities sampled in a frame turning with a rotor to its hub frame.

A quasi-steady rotor holds its blades still and carries the rotation in the free stream, so a probe there is taken to read the velocity relative to a frame that turns at omega about axis (FR-1037; not measured in a committed report). The hub-frame velocity adds back the frame velocity at the probe, v_hub = v + Omega x (x - x_hub) with Omega = omega axis (FR-1037). The positions are not moved: the balances of one solve read the field at one instant, where the two frames coincide.

Parameters:

Name Type Description Default
points ndarray

Probe positions, shape (n, 3), m, in the frame the velocities are stated in.

required
velocities ndarray

Sampled velocities in the turning frame, shape (n, 3), m/s.

required
omega float

Signed rotational speed in rad/s about axis (right-handed); the sign is the sense of the rotor's speed.

required
axis ndarray

The rotation axis, shape (3,); normalized here.

required
origin ndarray

A point of the rotation axis (the hub), shape (3,), m.

required

Returns:

Type Description
ndarray

Hub-frame velocities, shape (n, 3), m/s.

Raises:

Type Description
FarfieldInputError

If the axis is not a finite non-zero vector, or points and velocities are not matching (n, 3) arrays.

pyflightstream.farfield.fields.lattice_fields

lattice_fields(
    lattice: ProbeLattice,
    *,
    fields: Mapping[str, ndarray],
    lateral: Mapping[str, ndarray] | None = None,
) -> LatticeFields

Assemble the survey samples of a lattice, the replacement of lattice_dataset.

Parameters:

Name Type Description Default
lattice ProbeLattice

Lattice that placed the probes; supplies stations, ring centers, ring edges, azimuths, the tip radius and the lateral cylinder. Supply the tip radius in metres for SI balances; this function copies it without converting simulation length units.

required
fields mapping of str to numpy.ndarray

Sampled fields of the annular planes, each shaped (n_stations, n_r, n_psi) in the lattice sampling order.

required
lateral mapping of str to numpy.ndarray

Sampled fields of the lateral rings, each (n_lateral, n_psi).

None

Returns:

Type Description
LatticeFields

The frozen container every balance integrates.

pyflightstream.farfield.fields.plane_fields

plane_fields(
    y: object, *, z: object, fields: Mapping[str, ndarray]
) -> PlaneFields

Assemble the samples of a far-field plane.

Parameters:

Name Type Description Default
y array_like

Uniform grid axes in m, each with at least three points.

required
z array_like

Uniform grid axes in m, each with at least three points.

required
fields mapping of str to numpy.ndarray

Sampled fields shaped (len(y), len(z)).

required

Returns:

Type Description
PlaneFields

The frozen container the Trefftz C integrals take.

Raises:

Type Description
FarfieldInputError

If coordinates or field arrays do not form the declared rectangular plane.