pyflightstream.results.log (provisional)¶
Generated from the docstrings at build time: every one of the 14 names in the __all__ of pyflightstream.results.log has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The solver log and its residual history, parsed.
The residual history and the per-solve residuals (:func:parse_residual_history,
:func:parse_residual_solves), the frozen time steps of an unsteady solve
(:func:frozen_time_steps), the run's wall times (:func:parse_log_times)
and the trailing edges the solver reports it imported
(:func:imported_trailing_edges); and the cumulative log of a job that
ran several points cut into each point's own log (:func:split_job_log,
:func:point_log_text).
Residual, timing and trailing-edge helpers are re-exported by
:mod:pyflightstream.results (AD-11). Job-log splitting helpers are
accessed through this module by grouped collection.
Advanced¶
pyflightstream.results.log.FrozenSolve
dataclass
¶
FrozenSolve(first_step: int, count: int)
A frozen unsteady solve, counted in the log's 1-based time steps.
pyflightstream.results.log.LogSegment
dataclass
¶
LogSegment(
index: int,
first_line: int,
last_line: int,
complete: bool,
)
One point's run inside the cumulative log of a job (FR-368).
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
The segment's position in the log, from 0; a job's point of order
|
first_line |
int
|
The segment's first line, a 0-based index into the log's lines. |
last_line |
int
|
The segment's last line, inclusive. The marker lines belong to no segment. |
complete |
bool
|
True when a later marker follows the segment. The last segment of a log is never complete here: whether its point finished is known only to a caller that knows the job ended. |
pyflightstream.results.log.LogTimes
dataclass
¶
LogTimes(
solver_run_time_s: float | None = None,
solver_initialization_s: float | None = None,
time_steps: int | None = None,
solver_mode: str | None = None,
)
The times and the step count a solver log prints.
Every field is None where the log does not print it, so an absent line is never reported as a zero.
Attributes:
| Name | Type | Description |
|---|---|---|
solver_run_time_s |
float or None
|
The LAST |
solver_initialization_s |
float or None
|
The last |
time_steps |
int or None
|
The total of the |
solver_mode |
str or None
|
|
pyflightstream.results.log.RESTART_MARKER
module-attribute
¶
RESTART_MARKER = "Solution cleared. Initialization removed."
pyflightstream.results.log.ResidualSample
dataclass
¶
ResidualSample(
iteration: int,
velocity_residual: float,
pressure_residual: float,
overflowed: frozenset[str] = frozenset(),
)
One row of the solver residual history.
Attributes:
| Name | Type | Description |
|---|---|---|
iteration |
int
|
Solver iteration number. |
velocity_residual |
float
|
Surface velocity residual, dimensionless. |
pressure_residual |
float
|
Surface pressure residual, dimensionless. |
overflowed |
frozenset of str
|
The columns ( |
pyflightstream.results.log.UnjudgeableSolve
dataclass
¶
UnjudgeableSolve(
first_step: int,
count: int,
steps: tuple[int, ...] = (),
frozen_from: int | None = None,
detail: str = "",
)
Bases: FrozenSolve
A solve whose native log cannot answer the freeze question.
A run that was stopped or killed leaves its last residual page without a
closing separator, and the detector refuses to read a table that ends
mid-write. That is not evidence of a freeze and it is NOT evidence of a
healthy solve either: on a real frozen log, cutting the last page hides
FrozenSolve(60, 2) entirely. An average that cannot be shown to avoid a
frozen solve is therefore refused exactly as a frozen one is -- and so
first_step is 1, which every window of the point ends at or after.
steps names the time
steps whose residual blocks could not be read; first_step is the first
of them, so a reader that knows only FrozenSolve still refuses rather
than accepts.
pyflightstream.results.log.frozen_time_steps
¶
frozen_time_steps(
log_text: str, *, unjudged: list[int] | None = None
) -> FrozenSolve | None
Detect a freeze from the printed residuals of an unsteady log.
A time step is frozen when every inner iteration after its first prints
exactly zero velocity residual and its last iteration prints both residuals
exactly zero (the package's own criterion; no committed report measures it
against the solver). A solve is
frozen only when at least two consecutive time steps meet this rule; the
result names the first step of the first such stretch and counts the frozen
steps in qualifying stretches. Step numbers come from the solver's 1-based
(k/N) markers, never from its cumulative inner-iteration counter.
Steady logs, which have no unsteady step markers, return None.
unjudged OPTS IN TO TOLERANCE, and the post stage is its only caller.
A block whose residual pages cannot be read -- a header with no rows under
it, which is what a run stopped by its walltime guard leaves, or a page cut
mid-write -- is then SKIPPED and its step number appended, rather than
raising. Without it this raises as it always has, which is what the collect
path needs to record FAILED_INCOMPLETE_OUTPUT (FR-17).
A skipped block is not evidence of a healthy step and must never be read as one: it breaks the streak, so it can neither begin nor extend a freeze, and the caller is handed the step numbers to refuse the windows they fall in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_text
|
str
|
Complete text of an unsteady solver log. |
required |
unjudged
|
list of int
|
When given, the tolerant mode described above: the number of every block whose residual pages cannot be read is appended to this list instead of raising. |
None
|
Returns:
| Type | Description |
|---|---|
FrozenSolve or None
|
The first frozen step and the count of frozen steps, or None when no stretch of two consecutive steps is frozen. |
Raises:
| Type | Description |
|---|---|
IncompleteOutputError
|
If a block has no readable residual page and |
MalformedOutputError
|
If a residual page of a block cannot be parsed and |
pyflightstream.results.log.imported_trailing_edges
¶
imported_trailing_edges(log_text: str) -> dict[str, int]
Read how many trailing edges the solver says it imported, per boundary.
The wake-edge import logs N trailing edges imported for boundary
<name> when it marks something and logs nothing when a file marks
nothing (RPT-061), so this count is the one statement the solver makes
about a file of points. Several import lines for one boundary are
summed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_text
|
str
|
Complete log text, an EXPORT_LOG output or the log the solver left. The NUL bytes a hidden-mode log carries between lines are removed. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to int
|
Edges imported per boundary name, in the order first logged. Empty when the log carries no import line, which is what a file that matched no edge leaves. |
Examples:
>>> from pyflightstream.results import imported_trailing_edges
>>> imported_trailing_edges("16 trailing edges imported for boundary Wing")
{'Wing': 16}
pyflightstream.results.log.lifting_log_warnings
¶
lifting_log_warnings(log_text: str) -> list[str]
Name explicitly zero trailing-edge or growing-wake counts in a lifting log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_text
|
str
|
Native solver log text to inspect. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Diagnostic warning strings for the lifting-surface log findings. |
pyflightstream.results.log.parse_log_times
¶
parse_log_times(text: str) -> LogTimes
Read the solver run time, the initialization time and the time steps off a log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Complete log text, an EXPORT_LOG output or a scheduler's job output carrying the same lines. |
required |
Returns:
| Type | Description |
|---|---|
LogTimes
|
Each field None where the log prints no such line. |
pyflightstream.results.log.parse_residual_history
¶
parse_residual_history(text: str) -> list[ResidualSample]
Parse the residual table of an exported solver log.
The log's iteration table carries the velocity and pressure residuals the convergence threshold applies to (FSM-26.120 p.200); the final row is the convergence evidence of the run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Complete log text (EXPORT_LOG output or captured log file). |
required |
Returns:
| Type | Description |
|---|---|
list of ResidualSample
|
The history in iteration order; the first three columns of each row (iteration, velocity residual, pressure residual) are parsed, further columns vary with the run setup. |
Raises:
| Type | Description |
|---|---|
IncompleteOutputError
|
If the log holds no residual table (a |
MalformedOutputError
|
If a row cannot be read, or the iteration counter does not
increase down the table (a |
pyflightstream.results.log.parse_residual_solves
¶
parse_residual_solves(
text: str,
) -> list[list[ResidualSample]]
Parse a solver log that holds several steady solves, one residual history each.
A quasi-steady rotor wheel is solved at each of its clockings in one run: the solver is
initialised again between them and each solve
prints its own residual table, its counter starting again at 1, so the
one log the run exports holds every clocking's solve in the order the
script ran them. :func:parse_residual_history refuses such a log, as it
must for a log of one solve, where a restart is two logs concatenated.
A NEW SOLVE IS A TABLE OF ITS OWN: the counter goes back to 1 on the
first row after the Iteration header. A counter that falls or repeats
anywhere else, or starts again at any other number, is refused as
:func:parse_residual_history refuses it, because it is not a solve the
solver started. Within each solve the counter increases. How many solves
the log must hold is the caller's to check against the run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Complete log text (EXPORT_LOG output or captured log file). |
required |
Returns:
| Type | Description |
|---|---|
list of list of ResidualSample
|
One history per solve, in the order the log prints them; a log of one solve gives one. |
Raises:
| Type | Description |
|---|---|
MalformedOutputError
|
A counter that does not increase inside a solve, or a restart that is not a new table starting at iteration 1. |
IncompleteOutputError
|
No residual row at all. |
Examples:
>>> page = "Iteration Res.Vel. Res.Pres.\n{}\n----------\n"
>>> log = page.format("1 1.0 1.0\n2 1e-6 1e-6") + page.format("1 1.0 1.0\n2 2e-6 1e-6")
>>> [[sample.iteration for sample in solve] for solve in parse_residual_solves(log)]
[[1, 2], [1, 2]]
pyflightstream.results.log.point_log_text
¶
point_log_text(
text: str,
segment: LogSegment,
*,
polar_start: LogSegment,
) -> str
Return one point's own log: its polar's preamble, then its own segment.
A point after the first of its polar runs in an instance that opened the
model once, so its segment carries neither the OPEN echo nor the
wake-edge import lines; they are in the polar's first segment, before its
initialisation echo, and they are put in front of the point's segment so
its log reads as the log of the point run alone (the trailing-edge import
count is judged per point). The process banner with the build is printed
once per job, so a point of a later polar does not
carry it; nothing of the package reads it off a log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The cumulative log :func: |
required |
segment
|
LogSegment
|
The point's segment. |
required |
polar_start
|
LogSegment
|
The segment of the first point of the same polar; the point's own segment when it is that first point, which then takes no preamble. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The point's log, every line ending in a line feed. |
pyflightstream.results.log.split_job_log
¶
split_job_log(text: str) -> list[LogSegment]
Cut a job log at point resets, retaining resets between initializations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The cumulative log, a point's own |
required |
Returns:
| Type | Description |
|---|---|
list of LogSegment
|
One segment per point, in the order the job ran them; empty for an
empty text. Line indexes count the lines of |
Examples:
>>> setup = f"Solver mode: Unsteady\n{RESTART_MARKER}\nSymmetry is disabled."
>>> len(split_job_log(setup))
1
>>> len(split_job_log(f"{setup}\nsolve ended\n{RESTART_MARKER}\nnext point"))
2