STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_impinging_feed_orifice_closure.py
Go to the documentation of this file.
1"""Feed loss ⇄ Bernoulli fixed point for impinging injector."""
2
3import unittest
4from pathlib import Path
5
6import numpy as np
7
8from engine.pipeline.io import load_config
9from engine.core.injectors.impinging import ImpingingInjector
10
11ROOT = Path(__file__).resolve().parents[1]
12
13
14class TestImpingingFeedOrificeClosure(unittest.TestCase):
16 """Regression: returned ṁ must satisfy ṁ = Cd A √(2 ρ Δp_inj) for final diagnostics."""
17 cfg = load_config(str(ROOT / "configs" / "impinging_smoke.yaml"))
18 Pc = 1.55e6
19 Po = float(cfg.lox_tank.initial_pressure_psi) * 6894.76
20 Pf = float(cfg.fuel_tank.initial_pressure_psi) * 6894.76
21
22 mdot_O, mdot_F, diag = ImpingingInjector(cfg).solve(Po, Pf, Pc)
23 self.assertGreater(mdot_O + mdot_F, 0.0)
24
25 rho_O = cfg.fluids["oxidizer"].density
26 rho_F = cfg.fluids["fuel"].density
27 geo = cfg.injector.geometry
28 A_O = geo.oxidizer.n_elements * np.pi * (geo.oxidizer.d_jet / 2.0) ** 2
29 A_F = geo.fuel.n_elements * np.pi * (geo.fuel.d_jet / 2.0) ** 2
30
31 dpi_O = diag["delta_p_injector_O"]
32 dpi_F = diag["delta_p_injector_F"]
33 Cd_O = diag["Cd_O"]
34 Cd_F = diag["Cd_F"]
35
36 expect_O = float(Cd_O * A_O * np.sqrt(2.0 * rho_O * dpi_O)) if dpi_O > 0 else 0.0
37 expect_F = float(Cd_F * A_F * np.sqrt(2.0 * rho_F * dpi_F)) if dpi_F > 0 else 0.0
38
39 # The reported mdot_from_bernoulli_* is, by construction, exactly Cd·A·√(2ρΔp).
40 np.testing.assert_allclose(diag["mdot_from_bernoulli_O"], expect_O, rtol=1e-14, atol=1e-12)
41 np.testing.assert_allclose(diag["mdot_from_bernoulli_F"], expect_F, rtol=1e-14, atol=1e-12)
42 # The RETURNED mdot is the feed-orifice coupled fixed point (Cd depends on Re depends on
43 # mdot), which converges to the closure tolerance (solver.closure.tolerance, ~1e-4), not to
44 # machine precision. So it equals the Bernoulli form only to that tolerance.
45 closure_tol = float(getattr(cfg.solver.closure, "tolerance", 1e-4) or 1e-4)
46 np.testing.assert_allclose(mdot_O, expect_O, rtol=max(closure_tol, 1e-5), atol=1e-9)
47 np.testing.assert_allclose(mdot_F, expect_F, rtol=max(closure_tol, 1e-5), atol=1e-9)
48 self.assertGreater(diag["feed_orifice_coupling_iterations"], 0)
49
50
51if __name__ == "__main__":
52 unittest.main()
#define max(a, b)
Definition Arduino.h:43