pyflightstream.fsi.state (stable)¶
Generated from the docstrings at build time: every one of the 14 names in the __all__ of pyflightstream.fsi.state has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Persistent coupling state: state.json model and atomic IO (WP6).
Pipeline role: the coupling executable is stateless per call (FSI-R01);
everything the next call needs survives in state.json inside the
run folder. This module owns that file: the validated model of its
content, atomic writes (temporary file plus rename, FSI-R13, so a call
killed mid-write leaves the previous state intact and the loop is
crash-recoverable), and the call/step counter bookkeeping (FSI-R12).
Counters: the Toolbox FSI iteration count is fixed at 1 per time step,
so calls and time steps advance together. The two counters are kept
separate anyway, with the consistency assertion living in the driver:
a call that receives the same solver iteration as the previous one is
a second FSI iteration inside one time step, which means
SET_AEROELASTIC_ITERATIONS is not 1, and the driver refuses to
continue instead of averaging over duplicated loads.
All stored arrays are plain JSON lists in SI units in the rotating blade frames; numpy conversion happens at the edges.
Advanced¶
pyflightstream.fsi.state.BEFORE_CALL_SURFACE_FILE
module-attribute
¶
BEFORE_CALL_SURFACE_FILE = 'fsi_before_call.vtk'
pyflightstream.fsi.state.FsiState
¶
Bases: BaseModel
Complete persisted state of the coupling loop (DLV-007 Section 5).
Attributes:
| Name | Type | Description |
|---|---|---|
call_count |
int
|
Executable invocations so far. |
step_count |
int
|
Time steps with fresh loads so far; equals |
phase |
int
|
Phase of the last executed coupling call (1 to 4, DLV-007 Section 4.5). |
last_solver_iteration |
int or None
|
Solver iteration of the last parsed loads file; the freshness anchor of the counter assertion. |
previous_displacements |
list of list of float or None
|
Last written FSIDisp rows [m], the relaxation memory (FSI-R07). |
previous_twist_rad |
list of list of float or None
|
Elastic twist per blade at the config stations [rad] of the last solve, kept for the propeller-moment continuity and as a warm start. |
load_history |
list of LoadSample
|
Averaging buffer of phases 2 and 3, trimmed to the configured window. |
revolution_history |
list of RevolutionSample
|
Per-revolution tip response, the convergence-log source (FSI-R09). |
recorded_twist |
list of RecordedTwist
|
Phase 4 recording of the twist distributions. |
phase4_start_step |
int or None
|
Step at which phase 4 recording began. |
config_sha256 |
str or None
|
Canonical sha256 of the configuration this state was CREATED
under, from :func: REV010-009. Shape compatibility is not physical identity. The
resume check compared per-blade and per-station array shapes
and nothing else, so a state saved at
None means the state predates the field and its creating configuration is unknown, which is different from matching. RENAMED, from |
completed_revolutions
property
¶
completed_revolutions: int
Revolutions completed so far, from the recorded history.
pyflightstream.fsi.state.LoadSample
¶
Bases: BaseModel
One call's aerodynamic load densities, in the averaging buffer.
Attributes:
| Name | Type | Description |
|---|---|---|
step |
int
|
Time step the sample belongs to. |
flap_n_per_m |
list of list of float
|
Distributed flap load per blade at the config stations [N/m]. |
torsion_nm_per_m |
list of list of float
|
Distributed elastic-axis moment per blade at the config stations [N m / m]. |
pyflightstream.fsi.state.QUASI_STEADY_ROTOR_FILE
module-attribute
¶
QUASI_STEADY_ROTOR_FILE = 'fsi_quasi_steady_rotor'
pyflightstream.fsi.state.RecordedTwist
¶
Bases: BaseModel
One phase 4 recording entry: the twist distribution of one step.
The azimuth of a step is not stored (FSI-R02: the structural code never handles azimuth); it is reconstructed downstream from the step index, the time increment, and Omega.
Attributes:
| Name | Type | Description |
|---|---|---|
step |
int
|
Time step of the record. |
elastic_twist_rad |
list of list of float
|
Elastic twist per blade at the config stations [rad]. |
pyflightstream.fsi.state.RevolutionSample
¶
Bases: BaseModel
Tip response recorded at one completed revolution (FSI-R09).
Attributes:
| Name | Type | Description |
|---|---|---|
revolution |
int
|
Completed revolution count. |
tip_twist_deg |
list of float
|
Tip elastic twist per blade [deg] at the completing call. |
tip_flap_m |
list of float
|
Tip flap deflection per blade [m] at the completing call. |
total_normal_force_n |
float or None
|
Integrated total normal force [N] at the completing call, the thrust half of the phase 3 acceptance model (REV010-010). It was computed and written to the convergence log without ever being carried here, which is why the second criterion could not be tested. None means the sample predates the field. |
pyflightstream.fsi.state.StaleLoadsError
¶
Bases: PyflightstreamError, ValueError
The loads file did not advance between calls (FSI-R12).
A call receiving the same solver iteration as the previous one is
a second FSI iteration inside one time step: the Toolbox is not
configured with SET_AEROELASTIC_ITERATIONS 1, and continuing
would average duplicated loads and desynchronize the call and step
counters. Defined here (the import-light state module) so the
exception catalog stays importable without the [fsi] extra;
the driver raises it.
pyflightstream.fsi.state.TwistIterationError
¶
TwistIterationError(
message: str,
*,
residuals_rad: tuple[float, ...] = (),
tolerance_rad: float = 0.0,
inner_solves: int = 0,
)
Bases: PyflightstreamError, RuntimeError
The inner twist iteration ran out of solves above its tolerance.
solve_rotating_static iterates the beam solve until the twist
distribution stops moving, and returns the last iterate whatever
happens. Above tolerance that iterate is NOT a solution: the twist
was still changing when the solve budget ran out, so the deflections
computed from it describe a blade shape the structural model never
settled on.
Until this class existed the driver read only solution from that
result, never twist_residual_rad, and wrote those deflections
straight into FSIDisp.txt. The solver then flew the unconverged
shape, the coupled run continued, and the only trace was a
logger.warning nobody reads in a batch run (PYFS-013). Writing
the file is the irreversible step, so the refusal is placed before
it.
Defined here (the import-light state module) so the exception
catalog stays importable without the [fsi] extra; the driver
raises it.
Attributes:
| Name | Type | Description |
|---|---|---|
residuals_rad |
tuple of float
|
Final twist residual per blade [rad], in blade order. |
tolerance_rad |
float
|
Threshold they were judged against [rad]. |
inner_solves |
int
|
Solves the worst blade spent before giving up. |
pyflightstream.fsi.state.check_state_matches_config
¶
check_state_matches_config(
state: FsiState,
*,
blade_count: int,
station_count: int,
config_sha256: str | None = None,
allow_config_change: bool = False,
) -> None
Refuse a resumed state whose shape disagrees with the configuration.
PYFS-012, second half. state.json carries per-blade, per-station
arrays (the relaxation memory, the warm-start twist, the phase 4
recordings) and validates only that they are lists of lists of floats.
Nothing tied those shapes to the configuration they were produced
under, so a 5-station, 3-blade config resumed happily on a 3-station,
2-blade state and NOTHING WAS RAISED.
What happens then is not a crash. The arrays are consumed positionally, so blade 3 has no memory, stations 4 and 5 read off the end or are silently truncated by whichever numpy broadcast gets there first, and the relaxation continues from a structure that does not exist. The run keeps producing numbers and its convergence log keeps looking healthy.
The two counts are KEYWORD-ONLY, and deliberately so: they are same-typed integers, so a positional call transposing them type-checks, runs, and yields either a spurious refusal or a silent acceptance of the exact mismatch this function exists to catch. That is the same shape as the defects it was written for.
They are scalars rather than an FsiConfig so this module keeps its
import surface to pydantic alone. Stated honestly, because an earlier
version of this docstring claimed the split kept
:mod:pyflightstream.exceptions importable without the [fsi] extra
and a review pass measured that false: exceptions already reaches
fsi.config transitively through the fsi package __init__. The
real reasons are narrower and still hold: this module is the one the
persisted state belongs to, it is exercised directly by the state tests,
and nothing here needs the rest of a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
FsiState
|
State just loaded from disk. |
required |
blade_count
|
(int, keyword - only)
|
|
required |
station_count
|
(int, keyword - only)
|
Number of radial stations of the configuration about to be used. |
required |
config_sha256
|
(str or None, keyword - only)
|
Canonical sha256 of the configuration about to be used. When
both this and |
None
|
allow_config_change
|
(bool, keyword - only)
|
Resume anyway across a configuration change. This is the documented restart the finding's closure asks for, and it is opt-in because the memory being carried forward (relaxation state, warm-start twist, convergence history) was produced by the OTHER model. Shape disagreements are still refused: those are not a physical decision, they are arrays that do not fit. |
False
|
Raises:
| Type | Description |
|---|---|
FsiInputError
|
If any persisted array disagrees with the configured shape, or
if the state was created under a different configuration and
|
pyflightstream.fsi.state.initial_state
¶
initial_state() -> FsiState
Return the state of a run before its first coupling call.
Returns:
| Type | Description |
|---|---|
FsiState
|
The empty state. |
pyflightstream.fsi.state.load_state
¶
load_state(path: str | Path) -> FsiState
Load and validate a state.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
State file written by :func: |
required |
Returns:
| Type | Description |
|---|---|
FsiState
|
The validated state. |
pyflightstream.fsi.state.write_state_atomic
¶
write_state_atomic(
state: FsiState, path: str | Path
) -> None
Persist the state atomically: temporary file plus rename (FSI-R13).
A call killed between the write and the rename leaves the previous
state.json intact, so the loop resumes from the last completed
call instead of consuming a torn file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
FsiState
|
State after the current call. |
required |
path
|
str or Path
|
Destination |
required |