# How to use the fluids.numerics.interp function in fluids

## To help you get started, we’ve selected a few fluids examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately. CalebBell / fluids / tests / test_numerics.py View on Github ``````0.147613, 0.144052, 0.14305, 0.140107, 0.138981, 0.136794, 0.134737,
0.132847, 0.129303, 0.127637, 0.124758, 0.124006, 0.119269, 0.118449,
0.113605, 0.113269, 0.108995, 0.107109, 0.103688, 0.102529, 0.099567,
0.097791, 0.095055, 0.087681, 0.087648]

xs = np.linspace(0.29, 0.76, 100)
ys = [interp(xi, a, b) for xi in xs.tolist()]
ys_numpy = np.interp(xs, a, b)
assert_allclose(ys, ys_numpy, atol=1e-12, rtol=1e-11)

# Test custom extrapolation method
xs = [1,2,3]
ys = [.1, .2, .3]
assert_close(interp(3.5, xs, ys, extrapolate=True), .35, rtol=1e-15)
assert_close(interp(0, xs, ys, extrapolate=True), 0, rtol=1e-15)
assert_close(interp(-1, xs, ys, extrapolate=True), -.1, rtol=1e-15)
assert_close(interp(-100, xs, ys, extrapolate=True), -10, rtol=1e-15)
assert_close(interp(10, xs, ys, extrapolate=True), 1, rtol=1e-15)
assert_close(interp(10**30, xs, ys, extrapolate=True), 10**29, rtol=1e-15)`````` CalebBell / fluids / fluids / safety_valve.py View on Github ``````References
----------
..  API Standard 520, Part 1 - Sizing and Selection.
'''
gauge_backpressure = (Pback-atm)/(Pset-atm)*100.0 # in percent
if overpressure not in (0.1, 0.16, 0.21):
raise ValueError('Only overpressure of 10%, 16%, or 21% are permitted')
if (overpressure == 0.1 and gauge_backpressure &lt; 30.0) or (
overpressure == 0.16 and gauge_backpressure &lt; 38.0) or (
overpressure == 0.21 and gauge_backpressure &lt; 50.0):
return 1.0
elif gauge_backpressure &gt; 50.0:
raise ValueError('Gauge pressure must be &lt; 50%')
if overpressure == 0.16:
Kb = interp(gauge_backpressure, Kb_16_over_x, Kb_16_over_y)
elif overpressure == 0.1:
Kb = interp(gauge_backpressure, Kb_10_over_x, Kb_10_over_y)
return Kb
`````` CalebBell / fluids / fluids / pump.py View on Github ``````efficiency = interp(P, nema_high_P, nema_high_full_closed_2p)
elif poles == 4:
efficiency = interp(P, nema_high_P, nema_high_full_closed_4p)
elif poles == 6:
efficiency = interp(P, nema_high_P, nema_high_full_closed_6p)
else:
if poles == 2:
efficiency = interp(P, nema_high_P, nema_high_full_open_2p)
elif poles == 4:
efficiency = interp(P, nema_high_P, nema_high_full_open_4p)
elif poles == 6:
efficiency = interp(P, nema_high_P, nema_high_full_open_6p)
else:
if closed:
if poles == 2:
efficiency = interp(P, nema_min_P, nema_min_full_closed_2p)
elif poles == 4:
efficiency = interp(P, nema_min_P, nema_min_full_closed_4p)
elif poles == 6:
efficiency = interp(P, nema_min_P, nema_min_full_closed_6p)
elif poles == 8:
efficiency = interp(P, nema_min_P, nema_min_full_closed_8p)
else:
if poles == 2:
efficiency = interp(P, nema_min_P, nema_min_full_open_2p)
elif poles == 4:
efficiency = interp(P, nema_min_P, nema_min_full_open_4p)
elif poles == 6:
efficiency = interp(P, nema_min_P, nema_min_full_open_6p)
elif poles == 8:
efficiency = interp(P, nema_min_P, nema_min_full_open_8p)`````` CalebBell / fluids / fluids / filters.py View on Github ``````-----
Linear interpolation between a table of values.
The velocity the loss coefficient relates to is the approach velocity
before the screen.

Examples
--------
>>> square_edge_screen(0.99)
0.008000000000000007

References
----------
..  Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
'''
return interp(alpha, square_alphas, square_Ks)
`````` CalebBell / fluids / fluids / pump.py View on Github ``````if closed:
if poles == 2:
efficiency = interp(P, nema_min_P, nema_min_full_closed_2p)
elif poles == 4:
efficiency = interp(P, nema_min_P, nema_min_full_closed_4p)
elif poles == 6:
efficiency = interp(P, nema_min_P, nema_min_full_closed_6p)
elif poles == 8:
efficiency = interp(P, nema_min_P, nema_min_full_closed_8p)
else:
if poles == 2:
efficiency = interp(P, nema_min_P, nema_min_full_open_2p)
elif poles == 4:
efficiency = interp(P, nema_min_P, nema_min_full_open_4p)
elif poles == 6:
efficiency = interp(P, nema_min_P, nema_min_full_open_6p)
elif poles == 8:
efficiency = interp(P, nema_min_P, nema_min_full_open_8p)

