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
3
J. 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
8
The module anchors Cd_u to its inlet table (sharp 0.80 at the fit's L/d 3.18), which for a sharp
9
inlet reproduces the published Cd_u exactly; that is what the expected values below use. The old
10
law, Cd_inf - a_Re / sqrt(Re) with an unsourced a_Re = 0.18, sat ~0.06 high at Re 2e3.
11
12
Expected values are computed here from the paper's expression, not from the module.
13
"""
14
from
__future__
import
annotations
15
16
import
math
17
18
import
pytest
19
20
from
engine.core.discharge
import
cd_from_re
21
from
engine.pipeline.config_schemas
import
DischargeConfig
22
23
24
def
_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
31
def
_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])
38
def
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)])
47
def
test_audit_magnitudes_ld4
(Re, want):
48
assert
cd_from_re(Re,
_sharp
(4.0)) == pytest.approx(want, abs=0.002)
49
50
51
def
test_piecewise_keeps_legacy_a_re
():
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
57
def
test_no_inlet_keeps_legacy_a_re
():
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)
min
#define min(a, b)
Definition
Arduino.h:42
engine.pipeline.config_schemas.DischargeConfig
Definition
config_schemas.py:694
engine.core.discharge
Definition
discharge.py:1
engine.pipeline.config_schemas
Definition
config_schemas.py:1
test_cd_lichtarowicz_re.test_matches_paper
test_matches_paper(Re, lod)
Definition
test_cd_lichtarowicz_re.py:38
test_cd_lichtarowicz_re._sharp
DischargeConfig _sharp(float lod, **kw)
Definition
test_cd_lichtarowicz_re.py:31
test_cd_lichtarowicz_re._paper
float _paper(float Re, float lod)
Definition
test_cd_lichtarowicz_re.py:24
test_cd_lichtarowicz_re.test_audit_magnitudes_ld4
test_audit_magnitudes_ld4(Re, want)
Definition
test_cd_lichtarowicz_re.py:47
test_cd_lichtarowicz_re.test_no_inlet_keeps_legacy_a_re
test_no_inlet_keeps_legacy_a_re()
Definition
test_cd_lichtarowicz_re.py:57
test_cd_lichtarowicz_re.test_piecewise_keeps_legacy_a_re
test_piecewise_keeps_legacy_a_re()
Definition
test_cd_lichtarowicz_re.py:51
EngineDesign
tests
test_cd_lichtarowicz_re.py
Generated by
1.15.0