Safety/relief valve sizing (fluids.safety_valve)¶

fluids.safety_valve.
API520_round_size
(A)[source]¶ Rounds up the area from an API 520 calculation to an API526 standard valve area. The returned area is always larger or equal to the input area.
Parameters:  A : float
Minimum discharge area [m^2]
Returns:  area : float
Actual discharge area [m^2]
Notes
To obtain the letter designation of an input area, lookup the area with the following:
API526_letters[API526_A.index(area)]
An exception is raised if the required relief area is larger than any of the API 526 sizes.
References
[1] (1, 2) API Standard 526. Examples
From [1], checked with many points on Table 8.
>>> API520_round_size(1E4) 0.00012645136 >>> API526_letters[API526_A.index(API520_round_size(1E4))] 'E'

fluids.safety_valve.
API520_C
(k)[source]¶ Calculates coefficient C for use in API 520 critical flow relief valve sizing.
\[C = 0.03948\sqrt{k\left(\frac{2}{k+1}\right)^\frac{k+1}{k1}}\]Parameters:  k : float
Isentropic coefficient or ideal gas heat capacity ratio []
Returns:  C : float
Coefficient C []
Notes
If C cannot be established, assume a coefficient of 0.0239, the highest value possible for C.
Although not dimensional, C varies with the units used.
If k is exactly equal to 1, the expression is undefined, and the formula must be simplified as follows from an application of L’Hopital’s rule.
\[C = 0.03948\sqrt{\frac{1}{e}}\]References
[1] (1, 2) API Standard 520, Part 1  Sizing and Selection. Examples
From [1], checked with many points on Table 8.
>>> API520_C(1.35) 0.02669419967057233

fluids.safety_valve.
API520_F2
(k, P1, P2)[source]¶ Calculates coefficient F2 for subcritical flow for use in API 520 subcritical flow relief valve sizing.
\[ \begin{align}\begin{aligned}F_2 = \sqrt{\left(\frac{k}{k1}\right)r^\frac{2}{k} \left[\frac{1r^\frac{k1}{k}}{1r}\right]}\\r = \frac{P_2}{P_1}\end{aligned}\end{align} \]Parameters:  k : float
Isentropic coefficient or ideal gas heat capacity ratio []
 P1 : float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
 P2 : float
Builtup backpressure; the increase in pressure during flow at the outlet of a pressurerelief device after it opens, [Pa]
Returns:  F2 : float
Subcritical flow coefficient F2 []
Notes
F2 is completely dimensionless.
References
[1] (1, 2) API Standard 520, Part 1  Sizing and Selection. Examples
From [1] example 2, matches.
>>> API520_F2(1.8, 1E6, 7E5) 0.8600724121105563

fluids.safety_valve.
API520_Kv
(Re)[source]¶ Calculates correction due to viscosity for liquid flow for use in API 520 relief valve sizing.
\[K_v = \left(0.9935 + \frac{2.878}{Re^{0.5}} + \frac{342.75} {Re^{1.5}}\right)^{1}\]Parameters:  Re : float
Reynolds number for flow out the valve []
Returns:  Kv : float
Correction due to viscosity []
Notes
Reynolds number in the standard is defined as follows, with Q in L/min, G1 as specific gravity, mu in centipoise, and area in mm^2:
\[Re = \frac{Q(18800G_1)}{\mu \sqrt{A}}\]It is unclear how this expression was derived with a constant of 18800; the following code demonstrates what the constant should be:
>>> from scipy.constants import * >>> liter/minute*1000./(0.001*(milli**2)**0.5) 16666.666666666668
References
[1] (1, 2) API Standard 520, Part 1  Sizing and Selection. Examples
From [1], checked with example 5.
>>> API520_Kv(100) 0.6157445891444229

fluids.safety_valve.
API520_N
(P1)[source]¶ Calculates correction due to steam pressure for steam flow for use in API 520 relief valve sizing.
\[K_N = \frac{0.02764P_11000}{0.03324P_11061}\]Parameters:  P1 : float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
Returns:  KN : float
Correction due to steam temperature []
Notes
Although not dimensional, KN varies with the units used.
For temperatures above 922 K or 22057 kPa, KN is not defined.
Internally, units of kPa are used to match the equation in the standard.
References
[1] API Standard 520, Part 1  Sizing and Selection. Examples
Custom example:
>>> API520_N(1774700) 0.9490406958152466

fluids.safety_valve.
API520_SH
(T1, P1)[source]¶ Calculates correction due to steam superheat for steam flow for use in API 520 relief valve sizing. 2D interpolation among a table with 28 pressures and 10 temperatures is performed.
Parameters:  T1 : float
Temperature of the fluid entering the valve [K]
 P1 : float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
Returns:  KSH : float
Correction due to steam superheat []
Notes
For P above 20679 kPag, use the critical flow model. Superheat cannot be above 649 degrees Celcius. If T1 is above 149 degrees Celcius, returns 1.
References
[1] API Standard 520, Part 1  Sizing and Selection. Examples
Custom example from table 9:
>>> API520_SH(593+273.15, 1066.325E3) 0.7201800000000002

