Skip to content

pyflightstream.geometry (provisional)

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

Parametric geometry: component records, configuration, sections and lifting surfaces.

Pipeline role: pure numerical layer below the workspace. It describes aircraft components by a few parameters and rebuilds their skin as B-spline patches, with no geometry kernel, no solver and no import from the run, post or workspace layers. Stages that need a kernel (IGES writing, meshing) live in the workspace and import the types defined here.

The public names are :class:ComponentRecord (the parameter contract) and :func:load_config and :func:resolve_config (the TOML input boundary). The sections, distributions, lifting surfaces, caps and B-spline patches behind them are private modules of this package.

Examples:

>>> from pyflightstream.geometry import resolve_config
>>> resolved = resolve_config({"type": "lifting_surface"})
>>> resolved["components"]["COMPONENT"]["type"]["source"]
'given'

Used in the guides

pyflightstream.geometry.Propeller

Propeller(
    config=None,
    *,
    radius=None,
    blades=None,
    stations=None,
    airfoils=None,
    hub_radius=0.0,
    pitch_setting=30.0,
    pitch_reference_r_R=0.7,
    rotation="positive_x",
    options=None,
    output=None,
    frame=None,
    base_dir=None,
)

Classical planar propeller in mm, with degree-five sections and a cubic C2 loft.

Parameters:

Name Type Description Default
config dict

Strict schema 1 mapping. Alternatively supply radius, blades, stations and airfoils as keyword arguments. Station rows use r_R, c_R, beta_deg, t_c and airfoil, with optional stacking and displacement.

None
radius float

Radius and hub radius in mm.

None
hub_radius float

Radius and hub radius in mm.

None
blades int

Positive blade count.

None
stations list of dict or dict

Radial station rows or schema 1 column arrays.

None
airfoils dict

Named profiles, each containing exactly one of naca, file or cst.

None

Examples:

>>> from pyflightstream.geometry import Propeller
>>> Propeller({})
Traceback (most recent call last):
...
pyflightstream._errors.InputValueError: schema_version: got None, expected 1

config property

config

Independent schema 1 mapping; changing it does not change this design.

from_toml classmethod

from_toml(path)

Read schema 1 TOML, resolving coordinate files beside that input.

with_pitch

with_pitch(setting)

Return an independent design with the reference pitch setting in degrees.

with_skew

with_skew(value, *, units='deg')

Return a design with scalar, station array or callable skew, in deg or s/R.

with_rake

with_rake(value, *, units='x/R')

Return a design with scalar, station array or callable aft rake, in x/R or deg.

blade

blade()

Build one blade, returning patches and station information in mm.

rotor

rotor()

Build every blade at equal azimuths about the shaft.

spinner

spinner()

Build the spinner of every sector, split for periodicity, with its record, in mm.

Returns:

Type Description
SpinnerGeometry

patches (spinner_<i>_<part>), info (the record and its checks) and junction (the blade-0 trims of the dominance).

Raises:

Type Description
InputValueError

When the definition has no [spinner] table, or the blade root does not fit it.

report

report()

Return numerical checks and design measures; kernel checks live in run_geometry.

component

component(*, blades=None)

Return the component mapping accepted by resolve_config and run_geometry.

to_toml

to_toml(path)

Write schema 1 TOML that reads back with identical parameters and surfaces.

pyflightstream.geometry.resolve_config

resolve_config(data, stem=None, base=None)

Validate a geometry configuration and resolve it with the source of every value.

Parameters:

Name Type Description Default
data dict

A configuration as read from TOML: fresh input (a components table, or a single component carrying type) or a previously resolved configuration (format = "pyflightstream-geometry-resolved"), whose derived quantities are recomputed and compared.

required
stem str

File stem, the default of aircraft.name.

None
base str or PathLike

Directory that the data files named in the input (rings_file, sections_file, original) are read from; the working directory when absent.

None

Returns:

Type Description
dict

The resolved configuration: format, units (m and deg), aircraft, acceptance, reader, components with each leaf wrapped as {value, unit, source} (source given or default), derived quantities, dominance, variants, configurations (the effective member names) and registry (members with their versions, extends and variants), files (the SHA-256 of each data file), warnings and findings. A resolved input that checks out is returned as a copy of itself.

Raises:

Type Description
InputValueError

When the units are unknown, no component is given, a component lacks its type or an X.Y.Z version, a value or relationship is out of range, a dominance or extends cycle exists, a value has the wrong form, or a resolved input's derived quantity is inconsistent. Unknown keys do not raise: they are skipped and listed in warnings.

Examples:

>>> from pyflightstream.geometry import resolve_config
>>> resolved = resolve_config({"type": "body", "length_mm": 2000.0})
>>> resolved["components"]["COMPONENT"]["length"]["value"]
2.0

Advanced

pyflightstream.geometry.ComponentRecord

Bases: _Strict

The parameter record of one component (schema 0.2.0 of the contract).

symmetry is required for body and revolution components and absent for lifting components; te_base is explicit for lifting components and null for the others. Structural rules are enforced on construction. Checks that need the referenced files (that an entity exists, has the declared type and that splits lie on their curves) are not made here: the pin check covers the pins and the geometric checks belong to the check stage.

referenced_files

referenced_files() -> list[FileRef]

Every pinned file of the record, deduplicated by path and hash, in first-use order.

to_json

to_json() -> str

Serialize to strict JSON, the interchange form.

from_json classmethod

from_json(text: str) -> ComponentRecord

Parse and validate the interchange form, refusing with the validation message.

pyflightstream.geometry.load_config

load_config(path)

Read a TOML geometry configuration file and return it validated and resolved.

Parameters:

Name Type Description Default
path str or PathLike

The TOML file to read; the data files it names are read relative to its folder.

required

Returns:

Type Description
dict

The resolved configuration, as returned by :func:resolve_config.