Class: Fitting
The Fitting class represents a pipe fitting used in hydraulic calculations.
It provides access to equivalent length (Le) and K-factor values for fittings,
which are essential in computing minor losses in pipelines.
Parameters
-
fitting_type(str)
The type of fitting (e.g.,"elbow_90","tee_branch","valve_gate").
Must be recognized by the standards database (processpi.pipelines.standards). Standard Fitting StringsThe following
fitting_typeare supported in ProcessPI:gate_valveglobe_valveangle_valveball_valveplug_valve_straightwayplug_valve_3_way_through_flowplug_valve_branch_flowswing_check_valvelift_check_valvestandard_elbow_90_degstandard_elbow_45_deglong_radius_90_degstandard_tee_through_flowstandard_tee_through_branchmiter_bends_alpha_0miter_bends_alpha_30miter_bends_alpha_60miter_bends_alpha_90sudden_contractionsudden_expansionentrance_sharpentrance_roundedexit
-
diameter(Optional[Diameter], default=None)
Internal diameter of the pipe associated with this fitting.
Required for fittings where loss coefficients depend on pipe size. -
quantity(int, default=1)
Number of identical fittings of this type.
Must be a positive integer.
Attributes
fitting_type(str) – Name/type of fitting.diameter(Optional[Diameter]) – Pipe diameter associated with the fitting.quantity(int) – Count of fittings.
Methods
equivalent_length()
Computes the equivalent length (Le) of the fitting.
This is the effective pipe length that produces the same pressure drop as the fitting.
Returns
- Length (in meters) if available.
- None if not applicable.
Raises
- ValueError: If the equivalent length requires a diameter but none is provided.
k_factor()
Retrieves the K-factor (dimensionless loss coefficient) of the fitting.
Returns
- float: K-factor value.
- None: If not applicable.
Raises
- ValueError: If diameter is required but not provided.
calculate()
Returns a dictionary summary of the fitting, including geometry and loss data.
Returns
{
"fitting_type": str,
"quantity": int,
"diameter_in": float or None, # diameter in inches
"diameter_m": float or None, # diameter in meters
"equivalent_length_m": float or None,
"k_factor": float or None
}
✅ Example Usage
from processpi.units import Diameter
from processpi.pipelines.fittings import Fitting
# Define a 90-degree elbow fitting for a 4-inch pipe
elbow = Fitting(fitting_type="standard_elbow_90_deg", diameter=Diameter(4, "in"), quantity=2)
# Get equivalent length and K-factor
print(elbow.equivalent_length())
print(elbow.k_factor())
# Export fitting details
print(elbow.calculate())