Skip to content

pyflightstream.post.inflow_tools (provisional)

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

The quasi-steady inflow tools: frame change and the blade-view harmonics.

Pipeline role: the post row, where recorded exports become products. It holds the inflow tools beyond the field operations of :mod:pyflightstream.workspace.fields (the fluctuation report and fill-interior live there, beside the other operations that build a custom free stream):

  • :func:to_installed_frame writes a product table stated in the isolated frame as a second table in the installed frame, the mirror through y = 0. Which columns change sign, and which azimuths map, is the one list of :data:FLIPPED_COLUMNS and :data:AZIMUTH_COLUMNS, stated with its reason on the definitions page (docs/post-processing-definitions.md, "The installed-frame copy of a product table"); a test holds the two equal.
  • :func:blade_view_harmonics and :func:inflow_harmonics_map read a custom inflow as one blade of a wheel meets it. The plan's --inflow-fft (:func:pyflightstream.cases.qsteady.blade_inflow_harmonics) already reads the field, turns the blade through it and gives n95 per radius, n_max and the suggested PASSAGE_POSITIONS; this module uses THAT reading (:func:pyflightstream.cases.qsteady.blade_inflow_angles) and adds only what the plan does not give: the variance share of each of the first eight harmonics, the rms and half peak-to-peak of the angle-of-attack perturbation in degrees, the reduced frequency k_1P = Omega c / (2 mean V_rel) with the mean relative speed of the revolution (the plan's uses the free-stream speed), k_eff = n95 k_1P, and the map over the advance ratio J of one fixed field (J moves the rotor's speed, V stays), written as the two tables inflow_harmonics.csv and inflow_harmonics_J.csv.

Advanced

pyflightstream.post.inflow_tools.AZIMUTH_COLUMNS module-attribute

AZIMUTH_COLUMNS: tuple[str, ...] = (
    "AZIMUTH",
    "AZIMUTH_START",
    "AZIMUTH_END",
    "azimuth_deg",
    "H\\d+_PHASE_DEG",
)

pyflightstream.post.inflow_tools.ColumnClassification dataclass

ColumnClassification(
    flipped: tuple[str, ...], mapped: tuple[str, ...]
)

Which columns of a table the installed-frame copy negates and which it maps.

pyflightstream.post.inflow_tools.FLIPPED_COLUMNS module-attribute

FLIPPED_COLUMNS: tuple[str, ...] = (
    "FY",
    "MX",
    "MZ",
    "CY[A-Z]*",
    "CR(?!EF)[A-Z]*",
    "CN[BSW]\\d*",
    "CMX",
    "CMZ",
    "TORQUE",
    "RPM",
    "CQ",
    "BETA",
    "CS",
    "CMN",
    "Y",
    "YMOM",
    "VY",
    "VORTICITY_[XZ]",
)

pyflightstream.post.inflow_tools.HARMONIC_SHARES module-attribute

HARMONIC_SHARES = 8

pyflightstream.post.inflow_tools.HarmonicsMap dataclass

HarmonicsMap(
    stations: tuple[
        tuple[float, InflowStationHarmonics], ...
    ],
    diameter_m: float,
    v_inf_m_s: float,
    blades: int,
)

The blade-view harmonics of one fixed field over a range of advance ratios.

Attributes:

Name Type Description
stations tuple of (float, InflowStationHarmonics)

(J, station), advance ratio major, radius minor.

diameter_m, v_inf_m_s float

The rotor diameter and the fixed speed J is read against.

blades int

N.

n_max property

n_max: int

The largest n95 of any station at any J.

suggested_passage_positions property

suggested_passage_positions: int

ceil(n_max / N + 1): the plan's rule (:func:suggested_passage_positions).

pyflightstream.post.inflow_tools.InflowStationHarmonics dataclass

InflowStationHarmonics(
    radius_m: float,
    chord_m: float | None,
    dalpha_rms_deg: float,
    dalpha_half_ptp_deg: float,
    n95: int,
    shares: tuple[float, ...],
    k_1p: float | None,
    k_eff: float | None,
)

The harmonic content of the angle of attack one blade meets at one radius.

Attributes:

Name Type Description
radius_m, chord_m (float, float or None)

The station; the chord where it is known.

dalpha_rms_deg, dalpha_half_ptp_deg float

The root mean square and the half peak-to-peak of the perturbation dalpha(psi) = -(phi - mean phi) over one revolution, in degrees.

n95 int

The plan's n95 (0 for a perturbation the blade meets as constant).

shares tuple of float

The variance share of harmonics 1 to :data:HARMONIC_SHARES.

k_1p, k_eff float or None

Omega c / (2 mean V_rel) and n95 k_1P, where the chord is known.

pyflightstream.post.inflow_tools.blade_view_harmonics

blade_view_harmonics(
    rows: Sequence[Sequence[float]],
    *,
    hub: Sequence[float],
    axis: Sequence[float],
    omega_rad_s: float,
    radii_m: Sequence[float],
    chords_m: Sequence[float] | None = None,
    samples: int = AZIMUTH_SAMPLES,
) -> tuple[InflowStationHarmonics, ...]

Return the harmonic content of a custom inflow as one blade meets it, per radius.

The blade turns once round the disc through the field (blade 1 along +Z at psi = 0, psi positive in the sense of omega_rad_s, the sign of which is its hand about +X); at each azimuth the inflow angle phi = atan2(V_a, V_t) is read by :func:pyflightstream.cases.qsteady.blade_inflow_angles, the pitch cancels, and no self-induction is in a power-off field. n95 and the shares are the plan's own counting: a harmonic below :data:~pyflightstream.cases.qsteady.HARMONIC_AMPLITUDE_FLOOR_DEG is not counted, so the shares (those of the harmonics counted) and n95 agree.

Parameters:

Name Type Description Default
rows sequence of (x, y, z, vx, vy, vz)

The field, metres and m/s, global frame.

required
hub (x, y, z)

A point of the shaft and its direction; the axis must be along X.

required
axis (x, y, z)

A point of the shaft and its direction; the axis must be along X.

required
omega_rad_s float

The angular speed, signed by its hand.

required
radii_m sequence of float

The stations.

required
chords_m sequence of float

The chord at each station, from the mesh cut; without it k_1p and k_eff are None.

None
samples int

Azimuths per revolution.

AZIMUTH_SAMPLES

Returns:

Type Description
tuple of InflowStationHarmonics

One entry per radius, in the order given: n95, the per-harmonic shares, the perturbation's size and, with chords, k_1p and k_eff.

Raises:

Type Description
ProductError

If the axis is not along X, or chords_m does not match radii_m.

pyflightstream.post.inflow_tools.inflow_harmonics_map

inflow_harmonics_map(
    rows: Sequence[Sequence[float]],
    *,
    hub: Sequence[float],
    axis: Sequence[float],
    radii_m: Sequence[float],
    diameter_m: float,
    v_inf_m_s: float,
    advance_ratios: Sequence[float],
    blades: int,
    chords_m: Sequence[float] | None = None,
    sense: int = 1,
) -> HarmonicsMap

Return the blade-view harmonics of one field at each advance ratio J.

The field is fixed and J = V / (n D) moves through the rotor's speed n, V staying v_inf_m_s: omega = sense 2 pi V / (J D).

Parameters:

Name Type Description Default
sense int

+1 for a rotor right-handed about +X, -1 for the other hand.

1
rows sequence of (x, y, z, vx, vy, vz)

The field, metres and m/s, global frame.

required
hub (x, y, z)

A point of the shaft, in metres.

required
axis (x, y, z)

The shaft's direction; it must be along X.

required
radii_m sequence of float

The stations, in metres.

required
diameter_m float

The rotor's diameter D, in metres.

required
v_inf_m_s float

The free-stream speed V, in m/s.

required
advance_ratios sequence of float

The advance ratios J mapped.

required
blades int

The blade count.

required
chords_m sequence of float

The chord at each station, in metres; without it k_1p and k_eff are None.

None

Returns:

Type Description
HarmonicsMap

The stations of every J, with the diameter, the speed and the blade count.

Raises:

Type Description
ProductError

For a non-positive or non-finite J, diameter or speed, a non-positive blade count, a sense other than +-1, or what :func:blade_view_harmonics refuses.

pyflightstream.post.inflow_tools.installed_frame_columns

installed_frame_columns(
    columns: Sequence[str], *, flip: Sequence[str] = ()
) -> ColumnClassification

Classify the columns of a table for the installed-frame copy.

Parameters:

Name Type Description Default
columns sequence of str

The table's header.

required
flip sequence of str

Further columns to negate, by name (case-insensitive): the sectional FX, FZ and Moment are NOT negated by default because the section axes' orientation is not settled.

()

Returns:

Type Description
ColumnClassification

The columns negated and the columns mapped, in the table's order.

Raises:

Type Description
ProductError

If a name of flip is not a column.

Examples:

>>> installed_frame_columns(["FX", "FY", "AZIMUTH", "CT"])
ColumnClassification(flipped=('FY',), mapped=('AZIMUTH',))

pyflightstream.post.inflow_tools.to_installed_frame

to_installed_frame(
    table: str | Path,
    *,
    out: str | Path | None = None,
    flip: Sequence[str] = (),
) -> Path

Write a table stated in the isolated frame in the installed frame.

The installed frame is the isolated one mirrored through y = 0: the columns of :data:FLIPPED_COLUMNS (and those named in flip) change sign (a position along y, a polar vector's y component, an axial vector's x and z components), the azimuths and harmonic phases of :data:AZIMUTH_COLUMNS map psi -> -psi mod 360, as do the other *_PHASE_DEG columns except the Theodorsen and Sears phases C_PHASE_DEG and S_PHASE_DEG; every other cell is copied as written. The list holds the Y position, VY and the vorticity's x and z columns, so a table carrying them is mirrored there too. Blade and family names do not change: blade k of the image wheel (at +(k - 1) 60 degrees on a six-blade wheel) is blade k of the installed wheel (at -(k - 1) 60). A rotor table may open with ONE alias line with no comma, which is kept. Applying it twice returns the input.

Parameters:

Name Type Description Default
table str or Path

A product table (CSV) stated in the isolated frame.

required
out str or Path

Where the converted table is written; by default <table>_installed.csv beside the input.

None
flip sequence of str

Further columns to negate, by name.

()

Returns:

Type Description
Path

The file written.

Raises:

Type Description
ProductError

If the table is empty or its first line is numeric (no header), places no column under the mirror and flip names none (the copy would equal the input), or a name of flip is not a column. A flipped or mapped cell that is blank, a dash or not finite is written NA.

ProductExistsError

If the target exists: this never overwrites.

pyflightstream.post.inflow_tools.write_inflow_harmonics

write_inflow_harmonics(
    folder: str | Path,
    result: HarmonicsMap,
    *,
    overwrite: bool = False,
) -> tuple[Path, Path]

Write inflow_harmonics.csv and inflow_harmonics_J.csv into folder.

The first carries J, r_over_R, c_over_R, dalpha_rms_deg, dalpha_half_ptp_deg, n95, k_1P, k_eff, share_n1 ... share_n8, the second J, r_over_R, n95, k_1P, k_eff, dalpha_rms_deg, one row per (J, radius) in both (values %.9g, NA where the chord is unknown or a value is not finite).

Parameters:

Name Type Description Default
folder str or Path

The folder the two files are written into.

required
result HarmonicsMap

The map of :func:inflow_harmonics_map.

required
overwrite bool

Replace files that exist.

False

Returns:

Type Description
tuple of (Path, Path)

The full table and the short one.

Raises:

Type Description
ProductExistsError

If a file exists and overwrite is not set.