Skip to content

pyflightstream.script (stable)

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

The validating FlightStream script builder.

Pipeline role: turns typed Python calls into the ASCII script text the solver executes, validating every emission against the per-version command database before a single line reaches FlightStream. Errors happen at build time with manual citations, because solver-side failures are silent or cryptic.

A :class:Script is an ordinary object bound to one FlightStream version; two scripts coexist safely, and there is no module-level state. Emission is checked in order: command exists in the version, command is not recorded broken there, argument binding and types, enum membership, count-versus-list consistency, phase ordering, and cross references. The raw() escape hatch bypasses validation and flags the script for the run manifest.

A command whose per-version record is broken is refused by default (FR-48), because a probe measured that it does not do what the manual says, so emitting it hands the run a wrong number rather than an error. AIR_ALTITUDE on 26.120 is the sharp case: the licensed sweeps observed the 5000 FOOT standard density where 5000 metres was asked for, so the METERS argument read as ignored and the altitude the script asked for would not be the altitude solved, with nothing in the run saying so because the script was fully validated. Refusing to emit it is the only place that fact can still reach the caller. :meth:Script.allow_broken is the recorded way through the refusal, and the QA probe layer is its first caller, because re-measuring a broken record is the run that can unrecord it.

Cross references (SAD Section 4.2): an :class:EntityRegistry counts the local coordinate systems, actuators, and motions the script creates, and rejects a command citing an index that does not exist yet, because FlightStream expects auxiliary definitions before they are referenced and fails silently otherwise. Creation commands accept an optional label, and every entity-citing argument then takes the index or the label, so recipes can speak in configuration terms while the library maintains the label-to-index dictionary. Entities carried by an opened project file, including the mesh boundary inventory (by count or by a name-to-index mapping), are declared with :meth:Script.declare_existing; boundary citations are only range checked once the inventory was declared, because the boundary total lives in the geometry file and cannot be known statically.

The two gaps of the first cut are closed: the per-surface lines of INITIALIZE_SOLVER when SURFACES is not -1 (surface_toggles) and the PERIODIC symmetry copy count (symmetry_copies) are regular database arguments now, emitted comfortably through the curated helper layer in :mod:pyflightstream.script.helpers (SAD Section 4.3).

The layout of the helpers (AD-17): :func:pyflightstream.script.helpers.solver_settings keeps its signature and its path and is the facade over per-family emitters in the private module script._settings, which also holds the helpers that set up a run (the flow conditions, the unsteady solver, the solver initialization and start) and the toggle readers they share; the relaxed trailing edge is the private module script._relaxed_te. Only the helpers import the two, and the helpers import every moved name, so each public path is kept.

In the workflow, emitted surface operations and frame motions also form a provenance ledger. Geometry facts and unknown trajectory details remain distinct; consumers may resolve timing only against exact measured executable/build evidence. A raw emission cannot silently acquire that proof. Command validation alone does not establish a native physical effect.

Length conventions are command-specific: frame coordinates use the native simulation unit, while the measured unsteady fluid-plot VERTEX boundary uses metres (reports/RPT-083, measured on 26.124). The workflow converts at that boundary and retains declared local sample coordinates for later interpretation. Existing action-based exports remain the route for per-step surface sequences.

Used in the guides

pyflightstream.script.CommandArgumentError

Bases: PyflightstreamError, ValueError

An emitted argument does not satisfy the database specification.

The message names the command, the argument, the expectation, and the citation of the entry (a manual page or a committed probe report), so the fix can be checked against its source directly.

pyflightstream.script.Script

Script(
    version: str | FsVersion,
    registry: CommandRegistry | None = None,
)

Bases: _ScriptRendering

One FlightStream script under construction, bound to one version.

Parameters:

Name Type Description Default
version str or FsVersion

Target FlightStream version, canonical identifier (26.120); a vendor release name works only where it names exactly one registered build. Every emission is validated against this version's command view.

required
registry CommandRegistry

Alternative database, used by tests; defaults to the packaged one.

None

Attributes:

Name Type Description
version FsVersion

The resolved target version.

raw_flag bool

True once raw() was used; recorded in the run manifest so unvalidated scripts stay identifiable (FR-07).

waived_commands tuple of BrokenCommandUse

Commands emitted under a :meth:allow_broken waiver, one entry per command, recorded in the run manifest for the same reason as raw_flag (FR-48). Empty for a script that emitted nothing broken, whether or not waivers were registered.

entities EntityRegistry

Label-aware ledger of the frames, actuators, motions, and mesh boundaries the script created or declared (SAD Section 4.2); backs the cross-reference checks and the label-to-index resolution of entity citations.

solver_setup SolverSetup or None

Snapshot of the effective solver flags and their provenance, attached by :func:pyflightstream.script.helpers.solver_settings and serialized into the run manifest; None until a settings call builds it.

registry CommandRegistry

The command database this script validates against, the one passed at construction or the packaged one. Read-only, and public for one reason: everything that records a per-version fact ABOUT this script has to read the same database the script used. The provenance snapshot did not, and asked the packaged database instead (PFS-2012.05), so a manifest could carry an availability, a default and an evidence sentence from a database no line of the script was checked against.

