STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
engine.layerx.diag.waterhammer Namespace Reference

Classes

class  Pipeline
class  HammerSettings

Functions

float wave_speed (float a_fluid, float rho, float bore, float wall, float E=E_316_PA, float c1=1.0)
float joukowsky (float rho, float a, float dv)
float michaud (float rho, float length, float v0, float closure_s, float a)
float _solve_boundary (float R, float B, float rhs)
Dict[str, Any] moc (Pipeline pipe, *, float t_end, int n_reaches=16, Optional[Callable[[float], float]] valve_R=None, Optional[Callable[[float], float]] valve_flow=None, Optional[float] R_down0=None)
Dict[str, float] opening_surge (*, float p_front, float pc, float mdot_arrival, float phi, float B)
List[Dict[str, Any]] waterhammer_from_run (Any prep, Mapping[str, Any] result, Any config=None, HammerSettings settings=HammerSettings(), Optional[Mapping[str, Any]] start=None)
Dict[str, Any] _row (Any prep, Mapping[str, Any] result, str side, str key, HammerSettings settings, Optional[Mapping[str, Any]] start)

Variables

str MODEL_NAME = "water_hammer_moc"
float E_316_PA = 193.0e9
tuple E_316_SOURCE

Detailed Description

Layer X water hammer: the pressure a main valve's closing (and the start's arrival) puts on each
liquid line, against the ratings on the drawing.

``waterhammer_from_run(prep, result, config=None, settings=HammerSettings(), start=None)``
-> ``diagnostics.water_hammer`` (a list, one row per liquid feed line; DATA-CONTRACT 3).

Three numbers per line, each with its source:

* **Joukowsky** (Joukowsky 1898): an instantaneous stop of a column moving at ``v0`` raises the
  pressure at the valve by ``dp = rho a v0``. The upper bound for any closure faster than the
  line's round trip ``2L/a``.
* **Slow closure** (Michaud's formula; J. Michaud, "Coups de bélier dans les conduites", Bull. Soc.
  Vaud. Ing. Arch., 1878): a closure that brings the velocity down linearly over
  ``t_c > 2L/a`` raises it by ``2 rho L v0 / t_c`` at most: each part of the velocity change sends a
  ``rho a dv`` wave up the line, and the tank's reflection cancels it after ``2L/a``, so the peak is
  ``rho a (v0/t_c)(2L/a)``. Checked here against the MOC with a prescribed linear-velocity closure
  (tests/test_layerx_transients.py), not against a book's printed equation.
* **The closure as drawn**, by the method of characteristics on the reservoir-pipe-valve system
  (Wylie & Streeter 1993, the MOC for a single pipeline with a reservoir upstream and a valve
  downstream): the tank holds its pressure behind the outlet loss; the pipe has the drawing's bore,
  length and friction; the main valve closes linearly in travel over ``closure_s`` along its own Cv
  characteristic, in series with the downstream line and the injector, quasi-steady, discharging
  into the chamber held at its pre-closure pressure. A linear-*travel* closure does most of its
  velocity change at the end of the stroke, so it can exceed Michaud's linear-*velocity* figure;
  in a line this short (no line packing) its first wave does not exceed Joukowsky. The MOC's step
  is ``L/(N a)`` with ``N`` at least ``n_reaches`` and enough reaches that the step is under
  ``max_step_s``: the effective closure of a large valve is a few ms, and 16 reaches on the 0.91 m
  fuel line (50 us) read the LE4 peak 1.3 % low against the converged value.

If the valve-end pressure falls below the liquid's vapour pressure the column separates; the MOC
is not valid past that instant and the cavity's collapse is not computed. The collapse can put a
short pulse on the line above the Joukowsky value (A. Bergant, A. R. Simpson and A. S. Tijsseling,
"Water hammer with column separation: a historical review", J. Fluids Struct. 22(2), 2006), so the
row then carries the Joukowsky value as the figure it is graded on and says it is not a bound.

The wave speed carries the Korteweg correction for the tube's elasticity,
``a = a_f / sqrt(1 + c1 K D / (E e))``, ``K = rho a_f^2`` (Korteweg 1878, in the form of Wylie &
Streeter 1993), with the liquid's own sound speed from CoolProp (feedtwin ``Fluid``), the bore and
wall from the drawing, ``E`` of 316 stainless (an input: 193 GPa, AK Steel 316/316L product data
bulletin, 28.0e6 psi, room temperature) and ``c1`` (1: a pipe free to move axially; an input).

The **opening surge** is the start's: the liquid filling the gas-filled manifold arrives at the
orifices at the flow ``diag.start`` computes (rigid column) and must slow to what the orifices pass.
Treated as the MOC valve boundary appearing instantly at the front: ``p = p_front + B (m_arr - m)``
with ``m = phi sqrt(p - Pc)``, ``B = a/A``. The gas cushion the last of the manifold gas gives is
ignored, so this is an upper bound.