return round(efficiency, 4)`````` CalebBell / fluids / fluids / flow_meter.py View on Github ``````elif meter_type == CONE_METER:
epsilon = cone_meter_expansibility_Stewart(D=D, Dc=D2, P1=P1, P2=P2, k=k)
C = CONE_METER_C
elif meter_type == WEDGE_METER:
beta = diameter_ratio_wedge_meter(D=D, H=D2)
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P1, k=k, beta=beta)
C = C_wedge_meter_ISO_5167_6_2017(D=D, H=D2)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
epsilon = orifice_expansibility(D, D2, P1, P2, k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_cone_meter(D, D2)
epsilon = cone_meter_expansibility_Stewart(D=D, Dc=D2, P1=P1, P2=P2, k=k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_wedge_meter(D=D, H=D2)`````` CalebBell / fluids / fluids / safety_valve.py View on Github ``````----------
..  API Standard 520, Part 1 - Sizing and Selection.
'''
gauge_backpressure = (Pback-atm)/(Pset-atm)*100.0 # in percent
if overpressure not in (0.1, 0.16, 0.21):
raise ValueError('Only overpressure of 10%, 16%, or 21% are permitted')
if (overpressure == 0.1 and gauge_backpressure &lt; 30.0) or (
overpressure == 0.16 and gauge_backpressure &lt; 38.0) or (
overpressure == 0.21 and gauge_backpressure &lt; 50.0):
return 1.0
elif gauge_backpressure &gt; 50.0:
raise ValueError('Gauge pressure must be &lt; 50%')
if overpressure == 0.16:
Kb = interp(gauge_backpressure, Kb_16_over_x, Kb_16_over_y)
elif overpressure == 0.1:
Kb = interp(gauge_backpressure, Kb_10_over_x, Kb_10_over_y)
return Kb
`````` CalebBell / fluids / fluids / flow_meter.py View on Github ``````epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P1, k=k, beta=beta)
C = C_wedge_meter_ISO_5167_6_2017(D=D, H=D2)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
epsilon = orifice_expansibility(D, D2, P1, P2, k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_cone_meter(D, D2)
epsilon = cone_meter_expansibility_Stewart(D=D, Dc=D2, P1=P1, P2=P2, k=k)
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_wedge_meter(D=D, H=D2)
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P1, k=k, beta=beta)
elif meter_type == UNSPECIFIED_METER:
epsilon = orifice_expansibility(D, D2, P1, P2, k) # Default to orifice type expansibility
if C_specified is None:``````

## fluids

Fluid dynamics component of Chemical Engineering Design Library (ChEDL) GitHub MIT Latest version published 16 days ago

69 / 100