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


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

    This function return the thermal conductivity of Nylon
    
    ========== 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.6135, 2.3239, -4.7586, 7.1602, -4.9155, 1.6324, -0.2507, 0.0131, 0]
        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 Nylon is not defined for T = ' + str(Temperature) + ' K')
        return np.nan


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

    This function return the linear thermal expansion of Nylon
    
    ========== 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 = [-1.389e3, -1.561e-1, 2.988e-2, -7.948e-5, 1.181e-7]
        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 Nylon is not defined for T = ' + str(Temperature) + ' K')
        return np.nan
