engineeringkit.fluid_engineering#

Hydrostatic pressure, buoyancy and the force and centre of pressure on submerged planes; Bernoulli’s equation and continuity, with Pitot and Venturi meters; Reynolds number, Hagen-Poiseuille flow and its velocity profile, Darcy-Weisbach friction and minor losses, and the smooth, Nikuradse fully rough, Colebrook (scipy.optimize.brentq) and Swamee-Jain friction factors; Froude, Weber, Euler and Mach numbers and Buckingham’s Pi theorem by exact rational row reduction; Manning’s open-channel formula; Joukowsky’s water hammer with Korteweg’s wave speed; pump power, specific speed, NPSH and Thoma’s cavitation parameter; and Hardy Cross’s balancing of looped pipe networks.

engineeringkit.fluid_engineering: hydrostatics, momentum, pipe flow, drag, similarity, open channels, pumps and networks.

Stevin’s hydrostatic pressure and the force on submerged surfaces, Archimedes’s buoyancy; Bernoulli’s equation and continuity, with Pitot and Venturi meters, Torricelli’s orifice and sharp-crested weirs; the momentum equation for jets, bends and Pelton’s wheel; Couette flow and Stokes’s drag with the sphere drag curve; Reynolds’s regimes, Hagen-Poiseuille laminar flow, Darcy-Weisbach losses and the turbulent friction factors of Nikuradse, Colebrook and Swamee-Jain; Froude, Euler, Weber and Mach numbers and Buckingham’s Pi theorem by exact rational row reduction; Manning’s open-channel formula, specific energy, critical depth and Bélanger’s hydraulic jump; Joukowsky’s water hammer with Korteweg’s wave speed; Euler’s turbomachine head, pump and system curves, the affinity laws, pump power, specific speed, NPSH and Thoma’s cavitation parameter; and Hardy Cross’s balancing of looped pipe networks. Models are hand-written closed forms; SciPy supplies root bracketing.

class engineeringkit.fluid_engineering.NetworkResult(flows, head_losses, loop_residuals, corrections)[source]#

Bases: object

Output of engineeringkit.fluid_engineering.hardy_cross().

Parameters:
  • flows (ndarray)

  • head_losses (ndarray)

  • loop_residuals (ndarray)

  • corrections (ndarray)

corrections: ndarray#

Largest loop correction \(|\Delta Q|\) of each sweep [m^3/s].

Type:

ndarray

flows: ndarray#

Volume flow in each pipe [m^3/s], signed along the pipe’s reference direction.

Type:

ndarray

head_losses: ndarray#

Head loss in each pipe [m], signed like flows.

Type:

ndarray

loop_residuals: ndarray#

Signed sum of head losses round each loop [m]; zero at convergence.

Type:

ndarray

plot(ax=None)[source]#

Draw the loop correction against the sweep number; return (fig, ax).

summary()[source]#

Sweeps taken, final correction and largest loop residual.

Return type:

dict

class engineeringkit.fluid_engineering.OperatingPoint(flow, head, shutoff_head, a, b, static_head, k, series, parallel)[source]#

Bases: object

Output of engineeringkit.fluid_engineering.pump_operating_point().

Parameters:
  • flow (float)

  • head (float)

  • shutoff_head (float)

  • a (float)

  • b (float)

  • static_head (float)

  • k (float)

  • series (int)

  • parallel (int)

a: float#

Quadratic coefficient of one pump’s curve [s^2/m^5].

Type:

float

b: float#

Linear coefficient of one pump’s curve [s/m^2].

Type:

float

flow: float#

Volume flow where the pump and system curves cross [m^3/s].

Type:

float

head: float#

Head at the operating point [m].

Type:

float

k: float#

Loss coefficient of the system curve [s^2/m^5].

Type:

float

parallel: int#

Number of identical pumps (or series strings) in parallel.

Type:

int

plot(ax=None)[source]#

Draw the combined pump curve, the system curve and their crossing; return (fig, ax).

pump_head(Q)[source]#

Head of the combined pumps at flow Q [m^3/s], in m.

series: int#

Number of identical pumps in series.

Type:

int

shutoff_head: float#

Head of one pump at zero flow, \(H_0\) [m].

Type:

float

static_head: float#

Static lift of the system [m].

Type:

float

summary()[source]#

Flow, head and the pump arrangement.

Return type:

dict

system_head(Q)[source]#

Head the system needs at flow Q [m^3/s], in m.

class engineeringkit.fluid_engineering.PiGroups(names, bases, dimension_matrix, exponents, repeating)[source]#

Bases: object

Output of engineeringkit.fluid_engineering.buckingham_pi().

Parameters:
  • names (tuple)

  • bases (tuple)

  • dimension_matrix (ndarray)

  • exponents (ndarray)

  • repeating (tuple)

bases: tuple#

Base dimensions, one per row of dimension_matrix.

Type:

tuple of str

dimension_matrix: ndarray#

Exponent of each base dimension (rows) in each variable (columns).

Type:

ndarray of int

exponents: ndarray#

One Pi group per row, the exponent of each variable in it; shape (k, n).

Type:

ndarray of int

groups()[source]#

Each Pi group as a product such as "dp^1 rho^-1 V^-2".

Return type:

list

names: tuple#

Variable names, repeating variables first.

Type:

tuple of str

plot(ax=None)[source]#

Draw the exponent table as a colored grid; return (fig, ax).

property rank: int#

Rank of the dimension matrix, so k = n - rank groups.

Type:

int

repeating: tuple#

The repeating variables, which appear in every group.

Type:

tuple of str

summary()[source]#

Number of variables, rank, number of groups and the groups themselves.

Return type:

dict

engineeringkit.fluid_engineering.affinity_laws(Q, head, power, speed_ratio, diameter_ratio=1.0)[source]#

Scale a pump’s flow, head and power to a new speed or impeller size.

\[\frac{Q_2}{Q_1} = \frac{N_2}{N_1}\left(\frac{D_2}{D_1}\right)^3,\quad \frac{H_2}{H_1} = \left(\frac{N_2}{N_1}\right)^2\left(\frac{D_2}{D_1}\right)^2,\quad \frac{P_2}{P_1} = \left(\frac{N_2}{N_1}\right)^3\left(\frac{D_2}{D_1}\right)^5\]
Parameters:
  • Q (float or array_like) – Volume flow at the original condition [m^3/s], nonnegative.

  • head (float or array_like) – Head at the original condition [m].

  • power (float or array_like) – Shaft power at the original condition [W], nonnegative.

  • speed_ratio (float or array_like) – \(N_2/N_1\) [-], positive.

  • diameter_ratio (float or array_like, optional) – \(D_2/D_1\) [-], positive.

Returns:

(Q2, head2, power2) in m^3/s, m and W.

Return type:

tuple of float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The laws hold between geometrically similar pumps at equal flow coefficient \(Q/(ND^3)\), so a point on one curve maps to a point of equal efficiency on the other. Trimming an impeller is not exact geometric similarity.

Examples

>>> affinity_laws(0.1, 30.0, 40e3, 2.0)
(0.2, 120.0, 320000.0)
engineeringkit.fluid_engineering.alternate_depths(E, q, g=9.80665)[source]#

The subcritical and supercritical depths that carry q at specific energy E.

