STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_closure_keeps_cd.py
Go to the documentation of this file.
1"""The impinging closure never touches Cd, whatever solver.closure.Cd_reduction_factor says.
2
3configs/default.yaml (the template every new session loads) and 13 other configs still carry
4Cd_reduction_factor 0.95. With the spray constraints violated -- the 6500N's x* is 54 mm against
5its 50 mm limit -- the closure multiplied Cd by 0.95 up to six times: Cd_O 0.80 -> 0.62, F -12 %,
6and x* got WORSE (lower Cd, slower jets, bigger drops). Cd is orifice geometry and Reynolds
7number (Lichtarowicz 1965; SP-8089); an x* or We violation is reported, not "fixed".
8
9The expected Cd is the published sharp-inlet short-tube fit at the hole's L/d, less the Re term.
10"""
11from __future__ import annotations
12
13from pathlib import Path
14
15import pytest
16
17ROOT = Path(__file__).resolve().parents[1]
18PSI = 6894.757
19
20
21@pytest.fixture(autouse=True, scope="module")
23 """The authoritative Python path; engine/accel mirrors it and test_numba_ab_parity holds the
24 two together."""
25 from engine import accel
26 real = accel.enabled, accel.require
27 accel.enabled = lambda: False
28 accel.require = lambda: False
29 try:
30 yield
31 finally:
32 accel.enabled, accel.require = real
33
34
35def _evaluate(factor):
36 from engine.pipeline.io import load_config
37 from engine.pipeline.config_schemas import PintleEngineConfig
38 from engine.core.runner import PintleEngineRunner
39 d = load_config(str(ROOT / "configs/ethalox_6500N.yaml")).model_dump()
40 d["solver"]["closure"]["Cd_reduction_factor"] = factor
41 cfg = PintleEngineConfig.model_validate(d)
42 P = 584.2669657943025 * PSI
43 return PintleEngineRunner(cfg).evaluate(P_tank_O=P, P_tank_F=P)
44
45
47 r95, r1 = _evaluate(0.95), _evaluate(1.0)
48 d95 = r95["diagnostics"]
49 assert d95["constraints_satisfied"] is False, "the 6500N's x* is over its limit; the case needs a violation"
50 lod = 4.0
51 assert d95["Cd_O"] == pytest.approx(0.827 - 0.0085 * lod, abs=2e-3)
52 assert d95["Cd_O"] == pytest.approx(r1["diagnostics"]["Cd_O"], rel=1e-9)
53 assert r95["F"] == pytest.approx(r1["F"], rel=1e-9)
54
55
57 from engine.pipeline import assumptions
58 with assumptions.scope() as used:
59 _evaluate(0.95)
60 assert "solver.closure.Cd_reduction_factor" in used, used