Ratings: the drawing rates only the tanks (MAWP or burst pressure, estimated) and the bottle; no
line, valve or manifold carries a rating. Each line is graded against the absolute pressure its tank
trips the stand at (``prepare.vessel_trip``, feedtwin's own trip), and the row says so.

Function Documentation

◆ _row()

Dict[str, Any] engine.layerx.diag.waterhammer._row ( Any prep,
Mapping[str, Any] result,
str side,
str key,
HammerSettings settings,
Optional[Mapping[str, Any]] start )
protected

Definition at line 235 of file waterhammer.py.

References joukowsky(), max, michaud(), moc(), opening_surge(), and wave_speed().

Referenced by waterhammer_from_run().

◆ _solve_boundary()

float engine.layerx.diag.waterhammer._solve_boundary ( float R,
float B,
float rhs )
protected
``R m|m| + B m = rhs`` for m (monotone in m; written without cancellation).

Definition at line 95 of file waterhammer.py.

Referenced by moc(), and opening_surge().

◆ joukowsky()

float engine.layerx.diag.waterhammer.joukowsky ( float rho,
float a,
float dv )
Joukowsky 1898: dp = rho a dv [Pa].

Definition at line 82 of file waterhammer.py.

Referenced by _row(), and michaud().

◆ michaud()

float engine.layerx.diag.waterhammer.michaud ( float rho,
float length,
float v0,
float closure_s,
float a )
Slow-closure bound for a linear velocity decrease over ``closure_s`` [Pa]; Joukowsky when
the closure is inside the round trip 2L/a.

Definition at line 87 of file waterhammer.py.

References joukowsky().

Referenced by _row().

◆ moc()

Dict[str, Any] engine.layerx.diag.waterhammer.moc ( Pipeline pipe,
* ,
float t_end,
int n_reaches = 16,
Optional[Callable[[float], float]] valve_R = None,
Optional[Callable[[float], float]] valve_flow = None,
Optional[float] R_down0 = None )
Method of characteristics on the reservoir-pipe-valve line, in pressure and mass flow:

    C+:  p_P = p_A - B (m_P - m_A) - Rf m_A|m_A|        C-:  p_P = p_B + B (m_P - m_B) + Rf m_B|m_B|

with ``B = a/A`` and ``Rf`` the reach's friction (Pa/(kg/s)^2). The valve end is either a
resistance ``valve_R(t)`` [Pa/(kg/s)^2, inf = shut] to a downstream pressure set so the initial
state is steady (``R_down0`` is its value at t = 0), or a prescribed flow ``valve_flow(t)``.
Returns the valve-end pressure and flow histories and their extremes.

Definition at line 129 of file waterhammer.py.

References _solve_boundary(), max, and min.

Referenced by _row().

◆ opening_surge()

Dict[str, float] engine.layerx.diag.waterhammer.opening_surge ( * ,
float p_front,
float pc,
float mdot_arrival,
float phi,
float B )
The liquid front meets the orifices at ``mdot_arrival``: the orifice boundary appears at the
front, ``p = p_front + B (m_arr - m)``, ``m = phi sqrt(p - Pc)``. Returns the peak and the flow.

Definition at line 191 of file waterhammer.py.

References _solve_boundary().

Referenced by _row().

◆ waterhammer_from_run()

List[Dict[str, Any]] engine.layerx.diag.waterhammer.waterhammer_from_run ( Any prep,
Mapping[str, Any] result,
Any config = None,
HammerSettings settings = HammerSettings(),
Optional[Mapping[str, Any]] start = None )
``diagnostics.water_hammer`` rows. ``start`` is ``diagnostics.start`` (for the opening surge).
Never raises: a line that cannot be computed is a row ``{line, side, available: false, error}``.

Definition at line 221 of file waterhammer.py.

References _row().

◆ wave_speed()

float engine.layerx.diag.waterhammer.wave_speed ( float a_fluid,
float rho,
float bore,
float wall,
float E = E_316_PA,
float c1 = 1.0 )
Korteweg: pressure-wave speed in a liquid-filled elastic tube [m/s].

Definition at line 74 of file waterhammer.py.

Referenced by _row().

Variable Documentation

◆ E_316_PA

float engine.layerx.diag.waterhammer.E_316_PA = 193.0e9

Definition at line 64 of file waterhammer.py.

◆ E_316_SOURCE

tuple engine.layerx.diag.waterhammer.E_316_SOURCE
Initial value:
1= ("assumed 193 GPa (28.0 x 10^6 psi): the room-temperature modulus producers' 316/316L data sheets "
2 "list (the AK Steel 316/316L product data bulletin was cited from memory and not re-checked; a "
3 "distributor's 316/316L technical data sheet gives 193 GPa); not corrected to LOX temperature "
4 "(by Korteweg, a 10 % higher E moves the LE4 LOX wave speed by +0.3 %)")

Definition at line 65 of file waterhammer.py.

◆ MODEL_NAME

str engine.layerx.diag.waterhammer.MODEL_NAME = "water_hammer_moc"

Definition at line 63 of file waterhammer.py.