pyflightstream.qa.geometry (stable)¶
Generated from the docstrings at build time: every one of the 9 names in the __all__ of pyflightstream.qa.geometry has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Synthetic committable geometry for the Tier 3 physics cases.
Pipeline role: manufactures the NACA wing meshes the physics
regression matrix imports (PHY-01, PHY-02; SAD Section 11), so every
committed physics case is reproducible from code alone and no research
geometry ever enters the repository (CONTRIBUTING.md invariant 5). It also
MEASURES a mesh, which is the half the sentence above does not cover:
mean_edge_length returns the local face size, and a face size is only
ever wanted as one half of a ratio, because the vendor's caveat about
proximity-based boundary-layer mapping is stated relative to it. And it
can place a mesh, through the keyword-only translation_m, so two
components can be meshed at a controlled gap without a solver transform
command entering the measurement. The wing
is written as ASCII STL, one of the mesh formats the IMPORT command
accepts (FSM-26.120 p.307).
Reference frame: chord along +X (leading edge at x = 0), span along +Y, thickness along +Z; all lengths in meters. A half wing spans 0 <= y <= span/2 with an open root section lying in the XZ plane, the shape the solver's MIRROR symmetry expects: a face on the symmetry plane would duplicate itself into coincident faces (the tip-treatment caveat of FSM-26.120 p.386, paraphrased).
Advanced¶
pyflightstream.qa.geometry.BladeSpec
dataclass
¶
BladeSpec(
naca: str = "4409",
r_tip_m: float = 1.8288,
hub_ratio: float = 0.15,
chord_root_ratio: float = 0.14,
chord_tip_ratio: float = 0.06,
advance_ratio_design: float = 1.7,
beta_75_deg: float = 45.0,
n_chord: int = 25,
n_span: int = 30,
)
A generic propeller blade lofted from one NACA 4-digit section.
Every shape law is analytic and public (textbook blade-element relations with round coefficients), so the blade carries no proprietary geometry and any committed case built on it is shareable (CONTRIBUTING.md invariant 5). It is deliberately NOT a model of any research propeller; cases built on it seed their own references.
Reference frame: rotor axis along +X (free stream +X), blade spanning +Z from the hub radius to the tip, chord initially along +Y and twisted toward +X. With the suction side facing -X, thrust points -X (upstream) for positive rotation rates about +X when the twist exceeds the local inflow angle.
Attributes:
| Name | Type | Description |
|---|---|---|
naca |
str
|
Four-digit section designation, for example |
r_tip_m |
float
|
Tip radius in meters. |
hub_ratio |
float
|
Root radius as a fraction of |
chord_root_ratio, chord_tip_ratio |
float
|
Chord over tip radius at the root and tip stations; the chord varies linearly in radius between them. |
advance_ratio_design |
float
|
Design advance ratio J = V / (n D) shaping the ideal twist law beta(r) = atan(J / (pi r/R)) + collective. |
beta_75_deg |
float
|
Blade angle at 75 percent radius in degrees; fixes the collective offset (the standard propeller pitch convention). |
n_chord |
int
|
Chordwise panels per surface side. |
n_span |
int
|
Radial panel count. |
beta_rad
¶
beta_rad(rr: float) -> float
Blade angle from the rotation plane at radius fraction rr.
Ideal blade-element twist for the design advance ratio,
beta = atan(J / (pi rr)) plus the collective offset anchored
at beta(0.75) = beta_75_deg.
pyflightstream.qa.geometry.WingSpec
dataclass
¶
WingSpec(
naca: str = "0012",
chord_m: float = 1.0,
span_m: float = 8.0,
n_chord: int = 25,
n_span: int = 40,
)
A rectangular untwisted wing meshed from one NACA 4-digit section.
Attributes:
| Name | Type | Description |
|---|---|---|
naca |
str
|
Four-digit NACA designation, for example |
chord_m |
float
|
Chord length in meters; constant along the span. |
span_m |
float
|
Full span in meters, tip to tip. |
n_chord |
int
|
Chordwise panel count per surface side (upper and lower each). |
n_span |
int
|
Spanwise panel count over the full span; a half wing uses half of them, rounded down, so an odd count gives the half wing wider panels than the full wing has. |
Examples:
>>> from pyflightstream.qa.geometry import WingSpec
>>> spec = WingSpec(naca="0012", chord_m=1.0, span_m=4.0, n_chord=5, n_span=4)
>>> spec.chord_m, spec.span_m
(1.0, 4.0)
pyflightstream.qa.geometry.blade_triangles
¶
blade_triangles(spec: BladeSpec) -> np.ndarray
Mesh one blade into outward-oriented, watertight triangles.
The section loft places each scaled NACA contour at its radius, rotated by the local blade angle about the radial (+Z) axis, with the pitch axis at quarter chord; root and tip are capped so the body closes (the blade-only case has no spinner to join).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BladeSpec
|
Blade definition; see :class: |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Shape |
pyflightstream.qa.geometry.generate_blade_stl
¶
generate_blade_stl(
spec: BladeSpec, path: str | Path
) -> Path
Mesh spec and write it as ASCII STL in one call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BladeSpec
|
Blade definition. |
required |
path
|
str or Path
|
Destination STL file. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |
pyflightstream.qa.geometry.generate_wing_stl
¶
generate_wing_stl(
spec: WingSpec,
path: str | Path,
*,
half: bool = False,
translation_m: tuple[float, float, float] = (
0.0,
0.0,
0.0,
),
name: str | None = None,
) -> Path
Mesh spec and write it as ASCII STL in one call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
WingSpec
|
Wing definition. |
required |
path
|
str or Path
|
Destination STL file. |
required |
half
|
(bool, keyword - only)
|
Mesh the open-root y >= 0 half instead of the full span. |
False
|
translation_m
|
tuple of float, keyword-only
|
Rigid translation in meters, applied to the vertices rather than
by a solver command; see :func: |
(0.0, 0.0, 0.0)
|
name
|
(str, optional, keyword - only)
|
Solid name written into the STL, defaulting to the shape's own label. IT IS A PARAMETER BECAUSE THE DEFAULT COLLIDES. The label is derived from the aerofoil and the half flag alone, so two translated copies of one wing, which is exactly what the proximity study writes, get the SAME solid name in two files. Distinct names let the loads parser distinguish those bodies. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |
Examples:
>>> from pyflightstream.qa.geometry import WingSpec
>>> spec = WingSpec(naca="0012", chord_m=1.0, span_m=4.0, n_chord=5, n_span=4)
>>> import tempfile
>>> from pathlib import Path
>>> path = generate_wing_stl(spec, Path(tempfile.mkdtemp()) / "wing.stl")
>>> path.read_text(encoding="utf-8").splitlines()[0]
'solid naca0012_full'
pyflightstream.qa.geometry.mean_edge_length
¶
mean_edge_length(triangles: ndarray) -> float
Return the mean triangle edge length of a mesh, in meters.
The local face size, which is only ever wanted as one half of a RATIO. The vendor's caveat about proximity-based boundary-layer mapping is that it may fail where the gap between two components is large relative to the faces around it, so a gap measurement with no face length beside it says nothing either way, and a negative result reported without both numbers is not a result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
triangles
|
ndarray
|
Shape |
required |
Returns:
| Type | Description |
|---|---|
float
|
Mean length over all three edges of every triangle, the closing edge from the last vertex back to the first included. |
Examples:
The ratio is what the number is for. Mesh two copies of one wing at a chosen separation and express that separation in face lengths, so the gap can be compared against the vendor's stated condition rather than against a length in metres that means nothing on its own:
>>> from pyflightstream.qa.geometry import (
... WingSpec,
... mean_edge_length,
... wing_triangles,
... )
>>> spec = WingSpec()
>>> lower = wing_triangles(spec)
>>> face = mean_edge_length(lower)
>>> gap_m = 0.25 * face
THE TRANSLATION IS NOT THE GAP, which is the whole trap and is why
the thickness is measured rather than assumed. Translating by
gap_m puts the two copies INSIDE each other. The two copies start
COINCIDENT, so the upper copy's lower surface sits a full section
thickness BELOW the lower copy's upper surface, and the translation
that opens a gap of gap_m is therefore thickness + gap_m.
>>> thickness = float(lower[:, :, 2].max() - lower[:, :, 2].min())
>>> upper = wing_triangles(spec, translation_m=(0.0, 0.0, thickness + gap_m))
>>> gap = float(upper[:, :, 2].min() - lower[:, :, 2].max())
>>> round(gap / face, 2)
0.25
The mesh moves and its shape does not, which is what makes the pair comparable at all:
>>> import numpy as np
>>> bool(np.allclose(upper - lower, [0.0, 0.0, thickness + gap_m]))
True
pyflightstream.qa.geometry.naca4_contour
¶
naca4_contour(naca: str, n_chord: int) -> np.ndarray
Return the closed NACA 4-digit section contour in unit-chord axes.
The analytic thickness polynomial uses the closed-trailing-edge variant (last coefficient -0.1036), so the surface can be meshed watertight. Chordwise stations are cosine spaced, clustering points at the leading and trailing edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
naca
|
str
|
Four-digit designation, for example |
required |
n_chord
|
int
|
Panels per side; the contour has |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Shape |
Raises:
| Type | Description |
|---|---|
FsiInputError
|
If |
Examples:
>>> contour = naca4_contour("0012", 21)
>>> contour.shape, float(contour[0, 0])
((43, 2), 1.0)
pyflightstream.qa.geometry.wing_triangles
¶
wing_triangles(
spec: WingSpec,
*,
half: bool = False,
translation_m: tuple[float, float, float] = (
0.0,
0.0,
0.0,
),
) -> np.ndarray
Mesh the wing surface into outward-oriented triangles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
WingSpec
|
Wing definition; see :class: |
required |
half
|
(bool, keyword - only)
|
When True, mesh only the y >= 0 half with an open root section in the XZ symmetry plane (for MIRROR-symmetry runs, PHY-02); when False, mesh the full span with closed caps on both tips. |
False
|
translation_m
|
tuple of float, keyword-only
|
Rigid translation applied to every vertex, in meters, as
KEYWORD-ONLY, and NOT called IN THE MESH AND NOT THROUGH A SOLVER COMMAND, which is the point of it. Two components at a controlled gap are wanted for the proximity measurement, and translating one with a transform command would put the transform under test as well: on a build whose transform commands were renamed one release ago that is a second variable nobody asked for. Here it is arithmetic on the vertex array and the shape is provably untouched. |
(0.0, 0.0, 0.0)
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Shape |
Examples:
>>> from pyflightstream.qa.geometry import WingSpec
>>> spec = WingSpec(naca="0012", chord_m=1.0, span_m=4.0, n_chord=5, n_span=4)
>>> wing_triangles(spec).shape
(100, 3, 3)
pyflightstream.qa.geometry.write_stl
¶
write_stl(
triangles: ndarray,
path: str | Path,
name: str = "pyflightstream_wing",
) -> Path
Write triangles as deterministic ASCII STL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
triangles
|
ndarray
|
Shape |
required |
path
|
str or Path
|
Destination file; parent directories must exist. |
required |
name
|
str
|
Solid name recorded in the STL header. |
'pyflightstream_wing'
|
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |