"""
pressure_loss_correlations.py

Single-phase frictional pressure drop for internal tube flow.

Reference
---------
Darcy–Weisbach equation with Colebrook friction factor.
VDI-Wärmeatlas, Kap. G1, 11. Aufl., Springer Vieweg, 2013
"""

from .base_class_one_phase import OnePhaseTubeBase


class VDIPressureLoss(OnePhaseTubeBase):
    """
    Frictional pressure gradient for single-phase tube flow.

    Returns
    -------
    calc() -> dict with keys: dpdl [Pa/m], meta
    """

    def calc(self):
        fs = self.fluidstate
        dpdl = float(self.f_s / fs.sp_volume * 0.5 * (1 / self.dh) * self.u ** 2)  # Darcy equation Pa/m

        return {
            "dpdl": dpdl,
            "meta": {
                "Re":  float(self.Re),
                "f_s": float(self.f_s),
                "u":   float(self.u),
                "dh":  float(self.dh),
            },
        }