STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_tank_fields.py
Go to the documentation of this file.
1"""The tank columns a burn records, and the liquid surface among them.
2
3A saturation margin at the tank is the tank pressure against the vapour pressure
4of the liquid the ullage touches. With stratification on that is the surface
5layer, not the bulk, and the trace has to carry it (EngineDesign/docs/layerx/
6AUDIT.md 5.4). Off, the surface *is* the bulk, and the column says so exactly.
7"""
8
9from __future__ import annotations
10
11import json
12from pathlib import Path
13
14import pytest
15
16from feedtwin.pid import read_diagram
17from feedtwin.session import assemble_model, load_machine
18from feedtwin.session.burn import TANK_FIELDS, BurnPlan, burn_setup, open_session
19from feedtwin.session.burn import run_burn
20
21STAR = Path(__file__).resolve().parents[3]
22STAND = STAR / "feed-twin" / "backend" / "diagrams" / "ethalox_stand.json"
23TABLES = STAR / "feed-twin" / "backend" / "statemachines"
24
25pytestmark = pytest.mark.skipif(
26 not (STAND.exists() and TABLES.is_dir()), reason="stand drawing or tables absent"
27)
28
29PLAN = BurnPlan(tank_psi=550.0, settle=False, lead_in_s=0.5, horizon_s=0.0)
30
31
32def _trace(**setup): # type: ignore[no-untyped-def]
33 model = assemble_model(
34 read_diagram(json.loads(STAND.read_text()), name="ethalox_stand"),
35 diagram_id="ethalox_stand.json",
36 )
37 session = open_session(
38 model, load_machine(tables=TABLES), setup=burn_setup(**setup)
39 )
40 return session, run_burn(session, PLAN)
41
42
44 assert "surface_temperature_K" in TANK_FIELDS
45 session, trace = _trace()
46 for tank, columns in trace.tank.items():
47 assert len(columns["surface_temperature_K"]) == len(trace.t)
48 # Stratification off (the burn's setting): the surface is the bulk.
49 assert columns["surface_temperature_K"] == columns["liquid_temperature_K"]
50
51
53 session, trace = _trace(stratification=True)
54 for tank, sim in session.tanks.items():
55 column = trace.tank[tank]["surface_temperature_K"]
56 assert sim.state.surface_temperature is not None
57 assert column[-1] == sim.state.surface_temperature
58 # LOX over the hold: the layer the ullage sees and the saturation margin it
59 # sets, p_tank - p_sat(T_surface), computable from the trace alone.
60 lox = session.tanks["OXT"]
61 T_surface = trace.tank["OXT"]["surface_temperature_K"][-1]
62 # The leak and the warm pressurant warm the layer, not the bulk.
63 assert T_surface > trace.tank["OXT"]["liquid_temperature_K"][-1] + 0.01
64 p_sat = lox.tank.liquid.get("p", T=T_surface, q=0.0)
65 margin = trace.tank["OXT"]["pressure_Pa"][-1] - p_sat
66 assert margin > 0.0
None test_with_stratification_on_it_is_the_layer()
None test_the_surface_temperature_is_recorded()