pyflightstream.workspace.geometry_pipeline (provisional)¶
Generated from the docstrings at build time: every one of the 14 names in the __all__ of pyflightstream.workspace.geometry_pipeline has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The geometry pipeline of a parametric aircraft: generate, check, mesh and identify.
Pipeline role: the public entry points of the stages that need the geometry kernel, on the gmsh
kernel. :func:run_geometry runs the stages S0 to S13 for a configuration
(:func:pyflightstream.geometry.load_config), stops at the first failed check and returns a
report that names its stage and check, with the exposed skin as a named IGES file (one NAME per
component) from stage S11; :func:run_doe runs a loop of parameter sets and continues after a
failed one; :func:add_control_surfaces and :func:split_symmetry edit a written IGES;
:func:check_against_original measures a rebuilt surface against an original under a
named deviation profile; :func:mesh_generated meshes a configuration into an all-quad surface
mesh with its acceptance checks; :func:mesh_configuration meshes it by strategy 1 from its
per-component mesh controls (or plans it on a dry run) and writes the mesh, its record and a
saved simulation; and :func:identify_lifting_surface reads the planform and the
sections of a lifting surface back from an original IGES, in the form a configuration takes
(:class:LiftingIdentification). The pure parameter contract
(:class:~pyflightstream.geometry.ComponentRecord) and the TOML input boundary live in
:mod:pyflightstream.geometry and import no kernel.
A planform is reported with accepted set only when a coarse and a fine pass agree within
the tolerances of the result (convergence); sections carry their own accepted against
their residual tolerance.
Each function raises KernelUnavailableError (gmsh is a dependency of the package) when the
kernel library cannot load, and the message names the library that failed. The command line is
pyfs-geom run | doe | validate | schema | configurations | stages | identify | check |
add-control-surface | split-symmetry and pyfs-mesh mesh-generated | mesh.
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import __all__
>>> sorted(__all__)[:2]
['ConfigurationMesh', 'GeneratedMesh']
Used in the guides¶
pyflightstream.workspace.geometry_pipeline.run_geometry
¶
run_geometry(
config: Any,
*,
out: str | Path,
configuration: str | None = None,
variant: str = "clean",
overrides: Mapping[str, Any] | None = None,
until: str = "S13",
stages: Sequence[Stage] | None = None,
) -> dict[str, Any]
Run the stages S0 to until and return the report; it stops at the first failed check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
path or mapping
|
A configuration file or its raw mapping. |
required |
out
|
path
|
The folder the stage records ( |
required |
configuration
|
str
|
The entry of the configuration registry to build, and the variant of it. |
None
|
variant
|
str
|
The entry of the configuration registry to build, and the variant of it. |
None
|
overrides
|
mapping
|
|
None
|
until
|
str
|
The last stage to run, |
'S13'
|
stages
|
sequence of Stage
|
The stages to run, for a caller that replaces one; the stages of this tree by default. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The report: |
Examples:
>>> import tempfile
>>> from pyflightstream.workspace._geom_run import run_geometry
>>> with tempfile.TemporaryDirectory() as folder:
... report = run_geometry({"type": "lifting_surface"}, out=folder, until="S0")
>>> report["status"]
'accepted'
Advanced¶
pyflightstream.workspace.geometry_pipeline.ConfigurationMesh
dataclass
¶
ConfigurationMesh(
mesh: Mesh | None,
record: dict[str, Any],
written: dict[str, str],
)
A strategy 1 mesh of a configuration (None on a dry run), its record and written files.
pyflightstream.workspace.geometry_pipeline.GeneratedMesh
dataclass
¶
GeneratedMesh(mesh: Mesh, record: dict[str, Any])
The mesh of a generated configuration and the record of its checks.
pyflightstream.workspace.geometry_pipeline.LiftingIdentification
dataclass
¶
LiftingIdentification(
component: str,
source: str,
seed: str,
planform: dict[str, Any],
sections: list[dict[str, Any]],
midspan: dict[str, Any],
accepted: bool,
root_kind: str,
clean_cuts: int,
convergence: dict[str, Any] | None = None,
scan: dict[str, Any] = dict(),
)
The identified planform, sections and evidence of one lifting surface (metres, degrees).
planform is the result of :func:pyflightstream.geometry.stages.reference_planform;
sections are the root and tip CST fits and midspan the extra measured section.
accepted is true when the coarse and fine passes agree and every section met its
tolerance.
to_component
¶
to_component() -> dict[str, Any]
Return a lifting_surface component of a configuration that rebuilds this planform.
The configuration describes sections by NACA designation, so the seed designation
stands for the section shape and the measured CST fits stay in sections. A
configuration twists each section about its quarter chord, so the placement, the sweep
and the dihedral come from the quarter-chord line, which incidence and twist leave in
place, not from the measured leading edge, which they move. A left half is described by
its mirror image. A span axis tilted 89 degrees or more from the y axis (a fin) is
refused: place such a surface by rotation instead.
pyflightstream.workspace.geometry_pipeline.add_control_surfaces
¶
add_control_surfaces(
iges: str | Path,
component: str,
entries: Sequence[Mapping[str, Any]],
out: str | Path,
) -> dict[str, Any]
Add control surfaces to a named polynomial lifting skin in an IGES file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iges
|
str or Path
|
The IGES file to read. |
required |
component
|
str
|
The component that carries the control surfaces. |
required |
entries
|
sequence of Mapping
|
One table per control surface, with the keys of a |
required |
out
|
str or Path
|
The IGES file to write. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Written pieces and measured closure checks at 0.01 mm. |
Raises:
| Type | Description |
|---|---|
InputValueError
|
If entries are empty or not tables, the source is missing or its skin is unsupported. |
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import add_control_surfaces
>>> add_control_surfaces("a.igs", "WING", [], "b.igs")
Traceback (most recent call last):
...
pyflightstream._errors.InputValueError: control entries: at least one table is required
pyflightstream.workspace.geometry_pipeline.built_stages
¶
built_stages() -> set[str]
Return the ids of the stages this tree has a function for.
Returns:
| Type | Description |
|---|---|
set of str
|
The stage ids that run; the other stages of the table are reported as not measured. |
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import built_stages
>>> "S0" in built_stages()
True
pyflightstream.workspace.geometry_pipeline.check_against_original
¶
check_against_original(
rebuilt: Any,
original: Any,
limits: Mapping[str, Any],
*,
profile: str = "study_default",
) -> dict[str, Any]
Compare a rebuilt surface with an original: forward and restricted reverse distance.
rebuilt and original are OCC surface tags in the active model or IGES paths,
optionally path#component. Distances and local chord inputs are metres. Reverse
samples whose nearest original witness lies on an original face trim edge are excluded
explicitly. Empty reverse coverage is a rejection, never a vacuous acceptance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limits
|
mapping
|
The local chord (see :func: |
required |
rebuilt
|
Any
|
The two surfaces, as described above. |
required |
original
|
Any
|
The two surfaces, as described above. |
required |
profile
|
str
|
Named deviation profile; an unknown name is refused with the available names. |
'study_default'
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
InputValueError
|
For an unknown profile, limits that name no chord, or a surface that cannot be resolved. |
MissingExtraError
|
When the gmsh library cannot load ( |
pyflightstream.workspace.geometry_pipeline.describe_config
¶
describe_config(
config: Any, overrides: Mapping[str, Any] | None = None
) -> dict[str, Any]
Resolve a configuration (S0 only) and return every value with its unit and source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Mapping or str or Path
|
A configuration, or the path of a TOML file. |
required |
overrides
|
Mapping
|
Values to set before resolving, by dotted path. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import describe_config
>>> describe_config({"type": "lifting_surface"})["status"]
'valid'
pyflightstream.workspace.geometry_pipeline.identify_lifting_surface
¶
identify_lifting_surface(
source: str | Path,
component: str,
*,
hosts: Sequence[str] = (),
root: str = "auto",
mirrored: bool | None = None,
cut: str = "plain",
seed: str = "NACA0012",
span_axis: Sequence[float] | None = None,
stations: int = 161,
grid: int = 257,
section_tolerance_mm: float | None = None,
section_degree: int = 5,
section_max_degree: int = 20,
host_tolerance: float = 5e-05,
converge: bool = True,
) -> LiftingIdentification
Identify one lifting-surface component of an IGES file from its trimmed skin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str or Path
|
The IGES file, read only. Its faces are named by the NAME of their level. |
required |
component
|
str
|
The component to identify. |
required |
hosts
|
sequence of str
|
Components the surface sits on, as names in |
()
|
root
|
('auto', 'plane', 'host', 'boundary')
|
|
"auto"
|
mirrored
|
bool
|
Whether the surface has a mirror image across its root (doubles span and area); defaults to true for a plane root and false otherwise. |
None
|
cut
|
('plain', 'bridge_te', 'mirror')
|
|
"plain"
|
seed
|
str
|
The NACA designation the section fit starts from. |
'NACA0012'
|
span_axis
|
sequence of float
|
The first estimate of the span axis; the larger of y and z extent when omitted. |
None
|
stations
|
int
|
Stations of the fine pass and cut-grid points per side of each face. |
161
|
grid
|
int
|
Stations of the fine pass and cut-grid points per side of each face. |
161
|
section_tolerance_mm
|
float
|
Section residual tolerance; the larger of 0.5 mm and 0.1 percent of the chord when omitted. |
None
|
section_degree
|
int
|
The CST degree a section fit starts at and the highest it may rise to. |
5
|
section_max_degree
|
int
|
The CST degree a section fit starts at and the highest it may rise to. |
5
|
host_tolerance
|
float
|
The largest gap, in metres, at which the extended leading edge counts as meeting a host. |
5e-05
|
converge
|
bool
|
Run a coarse pass as well and require the planforms to agree for |
True
|
Returns:
| Type | Description |
|---|---|
LiftingIdentification
|
|
Raises:
| Type | Description |
|---|---|
MissingExtraError
|
The gmsh library cannot load ( |
InputValueError
|
An argument is refused, the component is unknown, or no clean band exists. |
pyflightstream.workspace.geometry_pipeline.list_configurations
¶
list_configurations(config: Any) -> dict[str, Any]
Return the configurations of a configuration file with their members and variants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Mapping or str or Path
|
A configuration, or the path of a TOML file. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The |
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import list_configurations
>>> list_configurations({"type": "lifting_surface"})["components"]
['COMPONENT']
pyflightstream.workspace.geometry_pipeline.mesh_configuration
¶
mesh_configuration(
config: Any,
controls: Any,
*,
dry_run: bool = False,
out: str | Path | None = None,
descriptor: str | None = None,
fsm_template: str | Path | None = None,
obj: str | Path | None = None,
) -> ConfigurationMesh
Mesh a generated configuration from its mesh controls (PFS-2214).
Strategy 1 is meshed here; mesh.strategy = 2 (full grid) goes to
:func:~pyflightstream.workspace._geometry_mesh_s2.mesh_full_grid with the same arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
mapping or path
|
A configuration (resolved or not) or the path of its TOML file. |
required |
controls
|
mapping or path
|
The mesh controls: |
required |
dry_run
|
bool
|
Validate and plan only: the record lists the realized counts and the warnings, no kernel is opened and nothing is written. |
False
|
out
|
str or Path
|
Folder for |
None
|
descriptor
|
str
|
File stem; |
None
|
fsm_template
|
str or Path
|
A fresh saved simulation of the target build (see :func: |
None
|
obj
|
str or Path
|
Write only the OBJ here. |
None
|
Returns:
| Type | Description |
|---|---|
ConfigurationMesh
|
The mesh (None on a dry run), the generation record (plan, counts, every acceptance
check with its measured value, |
Raises:
| Type | Description |
|---|---|
InputValueError
|
For a schema error (named E01 to E16) or a control this route cannot honour. |
MissingExtraError
|
When the gmsh library cannot load ( |
pyflightstream.workspace.geometry_pipeline.mesh_generated
¶
mesh_generated(
config: Any,
*,
component: str | None = None,
controls: Any = None,
obj: str | Path | None = None,
) -> GeneratedMesh
Mesh a generated parametric configuration into an all-quad surface mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
mapping or path
|
A configuration (resolved or not) or the path of its TOML file. |
required |
component
|
str
|
Name of one body or lifting surface to mesh alone in its own frame (a lifting surface carries its flat tip cap). When omitted, the whole assembly of a body, its attached wing and the wing-fuselage fairing is meshed, the fairing faces as one quad-dominant transition ring. |
None
|
controls
|
mapping or path
|
Mesh controls overriding the defaults, by table ( |
None
|
obj
|
str or Path
|
Write the mesh as OBJ, one group per component. |
None
|
Returns:
| Type | Description |
|---|---|
GeneratedMesh
|
The oriented mesh and its record: counts, the acceptance checks, the spacing rules
measured on the realized edge nodes, the orientation, and the |
Raises:
| Type | Description |
|---|---|
InputValueError
|
For an unknown component, an unsupported assembly or controls, a topology gate that fails, or a mesh that cannot be built all-quad. |
MissingExtraError
|
When the gmsh library cannot load ( |
pyflightstream.workspace.geometry_pipeline.run_doe
¶
run_doe(
config: Any,
parameter_sets: Sequence[Mapping[str, Any]],
*,
out: str | Path,
configuration: str | None = None,
variant: str = "clean",
until: str = "S13",
workers: int = 1,
) -> Iterator[dict[str, Any]]
Yield one report per parameter set, in order; a failed or refused set never stops the loop.
Each set runs in a worker process of its own (the kernel can fault natively) and writes
to out/set-0001, out/set-0002 and so on. A set whose worker dies is reported
failed at stage worker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Mapping or str or Path
|
A configuration, or the path of a TOML file. |
required |
parameter_sets
|
sequence of Mapping
|
One table of overrides per set, by dotted path. |
required |
out
|
str or Path
|
The folder that receives one sub-folder per set. |
required |
configuration
|
str
|
The configuration to build, for a file that holds several. |
None
|
variant
|
str
|
The variant to build; |
'clean'
|
until
|
str
|
The last stage to run; |
'S13'
|
workers
|
int
|
The number of sets run at once; 1 runs them in order. |
1
|
Yields:
| Type | Description |
|---|---|
dict
|
The report of each set, as :func: |
Raises:
| Type | Description |
|---|---|
InputValueError
|
If |
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import run_doe
>>> next(run_doe({}, [], out="doe", workers=0))
Traceback (most recent call last):
...
pyflightstream._errors.InputValueError: workers: at least 1 required
pyflightstream.workspace.geometry_pipeline.split_symmetry
¶
split_symmetry(
iges: str | Path,
out: str | Path,
*,
plane: str = "y",
component: str | None = None,
) -> dict[str, Any]
Cut a full model at its symmetry plane and write the half model (C8).
Every face that crosses the plane plane = 0 is cut on it by the kernel, the pieces on
the positive side are kept with their component names, and the cut edges are left open on
the plane as the symmetry boundary. Surfaces only; the source is read, never changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iges
|
str or Path
|
The full model to read. |
required |
out
|
str or Path
|
The half model to write; it must differ from |
required |
plane
|
str
|
The symmetry plane, |
'y'
|
component
|
str
|
The one component to cut, the others being written whole; None cuts every one. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
|
Raises:
| Type | Description |
|---|---|
InputValueError
|
If |
Examples:
>>> from pyflightstream.workspace.geometry_pipeline import split_symmetry
>>> split_symmetry("a.igs", "b.igs", plane="w")
Traceback (most recent call last):
...
pyflightstream._errors.InputValueError: plane: one of x, y, z required, got 'w'