TRANS_FACTOR
Converts between Darcy friction factor and transmission factor for gas-pipeline calculations, accepting exactly one of the two quantities as input. The relationship is algebraic, so the wrapper can be used in either direction depending on which quantity is already known.
The conversion formulas are:
F = \frac{2}{\sqrt{f_d}}
f_d = \frac{4}{F^2}
This is useful in compressible pipeline calculations and documentation that express line resistance in terms of transmission factor instead of Darcy friction factor.
Excel Usage
=TRANS_FACTOR(fd, F)
fd(float, optional, default: null): Darcy friction factor, [-]F(float, optional, default: null): Transmission factor, [-]
Returns (float): Transmission factor when fd is provided, or Darcy friction factor when F is provided [-]
Example 1: Convert typical Darcy friction factor to transmission factor
Inputs:
| fd |
|---|
| 0.0185 |
Excel formula:
=TRANS_FACTOR(0.0185)
Expected output:
14.7043
Example 2: Convert typical transmission factor to Darcy friction factor
Inputs:
| F |
|---|
| 20 |
Excel formula:
=TRANS_FACTOR(20)
Expected output:
0.01
Example 3: Convert high friction factor to transmission factor
Inputs:
| fd |
|---|
| 0.04 |
Excel formula:
=TRANS_FACTOR(0.04)
Expected output:
10
Example 4: Convert low transmission factor to Darcy friction factor
Inputs:
| F |
|---|
| 10 |
Excel formula:
=TRANS_FACTOR(10)
Expected output:
0.04
Python Code
Show Code
from fluids.friction import transmission_factor as fluids_transmission_factor
def trans_factor(fd=None, F=None):
"""
Convert between Darcy friction factor and transmission factor for compressible gas pipeline flow.
See: https://fluids.readthedocs.io/fluids.friction.html#fluids.friction.transmission_factor
This example function is provided as-is without any representation of accuracy.
Args:
fd (float, optional): Darcy friction factor, [-] Default is None.
F (float, optional): Transmission factor, [-] Default is None.
Returns:
float: Transmission factor when fd is provided, or Darcy friction factor when F is provided [-]
"""
try:
if fd is not None and F is not None:
return "Error: Provide only one of fd or F, not both."
if fd is None and F is None:
return "Error: Provide either fd or F."
if fd is not None:
fd = float(fd)
if fd <= 0:
return "Error: fd must be positive."
if F is not None:
F = float(F)
if F <= 0:
return "Error: F must be positive."
result = fluids_transmission_factor(fd=fd, F=F)
if result != result:
return "Error: Result is NaN."
if result == float('inf') or result == float('-inf'):
return "Error: Result is not finite."
return float(result)
except Exception as e:
return f"Error: {str(e)}"