Parameters:
  • E (float) – Specific energy [m], at least \(3y_c/2\).

  • q (float) – Flow per unit width [m^2/s], positive.

  • g (float, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

(y_subcritical, y_supercritical) [m]; both equal the critical depth when E is the minimum.

Return type:

tuple of float

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Scalar inputs only; each root is bracketed on its own side of the critical depth and found by Brent’s method. A sluice gate or a step in the bed moves the flow between the two depths at constant \(E\).

Examples

>>> [round(y, 4) for y in alternate_depths(1.2, 2.0, g=10.0)]
[1.0, 0.5583]
engineeringkit.fluid_engineering.bend_force(rho, Q, A1, A2, p1, p2, angle)[source]#

Force of the flow on a horizontal reducing bend, which its anchor must resist.

Flow enters along \(+x\) and leaves at angle from it. The momentum balance on the fluid inside the bend gives the force on the bend:

\[F_x = p_1A_1 + \rho QV_1 - (p_2A_2 + \rho QV_2)\cos\theta,\qquad F_y = -(p_2A_2 + \rho QV_2)\sin\theta\]
Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • Q (float or array_like) – Volume flow [m^3/s], nonnegative.

  • A1 (float or array_like) – Inlet area [m^2], positive.

  • A2 (float or array_like) – Outlet area [m^2], positive.

  • p1 (float or array_like) – Gauge pressure at the inlet [Pa].

  • p2 (float or array_like) – Gauge pressure at the outlet [Pa]; from bernoulli_pressure() less any loss.

  • angle (float or array_like) – Turning angle \(\theta\) [rad], in [0, π], counterclockwise.

Returns:

(Fx, Fy) [N]: the force of the fluid on the bend. The anchor supplies the opposite force.

Return type:

tuple of float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Gauge pressures, because the atmosphere acts on the outside of the bend too. Uniform velocity at each end; the weight of the bend and its water acts vertically and is not included.

Examples

A 180° return bend with no pressure: twice the momentum flux.

>>> round(float(bend_force(1000.0, 0.01, 0.01, 0.01, 0.0, 0.0, np.pi)[0]), 6)
20.0
engineeringkit.fluid_engineering.bernoulli_pressure(p1, rho, v1, v2, z1=0, z2=0, g=9.80665)[source]#

Pressure at point 2 from Bernoulli’s equation along a streamline.

\[p_2 = p_1 + \tfrac12\rho(v_1^2 - v_2^2) + \rho g (z_1 - z_2)\]
Parameters:
  • p1 (float or array_like) – Pressure at point 1 [Pa].

  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • v1 (float or array_like) – Speeds at points 1 and 2 [m/s].

  • v2 (float or array_like) – Speeds at points 1 and 2 [m/s].

  • z1 (float or array_like, optional) – Elevations of points 1 and 2 [m].

  • z2 (float or array_like, optional) – Elevations of points 1 and 2 [m].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Pressure at point 2 [Pa].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Steady, incompressible, inviscid flow with no pump or turbine between the points; add losses separately.

References

  1. Bernoulli, Hydrodynamica (Strasbourg, 1738).

Examples

>>> bernoulli_pressure(2000.0, 1000.0, 0.0, 2.0)
0.0
engineeringkit.fluid_engineering.buckingham_pi(variables, repeating=None)[source]#

Dimensionless groups of a set of variables by Buckingham’s Pi theorem.

The variables’ dimensions form a matrix \(D\) (base dimensions by variables). Every vector \(x\) with \(Dx = 0\) lists the exponents of one dimensionless product, and a basis of that null space has \(n - \operatorname{rank} D\) vectors. The repeating variables are placed first, so the exact row reduction pivots on them and each group contains exactly one other variable, raised to a positive power.

Parameters:
  • variables (mapping) – Variable name to its dimensions, itself a mapping from a base dimension ("M", "L", "T", "Θ", …) to an integer exponent; for example {"rho": {"M": 1, "L": -3}}. Dimensionless variables map to {}.

  • repeating (sequence of str, optional) – Names of the repeating variables, as many as the rank of the dimension matrix and dimensionally independent. Defaults to the first independent variables in variables order.

Returns:

Variables, dimension matrix and the integer exponents of each group.

Return type:

PiGroups

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The exponents come from exact rational arithmetic (integer_null_space()). The theorem fixes how many groups there are, not which ones: another choice of repeating variables gives products of these.

References

E. Buckingham, “On physically similar systems; illustrations of the use of dimensional equations,” Phys. Rev. 4 (1914) 345-376.

Examples

>>> pi = buckingham_pi(
...     {
...         "rho": {"M": 1, "L": -3},
...         "V": {"L": 1, "T": -1},
...         "D": {"L": 1},
...         "mu": {"M": 1, "L": -1, "T": -1},
...     }
... )
>>> pi.groups()
['rho^-1 V^-1 D^-1 mu^1']
engineeringkit.fluid_engineering.buoyancy_force(rho, displaced_volume, g=9.80665)[source]#

Archimedes’s buoyant force, \(F_B = \rho g V\).

Parameters:
  • rho (float or array_like) – Density of the surrounding fluid [kg/m^3], positive.

  • displaced_volume (float or array_like) – Volume of fluid displaced by the body [m^3], nonnegative.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Upward force [N], equal to the weight of the displaced fluid.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

Archimedes, On Floating Bodies, Book I, Prop. 7 (c. 250 BC), in T. L. Heath, The Works of Archimedes (Cambridge, 1897).

Examples

>>> round(buoyancy_force(1000.0, 0.001), 3)
9.807
engineeringkit.fluid_engineering.cavitation_number(p, p_vapor, rho, v)[source]#

Cavitation number \(\mathrm{Ca} = (p - p_v)/(\tfrac12\rho v^2)\).

Parameters:
  • p (float or array_like) – Reference absolute pressure [Pa].

  • p_vapor (float or array_like) – Vapour pressure of the liquid [Pa].

  • rho (float or array_like) – Liquid density [kg/m^3], positive.

  • v (float or array_like) – Reference speed [m/s], nonzero.

Returns:

Cavitation number [-]; negative when the pressure is below the vapour pressure.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> cavitation_number(3000.0, 1000.0, 1000.0, 2.0)
1.0
engineeringkit.fluid_engineering.center_of_pressure_depth(centroid_distance, area, second_moment)[source]#

Distance to the centre of pressure on a submerged plane, \(y_p = y_c + I_c/(y_c A)\).

Distances are measured along the plane from the line where its plane meets the free surface; for a vertical surface they are depths.

Parameters:
  • centroid_distance (float or array_like) – Distance \(y_c\) of the centroid from the free-surface line [m], positive.

  • area (float or array_like) – Wetted area [m^2], positive.

  • second_moment (float or array_like) – Second moment of area about the horizontal centroidal axis [m^4], nonnegative.

Returns:

Distance \(y_p\) of the centre of pressure [m]; always below the centroid.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Gauge pressure only: the atmosphere acting on both faces adds no moment.

Examples

A vertical rectangle 1 m wide reaching 3 m down from the surface:

>>> center_of_pressure_depth(1.5, 3.0, 3.0**3 / 12)
2.0
engineeringkit.fluid_engineering.colebrook_friction_factor(Re, relative_roughness)[source]#

Colebrook’s friction factor for commercial pipes.

Solves \(1/\sqrt f = -2\log_{10}\left(\frac{\varepsilon/D}{3.7} + \frac{2.51}{Re\sqrt f}\right)\) for turbulent flow, and returns \(64/Re\) for laminar flow.

Parameters:
  • Re (float or array_like) – Reynolds number [-], positive; the transition range 2300-4000 is rejected.

  • relative_roughness (float or array_like) – Roughness over diameter \(\varepsilon/D\) [-], in [0, 0.05].

Returns:

Darcy friction factor [-].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The implicit equation is solved by bracketed root finding (scipy.optimize.brentq()), element by element.

References

C. F. Colebrook, “Turbulent flow in pipes, with particular reference to the transition region between the smooth and rough pipe laws,” J. Inst. Civil Eng. 11 (1939) 133-156.

Examples

>>> round(colebrook_friction_factor(1e5, 1e-4), 6)
0.018514
engineeringkit.fluid_engineering.continuity_velocity(A1, v1, A2)[source]#

Mean velocity in section 2 from continuity, \(v_2 = A_1 v_1/A_2\).

Parameters:
  • A1 (float or array_like) – Area of section 1 [m^2], positive.

  • v1 (float or array_like) – Mean velocity in section 1 [m/s].

  • A2 (float or array_like) – Area of section 2 [m^2], positive.

Returns:

Mean velocity in section 2 [m/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> continuity_velocity(4.0, 1.0, 1.0)
4.0
engineeringkit.fluid_engineering.couette_flow_rate(h, U, mu, dp_dx=0.0)[source]#

Flow per unit width between the plates, \(q = Uh/2 - h^3\,(dp/dx)/(12\mu)\).

Parameters:
  • h (float or array_like) – Gap [m], positive.

  • U (float or array_like) – Speed of the moving plate [m/s].

  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

  • dp_dx (float or array_like, optional) – Pressure gradient [Pa/m].

Returns:

Volume flow per unit width [m^2/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The integral of couette_velocity() across the gap; the basis of Reynolds’s lubrication theory of slider bearings.

Examples

>>> couette_flow_rate(1e-3, 2.0, 0.1)
0.001
engineeringkit.fluid_engineering.couette_shear_stress(mu, U, h)[source]#

Shear stress in pure Couette flow, \(\tau = \mu U/h\).

Parameters:
  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

  • U (float or array_like) – Speed of the moving plate [m/s].

  • h (float or array_like) – Gap [m], positive.

Returns:

Shear stress [Pa], the same across the gap and on both plates.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Newton’s law of viscosity applied to the linear profile, so a measured force per area and speed give \(\mu\).

Examples

>>> couette_shear_stress(0.1, 2.0, 1e-3)
200.0
engineeringkit.fluid_engineering.couette_velocity(y, h, U, mu, dp_dx=0.0)[source]#

Velocity profile of plane Couette-Poiseuille flow.

\[u(y) = U\frac{y}{h} - \frac{1}{2\mu}\frac{dp}{dx}\,y\,(h - y)\]
Parameters:
  • y (float or array_like) – Distance from the fixed plate [m], in [0, h].

  • h (float) – Gap between the plates [m], positive.

  • U (float) – Speed of the moving plate at y = h [m/s].

  • mu (float) – Dynamic viscosity [Pa s], positive.

  • dp_dx (float, optional) – Pressure gradient along the flow [Pa/m]; negative pushes fluid forward. Zero gives pure Couette flow.

Returns:

Velocity [m/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Steady, fully developed laminar flow of a Newtonian fluid: an exact solution of the Navier-Stokes equations. Backflow appears at the fixed wall when \(dp/dx > 2\mu U/h^2\).

Examples

>>> float(couette_velocity(0.5e-3, 1e-3, 2.0, 0.1))
1.0
engineeringkit.fluid_engineering.couette_viscometer_torque(mu, omega, R_inner, R_outer, length)[source]#

Torque on the cylinders of a Couette viscometer.

\[T = \frac{4\pi\mu\Omega L\,R_1^2R_2^2}{R_2^2 - R_1^2}\]
Parameters:
  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

  • omega (float or array_like) – Angular speed of one cylinder relative to the other [rad/s].

  • R_inner (float or array_like) – Inner cylinder radius \(R_1\) [m], positive.

  • R_outer (float or array_like) – Outer cylinder radius \(R_2\) [m], greater than R_inner.

  • length (float or array_like) – Wetted length of the cylinders [m], positive.

Returns:

Torque [N m], the same on both cylinders.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The exact circular Couette solution \(v_\theta = Ar + B/r\) with end effects neglected. For a narrow gap it tends to the plane result, shear stress \(\mu\Omega R/h\) on area \(2\pi RL\) at arm \(R\). Taylor vortices appear when the inner cylinder rotates fast; Couette rotated the outer one, which keeps the flow stable.

References

M. Couette, “Études sur le frottement des liquides,” Ann. Chim. Phys., 6th ser., 21 (1890) 433-510.

Examples

>>> round(float(couette_viscometer_torque(1.0, 1.0, 1.0, np.sqrt(2.0), 1.0 / np.pi)), 6)
8.0
engineeringkit.fluid_engineering.critical_closure_time(length, wave_speed)[source]#

Round-trip time \(2L/a\) of a pressure wave along a pipe.

Parameters:
  • length (float or array_like) – Pipe length from valve to reservoir [m], positive.

  • wave_speed (float or array_like) – Pressure-wave speed [m/s], positive.

Returns:

Time [s]; a valve closed faster than this sees the full Joukowsky rise.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> critical_closure_time(600.0, 1200.0)
1.0
engineeringkit.fluid_engineering.critical_depth(q, g=9.80665)[source]#

Critical depth of a wide rectangular channel, \(y_c = (q^2/g)^{1/3}\).

Parameters:
  • q (float or array_like) – Flow per unit width [m^2/s], nonnegative.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Critical depth [m]: the depth of least specific energy, \(E_{min} = 3y_c/2\), where the Froude number is 1.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> round(float(critical_depth(np.sqrt(10.0), g=10.0)), 6)
1.0
engineeringkit.fluid_engineering.darcy_head_loss(f, L, D, v, g=9.80665)[source]#

Darcy-Weisbach friction head loss, \(h_f = f\,(L/D)\,v^2/(2g)\).

Parameters:
  • f (float or array_like) – Darcy friction factor [-], nonnegative.

  • L (float or array_like) – Pipe length [m], nonnegative.

  • D (float or array_like) – Pipe diameter [m], positive.

  • v (float or array_like) – Mean velocity [m/s].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Head loss [m]; multiply by \(\rho g\) for the pressure drop.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

J. Weisbach, Lehrbuch der Ingenieur- und Maschinen-Mechanik (Braunschweig: Vieweg, 1845); H. Darcy, Recherches expérimentales relatives au mouvement de l’eau dans les tuyaux (Paris: Mallet-Bachelier, 1857).

Examples

>>> darcy_head_loss(0.02, 100.0, 0.1, 2.0, g=10.0)
4.0
engineeringkit.fluid_engineering.dynamic_pressure(rho, v)[source]#

Dynamic pressure \(q = \tfrac12\rho v^2\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • v (float or array_like) – Flow speed [m/s].

Returns:

Dynamic pressure [Pa], the rise from static to stagnation pressure.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> dynamic_pressure(1000.0, 2.0)
2000.0
engineeringkit.fluid_engineering.euler_number(delta_p, rho, v)[source]#

Euler number \(Eu = \Delta p/(\rho v^2)\).

Parameters:
  • delta_p (float or array_like) – Pressure difference [Pa].

  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • v (float or array_like) – Speed [m/s], nonzero.

Returns:

Euler number [-], the ratio of pressure forces to inertia.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Some texts use \(\Delta p/(\tfrac12\rho v^2)\), twice this value.

Examples

>>> euler_number(4000.0, 1000.0, 2.0)
1.0
engineeringkit.fluid_engineering.euler_turbomachine_head(u2, v_t2, u1=0.0, v_t1=0.0, g=9.80665)[source]#

Ideal head of a rotor from Euler’s turbomachine equation.

\[H = \frac{u_2 V_{t2} - u_1 V_{t1}}{g}\]
Parameters:
  • u2 (float or array_like) – Blade speed at the outlet, \(\omega r_2\) [m/s].

  • v_t2 (float or array_like) – Tangential (swirl) component of the absolute velocity at the outlet [m/s].

  • u1 (float or array_like, optional) – Blade speed at the inlet [m/s].

  • v_t1 (float or array_like, optional) – Swirl velocity at the inlet [m/s]; zero for a pump without inlet guide vanes.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Ideal head [m]: positive for a pump, negative for a turbine (which takes head from the fluid).

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. For a radial impeller with outlet blade angle \(\beta_2\) and width \(b_2\), \(V_{t2} = u_2 - Q\cot\beta_2/(2\pi r_2 b_2)\), so the ideal head falls linearly with flow for backward-curved blades. Real pumps lose more to slip, friction and shock.

References

L. Euler, “Théorie plus complette des machines qui sont mises en mouvement par la réaction de l’eau,” Mém. Acad. Sci. Berlin 10 (1754, publ. 1756) 227-295 (Eneström E222).

Examples

>>> euler_turbomachine_head(20.0, 10.0, g=10.0)
20.0
engineeringkit.fluid_engineering.froude_number(v, length, g=9.80665)[source]#

Froude number \(Fr = v/\sqrt{gL}\).

Parameters:
  • v (float or array_like) – Speed [m/s].

  • length (float or array_like) – Characteristic length [m], positive (waterline length of a hull, depth of a channel).

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Froude number [-], the ratio of inertia to gravity.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

W. Froude, “Observations and suggestions on the subject of determining by experiment the resistance of ships,” memorandum to the Admiralty (1868), in The Papers of William Froude (London: INA, 1955).

Examples

>>> float(froude_number(3.0, 0.9, g=10.0))
1.0
engineeringkit.fluid_engineering.hardy_cross(resistances, loops, initial_flows, n=2.0, tol=1e-10, max_iter=200)[source]#

Balance the flows of a looped pipe network by Hardy Cross’s method.

Parameters:
  • resistances (array_like) – Resistance coefficient \(r_i\) of each pipe, so that \(h_i = r_i Q_i |Q_i|^{n-1}\) [s^n/m^(3n-1)], positive; for Darcy-Weisbach use pipe_resistance().

  • loops (array_like) – Loop matrix of shape (loops, pipes): +1 where the pipe’s reference direction runs clockwise round the loop, -1 where it runs anticlockwise, 0 where the pipe is not in the loop.

  • initial_flows (array_like) – Starting flow in each pipe [m^3/s], signed along its reference direction. It must satisfy continuity at every junction; the corrections preserve it.

  • n (float, optional) – Head-loss exponent, at least 1: 2 for Darcy-Weisbach with fixed friction factor, 1.852 for Hazen-Williams.

  • tol (float, optional) – Stop when the largest loop correction falls below this [m^3/s].

  • max_iter (int, optional) – Largest number of sweeps over all loops.

Returns:

Flows, head losses, loop residuals and the correction of each sweep.

Return type:

NetworkResult

Raises:
  • ValueError – If a loop has no pipes, or all its starting flows are zero so that the first correction is undefined.

  • RuntimeError – If the corrections do not fall below tol within max_iter sweeps.

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Loops are corrected one after another (Gauss-Seidel order), as Cross did by hand; a pipe shared by two loops receives both corrections, with opposite signs.

References

H. Cross, “Analysis of flow in networks of conduits or conductors,” Univ. Illinois Eng. Exp. Stn. Bull. 286 (1936).

Examples

One loop of two parallel pipes carrying 0.3 m³/s between two junctions:

>>> result = hardy_cross([1.0, 4.0], [[1, -1]], [0.15, 0.15])
>>> [round(float(q), 4) for q in result.flows]
[0.2, 0.1]
engineeringkit.fluid_engineering.hydraulic_diameter(area, wetted_perimeter)[source]#

Hydraulic diameter \(D_h = 4A/P\) of a non-circular duct.

Parameters:
  • area (float or array_like) – Flow area [m^2], positive.

  • wetted_perimeter (float or array_like) – Wetted perimeter [m], positive.

Returns:

Hydraulic diameter [m]; equal to the diameter for a full circular pipe.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> hydraulic_diameter(1.0, 4.0)
1.0
engineeringkit.fluid_engineering.hydraulic_jump_head_loss(y1, y2)[source]#

Head lost in a hydraulic jump, \(h_L = (y_2 - y_1)^3/(4y_1y_2)\).

Parameters:
  • y1 (float or array_like) – Depth before the jump [m], positive.

  • y2 (float or array_like) – Sequent depth after the jump [m], positive.

Returns:

Head loss [m], the drop in specific energy across the jump. Negative (impossible) if y2 < y1.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Holds only for a pair of sequent depths from sequent_depth().

Examples

>>> hydraulic_jump_head_loss(1.0, 3.0)
0.6666666666666666
engineeringkit.fluid_engineering.hydraulic_radius(area, wetted_perimeter)[source]#

Hydraulic radius \(R = A/P\) of a channel section.

Parameters:
  • area (float or array_like) – Flow area [m^2], positive.

  • wetted_perimeter (float or array_like) – Wetted perimeter, excluding the free surface [m], positive.

Returns:

Hydraulic radius [m]; a quarter of the hydraulic diameter.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

A rectangular channel 4 m wide flowing 1 m deep:

>>> hydraulic_radius(4.0, 6.0)
0.6666666666666666
engineeringkit.fluid_engineering.hydrostatic_force_plane(rho, depth_centroid, area, g=9.80665)[source]#

Resultant pressure force on a submerged plane surface, \(F = \rho g h_c A\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • depth_centroid (float or array_like) – Vertical depth of the surface’s centroid below the free surface [m], nonnegative.

  • area (float or array_like) – Wetted area of the surface [m^2], positive.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Force normal to the surface [N], from gauge pressure only.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The result holds for any orientation of the plane, because the mean pressure over a plane is the pressure at its centroid.

References

  1. Stevin, De Beghinselen des Waterwichts (Leiden: Plantijn, 1586).

Examples

>>> round(hydrostatic_force_plane(1000.0, 1.0, 2.0))
19613
engineeringkit.fluid_engineering.hydrostatic_pressure(rho, h, g=9.80665)[source]#

Gauge pressure at depth \(h\) in a fluid at rest, \(p = \rho g h\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • h (float or array_like) – Depth below the free surface [m], nonnegative.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Gauge pressure [Pa].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The density is constant (incompressible liquid).

References

  1. Stevin, De Beghinselen des Waterwichts (Leiden: Plantijn, 1586).

Examples

>>> round(hydrostatic_pressure(1000.0, 10.0), 1)
98066.5
engineeringkit.fluid_engineering.jet_force(rho, area, v, angle, vane_speed=0.0)[source]#

Force of a free jet on a single vane that turns it through angle.

\[F_x = \rho A (V - u)^2 (1 - \cos\theta),\qquad F_y = \rho A (V - u)^2 \sin\theta\]
Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • area (float or array_like) – Jet cross-section [m^2], positive.

  • v (float or array_like) – Jet speed [m/s], nonnegative.

  • angle (float or array_like) – Angle through which the vane turns the jet [rad], in [0, π]: π/2 for a flat plate normal to the jet, π for a full reversal.

  • vane_speed (float or array_like, optional) – Speed of the vane along the jet [m/s], in [0, v].

Returns:

(Fx, Fy) [N]: the force on the vane along the jet and across it, toward the side the jet is turned away from.

Return type:

tuple of float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The jet is at atmospheric pressure throughout, gravity and vane friction are neglected, so the relative speed \(V - u\) is unchanged over the vane. A single moving vane receives only \(\rho A (V - u)\) per second because it runs away from the jet; a wheel of vanes receives the whole flow, see pelton_wheel_power().

Examples

>>> round(float(jet_force(1000.0, 0.01, 10.0, np.pi / 2)[0]), 6)
1000.0
engineeringkit.fluid_engineering.laminar_friction_factor(Re)[source]#

Darcy friction factor of laminar pipe flow, \(f = 64/Re\).

Parameters:

Re (float or array_like) – Reynolds number [-], positive and below 2300.

Returns:

Darcy friction factor [-] (four times the Fanning factor).

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Follows from the Hagen-Poiseuille profile and the Darcy-Weisbach equation.

Examples

>>> laminar_friction_factor(1000)
0.064
engineeringkit.fluid_engineering.mach_number(v, speed_of_sound)[source]#

Mach number \(Ma = v/a\).

Parameters:
  • v (float or array_like) – Speed [m/s].

  • speed_of_sound (float or array_like) – Local speed of sound [m/s], positive.

Returns:

Mach number [-]; compressibility matters above about 0.3.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> mach_number(170.0, 340.0)
0.5
engineeringkit.fluid_engineering.manning_flow(n, area, wetted_perimeter, slope)[source]#

Volume flow of uniform open-channel flow, \(Q = A R^{2/3}S^{1/2}/n\) (SI).

Parameters:
  • n (float or array_like) – Manning roughness coefficient [s/m^(1/3)], positive.

  • area (float or array_like) – Flow area [m^2], positive.

  • wetted_perimeter (float or array_like) – Wetted perimeter [m], positive.

  • slope (float or array_like) – Bed slope [-], nonnegative.

Returns:

Volume flow [m^3/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Solve this for the depth to get the normal depth of a channel.

Examples

>>> round(float(manning_flow(0.013, 4.0, 6.0, 0.001)), 3)
7.425
engineeringkit.fluid_engineering.manning_velocity(n, R, slope)[source]#

Mean velocity of uniform open-channel flow, \(V = R^{2/3}S^{1/2}/n\) (SI).

Parameters:
  • n (float or array_like) – Manning roughness coefficient [s/m^(1/3)], positive (about 0.013 for finished concrete, 0.035 for a natural stream).

  • R (float or array_like) – Hydraulic radius [m], positive.

  • slope (float or array_like) – Bed slope \(S\) [-], nonnegative (equal to the energy slope in uniform flow).

Returns:

Mean velocity [m/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The coefficient 1 holds in SI only; US customary units need 1.486. Fully rough turbulent flow is assumed.

References

R. Manning, “On the flow of water in open channels and pipes,” Trans. Inst. Civil Eng. Ireland 20 (1891) 161-207 (read 4 December 1889).

Examples

>>> round(float(manning_velocity(0.013, 1.0, 0.001)), 3)
2.433
engineeringkit.fluid_engineering.minor_head_loss(K, v, g=9.80665)[source]#

Head loss in a fitting, \(h_m = K v^2/(2g)\).

Parameters:
  • K (float or array_like) – Loss coefficient of the fitting [-], nonnegative (about 0.5 for a sharp entrance, 1 for an exit, 0.3-1.5 for an elbow).

  • v (float or array_like) – Mean velocity [m/s].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Head loss [m].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> minor_head_loss(0.5, 2.0, g=10.0)
0.1
engineeringkit.fluid_engineering.nikuradse_friction_factor(relative_roughness)[source]#

Fully rough friction factor from Nikuradse’s sand-grain pipes.

\[\frac{1}{\sqrt f} = 1.74 + 2\log_{10}\frac{R}{k_s} = 1.74 + 2\log_{10}\frac{1}{2\,k_s/D}\]
Parameters:

relative_roughness (float or array_like) – Sand-grain roughness over diameter, \(k_s/D\) [-], in (0, 0.05]. Nikuradse covered 0.001 to 0.033.

Returns:

Darcy friction factor [-], independent of the Reynolds number.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Valid once the roughness Reynolds number \(Re\,(k_s/D)\sqrt{f/8}\) exceeds about 70.

References

J. Nikuradse, “Strömungsgesetze in rauhen Rohren,” VDI-Forschungsheft 361 (1933).

Examples

>>> round(float(nikuradse_friction_factor(0.01)), 4)
0.0379
engineeringkit.fluid_engineering.npsh_available(p_inlet, v_inlet, p_vapor, rho, g=9.80665)[source]#

Net positive suction head available at a pump inlet.

\[\mathrm{NPSH}_A = \frac{p - p_v}{\rho g} + \frac{v^2}{2g}\]
Parameters:
  • p_inlet (float or array_like) – Absolute static pressure at the pump inlet [Pa], positive.

  • v_inlet (float or array_like) – Mean velocity at the inlet [m/s].

  • p_vapor (float or array_like) – Vapour pressure of the liquid [Pa], nonnegative.

  • rho (float or array_like) – Liquid density [kg/m^3], positive.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

NPSH available [m]; the pump cavitates when it falls below the NPSH it requires.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. For a pump drawing from an open sump, \(p/(\rho g) + v^2/(2g) = p_{atm}/(\rho g) - z_s - h_{L}\), the atmosphere less the suction lift and the suction-line losses.

Examples

>>> npsh_available(103000.0, 0.0, 3000.0, 1000.0, g=10.0)
10.0
engineeringkit.fluid_engineering.orifice_flow(area, head, discharge_coefficient=0.61, g=9.80665)[source]#

Flow through a small orifice by Torricelli’s law, \(Q = C_d A\sqrt{2gh}\).

Parameters:
  • area (float or array_like) – Orifice area [m^2], positive.

  • head (float or array_like) – Height of the free surface above the orifice centre [m], nonnegative; a pressure difference \(\Delta p\) across the orifice counts as \(\Delta p/(\rho g)\).

  • discharge_coefficient (float or array_like, optional) – \(C_d\) in (0, 1]; the default 0.61 is a sharp-edged orifice, whose jet contracts to about 61% of the hole area (the vena contracta), and 1 is the ideal Torricelli jet.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Volume flow [m^3/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The orifice is small next to the head and the approach velocity is negligible. An orifice plate in a pipe, where it is not, is venturi_flow() with its own \(C_d\) (about 0.6).

References

E. Torricelli, “De motu aquarum,” in De motu gravium naturaliter descendentium et proiectorum, Opera geometrica (Florence: Masse and de Landis, 1644) 191-203.

Examples

>>> float(orifice_flow(0.01, 5.0, 1.0, g=10.0))
0.1
engineeringkit.fluid_engineering.pelton_wheel_power(rho, Q, v, bucket_speed, angle=np.float64(2.8797932657906435))[source]#

Power a Pelton wheel takes from its jet, \(P = \rho Q u (V - u)(1 - \cos\theta)\).

Parameters:
  • rho (float or array_like) – Water density [kg/m^3], positive.

  • Q (float or array_like) – Jet volume flow [m^3/s], nonnegative.

  • v (float or array_like) – Jet speed [m/s], nonnegative; \(C_v\sqrt{2gH}\) from the head.

  • bucket_speed (float or array_like) – Bucket speed at the pitch circle \(u = \omega r\) [m/s], in [0, v].

  • angle (float or array_like, optional) – Angle through which the buckets turn the jet [rad], in [0, π]; 165° by default, short of 180° so the water clears the next bucket.

Returns:

Power on the wheel [W]. It is greatest at \(u = V/2\), where the hydraulic efficiency is \((1 - \cos\theta)/2\).

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Unlike one vane in jet_force(), a wheel always has a bucket in the jet, so the whole flow \(Q\) is turned. Bucket friction is neglected.

References

    1. Pelton, “Water-wheel,” US Patent 233,692 (26 October 1880).

Examples

>>> float(pelton_wheel_power(1000.0, 0.1, 20.0, 10.0, np.pi))
20000.0
engineeringkit.fluid_engineering.pipe_resistance(f, L, D, g=9.80665)[source]#

Resistance coefficient \(r = 8fL/(g\pi^2D^5)\), so that \(h_f = r\,Q|Q|\).

Parameters:
  • f (float or array_like) – Darcy friction factor [-], nonnegative.

  • L (float or array_like) – Pipe length [m], nonnegative.

  • D (float or array_like) – Pipe diameter [m], positive.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Resistance coefficient [s^2/m^5].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The Darcy-Weisbach loss written in terms of volume flow, as pipe-network methods need it; f is held fixed.

Examples

>>> round(float(pipe_resistance(0.02, 100.0, 0.1)), 1)
16531.0
engineeringkit.fluid_engineering.pipe_wave_speed(bulk_modulus, rho, D, wall_thickness, E, c1=1.0)[source]#

Korteweg’s pressure-wave speed in a liquid-filled elastic pipe.

\[a = \sqrt{\frac{K/\rho}{1 + c_1\,K D/(E e)}}\]
Parameters:
  • bulk_modulus (float or array_like) – Bulk modulus of the liquid \(K\) [Pa], positive (2.2 GPa for water).

  • rho (float or array_like) – Liquid density [kg/m^3], positive.

  • D (float or array_like) – Pipe inner diameter [m], positive.

  • wall_thickness (float or array_like) – Wall thickness \(e\) [m], positive.

  • E (float or array_like) – Young’s modulus of the wall [Pa], positive.

  • c1 (float or array_like, optional) – Pipe-support factor [-], nonnegative: 1 for expansion joints throughout, \(1 - \nu^2\) for a pipe anchored against axial movement, 0 for a rigid pipe.

Returns:

Wave speed [m/s]; at most the speed of sound \(\sqrt{K/\rho}\) in the liquid.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Thin-walled pipe, \(D/e \ge 25\); a ValidityWarning is issued for thicker walls.

References

D. J. Korteweg, “Ueber die Fortpflanzungsgeschwindigkeit des Schalles in elastischen Röhren,” Ann. Phys. 241 (1878) 525-542.

Examples

>>> round(float(pipe_wave_speed(2.2e9, 1000.0, 0.5, 0.01, 200e9)))
1191
engineeringkit.fluid_engineering.pitot_velocity(delta_p, rho)[source]#

Flow speed from a Pitot-static reading, \(v = \sqrt{2\Delta p/\rho}\).

Parameters:
  • delta_p (float or array_like) – Stagnation minus static pressure [Pa], nonnegative.

  • rho (float or array_like) – Fluid density [kg/m^3], positive.

Returns:

Flow speed [m/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Incompressible flow; for gases the error is below 1% up to about Mach 0.2.

References

H. Pitot, “Description d’une machine pour mesurer la vitesse des eaux courantes et le sillage des vaisseaux,” Hist. Acad. R. Sci. (1732) 363-376.

Examples

>>> float(pitot_velocity(2000.0, 1000.0))
2.0
engineeringkit.fluid_engineering.poiseuille_flow(delta_p, radius, length, mu)[source]#

Hagen-Poiseuille volume flow, \(Q = \pi R^4 \Delta p/(8\mu L)\).

Parameters:
  • delta_p (float or array_like) – Pressure drop along the pipe [Pa]; the sign sets the direction.

  • radius (float or array_like) – Pipe radius [m], positive.

  • length (float or array_like) – Pipe length [m], positive.

  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

Returns:

Volume flow [m^3/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Fully developed laminar flow of a Newtonian fluid with no slip at the wall.

References

G. Hagen, “Über die Bewegung des Wassers in engen cylindrischen Röhren,” Ann. Phys. Chem. 46 (1839) 423-442; J. L. M. Poiseuille, “Recherches expérimentales sur le mouvement des liquides dans les tubes de très petits diamètres,” C. R. Acad. Sci. 11 (1840) 961-967, 1041-1048.

Examples

>>> f"{poiseuille_flow(100.0, 0.001, 1.0, 0.001):.4e}"
'3.9270e-08'
engineeringkit.fluid_engineering.poiseuille_velocity(r, delta_p, radius, length, mu)[source]#

Parabolic Hagen-Poiseuille velocity profile, \(u(r) = \Delta p\,(R^2 - r^2)/(4\mu L)\).

Parameters:
  • r (float or array_like) – Radial position [m], between 0 and radius.

  • delta_p (float or array_like) – Pressure drop along the pipe [Pa].

  • radius (float or array_like) – Pipe radius [m], positive.

  • length (float or array_like) – Pipe length [m], positive.

  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

Returns:

Axial velocity [m/s]; the centreline value is twice the mean.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> float(poiseuille_velocity(0.0, 4.0, 1.0, 1.0, 1.0))
1.0
engineeringkit.fluid_engineering.pressure_head(p, rho, g=9.80665)[source]#

Height of a fluid column that produces pressure \(p\), \(h = p/(\rho g)\).

Parameters:
  • p (float or array_like) – Pressure [Pa]; gauge or absolute, and the head is of the same kind.

  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Pressure head [m].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> round(pressure_head(101325.0, 13595.1), 4)
0.76
engineeringkit.fluid_engineering.pump_curve_head(Q, shutoff_head, a, b=0.0)[source]#

Head of a pump on a quadratic curve, \(H = H_0 + bQ - aQ^2\).

Parameters:
  • Q (float or array_like) – Volume flow [m^3/s], nonnegative.

  • shutoff_head (float or array_like) – Head at zero flow \(H_0\) [m], positive.

  • a (float or array_like) – Quadratic coefficient [s^2/m^5], nonnegative.

  • b (float or array_like, optional) – Linear coefficient [s/m^2]; a small positive value gives the rising-then-falling curve of some radial pumps.

Returns:

Pump head [m]; negative beyond the flow at which the pump runs out.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Fit shutoff_head, a and b to three points of a manufacturer’s curve.

Examples

>>> pump_curve_head(0.1, 40.0, 1000.0)
30.0
engineeringkit.fluid_engineering.pump_hydraulic_power(rho, Q, head, g=9.80665)[source]#

Power delivered to the fluid, \(P = \rho g Q H\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • Q (float or array_like) – Volume flow [m^3/s], nonnegative.

  • head (float or array_like) – Head added by the pump [m], nonnegative.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Hydraulic power [W].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> pump_hydraulic_power(1000.0, 0.01, 10.0, g=10.0)
1000.0
engineeringkit.fluid_engineering.pump_input_power(rho, Q, head, efficiency, g=9.80665)[source]#

Shaft power a pump needs, \(P = \rho g Q H/\eta\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • Q (float or array_like) – Volume flow [m^3/s], nonnegative.

  • head (float or array_like) – Head added by the pump [m], nonnegative.

  • efficiency (float or array_like) – Pump efficiency [-], in (0, 1].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Shaft power [W].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> pump_input_power(1000.0, 0.01, 10.0, 0.5, g=10.0)
2000.0
engineeringkit.fluid_engineering.pump_operating_point(shutoff_head, a, static_head, k, b=0.0, series=1, parallel=1)[source]#

Flow and head where identical pumps meet a system curve.

With \(n_s\) pumps in series and \(n_p\) such strings in parallel, the combined curve is \(H = n_s\,(H_0 + bQ/n_p - a(Q/n_p)^2)\). Setting it equal to \(H_s + kQ^2\) gives a quadratic in \(Q\) with one positive root.

Parameters:
  • shutoff_head (float) – Shut-off head of one pump [m], positive.

  • a (float) – Quadratic coefficient of one pump [s^2/m^5], nonnegative.

  • static_head (float) – Static lift of the system [m]; must be below the combined shut-off head.

  • k (float) – System loss coefficient [s^2/m^5], nonnegative; a and k must not both be zero.

  • b (float, optional) – Linear coefficient of one pump [s/m^2].

  • series (int, optional) – Pumps in series, at least 1.

  • parallel (int, optional) – Strings in parallel, at least 1.

Returns:

Flow [m^3/s] and head [m] at the crossing, with both curves.

Return type:

OperatingPoint

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Series pumps add head at a given flow; parallel pumps add flow at a given head. Which gains more depends on how steep the system curve is.

Examples

>>> pump_operating_point(40.0, 1000.0, 10.0, 2000.0).summary()["flow_m3_s"]
0.1
engineeringkit.fluid_engineering.pump_specific_speed(omega, Q, head, g=9.80665)[source]#

Dimensionless specific speed \(\Omega_s = \omega\sqrt Q/(gH)^{3/4}\).

Parameters:
  • omega (float or array_like) – Shaft speed [rad/s], nonnegative.

  • Q (float or array_like) – Volume flow at best efficiency [m^3/s], nonnegative.

  • head (float or array_like) – Head at best efficiency [m], positive.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Specific speed [-]: below about 1 for radial pumps, above about 4 for axial ones.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Industry values in rpm, gpm and feet differ by a constant factor.

Examples

>>> float(pump_specific_speed(10.0, 4.0, 1.0, g=1.0))
20.0
engineeringkit.fluid_engineering.rectangular_weir_flow(head, width, discharge_coefficient=0.62, g=9.80665)[source]#

Flow over a sharp-crested rectangular weir, \(Q = C_d\,\tfrac23\,b\sqrt{2g}\,H^{3/2}\).

Parameters:
  • head (float or array_like) – Head over the crest, measured upstream of the drawdown [m], nonnegative.

  • width (float or array_like) – Crest width [m], positive.

  • discharge_coefficient (float or array_like, optional) – \(C_d\) in (0, 1]; about 0.62, rising slowly with \(H/P\) (see rehbock_discharge_coefficient()).

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Volume flow [m^3/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The ideal flow integrates Torricelli’s speed \(\sqrt{2gz}\) over the depth below the free surface. A full-width weir with a ventilated nappe; end contractions reduce the effective width by about \(0.1H\) per end (Francis).

Examples

>>> round(float(rectangular_weir_flow(0.3, 2.0)), 4)
0.6016
engineeringkit.fluid_engineering.rehbock_discharge_coefficient(head, weir_height)[source]#

Rehbock’s discharge coefficient of a rectangular weir, \(C_d = 0.611 + 0.075\,H/P\).

Parameters:
  • head (float or array_like) – Head over the crest [m], nonnegative.

  • weir_height (float or array_like) – Height of the crest above the channel bed \(P\) [m], positive.

Returns:

Discharge coefficient [-] for rectangular_weir_flow().

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The \(H/P\) term accounts for the approach velocity. Fitted for \(H/P\) up to 5, as given in Munson et al., Fundamentals of Fluid Mechanics; a ValidityWarning is issued above.

Examples

>>> rehbock_discharge_coefficient(0.5, 1.0)
0.6485
engineeringkit.fluid_engineering.reynolds_number(rho, v, D, mu)[source]#

Reynolds number \(Re = \rho |v| D/\mu\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • v (float or array_like) – Mean flow velocity [m/s]; its magnitude is used.

  • D (float or array_like) – Pipe (or hydraulic) diameter [m], positive.

  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

Returns:

Reynolds number [-]. Pipe flow is laminar below about 2300.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

O. Reynolds, “An experimental investigation of the circumstances which determine whether the motion of water shall be direct or sinuous, and of the law of resistance in parallel channels,” Phil. Trans. R. Soc. 174 (1883) 935-982.

Examples

>>> reynolds_number(1000.0, 1.0, 0.1, 0.001)
100000.0
engineeringkit.fluid_engineering.sequent_depth(y1, v1, g=9.80665)[source]#

Depth after a hydraulic jump from Bélanger’s momentum balance.

\[\frac{y_2}{y_1} = \frac{\sqrt{1 + 8\,\mathrm{Fr}_1^2} - 1}{2}, \qquad \mathrm{Fr}_1 = \frac{v_1}{\sqrt{g y_1}}\]
Parameters:
  • y1 (float or array_like) – Depth before the jump [m], positive.

  • v1 (float or array_like) – Mean velocity before the jump [m/s].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Sequent (conjugate) depth [m]. A jump forms only from supercritical flow, \(\mathrm{Fr}_1 > 1\); the relation is symmetric, so a subcritical y1 returns the supercritical depth paired with it.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Horizontal, wide rectangular channel with bed friction over the short jump neglected: the pressure force plus momentum flux \(\rho g y^2/2 + \rho q^2/y\) per unit width is the same on both sides.

References

J.-B. Bélanger, Essai sur la solution numérique de quelques problèmes relatifs au mouvement permanent des eaux courantes (Paris: Carilian-Goeury, 1828); H. Chanson, “Development of the Bélanger equation and backwater equation by Jean-Baptiste Bélanger (1828),” J. Hydraul. Eng. 135 (2009) 159-163, doi:10.1061/(ASCE)0733-9429(2009)135:3(159).

Examples

>>> round(float(sequent_depth(0.5, np.sqrt(15.0), g=10.0)), 6)
1.0
engineeringkit.fluid_engineering.smooth_pipe_friction_factor(Re)[source]#

Prandtl-Kármán friction factor of a hydraulically smooth pipe.

Solves \(1/\sqrt f = 2\log_{10}(Re\sqrt f) - 0.8\), the fit to Nikuradse’s smooth-pipe measurements.

Parameters:

Re (float or array_like) – Reynolds number [-], at least 4000.

Returns:

Darcy friction factor [-].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

J. Nikuradse, “Gesetzmäßigkeiten der turbulenten Strömung in glatten Rohren,” VDI-Forschungsheft 356 (1932).

Examples

>>> round(smooth_pipe_friction_factor(1e5), 4)
0.018
engineeringkit.fluid_engineering.specific_energy(y, q, g=9.80665)[source]#

Specific energy of flow in a wide rectangular channel, \(E = y + q^2/(2gy^2)\).

Parameters:
  • y (float or array_like) – Flow depth [m], positive.

  • q (float or array_like) – Flow per unit width \(Q/b\) [m^2/s], nonnegative.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Head above the channel bed [m]: the depth plus the velocity head.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Hydrostatic pressure (straight, parallel streamlines) and a uniform velocity over the depth.

References

B. A. Bakhmeteff, O neravnomernom dvizhenii zhidkosti v otkrytom rusle [Varied flow of liquids in open channels] (St Petersburg, 1912); B. A. Bakhmeteff, Hydraulics of Open Channels (New York: McGraw-Hill, 1932).

Examples

>>> specific_energy(1.0, 2.0, g=10.0)
1.2
engineeringkit.fluid_engineering.sphere_drag_coefficient(Re)[source]#

Drag coefficient of a smooth sphere, \(C_D \approx 24/Re + 6/(1 + \sqrt{Re}) + 0.4\).

Parameters:

Re (float or array_like) – Reynolds number \(\rho V d/\mu\) [-], in (0, 2e5].

Returns:

Drag coefficient on the frontal area \(\pi d^2/4\) [-].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. White’s curve fit, within about 10% of measurements up to the drag crisis; it tends to Stokes’s \(24/Re\) as \(Re \to 0\). Above \(2\times10^5\) the boundary layer turns turbulent and \(C_D\) drops to about 0.1, which this fit does not represent, so those values are rejected.

References

F. M. White, Viscous Fluid Flow, 3rd ed. (New York: McGraw-Hill, 2006), chapter 3.

Examples

>>> float(sphere_drag_coefficient(1.0))
27.4
engineeringkit.fluid_engineering.stokes_drag(mu, v, d)[source]#

Stokes’s drag on a sphere in creeping flow, \(F = 3\pi\mu d V\).

Parameters:
  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

  • v (float or array_like) – Speed of the sphere relative to the fluid [m/s]; the force has its sign.

  • d (float or array_like) – Sphere diameter [m], positive.

Returns:

Drag force [N], opposing the motion.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Valid for \(Re = \rho V d/\mu\) below about 1. Two thirds of the drag is skin friction and one third pressure.

References

G. G. Stokes, “On the effect of the internal friction of fluids on the motion of pendulums,” Trans. Camb. Phil. Soc. 9, Part II (1851) 8-106 (read 9 December 1850).

Examples

>>> round(float(stokes_drag(1e-3, 0.01, 1e-3 / np.pi)), 12)
3e-08
engineeringkit.fluid_engineering.stokes_settling_velocity(d, rho_particle, rho, mu, g=9.80665)[source]#

Terminal velocity of a small sphere in Stokes flow, \(V = (\rho_p - \rho) g d^2/(18\mu)\).

Parameters:
  • d (float or array_like) – Sphere diameter [m], positive.

  • rho_particle (float or array_like) – Sphere density [kg/m^3], positive.

  • rho (float or array_like) – Fluid density [kg/m^3], nonnegative.

  • mu (float or array_like) – Dynamic viscosity [Pa s], positive.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Settling velocity [m/s], downward; negative when the sphere is lighter than the fluid and rises.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Valid while the Reynolds number \(\rho |V| d/\mu\) of the result is at most 1; above it a ValidityWarning is issued, and terminal_velocity() applies.

Examples

>>> round(float(stokes_settling_velocity(1e-4, 2650.0, 1000.0, 1e-3, g=10.0)), 6)
0.009167
engineeringkit.fluid_engineering.swamee_jain_friction_factor(Re, relative_roughness)[source]#

Swamee and Jain’s explicit approximation to Colebrook’s equation.

\[f = \frac{0.25}{\left[\log_{10}\left(\frac{\varepsilon/D}{3.7} + \frac{5.74}{Re^{0.9}}\right)\right]^2}\]
Parameters:
  • Re (float or array_like) – Reynolds number [-], in [5000, 1e8].

  • relative_roughness (float or array_like) – Roughness over diameter \(\varepsilon/D\) [-], in [0, 0.05].

Returns:

Darcy friction factor [-], within 3% of Colebrook in that range (largest near Re = 5000) and usually within 1%.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

P. K. Swamee and A. K. Jain, “Explicit equations for pipe-flow problems,” J. Hydraul. Div. ASCE 102 (1976) 657-664.

Examples

>>> round(float(swamee_jain_friction_factor(1e5, 1e-4)), 4)
0.0185
engineeringkit.fluid_engineering.system_curve_head(Q, static_head, k)[source]#

Head a piping system needs, \(H = H_s + kQ^2\).

Parameters:
  • Q (float or array_like) – Volume flow [m^3/s], nonnegative.

  • static_head (float or array_like) – Static lift, outlet minus inlet surface elevation plus any pressure difference as head [m]; may be negative.

  • k (float or array_like) – Loss coefficient [s^2/m^5], nonnegative: the sum of pipe_resistance() over the pipes in series plus the minor losses as \(K/(2gA^2)\).

Returns:

Required head [m].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Holding k fixed treats the friction factor as constant, which is exact for fully rough flow.

Examples

>>> system_curve_head(0.1, 10.0, 1000.0)
20.0
engineeringkit.fluid_engineering.tank_drain_time(tank_area, orifice_area, h0, h1=0.0, discharge_coefficient=0.61, g=9.80665)[source]#

Time for a tank of constant section to drain from h0 to h1 through an orifice.

\[t = \frac{A_t}{C_d A_o}\sqrt{\frac{2}{g}}\left(\sqrt{h_0} - \sqrt{h_1}\right)\]
Parameters:
  • tank_area (float or array_like) – Horizontal area of the tank [m^2], positive.

  • orifice_area (float or array_like) – Orifice area [m^2], positive and much smaller than the tank.

  • h0 (float or array_like) – Starting head above the orifice [m], nonnegative.

  • h1 (float or array_like, optional) – Final head [m], in [0, h0].

  • discharge_coefficient (float or array_like, optional) – \(C_d\) in (0, 1].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Drain time [s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Integrates \(A_t\,dh/dt = -Q(h)\) from orifice_flow(), treating the flow as quasi-steady. The level falls fastest at the start, so the first half of the depth drains in less than a third of the time.

Examples

>>> round(float(tank_drain_time(1.0, 0.01, 5.0, discharge_coefficient=1.0, g=10.0)), 6)
100.0
engineeringkit.fluid_engineering.terminal_velocity(d, rho_particle, rho, mu, g=9.80665)[source]#

Terminal velocity of a sphere falling through a fluid, from the drag curve.

Drag balances weight less buoyancy when \(C_D(Re)\,Re^2 = \tfrac43\,(\rho_p - \rho)\rho g d^3/\mu^2\); the left side, with sphere_drag_coefficient(), grows steadily with \(Re\), so Brent’s method finds the single root.

Parameters:
  • d (float) – Sphere diameter [m], positive.

  • rho_particle (float) – Sphere density [kg/m^3], greater than rho.

  • rho (float) – Fluid density [kg/m^3], positive.

  • mu (float) – Dynamic viscosity [Pa s], positive.

  • g (float, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Terminal velocity [m/s].

Return type:

float

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Scalar inputs only. Raises ValueError when the answer lies beyond the drag crisis (\(Re > 2\times10^5\)). Equal to stokes_settling_velocity() in the limit of small spheres.

Examples

A 1 mm sand grain in water:

>>> round(terminal_velocity(1e-3, 2650.0, 1000.0, 1e-3), 3)
0.145
engineeringkit.fluid_engineering.thoma_sigma(npsh, head)[source]#

Thoma’s cavitation parameter \(\sigma = \mathrm{NPSH}/H\).

Parameters:
  • npsh (float or array_like) – Net positive suction head [m].

  • head (float or array_like) – Head of the machine [m], positive.

Returns:

Thoma’s \(\sigma\) [-]. A machine runs free of cavitation while its plant \(\sigma\) stays above the critical value found by test for its design.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

References

D. Thoma, “Die Kavitation bei Wasserturbinen,” Wasserkraft-Jahrbuch (Munich, 1924).

Examples

>>> thoma_sigma(5.0, 50.0)
0.1
engineeringkit.fluid_engineering.v_notch_weir_flow(head, angle=1.5707963267948966, discharge_coefficient=0.58, g=9.80665)[source]#

Flow over a sharp-crested triangular (V-notch) weir.

\[Q = C_d\,\frac{8}{15}\,\sqrt{2g}\,\tan\frac{\theta}{2}\,H^{5/2}\]
Parameters:
  • head (float or array_like) – Head above the vertex of the notch [m], nonnegative.

  • angle (float or array_like, optional) – Included angle of the notch \(\theta\) [rad], in (0, π); the default is the 90° notch.

  • discharge_coefficient (float or array_like, optional) – \(C_d\) in (0, 1]; about 0.58 for a 90° notch.

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Volume flow [m^3/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. The flow section stays similar as the head changes, so \(C_d\) is nearly constant, and the \(H^{5/2}\) law keeps the head readable at small flows.

References

J. Thomson, “On experiments on the measurement of water by triangular notches in weir boards,” Rep. Br. Assoc. Adv. Sci. (1858), Trans. Sect., 181; (1861), Trans. Sect., 151.

Examples

>>> round(float(v_notch_weir_flow(0.2)), 5)
0.02451
engineeringkit.fluid_engineering.velocity_head(v, g=9.80665)[source]#

Velocity head \(v^2/(2g)\).

Parameters:
  • v (float or array_like) – Mean flow speed [m/s].

  • g (float or array_like, optional) – Gravitational acceleration [m/s^2], positive.

Returns:

Velocity head [m], the gap between the energy and hydraulic grade lines.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> velocity_head(2.0, g=10.0)
0.2
engineeringkit.fluid_engineering.venturi_flow(delta_p, rho, A1, A2, discharge_coefficient=1.0)[source]#

Volume flow through a Venturi meter.

\[Q = C_d\,A_2\sqrt{\frac{2\Delta p}{\rho\,(1 - (A_2/A_1)^2)}}\]
Parameters:
  • delta_p (float or array_like) – Inlet minus throat pressure [Pa], nonnegative.

  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • A1 (float or array_like) – Inlet area [m^2], positive.

  • A2 (float or array_like) – Throat area [m^2], positive and smaller than A1.

  • discharge_coefficient (float or array_like, optional) – \(C_d\) in (0, 1]; the default 1 is the ideal meter, and 0.98 is typical of a machined Venturi tube.

Returns:

Volume flow [m^3/s].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Horizontal meter and incompressible flow.

References

G. B. Venturi, Recherches expérimentales sur le principe de la communication latérale du mouvement dans les fluides (Paris, 1797); C. Herschel, “The Venturi water meter,” Trans. ASCE 17 (1887) 228-258.

Examples

>>> round(float(venturi_flow(15000.0, 1000.0, 0.02, 0.01)), 4)
0.0632
engineeringkit.fluid_engineering.water_hammer_pressure(rho, wave_speed, delta_v)[source]#

Joukowsky pressure rise for a sudden velocity change, \(\Delta p = \rho a\,\Delta v\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • wave_speed (float or array_like) – Pressure-wave speed in the pipe [m/s], positive (see pipe_wave_speed()).

  • delta_v (float or array_like) – Velocity reduction [m/s]; negative for a sudden opening.

Returns:

Pressure rise [Pa].

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities. Holds for closures shorter than \(2L/a\) and neglects friction.

References

N. Joukowsky, “Über den hydraulischen Stoss in Wasserleitungsröhren,” Mém. Acad. Imp. Sci. St.-Pétersbourg, 8th ser., 9(5) (1900) 1-71 (read 1898); English translation by O. Simin, Proc. AWWA 24 (1904) 341-424.

Examples

>>> water_hammer_pressure(1000.0, 1200.0, 1.0)
1200000.0
engineeringkit.fluid_engineering.weber_number(rho, v, length, surface_tension)[source]#

Weber number \(We = \rho v^2 L/\sigma\).

Parameters:
  • rho (float or array_like) – Fluid density [kg/m^3], positive.

  • v (float or array_like) – Speed [m/s].

  • length (float or array_like) – Characteristic length, such as a droplet diameter [m], positive.

  • surface_tension (float or array_like) – Surface tension [N/m], positive.

Returns:

Weber number [-], the ratio of inertia to surface tension.

Return type:

float or ndarray

Notes

Inputs are raw SI numbers with no dimensional metadata; see Fluid engineering: flow regimes and signed quantities.

Examples

>>> weber_number(1000.0, 1.0, 0.01, 0.1)
100.0

Utilities#

Supporting numerics for engineeringkit.fluid_engineering’s systems/ modules.

engineeringkit.fluid_engineering.utils.integer_null_space(matrix)[source]#

Integer basis of the null space of an integer matrix.

One basis vector is built per free (non-pivot) column: that column’s entry is set to one and the pivot entries are read from the reduced matrix. Each vector is then scaled to coprime integers.

Parameters:

matrix (array_like of int) – Matrix of shape (m, n).

Returns:

Basis vectors as rows, shape (n - rank, n); the free column of each row is positive.

Return type:

ndarray of int

engineeringkit.fluid_engineering.utils.rational_rref(matrix)[source]#

Reduced row echelon form of an integer matrix, computed exactly.

Parameters:

matrix (array_like of int) – Matrix of shape (m, n).

Returns:

  • rref (list of list of Fraction) – The reduced matrix, m rows of n entries.

  • pivots (list of int) – Column index of each pivot, in order; len(pivots) is the rank.

Visualizers#

Matplotlib visualizers for engineeringkit.fluid_engineering.

engineeringkit.fluid_engineering.visualizers.plot_grade_lines(x, z, pressure_head, velocity_head, ax=None)[source]#

Draw the pipe centreline with its hydraulic and energy grade lines.

The hydraulic grade line (HGL) is \(z + p/(\rho g)\), the height water would rise in a piezometer; the energy grade line (EGL) adds the velocity head. Friction makes both fall in the direction of flow.

Parameters:
  • x (array_like) – Distance along the pipe [m], shape (n,).

  • z (array_like) – Centreline elevation [m], shape (n,).

  • pressure_head (array_like) – \(p/(\rho g)\) [m], shape (n,).

  • velocity_head (array_like) – \(v^2/(2g)\) [m], shape (n,).

  • ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.

Return type:

matplotlib.axes.Axes

engineeringkit.fluid_engineering.visualizers.plot_moody_diagram(relative_roughness=(0.0, 1e-05, 0.0001, 0.001, 0.005, 0.01, 0.02, 0.05), ax=None)[source]#

Draw a Moody chart: Darcy friction factor against Reynolds number.

The laminar line \(64/Re\) is drawn up to 2300 and one Colebrook curve per relative roughness from 4000 to \(10^8\); the transition range between them is shaded.

Parameters:
  • relative_roughness (array_like, optional) – Values of \(\varepsilon/D\) [-] in [0, 0.05], one curve each.

  • ax (matplotlib.axes.Axes, optional) – Axes to draw on; a new figure is created if omitted.

Return type:

matplotlib.axes.Axes