STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_cd_lichtarowicz_re.py
Go to the documentation of this file.
1"""Cd(Re) of a drilled orifice follows Lichtarowicz, Duggins & Markland (1965).
2
3J. Mech. Eng. Sci. 7(2):210-219, sharp-inlet long orifice, non-cavitating, 2 <= L/d <= 10:
4
5 1/Cd = 1/Cd_u + 20 (1 + 2.25 L/d)/Re - 0.0015 (L/d) / (1 + 7.5 [log10(0.00015 Re)]^2)
6 Cd_u = 0.827 - 0.0085 L/d
7
8The module anchors Cd_u to its inlet table (sharp 0.80 at the fit's L/d 3.18), which for a sharp
9inlet reproduces the published Cd_u exactly; that is what the expected values below use. The old
10law, Cd_inf - a_Re / sqrt(Re) with an unsourced a_Re = 0.18, sat ~0.06 high at Re 2e3.
11
12Expected values are computed here from the paper's expression, not from the module.
13"""
14from __future__ import annotations
15
16import math
17
18import pytest
19
20from engine.core.discharge import cd_from_re
21from engine.pipeline.config_schemas import DischargeConfig
22
23
24def _paper(Re: float, lod: float) -> float:
25 cd_u = 0.827 - 0.0085 * lod
26 inv = 1.0 / cd_u + 20.0 * (1.0 + 2.25 * lod) / Re \
27 - 0.0015 * lod / (1.0 + 7.5 * math.log10(0.00015 * Re) ** 2)
28 return 1.0 / inv
29
30
31def _sharp(lod: float, **kw) -> DischargeConfig:
32 return DischargeConfig(Cd_inf=0.60, a_Re=0.18, Cd_min=0.2, inlet_geometry="sharp",
33 orifice_l_over_d=lod, **kw)
34
35
36@pytest.mark.parametrize("lod", [2.0, 3.0, 4.0, 6.0, 10.0])
37@pytest.mark.parametrize("Re", [1.0e3, 3.0e3, 1.0e4, 5.0e4, 2.0e5, 1.0e6])
38def test_matches_paper(Re, lod):
39 got = cd_from_re(Re, _sharp(lod), d_hyd_m=1.5e-3)
40 # The paper's expression can exceed Cd_u at very high Re and long L/d (its last term);
41 # the module clamps at Cd_u, which is the only difference allowed.
42 want = min(_paper(Re, lod), 0.827 - 0.0085 * lod)
43 assert got == pytest.approx(want, rel=1e-12, abs=1e-12)
44
45
46@pytest.mark.parametrize("Re, want", [(3.1e5, 0.7928), (3.4e4, 0.7901), (1.0e4, 0.784), (2.0e3, 0.736)])
48 assert cd_from_re(Re, _sharp(4.0)) == pytest.approx(want, abs=0.002)
49
50
52 c = _sharp(4.0, length_model="piecewise")
53 cd_inf = 0.80 # sharp, piecewise factor 1.0 at L/d 4
54 assert cd_from_re(1.0e4, c) == pytest.approx(cd_inf - 0.18 / 100.0, rel=1e-12)
55
56
58 c = DischargeConfig(Cd_inf=0.60, a_Re=0.18, use_geometry_cd=False, orifice_l_over_d=4.0)
59 assert cd_from_re(1.0e4, c) == pytest.approx(0.60 - 0.18 / 100.0, rel=1e-12)
#define min(a, b)
Definition Arduino.h:42
DischargeConfig _sharp(float lod, **kw)
float _paper(float Re, float lod)