103def _burn(case: str, overrides=(), **settings: Any) -> Dict[str, Any]:
104 """One LE4 burn as the router runs it: a private copy of the baseline's config, its own runner,
105 diagnostics on, the sidecar kept."""
108 pytest.importorskip(
"feedtwin", reason=
"lib/feedtwin is not installed")
110 from engine.layerx import LayerXSettings, prepare, run_prepared
113 config, _ = lb.load_engine_config(BASELINE)
114 drawing = lb.find_drawing(
"copv_study_he")
115 cfg = copy.deepcopy(config)
116 runner = PintleEngineRunner(cfg)
117 settings.setdefault(
"tank_pressure_psia", lb.STUDY_LOCKUP_PSIA)
118 prep = prepare(cfg, runner, drawing, LayerXSettings(drawing_id=drawing.id, **settings), list(overrides))
119 assert prep.ok, [f
"{c.key}: {c.detail}" for c
in prep.checks
if c.status ==
"fail"]
120 sidecars: Dict[str, Any] = {}
121 t0 = time.perf_counter()
122 result = run_prepared(prep, runner=runner, replay=prep.settings.replay, config=cfg, diagnostics=
True,
124 return {
"result": result,
"prep": prep,
"sidecars": sidecars,
"metrics": lb.metrics(result, prep),
125 "wall_s": time.perf_counter() - t0,
"case": case}
128@pytest.fixture(scope="module")
175 assert set(d) == set(DIAGNOSTIC_KEYS)
176 json.dumps(r, allow_nan=
False)
177 n = len(r[
"series"][
"t"])
178 for name, keys
in CONTRACT.items():
180 assert block.get(
"available",
True)
is not False, (name, block.get(
"error"))
181 missing = [k
for k
in keys
if k
not in block]
182 assert not missing, (name, missing)
183 for k
in FINITE.get(name, ()):
184 assert isinstance(block[k], (int, float))
and math.isfinite(block[k]), (name, k, block[k])
185 for name, keys
in ROWS.items():
187 assert isinstance(rows, list)
and rows, (name, rows)
189 assert row.get(
"available",
True)
is not False, (name, row.get(
"error"))
190 assert not [k
for k
in keys
if k
not in row], (name, [k
for k
in keys
if k
not in row])
193 assert math.isfinite(pr[
"required_kg"])
and math.isfinite(pr[
"margin_kg"])
and pr[
"margin_kg"] > 0
195 assert len(d[
"injector"][
"t"]) == n
and len(d[
"injector"][
"momentum_ratio"]) == n
198 assert len(st[
"t"]) == len(st[
"margin"]) == len(st[
"index"])
199 assert [r[
"series"][
"t"][i]
for i
in st[
"index"]] == st[
"t"]
201 for name
in (
"stability",
"hardware",
"start",
"shutdown",
"vv"):
203 assert m.get(
"name")
and m.get(
"source")
and isinstance(m.get(
"assumptions"), list), name
206 assert st[
"basis"] ==
"drawing" and st[
"other_basis"][
"basis"] ==
"config"
207 assert st[
"other_basis"][
"margin_min"] == pytest.approx(
min(r[
"replay"][
"chug_margin"]), rel=0.02)
308 r = he_trip[
"result"]
310 assert trip[
"vessel"] ==
"FUT" and trip[
"kind"] ==
"tank"
311 assert trip[
"mawp_psia"] == pytest.approx(TRIP_MAWP_PSI + 101325.0 / 6894.757293168361, abs=1e-6)
312 assert 2.5 < trip[
"t"] < r[
"summary"][
"burn_time_s"] + 1e-9 < 3.4
313 s, dv = r[
"summary"], r[
"delivered"][
"summary"]
315 assert s[
"burn_time_s"] == pytest.approx(trip[
"t"], abs=1e-12)
316 assert r[
"series"][
"t"][-1] == pytest.approx(trip[
"t"], abs=1e-12)
317 assert 0.8 * FULL_IMPULSE_NS < s[
"total_impulse_Ns"] < FULL_IMPULSE_NS
318 assert 0.8 * FULL_IMPULSE_NS < dv[
"total_impulse_Ns"] < FULL_IMPULSE_NS
319 assert r[
"delivered"][
"t"][-1] == pytest.approx(trip[
"t"], abs=1e-12)
322 pad = he_pad[
"result"][
"series"]
323 upto = sum(f * dt
for f, dt, on, t
in zip(pad[
"chamber"][
"thrust_N"], pad[
"dt"], pad[
"firing"], pad[
"t"])
324 if on
and t <= trip[
"t"] + 1e-9)
325 assert s[
"total_impulse_Ns"] == pytest.approx(upto, rel=0.01)
326 assert r[
"converged"]
is False and len(r[
"passes"]) == 1
and r[
"passes"][0][
"tripped"]
327 ev = {e[
"key"]: e
for e
in r[
"events"]}
328 assert ev[
"trip"][
"kind"] ==
"fail" and ev[
"trip"][
"t"] == pytest.approx(trip[
"t"])
329 assert not any(e[
"label"]
in (
"Horizon reached",
"Burn did not settle")
for e
in r[
"events"])
330 g = {e[
"key"]: e
for e
in r[
"limits"]}
332 assert g[
"vessel_trip"][
"grade"] ==
"bad" and g[
"tank_mawp_fuel"][
"grade"] ==
"info"
333 for name, block
in r[
"diagnostics"].items():
334 rows = block
if isinstance(block, list)
else [block]
335 assert all(row.get(
"available",
True)
is not False for row
in rows), (name, rows[0].get(
"error"))
336 assert len(r[
"network"][
"t"]) == len(r[
"series"][
"t"])