STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_body_acceleration.py
Go to the documentation of this file.
1"""Liquid columns feel the vehicle's acceleration, not standard gravity.
2
3On a stand every head is ``rho * g0 * dz``. In flight the column feels the
4proper acceleration along the vehicle axis -- thrust less drag over mass, what
5an accelerometer reads -- which is ~7 g on the 6.8 kN vehicle at burnout. The
6heads are arithmetic, so the checks are by hand. The default is standard
7gravity, and a session that does not set it runs exactly as it did.
8"""
9
10from __future__ import annotations
11
12import json
13from pathlib import Path
14
15import pytest
16
17from feedtwin.comps import FlowConditions, build_component
18from feedtwin.model import ComponentInstance, Param, Provenance
19from feedtwin.pid import read_diagram
20from feedtwin.session import Setup, assemble_model, load_machine
21from feedtwin.session.burn import burn_setup, open_session
22from feedtwin.solve.network import Network
23from feedtwin.vessels.volume import GRAVITY
24
25M = Provenance.MANUFACTURER
26STAR = Path(__file__).resolve().parents[3]
27STAND = STAR / "feed-twin" / "backend" / "diagrams" / "ethalox_stand.json"
28TABLES = STAR / "feed-twin" / "backend" / "statemachines"
29needs_stand = pytest.mark.skipif(
30 not (STAND.exists() and TABLES.is_dir()), reason="stand drawing or tables absent"
31)
32
33#: Seven standard gravities, the order of the vehicle's acceleration at burnout.
34SEVEN_G = 7.0 * 9.80665
35
36
38 assert GRAVITY == 9.80665
39 assert Setup().body_acceleration == GRAVITY
40 assert FlowConditions(rho=1.0, mu=1.0, p_upstream=1.0).gravity == GRAVITY
41 assert Network().gravity == GRAVITY
42
43
45 climb = 2.5
46 line = build_component(
47 ComponentInstance.build(
48 "FL-01",
49 "pipe",
50 {
51 "length": Param(3.0, "m", M, "test"),
52 "bore": Param(10.0, "mm", M, "test"),
53 "elevation_change": Param(climb, "m", M, "test"),
54 },
55 )
56 )
57 flow = FlowConditions(rho=789.0, mu=1.1e-3, p_upstream=4.0e6, gravity=SEVEN_G)
58 assert line.static_head(flow) == pytest.approx(789.0 * SEVEN_G * climb, rel=1e-12)
59
60
61@needs_stand
63 def session(setup: Setup): # type: ignore[no-untyped-def]
64 diagram = read_diagram(json.loads(STAND.read_text()), name="ethalox_stand")
65 model = assemble_model(diagram, diagram_id="ethalox_stand.json")
66 s = open_session(model, load_machine(tables=TABLES), setup=setup)
67 s.prime(tank_psi=500.0, copv_psi=4500.0)
68 s.step(0.02)
69 return s
70
71 flying = session(burn_setup(body_acceleration=SEVEN_G))
72 net = flying.model.built.network
73 assert net.gravity == SEVEN_G
74 # What every line's static head is computed with: the conditions the network hands out.
75 node = next(iter(net.nodes))
76 assert net.conditions(node, 1.0e6).gravity == SEVEN_G
77 for sim in flying.tanks.values():
78 rho = sim.tank.liquid_density(sim.state)
79 level = sim.tank.level(sim.state)
80 assert level > 0.05
81 assert sim.outlet_pressure - sim.pressure == pytest.approx(
82 rho * SEVEN_G * level, rel=1e-12
83 )
84
85 standing = session(burn_setup())
86 assert standing.model.built.network.gravity == GRAVITY
87 for sim in standing.tanks.values():
88 rho = sim.tank.liquid_density(sim.state)
89 level = sim.tank.level(sim.state)
90 assert sim.outlet_pressure - sim.pressure == pytest.approx(
91 rho * GRAVITY * level, rel=1e-12
92 )
None test_a_session_puts_its_acceleration_on_every_column()