def C2K(C):
    """Convert Celsius to Kelvin.

    Parameters
    ----------
    C : float
        Celsius temperature to be converted, [degC]

    Returns
    -------
    K : float
        Equivalent Kelvin temperature, [K]

    Notes
    -----
    Computes ``K = C + zero_Celsius`` where `zero_Celsius` = 273.15, i.e.,
    (the absolute value of) temperature "absolute zero" as measured in Celsius.

    Examples
    --------
    >>> C2K(-40)
    233.14999999999998
    """
    return C + zero_Celsius def K2C(K):
    """Convert Kelvin to Celsius.

    Parameters
    ----------
    K : float
        Kelvin temperature to be converted.

    Returns
    -------
    C : float
        Equivalent Celsius temperature.

    Notes
    -----
    Computes ``C = K - zero_Celsius`` where `zero_Celsius` = 273.15, i.e.,
    (the absolute value of) temperature "absolute zero" as measured in Celsius.

    Examples
    --------
    >>> K2C(233.15)
    -39.99999999999997
    """
    return K - zero_Celsius def F2C(F):
    """Convert Fahrenheit to Celsius.

    Parameters
    ----------
    F : float
        Fahrenheit temperature to be converted.

    Returns
    -------
    C : float
        Equivalent Celsius temperature.

    Notes
    -----
    Computes ``C = (F - 32) / 1.8``.

    Examples
    --------
    >>> F2C(-40.0)
    -40.0
    """
    return (F - 32.0) / 1.8 def C2F(C):
    """Convert Celsius to Fahrenheit.

    Parameters
    ----------
    C : float
        Celsius temperature to be converted.

    Returns
    -------
    F : float
        Equivalent Fahrenheit temperature.

    Notes
    -----
    Computes ``F = 1.8 * C + 32``.

    Examples
    --------
    >>> C2F(-40.0)
    -40.0
    """
    return 1.8*C + 32.0 def F2K(F):
    """Convert Fahrenheit to Kelvin.

    Parameters
    ----------
    F : float
        Fahrenheit temperature to be converted.

    Returns
    -------
    K : float
        Equivalent Kelvin temperature.

    Notes
    -----
    Computes ``K = (F - 32)/1.8 + zero_Celsius`` where `zero_Celsius` =
    273.15, i.e., (the absolute value of) temperature "absolute zero" as
    measured in Celsius.

    Examples
    --------
    >>> F2K(-40)
    233.14999999999998
    """
    return (F - 32.0)/1.8 + zero_Celsius def K2F(K):
    """Convert Kelvin to Fahrenheit.

    Parameters
    ----------
    K : float
        Kelvin temperature to be converted.

    Returns
    -------
    F : float
        Equivalent Fahrenheit temperature.

    Notes
    -----
    Computes ``F = 1.8 * (K - zero_Celsius) + 32`` where `zero_Celsius` =
    273.15, i.e., (the absolute value of) temperature "absolute zero" as
    measured in Celsius.

    Examples
    --------
    >>> K2F(233.15)
    -39.99999999999996
    """
    return 1.8*(K - zero_Celsius) + 32.0 def C2R(C):
    """Convert Celsius to Rankine.

    Parameters
    ----------
    C : float
        Celsius temperature to be converted.

    Returns
    -------
    Ra : float
        Equivalent Rankine temperature.

    Notes
    -----
    Computes ``Ra = 1.8 * (C + zero_Celsius)`` where `zero_Celsius` = 273.15,
    i.e., (the absolute value of) temperature "absolute zero" as measured in
    Celsius.

    Examples
    --------
    >>> C2R(-40)
    419.66999999999996
    """
    return 1.8 * (C + zero_Celsius) def K2R(K):
    """Convert Kelvin to Rankine.

    Parameters
    ----------
    K : float
        Kelvin temperature to be converted.

    Returns
    -------
    Ra : float
        Equivalent Rankine temperature.

    Notes
    -----
    Computes ``Ra = 1.8 * K``.

    Examples
    --------
    >>> K2R(273.15)
    491.66999999999996
    """
    return 1.8 * K def F2R(F):
    """Convert Fahrenheit to Rankine.

    Parameters
    ----------
    F : float
        Fahrenheit temperature to be converted.

    Returns
    -------
    Ra : float
        Equivalent Rankine temperature.

    Notes
    -----
    Computes ``Ra = F - 32 + 1.8 * zero_Celsius`` where `zero_Celsius` = 273.15,
    i.e., (the absolute value of) temperature "absolute zero" as measured in
    Celsius.

    Examples
    --------
    >>> F2R(100)
    559.67
    """
    return F - 32.0 + 1.8 * zero_Celsius def R2C(Ra):
    """Convert Rankine to Celsius.

    Parameters
    ----------
    Ra : float
        Rankine temperature to be converted.

    Returns
    -------
    C : float
        Equivalent Celsius temperature.

    Notes
    -----
    Computes ``C = Ra / 1.8 - zero_Celsius`` where `zero_Celsius` = 273.15,
    i.e., (the absolute value of) temperature "absolute zero" as measured in
    Celsius.

    Examples
    --------
    >>> R2C(459.67)
    -17.777777777777743
    """
    return Ra / 1.8 - zero_Celsius def R2K(Ra):
    """Convert Rankine to Kelvin.

    Parameters
    ----------
    Ra : float
        Rankine temperature to be converted.

    Returns
    -------
    K : float
        Equivalent Kelvin temperature.

    Notes
    -----
    Computes ``K = Ra / 1.8``.

    Examples
    --------
    >>> R2K(491.67)
    273.15
    """
    return Ra / 1.8 def R2F(Ra):
    """Convert Rankine to Fahrenheit.

    Parameters
    ----------
    Ra : float
        Rankine temperature to be converted.

    Returns
    -------
    F : float
        Equivalent Fahrenheit temperature.

    Notes
    -----
    Computes ``F = Ra + 32 - 1.8 * zero_Celsius`` where `zero_Celsius` = 273.15,
    i.e., (the absolute value of) temperature "absolute zero" as measured in
    Celsius.

    Examples
    --------
    >>> R2F(491.67)
    32.00000000000006
    """
    return Ra - 1.8*zero_Celsius + 32.0
