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


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

    This function return the thermal conductivity of Copper Beryllium
    
    ========== 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 = [-0.50015, 1.93190, -1.69540, 0.71218, 1.27880, -1.61450, 0.68722, -0.10501, 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 CuBe is not defined for T = ' + str(Temperature) + ' K')
        return np.nan


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

    This function return the linear thermal expansion of Copper Beryllium
    
    ========== Validity ==========

    4K < Temperature < 300K

    ========== FROM ==========
    
    https://trc.nist.gov/cryogenics/materials/Beryllium%20Copper/BerylliumCopper_rev.htm

    ========== 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 = [-3.1150e2, -4.4498e-1, 1.0133e-2, -2.4718e-5, 2.6277e-8]
        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 CuBe is not defined for T = ' + str(Temperature) + ' K')
        return np.nan
