Skip to content

pyflightstream.post.farfield_fields (provisional)

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

The far-field samples of one point: the Trefftz C plane and the survey lattice (FR-453, FR-38).

Pipeline role: the probe half of the far-field product family. It reads the probe values the plan laid for the far field (the steady probe export, or one time step of the unsteady fluid plots), finds the plane and the lattice among them by matching every exported position to the layout the run recorded (:func:recorded_layout; for a record written before the layout was recorded, to the layout the far-field table states, by shape), refuses a set it cannot match exactly once, turns the velocities to the plane's or the lattice's axes, and computes the Trefftz C values and the balances with the numpy core of :mod:pyflightstream.farfield. It writes nothing; :mod:pyflightstream.post.farfield_products writes the rows.

Positions in the exports are in the simulation's length unit; the unit is read from the point's saved simulation, and a point whose unit cannot be read is a named skip, never a guess.

Advanced

pyflightstream.post.farfield_fields.FarLayout dataclass

FarLayout(
    plane_m: ndarray | None = None,
    plane_grid: tuple[float, float, float] | None = None,
    lattice: ProbeLattice | None = None,
    lattice_m: ndarray | None = None,
    axis: str | tuple[float, float, float] = "X",
    lattice_local_m: ndarray | None = None,
    lattice_origin_m: ndarray | None = None,
    plane_placed: bool = True,
    lattice_placed: bool = True,
    lattice_frame: str | None = None,
    plane_record: Mapping[str, Any] | None = None,
    lattice_record: Mapping[str, Any] | None = None,
)

Where the far-field probes of one point are, in metres, reference frame (PFS-2081.58).

Attributes:

Name Type Description
plane_m ndarray or None

The Trefftz C plane's points, z fastest within y.

plane_grid tuple of float or None

The plane's half width, half height and spacing, m.

lattice ProbeLattice or None

The survey lattice, in metres.

lattice_m ndarray or None

The lattice's points.

axis str or tuple of float

The lattice's shaft letter or global unit direction.

lattice_local_m ndarray or None

The lattice's points in the frame its positions were recorded in, where that is not the reference frame (a declared lattice of a frame).

lattice_origin_m ndarray or None

Where the run placed the lattice's origin (a rotor's hub), m; None for a layout the run did not record.

lattice_frame str or None

The frame the run recorded the lattice's positions in (upper case); None for a layout derived from the table, whose owner is unknown.

plane_placed, lattice_placed bool

True where the set is placed, so every position is matched where it stands: always for a layout the run recorded, and for a rotor's lattice on its hub. False for a plane or a frame's lattice derived from the far-field table for a record without a layout, matched by shape, since such a record holds no placement.

pyflightstream.post.farfield_fields.LEDGER_COLUMNS module-attribute

LEDGER_COLUMNS: tuple[str, ...] = (
    "LATTICE",
    "STATION_X_R",
    "MDOT_KG_S",
    "AXIAL_FLUX_N",
    "FX_N",
    "FY_PLANE_N",
    "FY_PLANE_HARMONIC_N",
    "FZ_PLANE_N",
    "FZ_PLANE_HARMONIC_N",
    "FY_LATERAL_N",
    "FZ_LATERAL_N",
    "TORQUE_NM",
    "MY_LOADING_NM",
    "MY_ARM_NM",
    "MZ_LOADING_NM",
    "MZ_ARM_NM",
    "E_TOTAL_W",
    "E_SWIRL_W",
    "E_INDUCED_W",
    "COVERAGE",
    "MASS_SPREAD",
    "SYMMETRY_FLOOR",
    "SPURIOUS_COUNTS",
    "F_NEAR_N",
    "F_NEAR_VISCOUS_N",
    "STATUS",
)

pyflightstream.post.farfield_fields.ProbeSamples dataclass

ProbeSamples(
    positions: ndarray,
    velocity: ndarray,
    cp: ndarray,
    frames: tuple[str, ...] | None = None,
    digits: int | None = None,
)

The probe values of one instant, in probe creation order.

Attributes:

Name Type Description
positions ndarray

(n, 3) positions in the simulation's length unit, reference frame.

velocity ndarray

(n, 3) velocity in m/s, in the export frame (x aft, y right, z up).

cp ndarray

(n,) pressure coefficient on the reference velocity.

frames tuple of str, optional

