#!/usr/bin/env python3
# -*- coding: utf-8 -*-


# %%
def ThermalConductivity(Temperature):
    """
    ========== DESCRIPTION ==========

    This function return the thermal conductivity of Teflon
    
    ========== Validity ==========

    4K < Temperature < 300K

    ========== FROM ==========
    
    E. D. Marquardt, J. P. Le, et R. Radebaugh, « Cryogenic Material Properties Database », p. 7, 2000.

    ========== INPUT ==========

    [Temperature]
        The temperature of the material in [K]

    ========== OUTPUT ==========

    [ThermalConductivity]
        The thermal conductivity in [W].[m]**(-1).[K]**(-1)

    ========== STATUS ==========

    Status : Checked

    """

    ################## MODULES ###############################################

    import numpy as np

    ################## CONDITIONS ############################################

    if Temperature <= 300 and Temperature >= 4:

        ################## INITIALISATION ####################################

        Coefficients = [2.7380, -30.677, 89.430, -136.99, 124.69, -69.556, 23.320, -4.3135, 0.33829]
        Sum = 0
        ################## IF CONDITION TRUE #####################

        for i in range(len(Coefficients)):
            Sum = Sum + Coefficients[i] * np.log10(Temperature) ** i

        return 10 ** Sum

        ################## SINON NAN #########################################

    else:

        print('Warning: The thermal conductivity of Teflon is not defined for T = ' + str(Temperature) + ' K')
        return np.nan


# %%
def SpecificHeat(Temperature):
    """
    ========== DESCRIPTION ==========

    This function return the specific heat of Teflon
    
    ========== Validity ==========

    3K < Temperature < 300K

    ========== FROM ==========
    
    E. D. Marquardt, J. P. Le, et R. Radebaugh, « Cryogenic Material Properties Database », p. 7, 2000.

    ========== INPUT ==========

    [Temperature]
        The temperature of the material in [K]

    ========== OUTPUT ==========

    [ThermalConductivity]
        The thermal conductivity in [J].[kg]**(-1).[K]**(-1)

    ========== STATUS ==========

    Status : Checked

    """

    ################## MODULES ###############################################

    import numpy as np

    ################## CONDITIONS ############################################

    if Temperature <= 300 and Temperature >= 3:

        ################## INITIALISATION ####################################

        Coefficients = [31.8825, -166.519, 352.019, 259.981, -104.614, 24.9927, -3.20792, 0.165032, 0]
        Sum = 0
        ################## IF CONDITION TRUE #####################

        for i in range(len(Coefficients)):
            Sum = Sum + Coefficients[i] * np.log10(Temperature) ** i

        return Sum

        ################## SINON NAN #########################################

    else:

        print('Warning: The specitif heat of Teflon is not defined for T = ' + str(Temperature) + ' K')
        return np.nan


# %%
def LinearThermalExpansion(Temperature):
    """
    ========== DESCRIPTION ==========

    This function return the linear thermal expansion of Teflon
    
    ========== Validity ==========

    4K < Temperature < 300K

    ========== FROM ==========
    
    E. D. Marquardt, J. P. Le, et R. Radebaugh, « Cryogenic Material Properties Database », p. 7, 2000.

    ========== INPUT ==========

    [Temperature]
        The temperature of the material in [K]

    ========== OUTPUT ==========

    [LinearThermalExpansion]
        The linear thermal expansion in [%]

    ========== STATUS ==========

    Status : Checked

    """

    ################## MODULES ###############################################

    ################## CONDITIONS ############################################

    if Temperature <= 300 and Temperature >= 4:

        ################## INITIALISATION ####################################

        Coefficients = [-2.165e3, 3.278, -8.218e-3, 7.244e-5, 0]
        Sum = 0
        ################## IF CONDITION TRUE #####################

        for i in range(len(Coefficients)):
            Sum = Sum + Coefficients[i] * Temperature ** i

        return Sum * 1e-5

        ################## SINON NAN #########################################

    else:

        print('Warning: The linear thermal expansion of Teflon is not defined for T = ' + str(Temperature) + ' K')
        return np.nan
