pyflightstream.workspace.matrix (stable)¶
Generated from the docstrings at build time: every one of the 8 names in the __all__ of pyflightstream.workspace.matrix has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Binding a run matrix to the workspace input library.
Pipeline role: the workspace-layer half of the run matrix. The reader
and the converter stay in :mod:pyflightstream.cases.matrix, which
parses the verified 15-column file and maps it onto the canonical
campaign.toml model without needing anything above the cases layer.
What lives HERE is the step that needs the layer above: resolving the
matrix's reference columns against the input library under inputs/.
REF resolves to reference data (applied to each case's reference),
SET to a solver preset (its runtime subset applied to each case's
solver), PPROC to the post-processing artifact (bound onto the case),
FS_BUILD to an executable through the build registry, and the
GEOMETRY variable of the free VAR_NAMES_VALUES cell to a staged
geometry file (applied to each case's geometry). Plain conversion
never needs the library; resolution applies only when the matrix is
about to be planned or run.
Geometry is resolved alongside the reference, setup and post-processing inputs, so the run layer receives a complete bound case.
This module binds the parsed matrix (OPS-2007.01, PFS-2009.05). It imports
the cases layer downward, workspace siblings sideways and nothing from
:mod:pyflightstream.run. Execution belongs to :mod:pyflightstream.run.matrix.
It imports no module of the script layer itself. A preset's ENABLE/DISABLE gate is resolved
by :func:pyflightstream.script.toggles.resolve_toggle, in the same vocabulary
:class:pyflightstream.cases.SolverSettings validates its own toggles with, and that call
is made by the workspace's row-setup sibling; script is two rows below workspace in
:data:pyflightstream.overview._CORE_LAYERS, so the dependency is downward. This
paragraph is a rendering source for the architecture overview (AD-02), which is why an
enumeration that has drifted from the import block matters here more than it would in an
ordinary comment.
Used in the guides¶
pyflightstream.workspace.matrix.resolve_matrix
¶
resolve_matrix(
path: str | Path,
workspace: CampaignWorkspace,
*,
name: str,
fs_version: str | None,
recipes: Mapping[str, str],
fs_exe: str | Path | None = None,
ignore_missing_families: bool = True,
rows: list[MatrixRow] | None = None,
) -> ResolvedMatrix
Bind a run matrix to the workspace input library.
The matrix converts through the canonical campaign form
(:func:pyflightstream.cases.matrix.to_campaign) and its reference
columns resolve against the library under inputs/: REF to
reference data (applied to each case's reference), SET to a
solver preset (its runtime subset applied to each case's
solver), PPROC to the post-processing artifact (bound onto the case), and
FS_BUILD to an executable through the build registry. A missing
artifact fails with a didactic error naming the row, the missing id,
and the inputs/ file to create. The matrix remains the campaign
declaration; the resolved campaign is an in-memory API object.
THE GEOMETRY VARIABLE RESOLVES HERE TOO, and it is the fifth of
those bindings rather than a sixth kind of thing
(:data:GEOMETRY_VARIABLE, PFS-2025.02.01). A row writing
GEOMETRY: wing_v2 in its VAR_NAMES_VALUES cell resolves that
stem against inputs/geometries/ and the file lands on the case's
:attr:~pyflightstream.cases.SimCase.geometry, which is what the
campaign loop stages, hashes into the record, and rewrites to the
staged copy before a builder opens it. A row naming no geometry
leaves the field absent and resolves exactly as it did before this
release.
AN OBJ WITH NO SIDECAR GETS ONE HERE (G30): its boundaries are
written beside it from its groups, in the order of the file, by
:func:pyflightstream.workspace.inputs.ensure_inventory, and a line
on stderr says so. An existing sidecar is never rewritten.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Matrix location; only RUN = 1 rows resolve. |
required |
workspace
|
CampaignWorkspace
|
The managed campaign root carrying the input library. |
required |
name
|
str
|
Campaign name; the matrix has none, so it is explicit input. |
required |
fs_version
|
str
|
FlightStream version, canonical identifier (26.120); a vendor release name works only where it names exactly one registered build. The FS_BUILD column selects an executable, not a command-database version, so the version stays explicit input. It is also the build id a row whose FS_BUILD cell names nothing falls back to, which is the one sense in which it answers for an executable. It is a DEFAULT rather than the version every point runs under.
A build id is a key of the workspace registry and never a
declaration of which command database a build carries, so the
FS_BUILD cell alone still cannot change the version; what can is
the registry ENTRY that build id names, which may declare one
(:func: |
required |
recipes
|
mapping of str to str
|
FS_SCRIPT code to recipe reference, as in
:func: |
required |
rows
|
list of MatrixRow
|
Selected active rows, passed through conversion and artifact binding. When omitted, read every active row from path. |
None
|
fs_exe
|
str or Path
|
Explicit executable override; it always wins over the build registry and is the only way to run the MANUAL mode. |
None
|
ignore_missing_families
|
bool
|
Whether a pproc entry naming a family the opened mesh does not
carry is left out (the default, True) or REFUSES the point
(False, PFS-2035.13). It is a PER-INVOCATION choice and not a
property of the row or of the artifact, both of which are meant
to serve several geometries, so it travels as an argument and
lands on each case's variables as |
True
|
Returns:
| Type | Description |
|---|---|
ResolvedMatrix
|
The campaign with resolved artifacts applied, the artifacts
themselves keyed by their codes, the campaign's own executable,
the registry entry of every build a row names
(:attr: |
Raises:
| Type | Description |
|---|---|
MatrixError
|
Layout deviations, no active row, MANUAL mode without the explicit override, a POL that another matrix of the workspace root states (PFS-2031.04, naming both files and rows), an executable override with no default version and no row build left (PFS-2031.14), or a row naming no build with a campaign default that strips to empty. The last is raised before the build is selected, so no executable is looked up (PFS-2009.08.03). Distinct FS_BUILD values are allowed: each row runs on the installation it names (PFS-2009.05). |
InputArtifactError
|
A code the library cannot resolve, a |
CampaignConfigError
|
A row stating |
Warns:
| Type | Description |
|---|---|
PyflightstreamWarning
|
An OBJ whose sidecar's |
Examples:
>>> from pyflightstream.workspace import CampaignWorkspace
>>> from pyflightstream.workspace.matrix import resolve_matrix
>>> resolved = resolve_matrix(
... "matrix.fs",
... CampaignWorkspace("campaign"),
... name="wing_steady",
... fs_version="26.120",
... recipes={"003": "recipes.steady_polar:build"},
... )
>>> resolved.fs_exe
WindowsPath('C:/FlightStream/FlightStream.exe')
Advanced¶
pyflightstream.workspace.matrix.PRESET_ALIASES
module-attribute
¶
PRESET_ALIASES: Mapping[str, str] = MappingProxyType(
_PRESET_ALIASES
)
pyflightstream.workspace.matrix.PRESET_RECORDED_ONLY
module-attribute
¶
PRESET_RECORDED_ONLY: Mapping[str, str] = MappingProxyType(
_PRESET_RECORDED_ONLY
)
pyflightstream.workspace.matrix.PRESET_RESERVED_KEYS
module-attribute
¶
PRESET_RESERVED_KEYS: Mapping[str, InputKey] = (
MappingProxyType(
{
_PRESET_RECORDED_ONLY_KEY: InputKey(
"The keys of this preset to keep in the artifact and emit nowhere; each still warns, naming itself.",
"a list of key names",
),
_FLIGHT_CONDITION_TABLE: InputKey(
"Fluid pins every row naming this setup inherits; a row stating one wins over it.",
"a table of the pins below",
),
"stabilization": InputKey(
"Switches the stabilization whose strength stabilization_strength states; disabled, nothing is emitted.",
"true or false, or ENABLE or DISABLE; beside solver_stabilization, refused",
"SOLVER_STABILIZATION",
),
"stabilization_strength": InputKey(
"The strength of the stabilization the key above switches.",
"a number",
"SOLVER_STABILIZATION",
),
RAW_TABLE: InputKey(
"Solver command lines stated verbatim, every row naming this setup emitting each before the phase it names.",
"an array of tables; see `[[raw]]` below",
),
FLAGS_TABLE: InputKey(
"Solver commands this setup exposes to the matrix under a word, the row stating the value.",
"an array of tables; see `[[flags]]` below",
),
}
)
)
pyflightstream.workspace.matrix.PolChange
dataclass
¶
PolChange(row_number: int, old: str, new: str)
One row of a matrix that :func:renumber_repeated_pols moved to a new POL.
Attributes:
| Name | Type | Description |
|---|---|---|
row_number |
int
|
The data row, counted as :func: |
old |
str
|
The POL the row stated. |
new |
str
|
The POL it states now. |
pyflightstream.workspace.matrix.ResolvedMatrix
dataclass
¶
ResolvedMatrix(
campaign: Campaign,
conditions: dict[str, ResolvedCondition] = dict(),
references: dict[str, ReferenceArtifact] = dict(),
setups: dict[str, SetupArtifact] = dict(),
pprocs: dict[str, PprocArtifact] = dict(),
fs_exe: Path = Path(),
builds: dict[str, RegisteredBuild] = dict(),
row_builds: tuple[str | None, ...] = (),
additional_pprocs: dict[str, PprocArtifact] = dict(),
fsis: dict[str, ResolvedFsiSetup] = dict(),
geometry_failures: dict[str, dict[str, str]] = dict(),
)
A matrix bound to a workspace input library, ready to plan or run.
Attributes:
| Name | Type | Description |
|---|---|---|
campaign |
Campaign
|
The canonical campaign form, with the resolved reference data
applied to each case ( |
conditions |
dict of str to ResolvedCondition
|
The resolved flow state of every row that STATED a flight condition, keyed by POL (PFS-2027.02, .04). A row that states none has no entry, which is not the same as an empty one. It rides here rather than on the case because a case is not a record: the density, the temperature, the viscosity, the length the Reynolds number was measured against and WHICH branch produced the density are what the run record must carry so a reader can recompute the resolution rather than trust it. |
references |
dict of str to ReferenceArtifact
|
Resolved reference-data artifacts, keyed by REF code. |
setups |
dict of str to SetupArtifact
|
Resolved solver-setup presets, keyed by SET code; the raw
preset table is kept verbatim for consumers beyond the runtime
subset (see :func: |
pprocs |
dict of str to PprocArtifact
|
Resolved post-processing artifacts, keyed by PPROC code; group members are boundary labels or indices, verbatim, for the script layer and the post-processing aggregation. |
fs_exe |
Path
|
The executable the CAMPAIGN ITSELF binds to, which is the one answering for rows whose FS_BUILD cell names no build; existence is checked by the executor at construction, not here. Its meaning is unchanged by the multi-build support added at
PFS-2009.05, deliberately, because everything downstream reads
it as the campaign's own installation. Where several builds are
in play, Where no active row names a build, the campaign default answers for every row and this is its executable. Where EVERY active row names one, no row runs on the campaign's own installation at all, and this field takes the first active row's build rather than the default's, so it still names an installation this matrix really uses instead of one that would merely have to be registered. |
builds |
dict of str to RegisteredBuild
|
The registry entry of each build id an active row NAMES, keyed
by that id: its executable and the version it declares, or None
where it declares none. Empty under the explicit A build id appears here whether or not it is also the campaign
default: what puts it here is a row naming it, which is the same
condition that puts a non-None entry in |
row_builds |
tuple of (str or None)
|
Where each case's build came from, one entry per case of
It is the ONE fact only this function knows. Every entry is None under an explicit |
additional_pprocs |
dict of str to PprocArtifact
|
The additional pproc of every row stating |
geometry_failures |
dict of str to dict of str to str
|
The rows whose generated geometry could not be produced, keyed by POL, with
the |
pyflightstream.workspace.matrix.renumber_repeated_pols
¶
renumber_repeated_pols(
path: str | Path,
workspace: CampaignWorkspace,
*,
in_place: bool = False,
) -> list[PolChange]
Give every repeated row of ONE matrix the next free POL (PFS-2031.21).
A row keeps its POL unless another matrix of the workspace already states
it, or an earlier row of this matrix does. Each row that must move takes
the next free number, counted up from the highest POL claimed ANYWHERE in
the workspace: every row of every matrix, every sim_id in the manifest
and every sims/sim_<id> folder, so a new POL never lands on the
evidence of a study whose matrix has since been removed. Only this matrix
is rewritten, and only its POL cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
The matrix to renumber. |
required |
workspace
|
CampaignWorkspace
|
The workspace whose matrices, manifest and simulation folders claim POLs. |
required |
in_place
|
bool
|
Rewrite the file. Keyword-only and False by default, which computes the changes and writes nothing, as every rewriter in this package does. |
False
|
Returns:
| Type | Description |
|---|---|
list of PolChange
|
One entry per moved row, in row order; empty when nothing repeats, in which case the file is not touched. |
Raises:
| Type | Description |
|---|---|
MatrixError
|
A row that must move already has records of THIS matrix in the manifest. Moving it would orphan them from the row that produced them, so it is refused by name and nothing is written. |