STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_dew_line.py
Go to the documentation of this file.
1"""A gas node the enthalpy walk lands on its own saturation line.
2
3Venting nitrogen off a chilled LOX tank throttled it down to 77.87 K at
4107.6 kPa -- nitrogen's boiling point there. The walk solved T(p, h) to exactly
5that, the next solve asked for the line's properties at (p, T) on the
6saturation curve, the property layer refused (liquid or vapour is not said),
7and every solve failed on its first evaluation: 328 ticks of a stand that did
8not move, in Vent, on LE4 (6) with the cart drawn (2026-10-12).
9"""
10
11from __future__ import annotations
12
13from types import SimpleNamespace
14
15import pytest
16
17from feedtwin.props import Fluid, PropertyError
18from feedtwin.session.core import _DEW_MARGIN_K, Session
19
20N2 = Fluid("nitrogen")
21P = 107613.0
22
23
24def _land(quality: float) -> tuple[float, float, list[str]]:
25 h = N2.get("h", p=P, q=quality)
26 landed = N2.get("T", p=P, h=h)
27 holder = SimpleNamespace(assumptions=[])
28 held = Session._off_the_dew_line(holder, N2, P, h, landed, "n") # type: ignore[arg-type]
29 return landed, held, holder.assumptions
30
31
33 """The hazard: on the saturation curve a (p, T) state is not a state."""
34 on_the_line = N2.get("T", p=P, q=1.0)
35 with pytest.raises(PropertyError):
36 N2.get("rho", p=P, T=on_the_line)
37
38
40 landed, held, notes = _land(0.9)
41 dew = N2.get("T", p=P, q=1.0)
42 assert landed == pytest.approx(dew, abs=1e-6), "the walk lands on the line"
43 assert held == pytest.approx(dew + _DEW_MARGIN_K)
44 assert N2.get("rho", p=P, T=held) < 10.0, "a vapour, and one the layer serves"
45 assert len(notes) == 1
46
47
49 landed, held, notes = _land(0.1)
50 assert held == landed and not notes
51 h_warm = N2.get("h", p=P, T=150.0)
52 holder = SimpleNamespace(assumptions=[])
53 assert Session._off_the_dew_line(holder, N2, P, h_warm, 150.0, "n") == 150.0 # type: ignore[arg-type]
54 assert not holder.assumptions
55
56
58 """The same state reached another way -- a chilled LOX tank's nitrogen
59 ullage at 2.72 bar and 86.83 K, seeding its press line (Ethalox Stand,
60 13 s of failed solves in Vent)."""
61 from feedtwin.comps.elements import DEW_POINT_MARGIN_K, conditions_from_fluid
62
63 p = 271961.0
64 on_the_line = N2.get("T", p=p, q=1.0)
65 conditions = conditions_from_fluid(N2, p, on_the_line, phase="gas")
66 assert conditions.temperature == pytest.approx(on_the_line + DEW_POINT_MARGIN_K)
67 assert conditions.rho == pytest.approx(N2.get("rho", p=p, q=1.0), rel=0.01)
68 warm = conditions_from_fluid(N2, p, 150.0, phase="gas")
69 assert warm.temperature == 150.0
None test_the_line_itself_is_refused()
None test_a_flashing_liquid_and_a_dry_gas_are_left_alone()
None test_a_gas_line_on_its_dew_point_is_priced_as_vapour()
tuple[float, float, list[str]] _land(float quality)
None test_a_mostly_vapour_landing_is_held_as_vapour_off_the_line()