STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_spray_property_transfer.py
Go to the documentation of this file.
1"""TN 4222 property transfer as a named model, loud failure on degenerate spray inputs, and the
2accelerator gate for the transfer the kernel does not mirror."""
3from __future__ import annotations
4
5import copy
6import math
7
8import pytest
9
10from engine.core import spray
11from engine.core.spray import (
12 TN4222_HEPTANE_MU, TN4222_HEPTANE_RHO, TN4222_HEPTANE_SIGMA, TN4222_RHO_AIR,
13 smd_impinging_tn4222, smd_lefebvre, tn4222_property_factor, tn4222_transfer_model,
14)
15
16ETH = dict(rho_liq=789.0, mu_liq=1.2e-3, sigma=0.0223, rho_gas=2.2)
17
18
20 tn = tn4222_property_factor("tn4087", **ETH)
21 by_hand = ((0.0223 * 1.2e-3 / 789.0) / (TN4222_HEPTANE_SIGMA * TN4222_HEPTANE_MU / TN4222_HEPTANE_RHO)) ** 0.25 \
22 * (2.2 / TN4222_RHO_AIR) ** -0.25
23 assert tn == pytest.approx(by_hand, rel=1e-12)
24 dj = tn4222_property_factor("dombrowski_johns", **ETH)
25 by_hand = ((0.0223 ** 2 / (2.2 * 789.0)) / (TN4222_HEPTANE_SIGMA ** 2 / (TN4222_RHO_AIR * TN4222_HEPTANE_RHO))) ** (1 / 6)
26 assert dj == pytest.approx(by_hand, rel=1e-12)
27 assert tn4222_property_factor("none", **ETH) == 1.0
28 # heptane in TN 4222's air is the reference for every transfer
29 ref = dict(rho_liq=TN4222_HEPTANE_RHO, mu_liq=TN4222_HEPTANE_MU, sigma=TN4222_HEPTANE_SIGMA,
30 rho_gas=TN4222_RHO_AIR)
31 for t in spray.TN4222_PROPERTY_TRANSFERS:
32 assert tn4222_property_factor(t, **ref) == pytest.approx(1.0, rel=1e-12)
33
34
36 from engine.pipeline.config_schemas import SMDConfig
37 smd = SMDConfig()
38 assert tn4222_transfer_model(smd) == "tn4087"
39 assert tn4222_transfer_model(SMDConfig(smd_property_scaling=False)) == "none"
40 assert tn4222_transfer_model(SMDConfig(smd_property_transfer="dombrowski_johns")) == "dombrowski_johns"
41 a = smd_impinging_tn4222(1.5e-3, 30.0, **{k: ETH[k] for k in ("rho_liq", "mu_liq", "sigma", "rho_gas")})
42 b = smd_impinging_tn4222(1.5e-3, 30.0, **ETH, transfer="tn4087")
43 c = smd_impinging_tn4222(1.5e-3, 30.0, **ETH, transfer="dombrowski_johns")
44 assert a == b and c == pytest.approx(a / tn4222_property_factor("tn4087", **ETH)
45 * tn4222_property_factor("dombrowski_johns", **ETH), rel=1e-12)
46
47
48@pytest.mark.parametrize("bad", [dict(v_jet=0.0), dict(d_jet=-1e-3), dict(rho_gas=float("nan")),
49 dict(sigma=0.0)])
51 kw = dict(d_jet=1.5e-3, v_jet=30.0, **ETH)
52 kw.update(bad)
53 with pytest.raises(ValueError):
54 smd_impinging_tn4222(**kw)
55
56
57@pytest.mark.parametrize("We,d", [(0.0, 1e-3), (100.0, 0.0), (float("inf"), 1e-3)])
59 with pytest.raises(ValueError):
60 smd_lefebvre(d, We, 0.01, 0.5, 0.6, 0.0)
61
62
64 from engine import accel
65 from engine.pipeline.io import load_config
66 cfg = load_config("configs/impinging_smoke.yaml")
67 assert accel.can_handle(cfg) # a config the kernel takes
68 none = copy.deepcopy(cfg)
69 none.spray.smd.smd_property_transfer = "none"
70 dj = copy.deepcopy(cfg)
71 dj.spray.smd.smd_property_transfer = "dombrowski_johns"
72 assert accel.can_handle(cfg) == accel.can_handle(none) # mirrored by kernels._tn4222
73 assert accel.can_handle(dj) is False