Safety/relief valve sizing (fluids.safety_valve)¶
This module contains functions for sizing and rating pressure relief valves. At present, this consists of several functions from API 520.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker or contact the author at Caleb.Andrew.Bell@gmail.com.
Interfaces¶
- 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 sub-critical flow.
For critical flow:
For sub-critical flow:
- 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
Built-up backpressure; the increase in pressure during flow at the outlet of a pressure-relief 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 rupture disk upstream of the PRV; 1.0 when a rupture disk is not installed, and 0.9 if a rupture disk is present and the combination has not been certified, []
- m
- Returns
Notes
Units are interlally kg/hr, kPa, and mm^2 to match [1].
References
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 sub-critical 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
The mass flux in (kg/(s*m^2)) can be found by dividing the specified mass flow by the calculated area:
>>> (24270/3600.)/API520_A_g(m=24270/3600., T=348., Z=0.90, MW=51., k=1.11, P1=670E3, Kb=1, Kc=1) 1822.541960488834
- fluids.safety_valve.API520_A_steam(m, T, P1, Kd=0.975, Kb=1, Kc=1, edition='10E')[source]¶
Calculates required relief valve area for an API 520 valve passing a steam, at either saturation or superheat but not partially condensed.
- 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 backpressure, see
API520_B
[-]- Kc
float
,optional
Combination correction factor for installation with a rupture disk upstream of the PRV; 1.0 when a rupture disk is not installed, and 0.9 if a rupture disk is present and the combination has not been certified, []
- edition
str
,optional
One of ‘10E’, ‘7E’, [-]
- m
- Returns
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
Examples
Example 4 from [1] 7th edition, matches:
>>> API520_A_steam(m=69615/3600., T=592.5, P1=12236E3, Kd=0.975, Kb=1, Kc=1, edition='7E') 0.001103471242369
Example 4 from the 10th edition of [1]:
>>> API520_A_steam(m=69615/3600., T=707.0389, P1=12236E3, Kd=0.975, Kb=1, Kc=1, edition='10E') 0.00128518893191
- fluids.safety_valve.API520_A_l(m, rho, P1, P2, overpressure, Kd=0.65, Kc=1.0, Kw=None, Kv=None, edition='10E', mu=None)[source]¶
Calculates required relief valve area for an API 520 valve passing a liquid in sub-critical flow.
- Parameters
- m
float
Mass flow rate of liquid through the valve, [kg/s]
- rho
float
Liquid density, [kg/m^3]
- P1
float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
- P2
float
Built-up backpressure; the increase in pressure during flow at the outlet of a pressure-relief device after it opens, [Pa]
- overpressure
float
The maximum fraction overpressure; used if Kw is not specified, [-]
- Kd
float
,optional
The effective coefficient of discharge, from the manufacturer or for preliminary sizing, using 0.65 normally or 0.62 when used with a rupture disc as described in [1], []
- Kc
float
,optional
Combination correction factor for installation with a rupture disk upstream of the PRV; 1.0 when a rupture disk is not installed, and 0.9 if a rupture disk is present and the combination has not been certified, []
- Kw
float
,optional
Correction due to liquid backpressure [-]
- Kv
float
,optional
Correction due to viscosity [-]
- edition
str
,optional
One of ‘10E’, ‘7E’, [-]
- mu
float
,optional
If provided and Kv is None, Kv will be calculated automatically, [Pa*s]
- m
- Returns
Notes
Units are interlally kg/hr, kPa, and mm^2 to match [1].
This expression is essentially a form of the Loss coefficient K expression, with many factors and unit conversions. The raw expression in SI units, with K the true loss coefficient, is as follows:
The constant 11.78 is the result of the following conversions:
60000, converting from m^3/s to L/min
sqrt(2)/2 as a factor from algebra
1e6 converting from m^2 to mm^2
sqrt(1e-3*(rho0)) converting from Pa to kPa and kg/m^3 to specific gravity
The full precise value is (depending on the reference density chosen)
>>> sqrt(1e-3*(999.0107539518483))/60000*sqrt(2)/2*1e6 11.779282389196
The K value from a relief valve sized with this method can be calculated as follows:
The K value can also be directly calculated from the coefficients Kd, Kc, Kw, and Kv. The calculation is as follows, making use of the correction above.
References
Examples
Example 5 in [1], 10th edition. The calculation involves numerous steps, shown below and ending with a recalculation with a viscosity correction.
>>> Q = 6814*1.6666666666666667e-05 # L/min to m^3/s >>> rho = 0.9*999 # specific gravity times density of water kg/m^3 >>> m = rho*Q # mass flow rate, kg/s >>> overpressure = 0.1 >>> P_design_g = 1724E3 # design pressure, guage >>> P1 = (1+overpressure)*P_design_g + 101325.0 # upstream relieving pressure, Pa >>> backpressure = 0.2 >>> mu = 0.388 # viscosity, Pa*s, converted from 2000 Saybolt Universal Seconds >>> P2 = backpressure*P_design_g + 101325.0 # backpressure, Pa
Do the first calculation, using the value of Kw=0.97 shown in [1]
>>> A0 = API520_A_l(m=m, rho=rho, P1=P1, P2=P2, overpressure=overpressure, Kd=0.65, Kw=0.97, Kc=1.0, Kv=1.0) >>> A0 0.0030661356203
This value matches the 3066 mm^2 shown in the example calculation.
Do the same calculation but allow the calculation of Kw automatically:
>>> A0 = API520_A_l(m=m, rho=rho, P1=P1, P2=P2, overpressure=overpressure, Kd=0.65, Kc=1.0, Kv=1.0) >>> A0 0.0030585022573
There is a slight deviation with a more precise Kw value.
Compute Reynolds number from this original area
>>> from math import pi >>> D = (A0*4/pi)**0.5 >>> v = Q/A0 >>> Re = rho*v*D/mu >>> Re 5369.4253339
The reynolds number shown in [1] is 4525; the difference comes from the less precise Saybolt Universal Seconds conversion.
Compute the viscosity correction:
>>> Kv = API520_Kv(Re, '10E') >>> Kv 0.984535878488
Compute the final area
>>> A = API520_A_l(m=m, rho=rho, P1=P1, P2=P2, overpressure=overpressure, Kd=0.65, Kc=1.0, Kv=Kv) >>> A 0.003106542203
The final answer given in API 520 example 5 is 3122 mm^2, a very similar value despite the small differences.
If is also possible to have Kv be calculated by this routine automatically, by setting Kv to None and providing the fluid’s viscosity.
>>> A = API520_A_l(m=m, rho=rho, P1=P1, P2=P2, overpressure=overpressure, Kd=0.65, Kc=1.0, Kv=None, mu=mu) >>> A 0.003106542203
As described in the note, an overall K value can be calculated for the valve
>>> K = 2*A**2*rho*(P1 - P2)/m**2 >>> K 2.5825844233354602
We can check the calculation
>>> from fluids.core import dP_from_K >>> v = Q/A >>> dP_from_K(K=K, rho=rho, V=v), P1-P2 (1551600.000, 1551600.00)
- fluids.safety_valve.API521_noise(m, P1, P2, c, r)[source]¶
Calculate the the noise coming from a flare tip at a specified distance according to API 521. A graphical technique is used to get the noise at 30 m from the tip, and it is then adjusted for distance.
- Parameters
- Returns
- L
float
Sound pressure level at the specified distance from the stack tip [decibels]
- L
References
- 1
API Standard 521.
Examples
Example as shown in [1]:
>>> API521_noise(m=14.6, P1=330E3, P2=101325, c=353.0, r=30) 113.6841057
Functions and Data¶
- 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.
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
API Standard 526.
Examples
From [1], checked with many points on Table 8.
>>> API520_round_size(1E-4) 0.00012645136 >>> API526_letters[API526_A.index(API520_round_size(1E-4))] 'E'
- fluids.safety_valve.API520_C(k)[source]¶
Calculates coefficient C for use in API 520 critical flow relief valve sizing.
- Parameters
- k
float
Isentropic coefficient or ideal gas heat capacity ratio [-]
- k
- Returns
- C
float
Coefficient C [-]
- 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.
References
- 1
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.
- 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
Built-up backpressure; the increase in pressure during flow at the outlet of a pressure-relief device after it opens, [Pa]
- k
- Returns
- F2
float
Subcritical flow coefficient F2 [-]
- F2
Notes
F2 is completely dimensionless.
References
- 1
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, edition='10E')[source]¶
Calculates correction due to viscosity for liquid flow for use in API 520 relief valve sizing.
From the 7th to 9th editions, the formula for this calculation is as follows:
Startign in the 10th edition, the formula is
In the 10th edition, the formula is applicable for Re > 80. It is also recommended there that if the viscosity is < 0.1 Pa*s, this correction should be set to 1.
- Parameters
- Returns
- Kv
float
Correction due to viscosity [-]
- Kv
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:
The constant 18800 is derived as follows, combining multiple unit conversions and the formula from diameter from area together. The precise value is shown below.
>>> from scipy.constants import * >>> liter/minute*1000./(0.001*(milli**2)**0.5)*sqrt(4/pi) 18806.319451591
Note that 4 formulas are provided in API 520 part 1; two metric and two imperial. One pair of formulas uses viscosity in conventional units; the other uses it in Saybolt Universal Seconds. A conversion is essentially embedded in the the Saybolt Universal Seconds formula. A more precise conversion can be obtained from
chemicals.viscosity.viscosity_converter
.In both editions, if the formula is used below the recommended Re range and into the very low Re region this correction tends towards 0.
In the 10th edition, the formula tends to 1 exactly as Re increases. In the 7th edition, the formula can actually produce corrections above 1; this is handled by truncating the factor to 1.
References
- 1
API Standard 520, Part 1 - Sizing and Selection, 7E
- 2
API Standard 520, Part 1 - Sizing and Selection, 10E
- 3
CCPS. Guidelines for Pressure Relief and Effluent Handling Systems. 2nd edition. New York, NY: Wiley-AIChE, 2017.
Examples
From [1] 7E, checked with example 5.
>>> API520_Kv(100, edition='7E') 0.615744589
From [2] 10E, checked with example 5:
>>> API520_Kv(4525, edition='10E') 0.9817287137013179
Example in [3], using the 7th edition formula:
>>> API520_Kv(2110, edition='7E') 0.943671807
- fluids.safety_valve.API520_N(P1)[source]¶
Calculates correction due to steam pressure for steam flow for use in API 520 relief valve sizing.
For pressures below 10339 kPa, the correction factor is 1.
- Parameters
- P1
float
Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]
- P1
- Returns
- KN
float
Correction due to steam temperature [-]
- KN
Notes
Although not dimensional, KN varies with the units used.
For temperatures above 922 K or pressures above 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
>>> API520_N(10500e3) 0.9969100255
- fluids.safety_valve.API520_SH(T1, P1, edition='10E')[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
- Returns
- KSH
float
Correction due to steam superheat [-]
- KSH
Notes
For P above 20679 kPag, use the critical flow model. Superheat cannot be above 649 degrees Celsius. If T1 is above 149 degrees Celsius, returns 1.
References
- 1
API Standard 520, Part 1 - Sizing and Selection.
Examples
Custom example from table 9, 7th edition:
>>> API520_SH(593+273.15, 1066.325E3, '7E') 0.7201800000
- fluids.safety_valve.API520_B(Pset, Pback, overpressure=0.1)[source]¶
Calculates capacity correction due to backpressure on balanced spring-loaded 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
- Returns
- Kb
float
Correction due to vapor backpressure [-]
- Kb
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 spring-loaded 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
- Returns
- KW
float
Correction due to liquid backpressure [-]
- KW
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. 7E
- 2
API Standard 520, Part 1 - Sizing and Selection. 10E
Examples
Custom example from figure 31 in [1]:
>>> API520_W(1E6, 3E5) # 22% overpressure 0.95114718480085
Example 5 from [2], set pressure 250 psig and backpressure up to 50 psig:
>>> API520_W(Pset=1825014, Pback=446062) 0.97242133397677
- fluids.safety_valve.API521_noise_graph(P_ratio)[source]¶
Calculate the L parameter used in the API 521 noise calculation, from their Figure 18, Sound Pressure Level at 30 m from the stack tip.
- Parameters
- P_ratio
float
The ratio of relieving pressure to atmospheric pressure [-]
- P_ratio
- Returns
- L
float
Sound pressure level at 30 m from the stack tip [decibels]
- L
Notes
Two logarithmic linear polynomials are used. The function is continious throughout. The pressure ratio should be more than 1 for physical reasons; the value is checked for this case.
References
- 1
API Standard 521.
- fluids.safety_valve.VDI_3732_noise_ground_flare(m)[source]¶
Calculate the the noise at the flare tip of a ground flare [1], [2].
- Parameters
- m
float
Mass flow rate of relieving fluid, [kg/s]
- m
- Returns
- noise
float
Sound pressure level at the relieving flare stack [decibels]
- noise
References
- 1
VDI 3732 - Standard Noise Levels of Technical Sound Sources - Flares, 1999. https://www.vdi.de/en/home/vdi-standards/details/vdi-3732-standard-noise-levels-of-technical-sound-sources-flares.
- 2
AdminFlare Noise Calculator. WKC Group (blog). https://www.wkcgroup.com/tools-room/flare-noise-calculator/.
Examples
>>> VDI_3732_noise_ground_flare(3.0) 145.501356332
- fluids.safety_valve.VDI_3732_noise_elevated_flare(m)[source]¶
Calculate the the noise at the flare tip of an elevated flare stack [1], [2].
- Parameters
- m
float
Mass flow rate of relieving fluid, [kg/s]
- m
- Returns
- noise
float
Sound pressure level at the relieving flare stack [decibels]
- noise
References
- 1
VDI 3732 - Standard Noise Levels of Technical Sound Sources - Flares, 1999. https://www.vdi.de/en/home/vdi-standards/details/vdi-3732-standard-noise-levels-of-technical-sound-sources-flares.
- 2
AdminFlare Noise Calculator. WKC Group (blog). https://www.wkcgroup.com/tools-room/flare-noise-calculator/.
Examples
>>> VDI_3732_noise_elevated_flare(3.0) 163.56820384
- fluids.safety_valve.API526_letters = ['D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T']¶
list: Letter size designations for different valve sizes in API 520
- fluids.safety_valve.API526_A_sq_inch = [0.11, 0.196, 0.307, 0.503, 0.785, 1.287, 1.838, 2.853, 3.6, 4.34, 6.38, 11.05, 16.0, 26.0]¶
list: Nominal relief area in for different valve sizes in API 520, [in^2]
- fluids.safety_valve.API526_A = [7.09676e-05, 0.00012645136, 0.00019806412, 0.00032451547999999997, 0.0005064506, 0.00083032092, 0.00118580408, 0.00184064148, 0.002322576, 0.0027999944, 0.004116120799999999, 0.007129018, 0.01032256, 0.01677416]¶
list: Nominal relief area in for different valve sizes in API 520, [m^2]