Skip to content

pyflightstream.workspace.fsi_setup (stable)

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

Resolve the existing solid Euler beam from a workspace input artifact.

Used in the guides

pyflightstream.workspace.fsi_setup.load_fsi_setup

load_fsi_setup(
    path: str | Path,
    *,
    matrix_calibration: Mapping[str, float] | None = None,
) -> FsiConfig

Load the effective config for the established FSI driver.

Parameters:

Name Type Description Default
path str or Path

The FSI input artifact.

required
matrix_calibration mapping of str to float

The calibration factors the matrix row states, each replacing the file's factor of the same name.

None

Returns:

Type Description
FsiConfig

The effective configuration.

Examples:

>>> import tempfile
>>> from pathlib import Path
>>> with tempfile.TemporaryDirectory() as folder:
...     path = Path(folder) / "f001.toml"
...     _ = path.write_text(
...         'mode = "calculated"\nmaterial = "ti-6al-4v-grade5-annealed"\n'
...         "[config]\nblade_count = 2\nomega_rad_per_s = 100.0\n"
...         "[sections]\nstation_radii_m = [0.3, 0.6]\nchord_m = [0.2, 0.15]\n"
...         'geometric_pitch_deg = [30.0, 20.0]\nnaca = "4412"\n'
...         'pitch_axis_chord_fraction = 0.25\ngeometry_source = "NACA 4412"\n'
...         "torsion_grid_cells = 16\n",
...         encoding="utf-8",
...     )
...     config = load_fsi_setup(path)
>>> config.blade_count
2

Advanced

pyflightstream.workspace.fsi_setup.BeamSections dataclass

BeamSections(
    path: Path,
    sha256: str,
    sections: dict[str, Any],
    pdf: Path | None = None,
)

A geometry's <geometry>.<family>.beam.toml, as :func:beam_sections left it.

Attributes:

Name Type Description
path Path

The file.

sha256 str

Its sha256.

sections dict

Its [sections] table: station_radii_m, chord_m, geometric_pitch_deg, sections_m and geometry_source.

pdf Path or None

The <geometry>.<family>.beam.pdf drawn, when one was asked for.

pyflightstream.workspace.fsi_setup.FSI_TEMPLATE module-attribute

FSI_TEMPLATE = '# Synthetic solid-section example; no native coupled validation is implied.\nmode = "calculated"\nmaterial = "ti-6al-4v-grade5-annealed"\n\n[calibration]\n# Scale structural angles once; this does not re-pitch the aerodynamic mesh.\ngeometric_pitch_deg = 1.0\nbending_stiffness_n_m2 = 1.0\ntorsion_stiffness_n_m2 = 1.0\nmass_per_length_kg_per_m = 1.0\n\n[config]\nblade_count = 2\nomega_rad_per_s = 0.0\n\n[sections]\nstation_radii_m = [0.1, 0.5]\nchord_m = [0.04, 0.04]\ngeometric_pitch_deg = [0.0, 0.0]\ngeometry_source = "Synthetic closed rectangular contours in metres"\ntorsion_grid_cells = 16\nsections_m = [\n  [[-0.02, -0.002], [0.02, -0.002], [0.02, 0.002], [-0.02, 0.002]],\n  [[-0.02, -0.002], [0.02, -0.002], [0.02, 0.002], [-0.02, 0.002]]\n]\n'

pyflightstream.workspace.fsi_setup.FsiSetupError

Bases: PyflightstreamError, ValueError

An FSI artifact cannot define an admissible existing beam model.

pyflightstream.workspace.fsi_setup.FsiSetupSpec

Bases: BaseModel

The two explicit configuration modes accepted in workspace FSI TOML.

pyflightstream.workspace.fsi_setup.ResolvedFsiSetup dataclass

ResolvedFsiSetup(
    source: Path,
    source_sha256: str,
    mode: str,
    base: FsiConfig,
    effective: FsiConfig,
    factors: dict[str, float],
    origins: dict[str, str],
    material_base: dict[str, Any] | None = None,
    material_effective: dict[str, Any] | None = None,
    frozen_displacements_file: str | None = None,
    frozen_displacements_sha256: str | None = None,
    allow_configuration_change: bool = False,
    structural_start: dict[str, Any] | None = None,
    frame_compensation: dict[str, Any] | None = None,
    beam_sections: dict[str, str] | None = None,
)

