courant-dev 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- courant/__init__.py +26 -0
- courant/case/__init__.py +0 -0
- courant/case/_foam_reader.py +269 -0
- courant/case/config.py +134 -0
- courant/case/mesh.py +135 -0
- courant/case/reads.py +90 -0
- courant/case/schemes.py +99 -0
- courant/case/solvers.py +170 -0
- courant/cli/__init__.py +0 -0
- courant/cli/commands/__init__.py +6 -0
- courant/cli/commands/audit.py +40 -0
- courant/cli/commands/convergence.py +68 -0
- courant/cli/commands/ctest.py +76 -0
- courant/cli/commands/doctor.py +162 -0
- courant/cli/commands/gate.py +88 -0
- courant/cli/commands/live.py +73 -0
- courant/cli/commands/mcp.py +57 -0
- courant/cli/commands/preflight.py +36 -0
- courant/cli/commands/spec.py +231 -0
- courant/cli/commands/tour.py +122 -0
- courant/cli/commands/update.py +213 -0
- courant/cli/commands/verify.py +222 -0
- courant/cli/config.py +244 -0
- courant/cli/guard.py +69 -0
- courant/cli/main.py +130 -0
- courant/cli/tail.py +351 -0
- courant/config.py +155 -0
- courant/converge/__init__.py +57 -0
- courant/converge/assess.py +823 -0
- courant/converge/exact.py +112 -0
- courant/converge/render.py +182 -0
- courant/converge/scale.py +87 -0
- courant/converge/sentences.py +82 -0
- courant/converge/series.py +413 -0
- courant/converge/steady.py +261 -0
- courant/converge/tables.py +1019 -0
- courant/converge/transient.py +314 -0
- courant/ctest/__init__.py +6 -0
- courant/ctest/build.py +82 -0
- courant/ctest/data/judge-v0.labels.jsonl +31 -0
- courant/ctest/data/judge-v0.tasks.jsonl.gz +0 -0
- courant/ctest/judges/__init__.py +27 -0
- courant/ctest/judges/constant.py +18 -0
- courant/ctest/judges/courant.py +23 -0
- courant/ctest/judges/llm.py +166 -0
- courant/ctest/run.py +74 -0
- courant/ctest/schema.py +46 -0
- courant/ctest/score.py +91 -0
- courant/ctest/splits.py +20 -0
- courant/data/__init__.py +46 -0
- courant/data/certification.json +1 -0
- courant/data/certified_codes.json +18 -0
- courant/data/demo/icoFoam_cavity__cfl_blowup.case.json +68 -0
- courant/data/demo/icoFoam_cavity__cfl_blowup.log.gz +0 -0
- courant/data/demo/icoFoam_cavity__healthy.case.json +68 -0
- courant/data/demo/icoFoam_cavity__healthy.log.gz +0 -0
- courant/data/demo/icoFoam_cavity__transport_units.case.json +68 -0
- courant/data/demo/icoFoam_cavity__transport_units.log.gz +0 -0
- courant/data/demo/pitzDaily_fixed_budget.tar.gz +0 -0
- courant/data/schemas/audit.1.json +129 -0
- courant/data/schemas/cache.1.json +77 -0
- courant/data/schemas/convergence.1.json +112 -0
- courant/data/schemas/error-rates.1.json +53 -0
- courant/data/schemas/preflight.1.json +250 -0
- courant/data/schemas/record.1.json +155 -0
- courant/data/schemas/release-signature.1.json +39 -0
- courant/data/schemas/spec.1.json +258 -0
- courant/data/schemas/support.1.json +80 -0
- courant/data/schemas/verdict.1.json +716 -0
- courant/data/schemas/verdict.2.json +752 -0
- courant/diagnosis/__init__.py +0 -0
- courant/diagnosis/bundle.py +168 -0
- courant/diagnosis/checkers.py +919 -0
- courant/diagnosis/deterministic.py +110 -0
- courant/diagnosis/findings.py +107 -0
- courant/diagnosis/kb.py +188 -0
- courant/diagnosis/kb_data.py +253 -0
- courant/diagnosis/llm.py +299 -0
- courant/diagnosis/redact.py +425 -0
- courant/diagnosis/schema.py +83 -0
- courant/events/__init__.py +35 -0
- courant/events/core.py +194 -0
- courant/events/diverged.py +55 -0
- courant/gate/__init__.py +1 -0
- courant/gate/config.py +150 -0
- courant/gate/run.py +295 -0
- courant/live/__init__.py +16 -0
- courant/live/engine.py +155 -0
- courant/live/watch.py +164 -0
- courant/llm/__init__.py +59 -0
- courant/llm/allowlist.py +60 -0
- courant/llm/anthropic.py +137 -0
- courant/llm/budget.py +491 -0
- courant/llm/door.py +1071 -0
- courant/llm/errors.py +105 -0
- courant/llm/openrouter.py +118 -0
- courant/llm/policy.py +268 -0
- courant/llm/transport.py +48 -0
- courant/mcp/__init__.py +7 -0
- courant/mcp/server.py +113 -0
- courant/mcp/tools.py +177 -0
- courant/record/__init__.py +22 -0
- courant/record/filter.py +99 -0
- courant/record/record.py +149 -0
- courant/release.py +205 -0
- courant/signing.py +99 -0
- courant/spec/__init__.py +31 -0
- courant/spec/check.py +353 -0
- courant/spec/deck.py +455 -0
- courant/spec/extract.py +181 -0
- courant/spec/impossible.py +197 -0
- courant/spec/model.py +194 -0
- courant/taxonomy.py +219 -0
- courant/verification/__init__.py +30 -0
- courant/verification/_fluid_reader.py +228 -0
- courant/verification/bounding.py +84 -0
- courant/verification/checks.py +369 -0
- courant/verification/convergence.py +257 -0
- courant/verification/fields.py +38 -0
- courant/verification/grade.py +101 -0
- courant/verification/suite.py +30 -0
- courant/verify/__init__.py +37 -0
- courant/verify/about.py +100 -0
- courant/verify/audit.py +209 -0
- courant/verify/batch.py +141 -0
- courant/verify/cache.py +329 -0
- courant/verify/checks.py +37 -0
- courant/verify/html.py +330 -0
- courant/verify/ingest.py +115 -0
- courant/verify/junit.py +48 -0
- courant/verify/outcome.py +74 -0
- courant/verify/pack.py +106 -0
- courant/verify/pipeline.py +396 -0
- courant/verify/policy.py +167 -0
- courant/verify/preflight.py +166 -0
- courant/verify/render.py +174 -0
- courant/verify/schema.py +398 -0
- courant/verify/sentences.py +137 -0
- courant/verify/support.py +142 -0
- courant/verify/verdict2.py +235 -0
- courant/watcher/__init__.py +13 -0
- courant/watcher/anomaly.py +244 -0
- courant/watcher/exitcode.py +23 -0
- courant/watcher/parser.py +435 -0
- courant/watcher/watcher.py +49 -0
- courant_dev-0.5.0.dist-info/METADATA +146 -0
- courant_dev-0.5.0.dist-info/RECORD +152 -0
- courant_dev-0.5.0.dist-info/WHEEL +5 -0
- courant_dev-0.5.0.dist-info/entry_points.txt +3 -0
- courant_dev-0.5.0.dist-info/licenses/LICENSE +202 -0
- courant_dev-0.5.0.dist-info/licenses/NOTICE +4 -0
- courant_dev-0.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Exact window sums (TRD CONV-2, replacing M1-D-5's blocked reduction).
|
|
2
|
+
|
|
3
|
+
Every reduction over more than two floats in this package is `math.fsum`, which returns the
|
|
4
|
+
correctly rounded value of the exact sum, so its result depends only on the multiset of
|
|
5
|
+
addends and never on their order.
|
|
6
|
+
|
|
7
|
+
The stopping-point search needs the sum over thousands of overlapping windows. M1 proposed
|
|
8
|
+
caching one fsum per block of 256 and reducing each window over its head elements, cached
|
|
9
|
+
blocks and tail elements. That is deterministic, but not equal to fsum over the window,
|
|
10
|
+
because each block sum is itself rounded, and it costs O(w/256 + 512) per window.
|
|
11
|
+
|
|
12
|
+
This module holds every prefix sum exactly instead, as Shewchuk's non-overlapping partials
|
|
13
|
+
(the representation `math.fsum` uses internally). The sum over `[a, b)` is then
|
|
14
|
+
`fsum(P_b + (-P_a))`, the correctly rounded value of an exact difference. That is equal,
|
|
15
|
+
bit for bit, to `fsum(values[a:b])`, and costs O(p) per window, where p is the partials
|
|
16
|
+
count, typically 1 to 4. The test suite asserts the equality on random and adversarial
|
|
17
|
+
arrays.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import math
|
|
23
|
+
from array import array
|
|
24
|
+
from collections.abc import Sequence
|
|
25
|
+
|
|
26
|
+
SCHEME = "exact-prefix-partials"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _grow(partials: Sequence[float], x: float) -> list[float]:
|
|
30
|
+
"""`partials` plus `x`, exactly, as non-overlapping partials (Shewchuk 1997)."""
|
|
31
|
+
out: list[float] = []
|
|
32
|
+
for y in partials:
|
|
33
|
+
if abs(x) < abs(y):
|
|
34
|
+
x, y = y, x
|
|
35
|
+
hi = x + y
|
|
36
|
+
lo = y - (hi - x)
|
|
37
|
+
if lo:
|
|
38
|
+
out.append(lo)
|
|
39
|
+
x = hi
|
|
40
|
+
out.append(x)
|
|
41
|
+
return out
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ExactSums:
|
|
45
|
+
"""Correctly rounded sums over any window of one finite addend array."""
|
|
46
|
+
|
|
47
|
+
__slots__ = ("_n", "_flat", "_start")
|
|
48
|
+
|
|
49
|
+
def __init__(self, addends: Sequence[float]) -> None:
|
|
50
|
+
flat = array("d")
|
|
51
|
+
start = array("q", [0])
|
|
52
|
+
partials: list[float] = []
|
|
53
|
+
for x in addends:
|
|
54
|
+
if not math.isfinite(x):
|
|
55
|
+
raise ValueError("non-finite addend: filter before summing (CONV-9)")
|
|
56
|
+
partials = _grow(partials, float(x))
|
|
57
|
+
flat.extend(partials)
|
|
58
|
+
start.append(len(flat))
|
|
59
|
+
self._n = len(start) - 1
|
|
60
|
+
self._flat = flat
|
|
61
|
+
self._start = start
|
|
62
|
+
|
|
63
|
+
def __len__(self) -> int:
|
|
64
|
+
return self._n
|
|
65
|
+
|
|
66
|
+
def _prefix(self, k: int) -> array:
|
|
67
|
+
if k == 0:
|
|
68
|
+
return array("d")
|
|
69
|
+
return self._flat[self._start[k - 1]:self._start[k]]
|
|
70
|
+
|
|
71
|
+
def window(self, a: int, b: int) -> float:
|
|
72
|
+
"""fsum(addends[a:b]), exactly, in O(partials)."""
|
|
73
|
+
if a < 0 or b > self._n:
|
|
74
|
+
raise IndexError(f"window [{a}, {b}) outside 0..{self._n}")
|
|
75
|
+
if b <= a:
|
|
76
|
+
return 0.0
|
|
77
|
+
parts = list(self._prefix(b))
|
|
78
|
+
parts.extend(-v for v in self._prefix(a))
|
|
79
|
+
return math.fsum(parts)
|
|
80
|
+
|
|
81
|
+
def total(self) -> float:
|
|
82
|
+
return self.window(0, self._n)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def mean(values: Sequence[float]) -> float:
|
|
86
|
+
"""The fsum mean of a non-empty sequence."""
|
|
87
|
+
return math.fsum(values) / len(values)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def variance(values: Sequence[float], ddof: int = 1) -> float:
|
|
91
|
+
"""Two-pass variance by fsum: the mean first, then the squared deviations."""
|
|
92
|
+
n = len(values)
|
|
93
|
+
if n - ddof <= 0:
|
|
94
|
+
return 0.0
|
|
95
|
+
m = mean(values)
|
|
96
|
+
return math.fsum((v - m) * (v - m) for v in values) / (n - ddof)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def icbrt(n: int) -> int:
|
|
100
|
+
"""The integer cube root, floor(n ** (1/3)), by binary search (M1-D-3)."""
|
|
101
|
+
if n < 0:
|
|
102
|
+
raise ValueError("negative")
|
|
103
|
+
lo, hi = 0, 1
|
|
104
|
+
while hi * hi * hi <= n:
|
|
105
|
+
hi = hi * 2
|
|
106
|
+
while hi - lo > 1:
|
|
107
|
+
mid = (lo + hi) // 2
|
|
108
|
+
if mid * mid * mid <= n:
|
|
109
|
+
lo = mid
|
|
110
|
+
else:
|
|
111
|
+
hi = mid
|
|
112
|
+
return lo
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""How a convergence assessment is shown (TRD CONV-13, M1-A-13).
|
|
2
|
+
|
|
3
|
+
Five lines, in this order, whenever a stopping point exists:
|
|
4
|
+
1. the answer at the stopping point and at the end;
|
|
5
|
+
2. how much the answer changed after the stopping point;
|
|
6
|
+
3. iterations past convergence;
|
|
7
|
+
4. wall clock past convergence;
|
|
8
|
+
5. core-hours past convergence, or the fixed sentence saying why they were not computed.
|
|
9
|
+
|
|
10
|
+
Every number printed is taken from the assessment's data, and every share carries its
|
|
11
|
+
denominator.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from courant.converge.assess import FAIL, NOT_ASSESSABLE, PASS, WARN, Convergence
|
|
17
|
+
|
|
18
|
+
FOOTER = ("Courant reports where this run could have stopped. It does not say where a future "
|
|
19
|
+
"run will.")
|
|
20
|
+
MAX_ROWS = 24
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _g(x) -> str:
|
|
24
|
+
return "n/a" if x is None else f"{x:.6g}"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _int(n) -> str:
|
|
28
|
+
return "n/a" if n is None else f"{n:,}"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _pct(x) -> str:
|
|
32
|
+
if x is None:
|
|
33
|
+
return "n/a"
|
|
34
|
+
if 0 < abs(x) < 0.001:
|
|
35
|
+
return f"{100.0 * x:.2g}%" # 0.021%, not 0.0%
|
|
36
|
+
return f"{100.0 * x:.1f}%"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _change(row: dict) -> str:
|
|
40
|
+
if row.get("delta") is None:
|
|
41
|
+
return "-"
|
|
42
|
+
if row.get("delta_counts") is not None:
|
|
43
|
+
return f"{row['delta_counts']:.2f} counts"
|
|
44
|
+
if row.get("delta_fraction") is not None:
|
|
45
|
+
return f"{_pct(row['delta_fraction'])} of scale"
|
|
46
|
+
return _g(row["delta"])
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _limit(row: dict) -> str:
|
|
50
|
+
tol = row.get("tolerance") or {}
|
|
51
|
+
if tol.get("branch") == "absolute":
|
|
52
|
+
if tol.get("value") == 1e-4:
|
|
53
|
+
return "1 count"
|
|
54
|
+
return f"{_g(tol.get('value'))} absolute"
|
|
55
|
+
return f"{_pct(tol.get('value'))} of scale"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def summary(conv: Convergence) -> dict:
|
|
59
|
+
"""The compact block a verdict and the MCP tool carry (CONV-12)."""
|
|
60
|
+
d = conv.data
|
|
61
|
+
w = d.get("waste") or {}
|
|
62
|
+
b = d.get("binding_monitor")
|
|
63
|
+
row = (d.get("monitors") or {}).get(b) or {}
|
|
64
|
+
return {
|
|
65
|
+
"status": conv.status, "regime": conv.regime, "enters_verdict": conv.counted,
|
|
66
|
+
"converged_at_step": d.get("converged_at_step"), "binding_monitor": b,
|
|
67
|
+
"change_after_stop": row.get("delta"), "change_counts": row.get("delta_counts"),
|
|
68
|
+
"change_fraction": row.get("delta_fraction"),
|
|
69
|
+
"wasted_steps": w.get("wasted_steps"), "steps_total": w.get("steps_total"),
|
|
70
|
+
"wasted_fraction": w.get("wasted_fraction"),
|
|
71
|
+
"wasted_wall_clock_s": w.get("wasted_wall_clock_s"),
|
|
72
|
+
"wasted_core_hours": w.get("wasted_core_hours"),
|
|
73
|
+
"monitors_assessed": len([m for m in (d.get("monitors") or {}).values()
|
|
74
|
+
if m.get("counts") and m.get("verdict") != NOT_ASSESSABLE]),
|
|
75
|
+
"monitors_found": len(d.get("monitors") or {}),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def five_lines(conv: Convergence) -> list[str]:
|
|
80
|
+
d = conv.data
|
|
81
|
+
w = d.get("waste")
|
|
82
|
+
b = d.get("binding_monitor")
|
|
83
|
+
if not w or not b:
|
|
84
|
+
return []
|
|
85
|
+
row = d["monitors"][b]
|
|
86
|
+
unit = "iterations" if conv.regime == "steady" else "time steps"
|
|
87
|
+
noun = "value" if conv.regime == "steady" else "time-average"
|
|
88
|
+
lines = [
|
|
89
|
+
f"1 Answer {b}: {noun} {_g(row['value_at_stop'])} at step {_int(w['converged_at_step'])}, "
|
|
90
|
+
f"{_g(row['value_at_end'])} at the end (step {_int(w['final_step'])})",
|
|
91
|
+
f"2 Change {_change(row)} after the stopping point (limit {_limit(row)})",
|
|
92
|
+
f"3 {unit.capitalize():<12} {_int(w['wasted_steps'])} of {_int(w['steps_total'])} past convergence "
|
|
93
|
+
f"({_pct(w['wasted_fraction'])})",
|
|
94
|
+
]
|
|
95
|
+
if w.get("wasted_wall_clock_s") is not None:
|
|
96
|
+
total = w.get("wall_clock_total_s")
|
|
97
|
+
of = f" of {_g(total)} s" if total is not None else ""
|
|
98
|
+
cpu = (f"; rank-0 CPU {_g(w['wasted_cpu_s'])} s" if w.get("wasted_cpu_s") is not None else "")
|
|
99
|
+
lines.append(f"4 Wall clock {_g(w['wasted_wall_clock_s'])} s{of} past convergence "
|
|
100
|
+
f"(solver ClockTime{cpu})")
|
|
101
|
+
else:
|
|
102
|
+
lines.append("4 Wall clock not available: the log carried no clock at these steps")
|
|
103
|
+
if w.get("wasted_core_hours") is not None:
|
|
104
|
+
cost = ""
|
|
105
|
+
if w.get("wasted_cost") is not None:
|
|
106
|
+
cost = (f"; {_g(w['wasted_cost'])} at your rate of {_g(w['cost_per_core_hour'])} "
|
|
107
|
+
f"per core-hour")
|
|
108
|
+
basis = {"log_nprocs": "nProcs in the log", "serial": "a serial run",
|
|
109
|
+
"user": "as given"}.get(w["ranks_basis"], w["ranks_basis"])
|
|
110
|
+
lines.append(f"5 Core-hours {_g(w['wasted_core_hours'])} past convergence "
|
|
111
|
+
f"({w['ranks']} rank{'s' if w['ranks'] != 1 else ''}, {basis}, x wall clock)"
|
|
112
|
+
f"{cost}")
|
|
113
|
+
else:
|
|
114
|
+
note = next((f.message for f in conv.findings if f.code == "CONV.CORE_HOURS_NOT_COMPUTED"), "")
|
|
115
|
+
lines.append(f"5 Core-hours {note}")
|
|
116
|
+
return lines
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def render_text(conv: Convergence, name: str = "", solver: str | None = None) -> str:
|
|
120
|
+
d = conv.data
|
|
121
|
+
head = " · ".join(x for x in (name, solver, conv.regime or "regime unknown") if x)
|
|
122
|
+
out = [f"Courant convergence · {head}"]
|
|
123
|
+
stop = d.get("converged_at_step")
|
|
124
|
+
lead = {
|
|
125
|
+
PASS: f" PASS the answer stopped changing at step {_int(stop)}",
|
|
126
|
+
WARN: " WARN converged where it could be assessed; see below",
|
|
127
|
+
FAIL: " FAIL the answer did not settle",
|
|
128
|
+
NOT_ASSESSABLE: " NOT ASSESSABLE convergence of the answer could not be judged",
|
|
129
|
+
}[conv.status]
|
|
130
|
+
if conv.status == WARN and stop is not None:
|
|
131
|
+
lead = f" WARN the answer stopped changing at step {_int(stop)}; see below"
|
|
132
|
+
out += [lead, ""]
|
|
133
|
+
lines = five_lines(conv)
|
|
134
|
+
if lines:
|
|
135
|
+
out += [" " + ln for ln in lines] + [""]
|
|
136
|
+
for f in conv.findings:
|
|
137
|
+
if f.severity in (FAIL, WARN) and f.message:
|
|
138
|
+
out.append(f" {f.severity:<4} {f.message}")
|
|
139
|
+
for f in conv.findings:
|
|
140
|
+
if f.code in ("CONV.TRANSIENT_NO_INTENT",) and f.message:
|
|
141
|
+
out.append(f" NOTE {f.message}")
|
|
142
|
+
mons = d.get("monitors") or {}
|
|
143
|
+
if mons:
|
|
144
|
+
if out[-1] != "":
|
|
145
|
+
out.append("")
|
|
146
|
+
out += [f" Monitors ({len(mons)})"]
|
|
147
|
+
width = min(60, max(len(k) for k in mons))
|
|
148
|
+
for k in sorted(mons)[:MAX_ROWS]:
|
|
149
|
+
r = mons[k]
|
|
150
|
+
stop_s = _int(r.get("stop_step")) if r.get("stop_step") is not None else "-"
|
|
151
|
+
flag = "" if r.get("counts") else f" [{(r.get('advisory_reason') or '').lower()}]"
|
|
152
|
+
out.append(f" {k:<{width}} {r.get('verdict', '-'):<29} stop {stop_s:>8} {_change(r)}{flag}")
|
|
153
|
+
if len(mons) > MAX_ROWS:
|
|
154
|
+
out.append(f" … and {len(mons) - MAX_ROWS} more in --json")
|
|
155
|
+
res = d.get("residuals") or {}
|
|
156
|
+
orders = {k: v.get("orders_dropped_floor") for k, v in res.items()
|
|
157
|
+
if v.get("orders_dropped_floor") is not None}
|
|
158
|
+
if orders:
|
|
159
|
+
shown = ", ".join(f"{k} {v}" for k, v in sorted(orders.items()))
|
|
160
|
+
out += ["", f" Residual orders dropped (Celik et al. 2008 ask for 3, prefer 4): {shown}"]
|
|
161
|
+
out += ["", f" {FOOTER}"]
|
|
162
|
+
return "\n".join(out) + "\n"
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def render_markdown(conv: Convergence) -> str:
|
|
166
|
+
"""The convergence section of an evidence report (REP-1, REP-6)."""
|
|
167
|
+
d = conv.data
|
|
168
|
+
out = ["## Convergence", "", f"**Status:** {conv.status} · regime: {conv.regime or 'unknown'}"]
|
|
169
|
+
lines = five_lines(conv)
|
|
170
|
+
if lines:
|
|
171
|
+
out += [""] + [f"- {ln[3:].strip()}" for ln in lines]
|
|
172
|
+
msgs = [f for f in conv.findings if f.severity in (FAIL, WARN) and f.message]
|
|
173
|
+
if msgs:
|
|
174
|
+
out += [""] + [f"- **{f.severity}** `{f.code}`: {f.message}" for f in msgs]
|
|
175
|
+
mons = d.get("monitors") or {}
|
|
176
|
+
if mons:
|
|
177
|
+
out += ["", "| Monitor | Verdict | Stop step | Change after stop |", "|---|---|---|---|"]
|
|
178
|
+
for k in sorted(mons):
|
|
179
|
+
r = mons[k]
|
|
180
|
+
out.append(f"| `{k}` | {r.get('verdict')} | {_int(r.get('stop_step')) if r.get('stop_step') is not None else '-'} | {_change(r)} |")
|
|
181
|
+
out += ["", FOOTER, ""]
|
|
182
|
+
return "\n".join(out)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Tolerances and the reference-scale ladder (TRD CONV-8, M1-C-1 to C-6).
|
|
2
|
+
|
|
3
|
+
Force and moment coefficients are judged in counts: one count is 1e-4 in a coefficient, which
|
|
4
|
+
is a tolerance an aerodynamicist recognises. Everything else is judged relatively, at 1% of a
|
|
5
|
+
reference scale, and the scale is chosen by a ladder whose rung is always recorded.
|
|
6
|
+
|
|
7
|
+
Two stated deviations from M1:
|
|
8
|
+
- **Coefficient names match by prefix** (`^C[dlmsyn]`), not by word boundary, so `CmPitch` and
|
|
9
|
+
`Cd(f)` count as coefficients. Under `\\b` they would have been judged at 1%.
|
|
10
|
+
- **A vector component is measured against its vector's mean magnitude**, before its own
|
|
11
|
+
mean. On the first real run (pitzDaily, a 2-D case) the z-components of the wall force
|
|
12
|
+
were round-off, 1e-21 to 1e-24. Judged against their own means, they were "not converged"
|
|
13
|
+
and "in a limit cycle", which is absurd. A component's tolerance is a share of the force
|
|
14
|
+
it is a component of: for the dominant component the two scales coincide, and for a minor
|
|
15
|
+
one the vector's scale is the meaningful one.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import math
|
|
21
|
+
import re
|
|
22
|
+
from collections.abc import Mapping, Sequence
|
|
23
|
+
from dataclasses import dataclass
|
|
24
|
+
|
|
25
|
+
from courant.converge.exact import mean, variance
|
|
26
|
+
|
|
27
|
+
TOL_ABS_COEFFICIENT = 1.0e-4
|
|
28
|
+
TOL_REL_DEFAULT = 0.01
|
|
29
|
+
|
|
30
|
+
_COEFFICIENT = re.compile(r"^C[dlmsyn]")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def is_coefficient(column: str) -> bool:
|
|
34
|
+
return bool(_COEFFICIENT.match(column)) or "coeff" in column.lower()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass(frozen=True, slots=True)
|
|
38
|
+
class Tolerance:
|
|
39
|
+
branch: str # "absolute" | "relative"
|
|
40
|
+
value: float
|
|
41
|
+
source: str # "default" | "user"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _lookup(table: Mapping[str, float], monitor: str, column: str) -> float | None:
|
|
45
|
+
if monitor in table:
|
|
46
|
+
return table[monitor]
|
|
47
|
+
return table.get(column)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def tolerance(monitor: str, column: str, tol_abs: Mapping[str, float],
|
|
51
|
+
tol_rel: Mapping[str, float]) -> Tolerance:
|
|
52
|
+
"""The criterion for one monitor. Both kinds supplied for one monitor is an error."""
|
|
53
|
+
a = _lookup(tol_abs, monitor, column)
|
|
54
|
+
r = _lookup(tol_rel, monitor, column)
|
|
55
|
+
if a is not None and r is not None:
|
|
56
|
+
raise ValueError(f"both an absolute and a relative tolerance were given for {monitor}")
|
|
57
|
+
if a is not None:
|
|
58
|
+
return Tolerance("absolute", float(a), "user")
|
|
59
|
+
if r is not None:
|
|
60
|
+
return Tolerance("relative", float(r), "user")
|
|
61
|
+
if is_coefficient(column):
|
|
62
|
+
return Tolerance("absolute", TOL_ABS_COEFFICIENT, "default")
|
|
63
|
+
return Tolerance("relative", TOL_REL_DEFAULT, "default")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True, slots=True)
|
|
67
|
+
class Scale:
|
|
68
|
+
value: float | None # None only for the constant rung
|
|
69
|
+
basis: str # user | mean | vector_magnitude | stdev | constant
|
|
70
|
+
mean: float
|
|
71
|
+
stdev: float
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def reference_scale(values: Sequence[float], *, user: float | None = None,
|
|
75
|
+
vector_magnitude: float | None = None) -> Scale:
|
|
76
|
+
"""R_q for one monitor over the values it is judged on."""
|
|
77
|
+
m = mean(values) if values else 0.0
|
|
78
|
+
sd = math.sqrt(variance(values)) if len(values) > 1 else 0.0
|
|
79
|
+
if user is not None and user > 0:
|
|
80
|
+
return Scale(float(user), "user", m, sd)
|
|
81
|
+
if vector_magnitude is not None and vector_magnitude > 0.0:
|
|
82
|
+
return Scale(vector_magnitude, "vector_magnitude", m, sd)
|
|
83
|
+
if abs(m) >= sd and m != 0.0:
|
|
84
|
+
return Scale(abs(m), "mean", m, sd)
|
|
85
|
+
if sd > 0.0:
|
|
86
|
+
return Scale(sd, "stdev", m, sd)
|
|
87
|
+
return Scale(None, "constant", m, sd)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""The fixed sentences of the convergence assessment (TRD CONV-14, M1-O-7).
|
|
2
|
+
|
|
3
|
+
Product surface: rendered character for character, and every numeral in them is a slot
|
|
4
|
+
filled from the assessment's `data` (M1-O-8). M1 wrote them for an allocation-unit pack.
|
|
5
|
+
Where M1 said "allocation figure", these say "waste figure", because the waste figure is
|
|
6
|
+
what this product reports by default. The FIA sentences are kept for `--ccf-ghz`.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
NO_STOPPING_POINT_UNSTEADY = (
|
|
10
|
+
"This run used a steady solver on a flow that is not steady. The monitored quantity is in a "
|
|
11
|
+
"limit cycle of period {period_steps} iterations with a peak-to-peak amplitude of {amplitude}, "
|
|
12
|
+
"which is {amplitude_rel} of the reference scale. There is no fixed point to stop at, so no "
|
|
13
|
+
"stopping point and no waste figure are reported. The mean over {n_periods} complete "
|
|
14
|
+
"cycles is {cycle_mean}; it is an indicative cycle mean and not a converged value.")
|
|
15
|
+
|
|
16
|
+
ITERATION_OSCILLATION = (
|
|
17
|
+
"{monitor} alternates with a period of {lag} iterations, a numerical oscillation of the steady "
|
|
18
|
+
"iteration rather than unsteady flow, with a peak-to-peak amplitude of {amplitude}. Its cycle "
|
|
19
|
+
"mean is {cycle_mean}, and the answer is known only to within {half} of it, which is more "
|
|
20
|
+
"than the tolerance of {tol}. No stopping point is reported.")
|
|
21
|
+
|
|
22
|
+
NOT_CONVERGED = (
|
|
23
|
+
"This run did not reach a fixed point. {monitor} was still moving at the end, by {drift_rel} "
|
|
24
|
+
"of the reference scale across the last {window} samples, against a limit of {tol}. No "
|
|
25
|
+
"stopping point is reported.")
|
|
26
|
+
|
|
27
|
+
NOT_STATIONARY = (
|
|
28
|
+
"After removing the initial transient, the remaining series for {monitor} is not stationary. "
|
|
29
|
+
"{which_failed} No mean, no confidence interval and no stopping point are reported, because a "
|
|
30
|
+
"confidence interval on the mean of a non-stationary series does not describe anything.")
|
|
31
|
+
|
|
32
|
+
INSUFFICIENT_DATA = (
|
|
33
|
+
"There is not enough data to separate the initial transient from the steady state for "
|
|
34
|
+
"{monitor}. {detail} No stopping point is reported. Running longer is the only remedy; there "
|
|
35
|
+
"is no setting that makes a shorter series answer this question.")
|
|
36
|
+
|
|
37
|
+
CORE_HOURS_NOT_COMPUTED = (
|
|
38
|
+
"Core-hours were not computed, because {missing}. Iterations past convergence are reported "
|
|
39
|
+
"above and do not depend on it.")
|
|
40
|
+
|
|
41
|
+
ALLOCATION_NOT_COMPUTED = (
|
|
42
|
+
"Allocation unit hours were not computed, because {missing}. Supply it with {flags} and the "
|
|
43
|
+
"figure will be reported. Wall-clock seconds and core count past convergence are reported "
|
|
44
|
+
"above and do not depend on it.")
|
|
45
|
+
|
|
46
|
+
ALLOCATION_DISCLAIMER = (
|
|
47
|
+
"This allocation figure is computed under the formula in FIA 2026 Sporting Regulations "
|
|
48
|
+
"Section F Article F4.4.4 from the inputs listed above. It is not an FIA determination.")
|
|
49
|
+
|
|
50
|
+
RUN_KILLED = (
|
|
51
|
+
"This run was stopped by a signal at step {last_complete_step}, not by reaching its end "
|
|
52
|
+
"condition. The convergence assessment above covers the samples that were written. No "
|
|
53
|
+
"wall-clock or allocation figure is reported, because time after a kill was not spent.")
|
|
54
|
+
|
|
55
|
+
RUN_CRASHED = (
|
|
56
|
+
"This run ended in a crash at step {last_complete_step}, not by reaching its end condition. "
|
|
57
|
+
"The convergence assessment above covers the samples that were written. No waste figure is "
|
|
58
|
+
"reported, because a run that crashed did not finish the work it was set.")
|
|
59
|
+
|
|
60
|
+
NOT_ASSESSABLE_NO_MONITORS = (
|
|
61
|
+
"No engineering monitor was found in this case, so convergence of the answer could not be "
|
|
62
|
+
"assessed. Residual behaviour is reported below and is not a substitute. The paths searched "
|
|
63
|
+
"were: {paths}.")
|
|
64
|
+
|
|
65
|
+
TRANSIENT_NO_INTENT = (
|
|
66
|
+
"This is a transient run. Whether its answer is a time-average or a trajectory is the "
|
|
67
|
+
"engineer's call, so the statistics below are reported for reference and do not grade the "
|
|
68
|
+
"run. Declare --transient-average to judge time-averaged monitors.")
|
|
69
|
+
|
|
70
|
+
ZERO_MEAN_SCALE = (
|
|
71
|
+
"{monitor} sits at zero within its own variability, so a relative tolerance has no scale to "
|
|
72
|
+
"be relative to. It is not judged. Supply --ref-scale {monitor}=VALUE or an absolute "
|
|
73
|
+
"--tol to judge it.")
|
|
74
|
+
|
|
75
|
+
DECIMATED = (
|
|
76
|
+
"The stopping point was located to a resolution of {step_resolution} steps rather than to a "
|
|
77
|
+
"single step, because the exhaustive search would have exceeded this module's evaluation "
|
|
78
|
+
"budget. The reported stopping point is the later of the two bracketing candidates, so the "
|
|
79
|
+
"reported saving is understated rather than overstated.")
|
|
80
|
+
|
|
81
|
+
#: Every sentence, for the character-for-character test.
|
|
82
|
+
ALL = {k: v for k, v in dict(globals()).items() if k.isupper() and isinstance(v, str)}
|