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:

\[A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}}\]

For sub-critical flow:

\[A = \frac{17.9m}{F_2K_dK_c}\sqrt{\frac{TZ}{MP_1(P_1-P_2)}}\]
Parameters:
mfloat

Mass flow rate of vapor through the valve, [kg/s]

Tfloat

Temperature of vapor entering the valve, [K]

Zfloat

Compressibility factor of the vapor, [-]

MWfloat

Molecular weight of the vapor, [g/mol]

kfloat

Isentropic coefficient or ideal gas heat capacity ratio [-]

P1float

Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]

P2float, optional

Built-up backpressure; the increase in pressure during flow at the outlet of a pressure-relief device after it opens, [Pa]

Kdfloat, 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], []

Kbfloat, optional

Correction due to vapor backpressure [-]

Kcfloat, optional

Combination correction factor for installation with a ruture disk upstream of the PRV, []

Returns:
Afloat

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)

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 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)[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:
mfloat

Mass flow rate of steam through the valve, [kg/s]

Tfloat

Temperature of steam entering the valve, [K]

P1float

Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]

Kdfloat, 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], []

Kbfloat, optional

Correction due to vapor backpressure [-]

Kcfloat, optional

Combination correction factor for installation with a rupture disk upstream of the PRV, []

Returns:
Afloat

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)

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

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.

Parameters:
Afloat

Minimum discharge area [m^2]

Returns:
areafloat

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]

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.

\[C = 0.03948\sqrt{k\left(\frac{2}{k+1}\right)^\frac{k+1}{k-1}}\]
Parameters:
kfloat

Isentropic coefficient or ideal gas heat capacity ratio [-]

Returns:
Cfloat

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]

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.

\[F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k} \left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]}\]
\[r = \frac{P_2}{P_1}\]
Parameters:
kfloat

Isentropic coefficient or ideal gas heat capacity ratio [-]

P1float

Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]

P2float

Built-up backpressure; the increase in pressure during flow at the outlet of a pressure-relief device after it opens, [Pa]

Returns:
F2float

Subcritical flow coefficient 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)[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:
Refloat

Reynolds number for flow out the valve [-]

Returns:
Kvfloat

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]

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.

For pressures below 10339 kPa, the correction factor is 1.

\[K_N = \frac{0.02764P_1-1000}{0.03324P_1-1061}\]
Parameters:
P1float

Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]

Returns:
KNfloat

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

>>> API520_N(10500e3)
0.9969100255
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:
T1float

Temperature of the fluid entering the valve [K]

P1float

Upstream relieving pressure; the set pressure plus the allowable overpressure, plus atmospheric pressure, [Pa]

Returns:
KSHfloat

Correction due to steam superheat [-]

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:

>>> 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 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:
Psetfloat

Set pressure for relief [Pa]

Pbackfloat

Backpressure, [Pa]

overpressurefloat, optional

The maximum fraction overpressure; one of 0.1, 0.16, or 0.21, [-]

Returns:
Kbfloat

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 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:
Psetfloat

Set pressure for relief [Pa]

Pbackfloat

Backpressure, [Pa]

Returns:
KWfloat

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.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]