Unscaled input, effective beam, and explicit factor selection provenance.

provenance

provenance() -> dict[str, Any]

Return the source, base/effective configurations and factor origins.

A row that states FSI_START_REV or FSI_START_ITER adds a structural_start record: the key, its value, the revolutions it became and the file's own value. An input or a row that states the solver-frame compensation adds a frame_compensation record: its value and its origin (matrix, file or default, FR-3415). An input whose sections come from the mesh adds beam_sections: the name and the sha256 of the .beam.toml its sections were read from.

pyflightstream.workspace.fsi_setup.SolidSections

Bases: BaseModel

Closed solid section contours, in metres in the existing section frame.

source = "mesh" with stations = <n> states none of them: they are cut from the row's mesh into <geometry>.<family>.beam.toml (:func:beam_sections).

pyflightstream.workspace.fsi_setup.beam_sections

beam_sections(
    geometry: str | Path,
    family: str,
    stations: int,
    *,
    metres_per_unit: float | None = None,
    hub_m: Sequence[float] = (0.0, 0.0, 0.0),
    inspection: bool = False,
) -> BeamSections

Return a blade's sections cut from its mesh, kept in <geometry>.<family>.beam.toml.

The file sits beside the mesh and its <geometry>.boundaries.toml, and records the mesh's sha256, the station count and the hub it was cut about. A file of the same sha256, count and hub is used as it is, hand edits included. One of another sha256, count or hub, or one that does not read as sections, is warned and kept as <geometry>.<family>.beam.toml.bak, and the sections are cut again (:func:pyflightstream.fsi.sections.sections_from_mesh) from the blade's surface in metres about the hub. The plan of an FSI input with [sections] source = "mesh" and pyfs-fsi beam both call it, so both write the same file.

Parameters:

Name Type Description Default
geometry str or Path

The OBJ or the saved simulation (.fsm) holding the blade.

required
family str

The blade's name in the mesh: an OBJ group, a saved simulation's boundary.

required
stations int

How many evenly spaced radii to cut.

required
metres_per_unit float

The factor taking an OBJ's coordinates to metres; by default the one its sidecar's [import] units states. A saved simulation is read in the unit it stores.

None
hub_m sequence of float

The hub [m] the blade's frame sits on, the shaft along x and the blade along +z from it; the mesh's origin by default.

(0.0, 0.0, 0.0)
inspection bool

Also draw <geometry>.<family>.beam.pdf beside the file: the sections on the blade and each station's contour.

False

Returns:

Type Description
BeamSections

The file, its sha256, its [sections] table and the drawing.

Raises:

Type Description
FsiSetupError

If the mesh holds no such family or the cut gives fewer than two usable stations.

Examples:

>>> import tempfile
>>> from pathlib import Path
>>> faces = [(i, (i + 1) % 3, 3 + (i + 1) % 3) for i in range(3)]
>>> faces += [(i, 3 + (i + 1) % 3, 3 + i) for i in range(3)]
>>> with tempfile.TemporaryDirectory() as folder:
...     mesh = Path(folder) / "blade.obj"
...     _ = mesh.write_text("o Blade1\n" + "".join(
...         f"v {x} {y} {z}\n" for z in (0.1, 0.5)
...         for x, y in ((0.0, -0.02), (0.002, 0.01), (-0.002, 0.01)))
...         + "".join(f"f {a + 1} {b + 1} {c + 1}\n" for a, b, c in faces))
...     written = beam_sections(mesh, "Blade1", 2, metres_per_unit=1.0)
...     name = written.path.name
>>> name, [round(r, 3) for r in written.sections["station_radii_m"]]
('blade.Blade1.beam.toml', [0.1, 0.5])

pyflightstream.workspace.fsi_setup.fsi_input_payloads

fsi_input_payloads(
    config: FsiConfig, provenance: Mapping[str, Any]
) -> dict[str, str]

Return files for the run layer's existing per-point input writer and hashes.

Parameters:

Name Type Description Default
config FsiConfig

The effective configuration.

required
provenance mapping of str to object

Its provenance.

required

Returns:

Type Description
dict of str to str

File name to text: config.json and fsi-provenance.json.

Raises:

Type Description
FsiSetupError

The frozen displacement file changed since matrix resolution.

pyflightstream.workspace.fsi_setup.resolve_fsi_setup