fluids.safety_valve.
API520_B
(Pset, Pback, overpressure=0.1)[source]¶ Calculates capacity correction due to backpressure on balanced springloaded PRVs in vapor service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolation among a table with 53 backpressures is performed.
Parameters:  Pset : float
Set pressure for relief [Pa]
 Pback : float
Backpressure, [Pa]
 overpressure : float, optional
The maximum fraction overpressure; one of 0.1, 0.16, or 0.21, []
Returns:  Kb : float
Correction due to vapor backpressure []
Notes
If the calculated gauge backpressure is less than 30%, 38%, or 50% for overpressures of 0.1, 0.16, or 0.21, a value of 1 is returned.
Percent gauge backpressure must be under 50%.
References
[1] API Standard 520, Part 1  Sizing and Selection. Examples
Custom examples from figure 30:
>>> API520_B(1E6, 5E5) 0.7929945420944432

fluids.safety_valve.
API520_W
(Pset, Pback)[source]¶ Calculates capacity correction due to backpressure on balanced springloaded PRVs in liquid service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolation among a table with 53 backpressures is performed.
Parameters:  Pset : float
Set pressure for relief [Pa]
 Pback : float
Backpressure, [Pa]
Returns:  KW : float
Correction due to liquid backpressure []
Notes
If the calculated gauge backpressure is less than 15%, a value of 1 is returned.
References
[1] API Standard 520, Part 1  Sizing and Selection. Examples
Custom example from figure 31:
>>> API520_W(1E6, 3E5) # 22% overpressure 0.9511471848008564

fluids.safety_valve.
API520_A_g
(m, T, Z, MW, k, P1, P2=101325, Kd=0.975, Kb=1, Kc=1)[source]¶ Calculates required relief valve area for an API 520 valve passing a gas or a vapor, at either critical or subcritical flow.
For Critical flow:
\[A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}}\]For subcritical flow:
\[A = \frac{17.9m}{F_2K_dK_c}\sqrt{\frac{TZ}{MP_1(P_1P_2)}}\]Parameters:  m : float
Mass flow rate of vapor through the valve, [kg/s]
 T : float
Temperature of vapor entering the valve, [K]
 Z : float
Compressibility factor of the vapor, []
 MW : float
Molecular weight of the vapor, [g/mol]
 k : float
Isentropic coefficient or ideal gas heat capacity ratio []
 P1 : float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
 P2 : float, optional
Builtup backpressure; the increase in pressure during flow at the outlet of a pressurerelief device after it opens, [Pa]
 Kd : float, optional
The effective coefficient of discharge, from the manufacturer or for preliminary sizing, using 0.975 normally or 0.62 when used with a rupture disc as described in [1], []
 Kb : float, optional
Correction due to vapor backpressure []
 Kc : float, optional
Combination correction factor for installation with a ruture disk upstream of the PRV, []
Returns:  A : float
Minimum area for relief valve according to [1], [m^2]
Notes
Units are interlally kg/hr, kPa, and mm^2 to match [1].
References
[1] (1, 2, 3, 4, 5, 6) API Standard 520, Part 1  Sizing and Selection. Examples
Example 1 from [1] for critical flow, matches:
>>> API520_A_g(m=24270/3600., T=348., Z=0.90, MW=51., k=1.11, P1=670E3, Kb=1, Kc=1) 0.0036990460646834414
Example 2 from [1] for subcritical flow, matches:
>>> API520_A_g(m=24270/3600., T=348., Z=0.90, MW=51., k=1.11, P1=670E3, P2=532E3, Kd=0.975, Kb=1, Kc=1) 0.004248358775943481

fluids.safety_valve.
API520_A_steam
(m, T, P1, Kd=0.975, Kb=1, Kc=1)[source]¶ Calculates required relief valve area for an API 520 valve passing a steam, at either saturation or superheat but not partially condensed.
\[A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}}\]Parameters:  m : float
Mass flow rate of steam through the valve, [kg/s]
 T : float
Temperature of steam entering the valve, [K]
 P1 : float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
 Kd : float, optional
The effective coefficient of discharge, from the manufacturer or for preliminary sizing, using 0.975 normally or 0.62 when used with a rupture disc as described in [1], []
 Kb : float, optional
Correction due to vapor backpressure []
 Kc : float, optional
Combination correction factor for installation with a rupture disk upstream of the PRV, []
Returns:  A : float
Minimum area for relief valve according to [1], [m^2]
Notes
Units are interlally kg/hr, kPa, and mm^2 to match [1]. With the provided temperature and pressure, the KN coefficient is calculated with the function API520_N; as is the superheat correction KSH, with the function API520_SH.
References
[1] (1, 2, 3, 4, 5) API Standard 520, Part 1  Sizing and Selection. Examples
Example 4 from [1], matches:
>>> API520_A_steam(m=69615/3600., T=592.5, P1=12236E3, Kd=0.975, Kb=1, Kc=1) 0.0011034712423692733