The frame each position is recorded in, upper case, for samples read from the recorded positions of an unsteady run (a declared entry's points stand in its own frame there); None for a steady export, whose positions are all in the reference frame.

digits (int, optional)

The significant digits the export printed the positions with; None where the positions are the recorded ones (five decimals, native).

pyflightstream.post.farfield_fields.ROTOR_LEDGER_COLUMNS module-attribute

ROTOR_LEDGER_COLUMNS: tuple[str, ...] = (
    "P_PRIME_CORRECTION_N",
    "AXIAL_FLUX_CORRECTED_N",
    "FX_CORRECTED_N",
)

pyflightstream.post.farfield_fields.average_rows

average_rows(
    rows: Sequence[Sequence[tuple[object, ...]]], first: int
) -> list[tuple[object, ...]]

Average per-step rows of one shape, cell by cell, from column first (FR-484).

rows holds one list of rows per time step, each step's rows in the same order. Every flux is computed on each step's field and then averaged here, never computed on an averaged field. A step's NaN makes the average NaN, never a smaller number; a column that is text in some steps and a number in others is NA, never the first step's value; a text column keeps the first step's; STEP (the second cell) reads AVERAGE.

Parameters:

Name Type Description Default
rows Sequence[Sequence[tuple[object, ...]]]

One ordered sequence of product rows per time step.

required
first int

First column whose numeric cells are averaged.

required

Returns:

Type Description
list[tuple[object, ...]]

Rows with AVERAGE step labels and averaged numeric cells.

pyflightstream.post.farfield_fields.axial_coefficient

axial_coefficient(
    total: Mapping[str, Any], axis: str | Sequence[float]
) -> float

Project global force coefficients onto a letter or installed shaft direction.

Parameters:

Name Type Description Default
total mapping

Global Cx, Cy and Cz load coefficients.

required
axis str or sequence of float

Shaft letter or unit direction in global coordinates.

required

Returns:

Type Description
float

Signed axial coefficient; missing contributing components give NaN.

pyflightstream.post.farfield_fields.coordinate_tolerance

coordinate_tolerance(
    points: ndarray, digits: int | None
) -> np.ndarray

Return the per-component tolerance of exported coordinates near points (native).

The relative term is 10**(1 - digits) * |x|: between one and ten units of the last printed significant digit of a coordinate (one at a coordinate whose leading digit is 9, ten at one whose leading digit is 1), where the export printed them (digits), plus the native unit's fifth decimal. The match is therefore looser than one unit; the spacing check refuses a layout it would make ambiguous.

Parameters:

Name Type Description Default
points ndarray

The coordinates, in native units, whose export tolerance is wanted.

required
digits int or None

The significant digits the export printed; None or zero when unknown.

required

Returns:

Type Description
ndarray

The tolerance of each component, of the shape of points.

pyflightstream.post.farfield_fields.derived_layout

derived_layout(
    *,
    plane_grid: tuple[float, float, float] | None = None,
    direction: Sequence[float] | None = None,
    lattice: tuple[
        ProbeLattice,
        ndarray | None,
        str | tuple[float, float, float],
    ]
    | None = None,
) -> FarLayout

Lay the far-field probes a record without a layout should hold, from the table as it stands.

A record written before the run recorded its layout holds no placement of the plane (it sits behind the body the plan read) nor of a frame's lattice, so post matches those by shape; a rotor's lattice is placed on its hub and matched where it stands.

Parameters:

Name Type Description Default
plane_grid tuple of float

The plane's half width, half height and spacing, m.

None
direction sequence of float

The point's free-stream direction, with plane_grid.

None
lattice tuple

The lattice, its points in metres (None for a frame's) and its axis.

None

Returns:

Type Description
FarLayout

The layout; the plane, and a frame's lattice, are not placed.

pyflightstream.post.farfield_fields.disk_loading

disk_loading(
    blocks: Sequence[tuple[ndarray, str]],
    *,
    shaft: str,
    blades: int,
    tip_radius_m: float,
) -> DiskLoading | str

Return a rotor's disk loading from blade sectional loads, or why there is none.

blocks holds, per blade distribution (one family, one blade frame, already averaged over the window where the row has one), the export rows (Offset, Chord, X_QC, Z_QC, Fx, Fz, Moment) and the cut plane's two letters. In a blade frame the shaft keeps its letter, so the force density along the shaft letter is the blade's axial force and the other in-plane one its tangential force; the span is the third letter and Offset the signed distance along it. The blades are averaged and the loading is summed over blades, the force and torque on the fluid being opposite to those on the blades.

Parameters:

Name Type Description Default
blocks sequence of (numpy.ndarray, str)

Rows and plane letters of each blade distribution.

required
shaft str

The shaft letter of the blade frames.

required
blades int

The rotor's blade count, periodic copies included.

required
tip_radius_m float

The lattice tip radius in m, for the blades' axial reach in x/R.

required

Returns:

Type Description
DiskLoading or str

The loading, or the reason it cannot be formed.

pyflightstream.post.farfield_fields.far_samples

far_samples(
    samples: ProbeSamples,
    layout: FarLayout,
    *,
    per_m: float,
    final: bool = True,
) -> tuple[
    slice | np.ndarray | None,
    slice | np.ndarray | None,
    str,
]

Locate the lattice and the plane among a point's probes (FR-1045, PFS-2081.58).

Every exported position of a set must match the layout, each set exactly once: where the run recorded the layout, where it stands, in the one frame it recorded the positions in; for a record without one, the plane and a frame's lattice by their shape and a rotor's lattice where its hub places it, among every point. Positions are compared within the export's printed precision of each coordinate (PFS-2081.103). A set not found, or found twice, is returned as None with the reason, never as the points that happen to be last or to number as many.

Parameters:

Name Type Description Default
samples ProbeSamples

Probe positions, velocity components and pressure coefficients.

required
layout FarLayout

The far-field probes of the point (:func:recorded_layout, :func:derived_layout).

required
per_m float

Number of native simulation length units per metre.

required
final bool

Select final-export offsets; False selects window-import offsets.

True

Returns:

Type Description
tuple

The lattice's and the plane's sample selection (a slice, or the indices where the set's points are not consecutive), and the reasons a set in the layout is missing.

pyflightstream.post.farfield_fields.frame_lattice

frame_lattice(
    shape: LatticeShape,
) -> tuple[ProbeLattice, None, str]

Return a frame's lattice, laid along the frame's x axis on the reference axes.

Parameters:

Name Type Description Default
shape LatticeShape

Declared annular probe-lattice geometry.

required

Returns:

Type Description
tuple[ProbeLattice, None, str]

Probe lattice, None for unavailable reference positions, and axis X.

pyflightstream.post.farfield_fields.ledger_values

ledger_values(
    fields: LatticeFields,
    spec: LedgersSpec,
    *,
    rho: float,
    speed: float,
    near: tuple[float, float],
    viscous: float = _NA,
    excluded_orders: Sequence[int] = (),
    rotor: bool = False,
    loading: DiskLoading | None = None,
) -> list[dict[str, float]]

Return one mapping of ledger columns per lattice station (FR-38, FR-1056).

near is the inviscid near-field axial force of the configuration (N) and the reference area (m^2) the spurious counts are stated against. A balance the table does not select stays out (NA); the control-volume columns are NA on the inlet row.

Parameters:

Name Type Description Default
fields LatticeFields

Survey samples in the shaft-aligned axes of :mod:pyflightstream.probes.lattice, with the units of :class:~pyflightstream.farfield.fields.LatticeFields.

required
spec LedgersSpec

Selected balance channels and harmonic order of the ledger.

required
rho float

Density in kg/m3.

required
speed float

Free-stream speed in m/s.

required
near tuple[float, float]

Inviscid near-field axial force in N and its reference area in m2.

required
viscous float

Viscous axial force in N, projected along the free-stream direction.

_NA
excluded_orders sequence of int

Blade-passage orders omitted from G3 on this row's rotor lattice.

()
rotor bool

Whether the row is a rotor recipe, even when the entry names a frame. Rotor entries and rows omit G4 and its near-force comparison because probe pressure carries no disk total-pressure jump, unless loading supplies it.

False
loading DiskLoading or None

The rotor's disk loading (P0470-FFR option 1a): the corrected columns are written and a rotor's G4 compares the near field with the corrected axial balance.

None

Returns:

Type Description
list[dict[str, float]]

One ledger column mapping per lattice station.

pyflightstream.post.farfield_fields.native_per_m

native_per_m(
    sim_dir: Path,
    outputs: Sequence[str],
    version: str | None,
) -> float | None

Return the simulation length units per metre of a point, from its saved simulation.

Parameters:

Name Type Description Default
sim_dir Path

Folder containing the point exports and saved simulation.

required
outputs Sequence[str]

Recorded output filenames relative to the simulation folder.

required
version str | None

Package version that wrote the output names, or None for current names.

required

Returns:

Type Description
float | None

Native length units per metre, or None when the saved unit is unavailable.

pyflightstream.post.farfield_fields.plane_values

plane_values(
    samples: ProbeSamples,
    block: slice | ndarray,
    *,
    flow: tuple[float, float, float, float],
    grid: tuple[float, float, float],
    per_m: float,
    q_ref: float,
    hub: tuple[float, ndarray, ndarray] | None = None,
) -> dict[str, float]

Return the Trefftz C values of a wing's plane, in N and m.

(FR-1030, FR-1031, FR-1034, FR-1035).

flow is the density, the free-stream speed, alpha and beta (deg); grid is the plane's half width, half height and spacing in m.

Parameters:

Name Type Description Default
samples ProbeSamples

Probe positions, velocity components and pressure coefficients.

required
block slice or ndarray

Slice selecting the plane points from the probe samples.

required
flow tuple[float, float, float, float]

Density in kg/m3, speed in m/s, incidence and sideslip in degrees.

required
grid tuple[float, float, float]

Plane half width, half height and spacing, all in m.

required
per_m float

Number of native simulation length units per metre.

required
q_ref float

Recorded reference dynamic pressure in Pa, the basis of Cp_ref.

required
hub tuple

The frame speed (rad/s, signed), axis and origin (m, reference frame) of a quasi-steady rotor whose turning frame the probes were read in; the velocities are converted to the hub frame first, as the lattice's are (FR-1037). The static pressure is kept.

None

Returns:

Type Description
dict[str, float]

Trefftz-plane product columns with forces in N and distances in m.

Raises:

Type Description
PyflightstreamError

If the selected probes do not form the declared free-stream-normal plane.

pyflightstream.post.farfield_fields.recorded_layout

recorded_layout(
    shapes: Sequence[Mapping[str, Any]],
) -> FarLayout

Rebuild the far-field probes a run recorded, in metres (FR-1047, PFS-2081.58).

Each shape is one entry of the record's farfield_layout (kind, source, count and the geometry the plan laid it from); the points are laid again by the functions that laid them.

Parameters:

Name Type Description Default
shapes sequence of mapping

The recorded shapes of one point.

required

Returns:

Type Description
FarLayout

The plane and the lattice, each where the run laid it.

Raises:

Type Description
PyflightstreamError

If a shape cannot be rebuilt, or rebuilds to another point count than the run recorded, or the run left the entry's only shape out (a lattice in a rotor frame the row does not place), naming that reason.

pyflightstream.post.farfield_fields.rotor_lattice

rotor_lattice(
    shape: LatticeShape, rotor: Any
) -> tuple[
    ProbeLattice,
    np.ndarray,
    str | tuple[float, float, float],
]

Return a rotor's lattice, its points in metres (reference frame) and its axis letter.

Parameters:

Name Type Description Default
shape LatticeShape

Declared annular probe-lattice geometry.

required
rotor Any

Resolved rotor with diameter, hub origin and axis.

required

Returns:

Type Description
tuple[ProbeLattice, ndarray, str]

Lattice, reference-frame point coordinates in m and rotor axis letter.

Raises:

Type Description
PyflightstreamError

If the rotor axis is not an axis letter.

pyflightstream.post.farfield_fields.rotor_values

rotor_values(
    fields: LatticeFields,
    *,
    rho: float,
    speed: float,
    station: float,
    loading: DiskLoading | None = None,
) -> dict

Return the rotor channels of FR-1032 at one station, in W.

With the disk loading of a rotor row, P_TOTAL_CORRECTED_W and ETA_FF_CORRECTED are the same channels on the pressure corrected by the disk total-pressure rise (:func:corrected_fields); the uncorrected columns stay.

Parameters:

Name Type Description Default
fields LatticeFields

Survey samples in the shaft-aligned axes of :mod:pyflightstream.probes.lattice, with the units of :class:~pyflightstream.farfield.fields.LatticeFields.

required
rho float

Density in kg/m3.

required
speed float

Free-stream speed in m/s.

required
station float

Outlet station coordinate x/R.

required
loading DiskLoading or None

The rotor's disk loading from its blade sectional loads, or None.

None

Returns:

Type Description
dict

Rotor far-field product columns in the units named by their keys.

pyflightstream.post.farfield_fields.steady_samples

steady_samples(text: str) -> ProbeSamples

Read a steady probe export into its positions, velocities and Cp.

Parameters:

Name Type Description Default
text str

Native steady probe-export text.

required

Returns:

Type Description
ProbeSamples

Probe positions, velocities and pressure coefficients in export order.

Raises:

Type Description
PyflightstreamError

If required position, velocity or pressure columns are absent.