resolve_fsi_setup(
    path: str | Path,
    *,
    matrix_calibration: Mapping[str, float] | None = None,
    mesh_sections: Callable[[int], BeamSections]
    | None = None,
) -> ResolvedFsiSetup

Resolve one artifact; an explicit matrix factor replaces its file factor once.

Source material and derived properties cannot both be calibrated along the same dependency. The existing solve-time stiffness scale must remain unity.

Parameters:

Name Type Description Default
path str or Path

The FSI input artifact.

required
matrix_calibration mapping of str to float

The calibration factors the matrix row states, each replacing the file's factor of the same name.

None
mesh_sections callable

For an input whose [sections] state source = "mesh": called with its stations, it returns the row's :class:BeamSections (:func:beam_sections).

None

Returns:

Type Description
ResolvedFsiSetup

The source and its digest, the mode, the base and effective configurations, the factors and where each came from.

Raises:

Type Description
FsiSetupError

If the file cannot be read, the mode and the artifact's content disagree, a factor calibrates one property twice, the material or the sections are refused by the FSI package, the effective inertias are out of order, or sections from the mesh state no stations or give fewer than two usable stations.

pyflightstream.workspace.fsi_setup.resolve_row_fsi

resolve_row_fsi(
    inputs_dir: str | Path,
    variables: Mapping[str, Any],
    *,
    require_beam: bool = False,
    mesh_sections: Callable[[int], BeamSections]
    | None = None,
) -> ResolvedFsiSetup | ExternalStructure | None

Resolve FSI: f001 and named factor keys from the matrix free cell.

An input of mode = "external" (FR-462) resolves to the :class:~pyflightstream.fsi.external.ExternalStructure it names, hashed.

Parameters:

Name Type Description Default
inputs_dir str or Path

The workspace's inputs folder.

required
variables mapping of str to object

The row's free-cell variables.

required
require_beam bool

Refuse external mode before binding its program, for structural-only studies.

False
mesh_sections callable

The row's sections cut from its mesh, for an input of [sections] source = "mesh" (:func:resolve_fsi_setup).

None

Returns:

Type Description
(ResolvedFsiSetup, ExternalStructure or None)

The resolved input, or None when the row states no FSI.

Raises:

Type Description
FsiSetupError

If the code is not an f-prefixed name, resolves outside the inputs folder or names no file there (the message lists the inputs that exist), a factor key is unknown or not a finite positive number, or factors are stated without an FSI input.

pyflightstream.workspace.fsi_setup.stage_fsi_setup

stage_fsi_setup(
    resolved: ResolvedFsiSetup, run_dir: str | Path
) -> tuple[Path, Path]

Stage the driver config and full provenance without running the solver.

Parameters:

Name Type Description Default
resolved ResolvedFsiSetup

The resolved input.

required
run_dir str or Path

The run folder the files are written into.

required

Returns:

Type Description
tuple of (Path, Path)

The configuration file and the provenance receipt written.

pyflightstream.workspace.fsi_setup.structural_assessment

structural_assessment(
    config: FsiConfig,
) -> dict[str, object]

Report effective station properties, modes and excitation ratios.

The modal calculation uses the existing rotating beam model, including centrifugal stiffness. The warning is a quasi-static validity screen, not a claim of dynamic stability or licensed coupling validation.

Parameters:

Name Type Description Default
config FsiConfig

Resolved structural configuration in SI units.

required

Returns:

Type Description
dict[str, object]

Effective properties, frequencies, excitation ratios and warnings.

pyflightstream.workspace.fsi_setup.write_campbell_study

write_campbell_study(
    root: str | Path,
    fsi_id: str,
    *,
    rpm: tuple[float, float, float],
    n_modes: int = 6,
    overwrite: bool = False,
) -> dict[str, Any]

Write a structural-only speed study using the workspace's FSI binder.

Parameters:

Name Type Description Default
root str or Path

Workspace containing inputs/fsi.

required
fsi_id str

FSI input code, without extension.

required
rpm tuple of float

Start, stop and integer count of inclusive speeds in revolutions per minute.

required
n_modes int

Number of lowest modes at each speed.

6
overwrite bool

Replace existing study products only when true.

False

Returns:

Type Description
dict

Provenance, written file names, crossings and named missing families.

Raises:

Type Description
FsiSetupError

Invalid sweep, external model, missing input or existing output.