unsteady_actions property

unsteady_actions: tuple[UnsteadyActionUse, ...]

Actions registered on this script, in creation order.

Returns:

Type Description
tuple of UnsteadyActionUse

One record per registered action, carrying the evidence the command rests on for this build.

pending_action_scripts property

pending_action_scripts: dict[str, str]

Child action scripts waiting to be written, by their filename.

Returns:

Type Description
dict of str to str

A copy, keyed by the path the registration line names and valued by the text of the child script. The run layer writes these beside the script it renders; the script layer neither opens nor resolves a path.

pending_input_files property

pending_input_files: dict[str, str | bytes]

Data files the script names, waiting to be written, by their path.

Returns:

Type Description
dict of str to str or bytes

A copy, keyed by the path the emitted command names and valued by the file's content: text, written in the platform's text mode (the trailing-edge node file), or bytes, written exactly as they are (the actuator disc's radial thrust profile, whose last row must end the file, G06). The run layer writes these before the solver starts, as it writes :attr:pending_action_scripts; the script layer neither opens nor resolves a path.

registry property

registry: CommandRegistry

Command database this script validates and is recorded against.

Returns:

Type Description
CommandRegistry

The registry passed at construction, or the packaged one.

Notes

Exposed so that a record ABOUT this script reads the database the script itself used. Reaching for :meth:~pyflightstream.commands.CommandRegistry.load while a Script is in hand is the defect this property exists to remove: the two answers agree for the packaged database and differ for every other one, and the case where they differ is exactly the case a provenance record is for.

num_local_frames property

num_local_frames: int

Local coordinate systems the script created or declared.

num_actuators property

num_actuators: int

Actuators the script created or declared.

num_motions property

num_motions: int

Motions the script created or declared.

num_boundaries property

num_boundaries: int | None

Declared mesh boundary total, or None while undeclared.

None means the boundary inventory of the loaded geometry was never declared, so boundary citations pass unverified: the boundary count lives in the geometry file and cannot be known statically by the builder.

waived_commands property

waived_commands: tuple[BrokenCommandUse, ...]

Commands emitted under a waiver, in the order first emitted.

One entry per command however many times it was emitted, because the fields that describe the BREAKAGE are properties of the command, the version and the waiver, so repeating the emission would repeat them without adding a fact. The exception is first_line, which is a property of one emission and keeps the FIRST: a script-lifetime waiver covers every later emission, and the reason was written for a particular one. :class:BrokenCommandUse is the single home of the field list.

Named for what the entries ARE (PFS-2022.01.05): each is a waiver the recipe registered, and the former name broken_commands read as the commands that broke in the run, which is the opposite claim.

frame_motions property

frame_motions: dict[int, dict[str, object]]

Final emitted frame geometry/motion evidence, indexed by frame.

Read after setup emission: probe creation may precede motion attachments. Unknown trajectories retain their reason and partial geometric evidence.

frame_placements property

frame_placements: Mapping[int, FramePlacement]

Where this script placed each coordinate system, by frame index (FR-100).

READ ONLY. A translation moves a frame to an absolute origin computed from this, so a caller writing into it would place a frame from a value no command emitted; it is filled by :meth:emit and nowhere else.

loads_frame property

loads_frame: int

The analysis loads frame, as far as THIS SCRIPT set it (G45).

The frame of the last SET_SOLVER_ANALYSIS_LOADS_FRAME emitted, or 1, the reference frame, while none has been. The solver writes the VTK surface export in this frame (RPT-074), so the Tecplot the package writes from it is undone by it.

Examples:

>>> from pyflightstream.script import Script
>>> script = Script("26.124")
>>> script.loads_frame
1

sets_loads_frame property

sets_loads_frame: bool

Whether THIS SCRIPT emitted SET_SOLVER_ANALYSIS_LOADS_FRAME (G45).

While it has not, :attr:loads_frame is the solver's default, the reference frame, for a simulation the script builds. A simulation it reopens keeps the loads frame it was saved with, which the script layer cannot read, so a continuation takes that frame from the run it continues.

Examples:

>>> from pyflightstream.script import Script
>>> Script("26.124").sets_loads_frame
False

periodic_copies property

periodic_copies: int | None

The copy count of the last INITIALIZE_SOLVER under PERIODIC symmetry.

None until the script initializes, and for any other symmetry. The solver writes a periodic row's native Tecplot surface as one zone per copy, the modelled sector first (measured on 26.124, reports/RPT-087), so the run reads that file by this count.

Examples:

>>> from pyflightstream.script import Script
>>> Script("26.124").periodic_copies is None
True

simulation_length_unit property

simulation_length_unit: str | None

The known simulation length unit (G05, G06, G32, G34).

Prefer the last SET_SIMULATION_LENGTH_UNITS emitted. When none was emitted, use the saved unit explicitly recorded by the workflow after reading the opened file's measured header. Return None when neither source establishes a unit. Reading a saved unit records provenance without emitting a command that changes the simulation.

Examples:

>>> from pyflightstream.script import Script
>>> script = Script("26.124")
>>> script.emit("SET_SIMULATION_LENGTH_UNITS", "MILLIMETER")
>>> script.simulation_length_unit
'MILLIMETER'

volume_sections property

volume_sections: int

How many volume sections this script has cut and not deleted (G05).

A create appends one, DELETE_VOLUME_SECTION removes one and DELETE_ALL_VOLUME_SECTIONS removes them all, whoever emitted the line, the builder or a raw line of the row. A create is taken to append at the end of the solver's list and a delete to close the gap, as the actuators and motions of this ledger are; neither is measured for sections. A section a saved simulation already carries is not counted: the script layer reads no file.

Examples:

>>> from pyflightstream.script import Script
>>> script = Script("26.124")
>>> circle = (1, "YZ", 0.5, 10, 12, 0.2, 1.0, "NONE", 0.1, 1, 1.2)
>>> script.emit("CREATE_NEW_CIRCLE_VOLUME_SECTION", *circle)
>>> script.emit("CREATE_NEW_CIRCLE_VOLUME_SECTION", *circle)
>>> script.emit("DELETE_VOLUME_SECTION", 1)
>>> script.volume_sections
1

park_input_file

park_input_file(path: str, payload: str | bytes) -> None

Park an input beside the script, using the shared case-insensitive path rule.

An identical input may be parked again. The run layer writes the parked payload before starting the solver.

Parameters:

Name Type Description Default
path str

Relative file destination inside the point folder, without a drive, root or parent traversal.

required
payload str or bytes

Text or exact bytes to stage at that destination.

required

Raises:

Type Description
CommandArgumentError

If the path escapes the point folder or collides case-insensitively with different input content or an action script. Nothing is replaced.

Examples:

>>> script = Script("26.124")
>>> script.park_input_file("inputs/profile.txt", "profile data")
>>> script.pending_input_files["inputs/profile.txt"]
'profile data'

emit_deferred_vorticity_before_solve

emit_deferred_vorticity_before_solve() -> None

Emit a pending unsteady selection before solving, preserving the phase guard.

The licensed pre-solve selection applies to each unsteady step. This exception admits only the deferred selection, never a later solver restart.

Raises:

Type Description
ScriptOrderError

If a solver execution or export phase has already been reached.

carry_unsteady_actions

carry_unsteady_actions(
    uses: Sequence[UnsteadyActionUse],
    scripts: Mapping[str, str],
) -> None

Carry saved-state actions and their files without emitting registrations.

Parameters:

Name Type Description Default
uses sequence of UnsteadyActionUse

Action records already registered in the saved solver state.

required
scripts mapping of str to str

Child script paths and text to stage for those actions.

required

Raises:

Type Description
CommandArgumentError

If an action name or parked-file destination conflicts. No partial update is retained on refusal.

observe_commands

observe_commands(
    observer: Callable[
        [
            str,
            tuple[object, ...],
            dict[str, object],
            str,
            bool,
        ],
        None,
    ],
) -> Iterator[None]

Observe accepted commands for this scope, without replacing validation.

The callback receives name, positional arguments, keyword arguments (including a stated label), rendered text, and whether emit_line was the source. Refused commands and raw text are never observed.

declare_existing

declare_existing(
    *,
    frames: int = 0,
    actuators: int = 0,
    motions: int = 0,
    boundaries: int | Mapping[str, int] = 0,
    volume_sections: int = 0,
) -> None

Declare auxiliary objects already present in the opened project.

A simulation file loaded with OPEN can carry local coordinate systems, actuators, and motions saved earlier, and the loaded geometry brings its mesh boundaries; the builder cannot see inside those files, so scripts citing such objects declare them here to satisfy the cross-reference check.

Parameters:

Name Type Description Default
frames int

Local coordinate systems in the project, beyond the reference frame (index 1), which always exists.

0
actuators int

Actuators in the project.

0
motions int

Motions in the project.

0
volume_sections int

Volume sections already present in the project, numbered from one.

0
boundaries int or mapping of str to int

Mesh boundary count (zero keeps the inventory undeclared), or a mapping of labels to 1-based indices in geometry-tree order, for example {"fuselage": 1, "wing": 2}. Declaring an inventory enables range verification; without it the total is unknown. Citations still follow each command's lower-bound rules without a count. Labels stand in for indices wherever a boundary is cited. A mapping raises the inventory to its highest mapped index if larger than the existing count; it is not a labels-only declaration. Integer declarations add to the existing count. For example, boundaries={"wing": 2} followed by boundaries=1 declares three.

0

resolve_boundary

resolve_boundary(
    value: int | str, *, context: str = "boundary citation"
) -> int

Resolve a mesh boundary citation to its 1-based index.

A label declared through :meth:declare_existing resolves to its index; an integer passes through after the range check. The two bounds are independent: the upper one needs a declared inventory and is skipped without it, the lower one does not, since indices are 1-based.

This method resolves a citation with no command attached, so it applies the generic all-boundaries form, -1, rather than any command's own. That is stated here and passed explicitly, because the emitter has no per-kind default: a command's all-form comes from its own argument, and six surface commands state none at all (FSM-26.120 pp.309-313). Passing -1 to :meth:emit for one of those is still refused, and correctly; it is this generic entry point that accepts it.

Parameters:

Name Type Description Default
value int or str

Boundary index (1-based, geometry-tree order; -1 selects all boundaries) or a declared boundary label.

required
context str

Prefix naming the citing location in error messages.

'boundary citation'

Returns:

Type Description
int

The resolved boundary index.

Raises:

Type Description
ScriptReferenceError

If the label is unknown (the message lists the declared labels) or the index falls outside the declared inventory.

emit

emit(
    name: str,
    /,
    *args: object,
    label: str | None = None,
    **kwargs: object,
) -> None

Validate and append one command.

Parameters:

Name Type Description Default
name str

Command name as in the database; positional-only, so a command argument may itself be called name (for example CREATE_NEW_ACTUATOR).

required
*args object

Argument values, positional in database order or by argument name. Optional arguments may be omitted. Arguments citing a frame, actuator, motion, or mesh boundary accept the entity's label instead of its index; labels resolve at emission through the entity registry.

()
**kwargs object

Argument values, positional in database order or by argument name. Optional arguments may be omitted. Arguments citing a frame, actuator, motion, or mesh boundary accept the entity's label instead of its index; labels resolve at emission through the entity registry.

()
label str

Only on a creation command (CREATE_NEW_COORDINATE_SYSTEM and the two that append a frame, DUPLICATE_COORDINATE_SYSTEM and MIRROR_COORDINATE_SYSTEM; CREATE_NEW_ACTUATOR; CREATE_NEW_MOTION and the four type-specific motion creations of 25.000): registers this label for the created entity, so later commands can cite it by name instead of by index.

None

Raises:

Type Description
CommandNotInVersionError

If the command does not exist in this version; the message carries the manual citation and successor when known.

BrokenCommandError

If the command's record in this version is broken and no :meth:allow_broken waiver covers it.

CommandArgumentError

If an argument violates the typed specification, or if label is given on a command that creates nothing.

ScriptOrderError

If the command's phase precedes the phase already reached.

ScriptReferenceError

If the command cites an entity index the script has not created or declared yet, or an unknown entity label.

ScriptLabelError

If label is already taken for this entity kind.

bind_native_solver_identity

bind_native_solver_identity(
    *, executable_sha256: str, build: str
) -> None

Bind an identity verified by the caller for exact motion-proof lookup.

This method records evidence supplied by the executor; it does not inspect an executable or establish that a nominal version denotes a particular build. Saved runs can instead resolve timing using their actual recorded identity.

loads_frame_record

loads_frame_record() -> dict[str, object]

Return the loads frame and where this script placed it, as a run records it.

frame is :attr:loads_frame; origin and axes are its placement in the reference frame (:attr:frame_placements), or None where this script did not place it: a frame a reopened simulation carries, or one a command moved in a way the ledger does not follow.

record_opened_length_unit

record_opened_length_unit(unit: str) -> None

Record a decoded saved-geometry unit; an explicit command wins.

This records measured metadata for coordinate conversion without emitting a command that changes the geometry.

entry

entry(name: str) -> CommandEntry

Return the database entry of name on this script's build.

The public reading of the per-version view a builder needs before it emits (the phase of a command, its layout): a caller outside this package read the private view in legacy releases, and the architecture lens of REL-0140 asked for the door. Raises :class:~pyflightstream.commands.CommandNotInVersionError as :meth:emit would.

emit_line

emit_line(line: str) -> None

Bind compact command input through the curated renderer (PFS-2033.01).

The line is split on whitespace; the first token is the command and the rest its arguments, each coerced to the type the database declares for its position (an int, a float, ENABLE/DISABLE or True/False for a bool, or the token itself for an enum, a string or a path), then handed to :meth:emit, so every check of a curated emission applies. A list argument takes the run of following tokens its element type reads, as the inline renderer writes it, so a sweep line such as SWEEPER_SET_AOA_SWEEP CUSTOM 0.0 2.0 4.0 round-trips. Declared following-line arguments are rendered on their own lines, preserving the compact input accepted before layouts distinguished mixed commands. Other blocks and payloads are refused.

Raises:

Type Description
CommandArgumentError

If the layout cannot bind compact input, a token is not the type its position declares, or tokens are left that no argument reads (a value containing a space, which splits into several).

raw

raw(text: str) -> None

Append unvalidated script text and flag the script (FR-07).

Unvalidated text may move any frame, so every placement but the reference's is forgotten, as the motion ledger forgets its motions: a reader of :attr:frame_placements then refuses the frame by name rather than computing from geometry the text may have changed (PFS-2104.021).

allow_broken

allow_broken(name: str, /, *, reason: str) -> None

Permit one command recorded broken to be emitted (FR-48).

Registers a waiver for name; a later :meth:emit of it then appends the command instead of raising :class:BrokenCommandError, and records what was waived in :attr:waived_commands, which the run manifest carries.

Two callers legitimately need this. A tier 2 probe re-measuring the record cannot avoid emitting the command, since emitting it is the measurement; and an operator may have established that the recorded defect does not reach their case, which is a judgement no database can make for them. reason is required because it is the only part of the record nothing else can supply.

Parameters:

Name Type Description Default
name str

Command name as in the database; positional-only for the same reason as in :meth:emit.

required
reason str

Why this run may emit it anyway. Recorded verbatim in the manifest; a blank string is refused.

required

Raises:

Type Description
CommandNotInVersionError

If the command is unknown, removed in this version, or has no recorded evidence for it. Checked here rather than left to the emission so a typo in the name fails at the waiver, where it was made.

CommandArgumentError

If reason is blank.

Notes

A waiver for a command that is not broken in this version is accepted and does nothing. That is deliberate: the same recipe is meant to run against several versions, and AIR_ALTITUDE is recorded broken in 26.120 and verified in 26.121, so refusing the unnecessary waiver would make a recipe fail on the version where the command is recorded working. Nothing is recorded in that case, so the manifest never reports a dependency the run did not have.

comment

comment(text: str) -> None

Append a comment; FlightStream ignores lines starting with #.

A multi-line text becomes one comment line per physical line, each independently prefixed. That is a fix rather than a convenience: prefixing only the first line left every line after it as an ordinary script line, so a comment carrying a newline emitted an unvalidated command with raw_flag still False, which is the comment half of the same defect the argument checks above refuse. Commenting each line keeps the caller's intent (it is all commentary) and cannot inject.

A blank line inside text becomes a bare # rather than an empty line, so the block stays visibly one comment.

render

render() -> str

Return the complete script text, newline terminated.

begin_point

begin_point() -> None

Open a new POINT inside one script, rewinding the phase to init.

FR-95. A warm steady sweep is one script holding several points, and each point runs the same cycle: set its condition, initialise if it must, start the solver, analyse, export. The phase guard is monotonic across a script, so the second point's SOLVER_SET_AOA, an init command, was refused as arriving after the export phase the first point had already reached.

THE REWIND STOPS AT INIT AND THAT IS THE POINT. Geometry and setup stay behind it, so a sweep still cannot open a second geometry or redefine a coordinate system halfway through, which is the half of the phase rule that catches real mistakes. What it allows is the cycle a sweep is made of, and nothing wider.

A single-point script never calls this, so its guard is unchanged.

emit_after_initialization

emit_after_initialization(
    name: str, /, *args: object, **kwargs: object
) -> None

Emit one setup command on an initialised solver, to be initialised again (G02).

:meth:emit refuses a setup command once INITIALIZE_SOLVER is in the script, and that is right for nearly all of them: a frame, a motion or a fluid is read when the solver initialises, so after it they come too late. A few act on what only the initialisation creates. On FlightStream 26.124 the wake-termination detection emitted right after a file import of the trailing edges marks nothing; emitted after an initialisation it marks the node, and the solver uses what it marked only once it initialises again, which clears the first initialisation (RPT-069, T07). The log reports the trailing-edge groups only during an initialisation, which is the inferred reason.

THIS IS THE ONE DOOR PAST THE PHASE GUARD, AND IT IS NARROW. The command must be a setup command; an INITIALIZE_SOLVER must precede it and the solver must not have started. The phase does not move, so a frame or a motion after it is still refused. Until INITIALIZE_SOLVER is emitted again, a command of the exec phase or a later one, START_SOLVER first, is refused naming the command that waits. Every other check of :meth:emit applies.

Parameters:

Name Type Description Default
name str

A setup command of this build's database.

required
*args object

Its arguments, as :meth:emit takes them.

()
**kwargs object

Its arguments, as :meth:emit takes them.

()

Raises:

Type Description
ScriptOrderError

If name is not a setup command, if no INITIALIZE_SOLVER precedes it, or if the solver was already started.

(CommandNotInVersionError, CommandArgumentError, ScriptReferenceError)

As :meth:emit raises them.

Examples:

>>> from pyflightstream.script import Script
>>> script = Script(version="26.124")
>>> initialization = dict(
...     solver_model="INCOMPRESSIBLE", surfaces=-1,
...     wake_termination_x="DEFAULT", symmetry="NONE",
... )
>>> script.emit("INITIALIZE_SOLVER", **initialization)
>>> script.emit_after_initialization("AUTO_DETECT_WAKE_TERMINATION_NODES")
>>> script.emit("INITIALIZE_SOLVER", **initialization)
>>> script.emit("START_SOLVER")
>>> script.render().count("INITIALIZE_SOLVER")
2

for_marking classmethod

for_marking(
    version: str | FsVersion,
    registry: CommandRegistry | None = None,
) -> Script

Construct the no-initialization policy used by the boundary-marking planner.

Late node selections, termination marks, combines and renames are permitted through setup only. All argument and reference checks remain active. Ordinary scripts retain their phase guard; marking scripts refuse init and execution.

Evidence: reports/compat/CMP-26124_2026-10-26_marking.yaml and CMP-26125_2026-10-26_marking.yaml measure saved marks and base/merge order without INITIALIZE_SOLVER. Command evidence admission remains the planner's separate per-build VERIFIED gate.

Advanced

pyflightstream.script.BrokenCommandError

Bases: PyflightstreamError, RuntimeError

A command recorded broken in the target version was emitted.

broken is the one status backed by a probe that measured the command failing to do what the manual documents (CONTRIBUTING.md invariant 3), so the database already knows the emission is wrong before the solver ever sees it. Unlike a removed command, this one exists and the solver accepts the line: the run therefore produces numbers, and they are the wrong numbers, with nothing in the manifest to distinguish them from right ones. That is why the refusal happens here rather than being left to a warning.

A RuntimeError rather than a ValueError because no argument is at fault: the call is well formed and the recorded state of the world is what refuses it, the same shape as :class:~pyflightstream.workspace.WorkspaceError.

The refusal has an answer, deliberately, because two callers legitimately need the command: a probe re-measuring the record, and an operator who has established that the defect does not reach their case. :meth:Script.allow_broken is that answer, and it records what it waived (see :class:BrokenCommandUse).

pyflightstream.script.BrokenCommandUse

Bases: BaseModel

One command emitted although its evidence record is broken.

The script records each waived command in the run manifest (FR-07), so its dependence on a known-broken command remains explicit.

Attributes:

Name Type Description
command str

Command name as emitted.

version str

Canonical identifier of the build the script targets.

source_version str

Canonical identifier of the build measured by report. A hotfix can inherit this evidence from its base release. Required and nonblank: min_length and pattern reject empty or whitespace-only values without stripping a stored identifier. The manifest reader refuses rows lacking this field and names their manifest and schema stamp.

report str

Repository-relative committed probe report recording the breakage. Broken status requires this evidence (CONTRIBUTING.md invariant 3).

note (str, optional)

Database paraphrase of the probe observation, when recorded.

reason str

Caller justification supplied to Script.allow_broken.

first_line str

First waived script line. This identifies the particular call behind the reason; the script-lifetime waiver covers subsequent emissions.

pyflightstream.script.EntityRegistry

EntityRegistry()

Ledger of created and declared entities with optional labels.

Tracks, per entity kind (frames, actuators, motions, boundaries), the number of entities the script has created or declared and a label-to-index mapping for the entities the user named. Indices are 1-based, in FlightStream order: frame index 1 is the always-present reference frame (FSM-26.120 p.329) and created local frames take indices 2 upward; actuators and motions start at 1; mesh boundaries are numbered from 1 in geometry-tree order.

The mesh boundary total starts unknown (None) because it is a property of the loaded geometry file, not of the script; range checks on boundary citations only run once the inventory was declared.

count

count(kind: str) -> int | None

Return the created or declared entity count of kind.

Parameters:

Name Type Description Default
kind str

One of frames, actuators, motions, boundaries.

required

Returns:

Type Description
int or None

The count. For frames this excludes the always-present reference frame (index 1). For boundaries it is None while the inventory has not been declared, because the boundary total lives in the geometry file and cannot be known statically.

limit

limit(kind: str) -> int | None

Return the highest currently valid index of kind.

Returns:

Type Description
int or None

Highest surviving boundary ID, or None for an undeclared inventory. Other kinds use the count, plus one for the reference frame.

labels

labels(kind: str) -> dict[str, int]

Return a copy of the label-to-index mapping of kind.

boundary_indices

boundary_indices() -> tuple[int, ...] | None

Return surviving boundary IDs, including unlabelled ones, or None if unknown.

copy_boundaries_from

copy_boundaries_from(other: EntityRegistry) -> None

Declare a saved simulation's boundary state without renumbering its survivors.

assert_label_free

assert_label_free(kind: str, label: str) -> None

Reject a label that is invalid or already taken for kind.

Parameters:

Name Type Description Default
kind str

Entity kind the label would be registered under.

required
label str

Candidate label.

required

Raises:

Type Description
ScriptLabelError

If the label is not a non-empty string, or already names another entity of the same kind.

create

create(kind: str, label: str | None = None) -> int

Record one created entity, optionally under a label.

Parameters:

Name Type Description Default
kind str

One of frames, actuators, motions; mesh boundaries come from the loaded geometry and are declared, never created by a script command.

required
label str

Label registered for the new entity.

None

Returns:

Type Description
int

1-based index of the created entity (frames start at 2 because the reference frame occupies index 1).

Raises:

Type Description
ScriptLabelError

If the label is invalid or already taken for this kind.

delete

delete(kind: str, index: int) -> None

Record the deletion of entity index and renumber the labels.

Removing an entity updates the indices of the surviving entities. The ledger follows the solver's numbering rather than retaining stale positions.

Parameters:

Name Type Description Default
kind str

One of frames, actuators, motions.

required
index int

The 1-based index the delete command cited, already checked against the range.

required

clear

clear(kind: str) -> None

Forget all entities of a script-created kind after its delete-all command.

declare

declare(kind: str, extra: int) -> None

Add extra project-carried entities of a created kind.

Parameters:

Name Type Description Default
kind str

One of frames, actuators, motions.

required
extra int

Number of entities the opened project file already holds; must be zero or positive.

required

Raises:

Type Description
ScriptDeclarationTypeError

If extra is not an integer (a bool is not one): a float would make the range limit fractional and a string fail the comparison with Python's own TypeError.

ScriptReferenceError

If extra is negative.

declare_boundaries

declare_boundaries(
    declaration: int | Mapping[str, int],
) -> None

Declare the mesh boundary inventory of the loaded geometry.

Declaring the inventory turns on range verification for every boundary-citing argument; until then boundary citations pass unverified, because the boundary total lives in the geometry file and cannot be known statically.

Parameters:

Name Type Description Default
declaration int or mapping of str to int

Either the total boundary count (added to any previous declaration; zero is a no-op that keeps the inventory unknown), or a mapping of configuration labels to 1-based boundary indices in geometry-tree order, for example {"fuselage": 1, "wing": 2}. A mapping raises the known total to its highest index.

required

Raises:

Type Description
ScriptLabelError

If a mapping entry has an invalid label or index, or a label collides with one already declared.

renumber_boundaries

renumber_boundaries(
    labels: Mapping[str, int], total: int
) -> None

Replace the inventory with an explicitly supplied contiguous numbering.

This explicit replacement is not DELETE_SURFACES semantics: the PFS-2119.016 licensed ID fixture shows that deletion keeps survivor IDs.

Parameters:

Name Type Description Default
labels mapping of str to int

The surviving labels with their new 1-based indices.

required
total int

The boundary count after the removal, duplicates included.

required

Raises:

Type Description
ScriptReferenceError

If the inventory was never declared, the total or indices are not integers (booleans excluded), or a label maps outside the total.

resolve

resolve(
    kind: str,
    value: object,
    *,
    context: str,
    citation: str | None = None,
) -> object

Resolve a label citation to its index; pass other values through.

Parameters:

Name Type Description Default
kind str

Entity kind the citation refers to.

required
value object

The cited value; a string is treated as a label, anything else is returned unchanged (type checks happen elsewhere).

required
context str

Prefix naming the citing location in the error message, for example "SET_ACTUATOR_AXIS: argument 'frame'".

required
citation str

Manual citation appended to the error message.

None

Returns:

Type Description
object

The resolved 1-based index for a known label, or value unchanged when it is not a string.

Raises:

Type Description
ScriptReferenceError

If the label is unknown; the message lists the labels the registry knows for this kind.

check_index

check_index(
    kind: str,
    value: object,
    *,
    context: str,
    citation: str | None = None,
    all_sentinel: int | None = None,
) -> None

Reject an index outside the created or declared range.

The two bounds are checked independently, which matters when the boundary inventory was never declared. The UPPER bound needs it and is skipped without it, since the total is unknowable statically. The LOWER bound does not: indices are 1-based, so a value at or below zero is refused whether or not an inventory exists, unless it is the argument's own all-entities sentinel.

The check is skipped entirely for non-integer values, whose type errors are reported elsewhere.

Parameters:

Name Type Description Default
kind str

Entity kind the index refers to.

required
value object

The cited index, 1-based.

required
context str

Prefix naming the citing location in the error message.

required
citation str

Manual citation appended to the error message.

None
all_sentinel int

The value this argument uses to select every entity, when its command's page states one. THERE IS NO DEFAULT: None means the command states no all-form and every index at or below zero is refused. Supplied from the argument's own database entry, because this is a per-command fact and the pages disagree three ways: the two TRANSLATE_SURFACE commands state zero (FSM-26.120 p.309), seven more state -1 (pp.307, 310-312), and six state none at all. Any per-kind default refuses a documented form somewhere, whichever value it picks.

None

Raises:

Type Description
ScriptReferenceError

If the index falls outside the valid range 1..limit and is not this argument's all-entities sentinel.

check_boundary_count

check_boundary_count(
    value: object,
    *,
    context: str,
    citation: str | None = None,
) -> None

Reject a boundary count above the declared inventory.

Count arguments such as NUM_BOUNDARIES say how many boundaries the following list selects; a count above the inventory means the command will cite boundaries that do not exist. Skipped for non-integer values, for an undeclared inventory, and for the -1 all-boundaries form.

Parameters:

Name Type Description Default
value object

The count value; -1 selects every boundary.

required
context str

Prefix naming the citing location in the error message.

required
citation str

Manual citation appended to the error message.

None

Raises:

Type Description
ScriptReferenceError

If the count exceeds the declared boundary total or is negative without being -1.

pyflightstream.script.FramePlacement

Bases: BaseModel

Placement retained from explicit coordinate-system commands (FR-100).

Origin values retain the numeric convention of emitted frame commands. Axes are the named X, Y and Z directions in REFERENCE. Explicit-unit origins are converted through the recorded simulation unit; while no unit is recorded (no SET_SIMULATION_LENGTH_UNITS and no decoded saved head) an origin stated in METER is kept as written and one stated in any other unit is forgotten rather than converted, because nothing in the command says what the native unit is (GEO-060 A1a). Physical interpretation requires a measured native unit contract; this ledger does not establish it. Unfollowed placement commands clear affected values.

pyflightstream.script.MARCH_ACTIONS module-attribute

MARCH_ACTIONS: MarchStrategy = 'actions'

pyflightstream.script.MARCH_SINGLE module-attribute

MARCH_SINGLE: MarchStrategy = 'single_march'

pyflightstream.script.MarchStrategy module-attribute

MarchStrategy = Literal['actions', 'single_march']

pyflightstream.script.ScriptLabelError

Bases: PyflightstreamError, ValueError

A label registration collides with a label already recorded.

Labels identify exactly one entity per kind, because they resolve to a single FlightStream index at emission; reusing a label would silently redirect every earlier citation. Pick a distinct label or cite the existing entity by its index.

pyflightstream.script.ScriptLineBreakError

Bases: CommandArgumentError

A value would have become more than one line of the script.

FlightStream reads a script one command per physical line, and this library's contract is that every line it writes came from a validated command. A line terminator inside an argument breaks both at once: the text after it is not an argument any more, it is the next COMMAND, and the manifest still presents the script as fully validated because raw_flag was never set.

The escape hatch for genuinely unvalidated text is :meth:Script.raw, which exists precisely so that this refusal has an answer: it appends the text and sets raw_flag, so the script carries the fact that something in it was not checked (FR-07).

Subclasses :class:CommandArgumentError so existing handlers keep working; caught on its own it identifies this one cause.

pyflightstream.script.ScriptOrderError

Bases: PyflightstreamError, ValueError

A command was emitted after its phase had already passed.

The script builder tracks the highest phase reached (geometry, setup, init, exec, analysis, export); FlightStream expects auxiliary definitions such as coordinate systems, actuators, and motions before solver initialization. Control commands are exempt, and a setup command that acts on an initialised solver passes through :meth:Script.emit_after_initialization alone.

pyflightstream.script.ScriptReferenceError

Bases: PyflightstreamError, ValueError

A command cites an entity that does not exist at that point.

FlightStream resolves frame, actuator, motion, and mesh boundary indices at execution time and fails silently or cryptically when they do not exist; the builder counts the objects the script creates and rejects the citation at build time instead (SAD Section 4.2). Raised both for an index outside the created or declared range and for a label the registry does not know. Objects already present in the opened project file are declared with :meth:pyflightstream.script.Script.declare_existing.

pyflightstream.script.SurfaceAverageWindow module-attribute

SurfaceAverageWindow = Annotated[
    _PackageWindow, AfterValidator(_validate_package)
]

pyflightstream.script.SurfaceAveragingWindow module-attribute

SurfaceAveragingWindow = Annotated[
    _ResolvedWindow, AfterValidator(_validate)
]

pyflightstream.script.UnsteadyActionUse

Bases: BaseModel

One action the solver runs after each unsteady time step.

Provenance, like :class:BrokenCommandUse: the script collects one per registered action so the run record can say what ran beside the solver, under which name, and on what evidence.

THE EVIDENCE FIELD IS THE POINT. SET_NEW_UNSTEADY_SOLVER_ACTION is documented on the two newest builds and PROBED ON NONE, so a workflow resting on it rests on a page rather than on a run. The status is read from the command database at the moment the action is registered and carried here, so it is stated once, at build time, instead of being assumed by every reader downstream.

Attributes:

Name Type Description
name str

Action name as registered, unique within one script.

kind str

SCRIPT for a FlightStream script, COMMAND_LINE for a shell command.

filename str

The path the registration line names, exactly as passed. WHAT IT IS RELATIVE TO IS UNSTATED BY BOTH EDITIONS: no manual page says which working directory the solver runs an action from (RPT-030), so this library records the caller's own string and claims nothing about how the solver resolves it. On 26.123 the action was measured to run from the simulation folder (RPT-041, the script-action re-read probe).

evidence str or None

Recorded status of the command on the script's build (documented, verified, broken), or None where the database holds no record for it.

inherited bool

Whether that status was recorded for this build or inherited from its base release. An inherited status is an assumption, and a record that cannot show the difference presents one as a measurement.

pyflightstream.script.turned_about

turned_about(
    vector: Sequence[float],
    axis: Sequence[float],
    angle_deg: float,
) -> tuple[float, float, float]

Return vector turned right-handed about the direction axis by angle_deg.

Rodrigues' rotation, the axis normalised here; each component is rounded to twelve decimals, so a frame turned by a whole passage reads as the axes it is and not as their last-bit residue. The one rotation of the package's frames: the placement ledger turns a frame with it (ROTATE_COORDINATE_SYSTEM) and a quasi-steady wheel turns its blade and clocking frames with it.

Parameters:

Name Type Description Default
vector sequence of float

The three components to turn.

required
axis sequence of float

The direction to turn about; it is normalised here and must not be zero.

required
angle_deg float

The right-handed angle, in degrees.

required

Returns:

Type Description
tuple of float

The three components of the turned vector, rounded to twelve decimals.

Examples:

>>> turned_about((0.0, 1.0, 0.0), (1.0, 0.0, 0.0), 90.0)
(0.0, 0.0, 1.0)