Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
References
----------
.. [1] 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 < 30.0) or (
overpressure == 0.16 and gauge_backpressure < 38.0) or (
overpressure == 0.21 and gauge_backpressure < 50.0):
return 1.0
elif gauge_backpressure > 50.0:
raise ValueError('Gauge pressure must be < 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
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)
-----
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
----------
.. [1] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
'''
return interp(alpha, square_alphas, square_Ks)
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)
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)
elif meter_type == HOLLINGSHEAD_ORIFICE:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
C = float(bisplev(D2/D, log(Re_D), orifice_std_Hollingshead_tck))
epsilon = orifice_expansibility(D, D2, P1, P2, k)
elif meter_type == HOLLINGSHEAD_VENTURI_SMOOTH:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
C = interp(log(Re_D), venturi_logRes_Hollingshead, venturi_smooth_Cs_Hollingshead, extrapolate=True)
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
elif meter_type == HOLLINGSHEAD_VENTURI_SHARP:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
C = interp(log(Re_D), venturi_logRes_Hollingshead, venturi_sharp_Cs_Hollingshead, extrapolate=True)
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
elif meter_type == HOLLINGSHEAD_CONE:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_cone_meter(D, D2)
C = float(bisplev(beta, log(Re_D), cone_Hollingshead_tck))
epsilon = cone_meter_expansibility_Stewart(D=D, Dc=D2, P1=P1, P2=P2, k=k)
elif meter_type == HOLLINGSHEAD_WEDGE:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_wedge_meter(D=D, H=D2)
----------
.. [1] 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 < 30.0) or (
overpressure == 0.16 and gauge_backpressure < 38.0) or (
overpressure == 0.21 and gauge_backpressure < 50.0):
return 1.0
elif gauge_backpressure > 50.0:
raise ValueError('Gauge pressure must be < 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
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)
elif meter_type == HOLLINGSHEAD_ORIFICE:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
C = float(bisplev(D2/D, log(Re_D), orifice_std_Hollingshead_tck))
epsilon = orifice_expansibility(D, D2, P1, P2, k)
elif meter_type == HOLLINGSHEAD_VENTURI_SMOOTH:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
C = interp(log(Re_D), venturi_logRes_Hollingshead, venturi_smooth_Cs_Hollingshead, extrapolate=True)
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
elif meter_type == HOLLINGSHEAD_VENTURI_SHARP:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
C = interp(log(Re_D), venturi_logRes_Hollingshead, venturi_sharp_Cs_Hollingshead, extrapolate=True)
epsilon = nozzle_expansibility(D=D, Do=D2, P1=P1, P2=P2, k=k)
elif meter_type == HOLLINGSHEAD_CONE:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_cone_meter(D, D2)
C = float(bisplev(beta, log(Re_D), cone_Hollingshead_tck))
epsilon = cone_meter_expansibility_Stewart(D=D, Dc=D2, P1=P1, P2=P2, k=k)
elif meter_type == HOLLINGSHEAD_WEDGE:
v = m/((0.25*pi*D*D)*rho)
Re_D = rho*v*D/mu
beta = diameter_ratio_wedge_meter(D=D, H=D2)
C = float(bisplev(beta, log(Re_D), wedge_Hollingshead_tck))
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:
Cv_char_linear = lambda opening: interp(opening, opening_linear, frac_CV_linear)