37MOODY = [(1.0e5, 0.0, 0.0180), (1.0e6, 1.0e-4, 0.0134), (1.0e4, 1.0e-3, 0.0324)]
48 """The no-fluids fallback solves the same equation to machine precision."""
49 fr = pytest.importorskip(
"fluids.friction")
50 assert colebrook_darcy(Re, eD) == pytest.approx(fr.Colebrook(Re, eD), rel=1e-12)
51 assert darcy_friction_factor(Re, eD) == pytest.approx(fr.Colebrook(Re, eD), rel=1e-12)
66 fit = [{
"name":
"1/2 in full-bore ball valve",
"K": 0.081,
"source":
"Crane TP-410, 3 f_T"},
67 {
"name":
"90 deg tube bend r/d 3",
"K": 0.324,
"source":
"Crane TP-410, 12 f_T"}]
68 cfg =
_fuel(fittings=fit)
69 dp = delta_p_feed(1.118, 789.0, cfg, 4.0e6)
70 assert dp == pytest.approx((2.019 + 0.081 + 0.324 + 1.0) *
_q(1.118, 789.0, A_TUBE), rel=1e-12)
72 cfg =
_fuel(fittings=fit, K1=1e-4, phi_type=
"sqrtP")
73 dp = delta_p_feed(1.118, 789.0, cfg, 4.0e6)
74 K = 2.019 + 0.405 + 1e-4 * math.sqrt(4.0e6)
75 assert dp == pytest.approx((K + 1.0) *
_q(1.118, 789.0, A_TUBE), rel=1e-12)
86 mdot, rho, mu = 1.118, 789.0, 1.2e-3
87 fit = [{
"name":
"ball valve",
"K": 0.081,
"source":
"Crane TP-410, 3 f_T"}]
88 cfg =
_fuel(roughness_m=EPS_DRAWN_SS, fittings=fit)
89 v = mdot / (rho * A_TUBE)
90 Re = rho * v * D_TUBE / mu
91 fr = pytest.importorskip(
"fluids.friction")
92 f = fr.Colebrook(Re, EPS_DRAWN_SS / D_TUBE)
93 K = 0.5 + f * 0.9144 / D_TUBE + 0.081
94 assert delta_p_feed(mdot, rho, cfg, 4.0e6, mu=mu) == pytest.approx((K + 1.0) *
_q(mdot, rho, A_TUBE), rel=1e-12)
96 f2 = fr.Colebrook(Re / 2, EPS_DRAWN_SS / D_TUBE)
97 K2 = 0.5 + f2 * 0.9144 / D_TUBE + 0.081
99 assert delta_p_feed(mdot / 2, rho, cfg, 4.0e6, mu=mu) == pytest.approx((K2 + 1.0) *
_q(mdot / 2, rho, A_TUBE), rel=1e-12)
101 cfg =
_fuel(roughness_m=EPS_DRAWN_SS, K_entrance=0.04)
102 K3 = 0.04 + f * 0.9144 / D_TUBE
103 assert delta_p_feed(mdot, rho, cfg, 4.0e6, mu=mu) == pytest.approx((K3 + 1.0) *
_q(mdot, rho, A_TUBE), rel=1e-12)
117 """ethalox_6500N declares neither fittings nor roughness_m: old formula to 1e-12, with or
118 without a viscosity passed."""
120 config = load_config(str(ROOT /
"configs/ethalox_6500N.yaml"))
121 for side, mdot
in ((
"oxidizer", 1.68), (
"fuel", 1.118)):
122 cfg = config.feed_system[side]
123 assert cfg.fittings == []
and cfg.roughness_m
is None
124 rho, mu = config.fluids[side].density, config.fluids[side].viscosity
126 Ax = math.pi * (cfg.d_exit / 2) ** 2
if cfg.d_exit
else A
127 for P
in (3.0e6, 4.0e6):
128 want = cfg.K0 *
_q(mdot, rho, A) + cfg.K_exit *
_q(mdot, rho, Ax)
129 assert delta_p_feed(mdot, rho, cfg, P, mu=mu) == pytest.approx(want, rel=1e-12)
130 assert delta_p_feed(mdot, rho, cfg, P, mu=mu) == delta_p_feed(mdot, rho, cfg, P)
152 """params._feed folds the fittings into K0; the injector solve must still be Python's."""
154 from engine
import accel
158 load_config(str(ROOT / KERNEL_CFG)),
159 oxidizer={
"fittings": [{
"name":
"LOX main solenoid",
"K": 3.0,
"source":
"test value"}]},
160 fuel={
"fittings": [{
"name":
"fuel main solenoid",
"K": 2.5,
"source":
"test value"},
161 {
"name":
"tee, run",
"K": 0.4,
"source":
"test value"}]},
163 assert accel.can_handle(config)
164 model = get_injector_model(config)
165 P = 584.27 * PSI_TO_PA
166 for Pc
in (2.0e6, 2.6e6):
167 got = accel.solve(config, P, P, Pc)
168 assert got
is not None
169 mO, mF, want = model.solve(P, P, Pc)
170 for name, g, w
in ((
"mdot_O", got[0], mO), (
"mdot_F", got[1], mF),
171 (
"dpf_O", got[2][
"delta_p_feed_O"], want[
"delta_p_feed_O"]),
172 (
"dpf_F", got[2][
"delta_p_feed_F"], want[
"delta_p_feed_F"])):
173 assert g == pytest.approx(w, rel=1e-9), name