from fluids.core import C2K, K2C, F2C, C2F, F2K, K2F, C2R, K2R, F2R, R2C, R2K, R2F
from fluids.core import *
from fluids.numerics import assert_close, assert_close1d
import pytest
    BeL1 = Bejan_L(1E4, 1., 1E-3, 1E-6)
    assert_close(BeL1, 10000000000000)

    Bep1 = Bejan_p(1E4, 1., 1E-3, 1E-6)
    assert_close(Bep1, 10000000000000)

    Bo = Boiling(300., 3000., 800000.)
    assert_close(Bo, 1.25e-05)

    e_D1 = relative_roughness(0.0254)
    e_D2 = relative_roughness(0.5, 1E-4)
    assert_close1d([e_D1, e_D2], [5.9842519685039374e-05, 0.0002])

    Co = Confinement(0.001, 1077, 76.5, 4.27E-3)
    assert_close(Co, 0.6596978265315191)

    De = Dean(10000., 0.1, 0.4)
    assert_close(De, 5000.0)

    Stk = Stokes_number(V=0.9, Dp=1E-5, D=1E-3, rhop=1000., mu=1E-5)
    assert_close(Stk, 0.5)

    Hg = Hagen(Re=2610., fd=1.935235)
    assert_close(Hg, 6591507.17175)
    # Where fd was obtained from:
    def Hagen2(rho, D, mu):
        return rho*D**3/mu**2

    correct = Hagen2(rho=992., mu=653E-6, D=6.568E-3)*10000

    guess = Hagen(Re=2610., fd=1.935235)
    assert_close(correct, guess)

    Fr = Froude_densimetric(1.83, L=2., rho2=1.2, rho1=800., g=9.81)
    assert_close(Fr, 0.4134543386272418)
    Fr = Froude_densimetric(1.83, L=2., rho2=1.2, rho1=800, g=9.81, heavy=False)
    assert_close(Fr, 0.016013017679205096)

    Mo = Morton(1077.0, 76.5, 4.27E-3, 0.023)
    assert_close(Mo, 2.311183104430743e-07)


def test_core_misc2():
    mu1 = nu_mu_converter(998., nu=1.0E-6)
    nu1 = nu_mu_converter(998., mu=0.000998)
    assert_close1d([mu1, nu1], [0.000998, 1E-6])
    with pytest.raises(Exception):
        nu_mu_converter(990)
    with pytest.raises(Exception):
        nu_mu_converter(990, 0.000998, 1E-6)

    g1 = gravity(55., 1E4)
    assert_close(g1, 9.784151976863571)

    K = K_from_f(fd=0.018, L=100., D=.3)
    assert_close(K, 6.0)

    K = K_from_L_equiv(240.)
    assert_close(K, 3.6)

    L_D = L_equiv_from_K(3.6)
    assert_close(L_D, 240.)

    L = L_from_K(K=6., fd=0.018, D=.3)
    assert_close(L, 100)

    dP = dP_from_K(K=10., rho=1000., V=3.)
    assert_close(dP, 45000)

    head = head_from_K(K=10., V=1.5)
    assert_close(head, 1.1471807396001694)

    head = head_from_P(P=98066.5, rho=1000.)
    assert_close(head, 10.0)

    P = P_from_head(head=5., rho=800.)
    assert_close(P, 39226.6)

    fd = f_from_K(K=0.6, L=100., D=.3)
    assert_close(fd, 0.0018, rtol=1e-13)



#from fluids.core import C2K, K2C, F2C, C2F, F2K, K2F, C2R, K2R, F2R, R2C, R2K, R2F

# The following are tests which were deprecated from scipy
# but are still desired to be here
# Taken from scipy/constants/constants.py as in commit
# https://github.com/scipy/scipy/commit/4b7d325cd50e8828b06d628e69426a18283dc5b5
# Also from https://github.com/scipy/scipy/pull/5292
# by Gillu13  (Gilles Aouizerate)
# Copyright individual contributors to SciPy


def test_fahrenheit_to_celcius():
    assert_close(F2C(32.), 0)
    assert_close1d([F2C(32)], [0])


def test_celcius_to_kelvin():
    assert_close1d([C2K(0.)], [273.15])


def test_kelvin_to_celcius():
    assert_close1d([K2C(0.)], [-273.15])


def test_fahrenheit_to_kelvin():
    assert_close1d([F2K(32.), F2K(32)], [273.15, 273.15])


def test_kelvin_to_fahrenheit():
    assert_close1d([K2F(273.15), K2F(273.15)], [32, 32])


def test_celcius_to_fahrenheit():
    assert_close1d([C2F(0.)]*2, [32, 32])


def test_celcius_to_rankine():

    assert_close1d([C2R(0.), C2R(0.)], [491.67, 491.67], rtol=0., atol=1e-13)