46def _flow(tank_psia: float, drawn_with_the_flow: bool, part: object) -> float:
47 """A gas tank to atmosphere through one component, drawn either way.
48 Returned as the flow out of the tank."""
50 net.add_node(
"tank",
"nitrogen", 293.0, pressure=tank_psia * PSI)
51 net.add_node(
"atm",
"nitrogen", 293.0, pressure=14.7 * PSI)
52 for node
in net.nodes.values():
54 if drawn_with_the_flow:
55 net.add_branch(
"X", part,
"tank",
"atm")
57 net.add_branch(
"X", part,
"atm",
"tank")
58 result = solve_steady(net)
59 assert result.converged
60 return result.flows[
"X"]
if drawn_with_the_flow
else -result.flows[
"X"]
63@pytest.mark.parametrize("tank_psia", [30.0, 100.0, 500.0, 3000.0])
72 """3000 psia to atmosphere is far past the critical ratio either way."""
74 net.add_node(
"tank",
"nitrogen", 293.0, pressure=3000.0 * PSI)
75 net.add_node(
"atm",
"nitrogen", 293.0, pressure=14.7 * PSI)
76 for node
in net.nodes.values():
79 net.add_branch(
"X", valve,
"atm",
"tank")
80 result = solve_steady(net)
81 assert result.converged
82 ceiling = valve.flow_ceiling(net.conditions(
"tank", 3000.0 * PSI))
83 assert result.flows[
"X"] == pytest.approx(-ceiling, rel=1e-6)
84 assert result.choked_branches == [
"X"]