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

    dens_ch4 = pd.read_csv(os.path.join(pp_dir, 'properties', 'methane',
                                        'density.txt'),
                           header=None,
                           sep=' ').values[:, 1]
    dens_n2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'nitrogen',
                                       'density.txt'),
                          header=None,
                          sep=' ').values[:, 1]
    dens_co2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'carbondioxid',
                                        'density.txt'),
                           header=None,
                           sep=' ').values[:, 1]
    dens_c2h6 = pd.read_csv(os.path.join(pp_dir, 'properties', 'ethane',
                                         'density.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_density = np.concatenate([[dens_ch4], [dens_n2], [dens_co2],
                                         [dens_c2h6]])
    components_molar_proportions = np.array([.85, .103, .013, .034])
    components_molar_mass = np.concatenate(
        [molar_ch4, molar_n2, molar_co2, molar_c2h6])
    components_mass_proportions = calculate_mass_fraction_from_molar_fraction(
        components_molar_proportions, components_molar_mass)
    mix_dens = calculate_mixture_density(
        components_density,
        components_mass_proportions=components_mass_proportions)

    assert np.allclose(mix_dens, test_mix_density, rtol=0, atol=1e-10)

    mix_dens = calculate_mixture_density(
        components_density[:, 0],
        components_mass_proportions=components_mass_proportions)

    assert np.allclose(mix_dens, test_mix_density[0], rtol=0, atol=1e-10)
def test_mixture_density_lgas():
    test_mix_density = pd.read_csv(os.path.join(pp_dir, 'properties', 'lgas', 'density.txt'),
                                   header=None, sep=' ').values[:, 1]

    dens_ch4 = pd.read_csv(os.path.join(pp_dir, 'properties', 'methane', 'density.txt'),
                           header=None, sep=' ', comment='#').values
    dens_n2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'nitrogen', 'density.txt'),
                            header=None, sep=' ', comment='#').values
    dens_co2 = pd.read_csv(os.path.join(pp_dir, 'properties', 'carbondioxide', 'density.txt'),
                           header=None, sep=' ', comment='#').values
    dens_c2h6 = pd.read_csv(os.path.join(pp_dir, 'properties', 'ethane', 'density.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]
    dens_ch4 = interp1d(dens_ch4[:, 0], dens_ch4[:, 1])
    dens_ch4 = dens_ch4((values_to_take))
    dens_n2 = interp1d(dens_n2[:, 0], dens_n2[:, 1], fill_value='extrapolate')
    dens_n2 = dens_n2((values_to_take))
    dens_co2 = interp1d(dens_co2[:, 0], dens_co2[:, 1])
    dens_co2 = dens_co2((values_to_take))
    dens_c2h6 = interp1d(dens_c2h6[:, 0], dens_c2h6[:, 1])
    dens_c2h6 = dens_c2h6((values_to_take))
    components_density = np.concatenate([[dens_ch4], [dens_n2], [dens_co2], [dens_c2h6]])
    components_molar_proportions = np.array([.85, .103, .013, .034])
    components_molar_mass = np.concatenate([molar_ch4, molar_n2, molar_co2, molar_c2h6])
    components_mass_proportions = calculate_mass_fraction_from_molar_fraction(
        components_molar_proportions,
        components_molar_mass)
    mix_dens = calculate_mixture_density(
        components_density, components_mass_proportions=components_mass_proportions)

    assert np.allclose(mix_dens, test_mix_density, rtol=0, atol=1e-10)

    mix_dens = calculate_mixture_density(
        components_density[:, 0], components_mass_proportions=components_mass_proportions)

    assert np.allclose(mix_dens, test_mix_density[0], rtol=0, atol=1e-10)