def test_mixture_viscosity_lgas():
    test_mix_viscos = pd.read_csv(os.path.join(pp_dir, 'properties', 'lgas',
                                               'viscosity.txt'),
                                  header=None,
                                  sep=' ').values[:, 1]

    viscos_ch4 = pd.read_csv(os.path.join(pp_dir, 'properties', 'methane',
                                          'viscosity.txt'),
                             header=None,
                             sep=' ').values[:, 1]
    viscos_n2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'nitrogen',
                                         'viscosity.txt'),
                            header=None,
                            sep=' ').values[:, 1]
    viscos_co2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'carbondioxid',
                                          'viscosity.txt'),
                             header=None,
                             sep=' ').values[:, 1]
    visco_c2h6 = pd.read_csv(os.path.join(pp_dir, 'properties', 'ethane',
                                          'viscosity.txt'),
                             header=None,
                             sep=' ').values[:, 1]
    molar_ch4 = pd.read_csv(os.path.join(pp_dir, 'properties', 'methane',
                                         'molar_mass.txt'),
                            header=None,
                            sep=' ').values[0]
    molar_n2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'nitrogen',
                                        'molar_mass.txt'),
                           header=None,
                           sep=' ').values[0]
    molar_co2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'carbondioxid',
                                         'molar_mass.txt'),
                            header=None,
                            sep=' ').values[0]
    molar_c2h6 = pd.read_csv(os.path.join(pp_dir, 'properties', 'ethane',
                                          'molar_mass.txt'),
                             header=None,
                             sep=' ').values[0]
    components_viscosities = np.concatenate([[viscos_ch4], [viscos_n2],
                                             [viscos_co2], [visco_c2h6]])
    components_molar_proportions = np.array([.85, .103, .013, .034])
    components_molar_mass = np.concatenate(
        [molar_ch4, molar_n2, molar_co2, molar_c2h6])
    mix_viscos = calculate_mixture_viscosity(components_viscosities,
                                             components_molar_proportions,
                                             components_molar_mass)

    assert np.allclose(mix_viscos, test_mix_viscos, rtol=0, atol=1e-8)

    mix_viscos = calculate_mixture_viscosity(components_viscosities[:, 0],
                                             components_molar_proportions,
                                             components_molar_mass)

    assert np.allclose(mix_viscos, test_mix_viscos, rtol=0, atol=2e-5)
def test_mixture_viscosity_lgas():
    test_mix_viscos = pd.read_csv(os.path.join(pp_dir, 'properties', 'lgas', 'viscosity.txt'),
                                  header=None, sep=' ', comment='#').values[:, 1]

    viscos_ch4 = pd.read_csv(os.path.join(pp_dir, 'properties', 'methane', 'viscosity.txt'),
                             header=None, sep=' ', comment='#').values
    viscos_n2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'nitrogen', 'viscosity.txt'),
                            header=None, sep=' ', comment='#').values
    viscos_co2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'carbondioxide', 'viscosity.txt'),
                             header=None, sep=' ', comment='#').values
    viscos_c2h6 = pd.read_csv(os.path.join(pp_dir, 'properties', 'ethane', 'viscosity.txt'),
                             header=None, sep=' ', comment='#').values
    molar_ch4 = pd.read_csv(os.path.join(pp_dir, 'properties', 'methane', 'molar_mass.txt'),
                            header=None, sep=' ', comment='#').values[0]
    molar_n2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'nitrogen', 'molar_mass.txt'),
                           header=None, sep=' ', comment='#').values[0]
    molar_co2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'carbondioxide', 'molar_mass.txt'),
                            header=None, sep=' ', comment='#').values[0]
    molar_c2h6 = pd.read_csv(os.path.join(pp_dir, 'properties', 'ethane', 'molar_mass.txt'),
                             header=None, sep=' ', comment='#').values[0]
    values_to_take = [263, 273, 283, 293, 303, 313, 323, 333]
    viscos_ch4 = interp1d(viscos_ch4[:, 0], viscos_ch4[:, 1])
    viscos_ch4 = viscos_ch4((values_to_take))
    viscos_n2 = interp1d(viscos_n2[:, 0], viscos_n2[:, 1], fill_value='extrapolate')
    viscos_n2 = viscos_n2((values_to_take))
    viscos_co2 = interp1d(viscos_co2[:, 0], viscos_co2[:, 1])
    viscos_co2 = viscos_co2((values_to_take))
    viscos_c2h6 = interp1d(viscos_c2h6[:, 0], viscos_c2h6[:, 1])
    viscos_c2h6 = viscos_c2h6((values_to_take))
    components_viscosities = np.concatenate([[viscos_ch4], [viscos_n2], [viscos_co2], [viscos_c2h6]])
    components_molar_proportions = np.array([.85, .103, .013, .034])
    components_molar_mass = np.concatenate([molar_ch4, molar_n2, molar_co2, molar_c2h6])
    mix_viscos = calculate_mixture_viscosity(
        components_viscosities, components_molar_proportions, components_molar_mass)

    assert np.allclose(mix_viscos, test_mix_viscos, rtol=0, atol=1e-8)

    mix_viscos = calculate_mixture_viscosity(
        components_viscosities[:, 0], components_molar_proportions, components_molar_mass)

    assert np.allclose(mix_viscos, test_mix_viscos, rtol=0, atol=2e-5)