Beispiel #1
0
def test_that_the_lique_cooling_function_is_computed_correctly():

    t_rad = 0.0 * u.K
    nc_h = 1e6 * u.m**-3

    species_data = DataLoader().load('H2_lique')

    t_array = u.Quantity([100.0, 500.0, 1000.0, 2000.0, 5000.0]) * u.K
    cooling_rate_expected = u.Quantity([
        1.09526153e-28,  # T=100K
        2.67540424e-26,  # T=500K
        6.64684189e-25,  # T=1000K
        8.35387575e-24,  # T=2000K
        1.00510330e-22  # T=5000K
    ]) * u.erg / u.s

    cooling_rate_for_t_array = u.Quantity([
        cooling_rate_at_steady_state(species_data, t, t_rad, nc_h)
        for t in t_array
    ])

    assert_allclose(cooling_rate_for_t_array.cgs.value,
                    cooling_rate_expected.cgs.value,
                    rtol=2e-6,
                    atol=0.0)
Beispiel #2
0
def test_that_the_lipovka_cooling_function_is_computed_correctly():

    t_rad = 0.0 * u.K
    nc_h = 1e6 * u.m**-3

    species_data = DataLoader().load('HD_lipovka')

    t_array = u.Quantity([100.0, 500.0, 1000.0, 1500.0, 2000.0]) * u.K
    cooling_rate_expected = u.Quantity([
        2.239044e-25,  # T=100K
        2.861033e-24,  # T=500K
        6.783145e-24,  # T=1000K
        1.108309e-23,  # T=1500K
        1.570218e-23  # T=2000K
    ]) * u.erg / u.s

    cooling_rate_for_t_array = u.Quantity([
        cooling_rate_at_steady_state(species_data, t, t_rad, nc_h)
        for t in t_array
    ])

    assert_allclose(cooling_rate_for_t_array.cgs.value,
                    cooling_rate_expected.cgs.value,
                    rtol=1e-6,
                    atol=0.0)
Beispiel #3
0
    def compute(self):
        """
        Compute the cooling function for the specified grid

        :return: ndarray
        """

        self._compute_mesh()

        cooling_rate = numpy.zeros_like(self.n_grid.value).flatten()
        for i, (n, t_kin, t_rad) in enumerate(
                zip(self.n_grid.flat, self.t_kin_grid.flat,
                    self.t_rad_grid.flat)):

            cooling_rate[i] = cooling_rate_at_steady_state(
                self.species, t_kin, t_rad, n).cgs.value

        cooling_rate_grid = cooling_rate.reshape(self.n_grid.shape)
        self.cooling_function = cooling_rate_grid
        return cooling_rate_grid
t_rng = numpy.logspace(2, 3.6, 10) * u.Kelvin
# T_rng = species_data.raw_data.collision_rates_T_range

plot_markers = [(2 + i // 2, 1 + i % 2, 0) for i in range(16)]

for nc_index, nc_h in enumerate(nc_h_rng):

    lambda_vs_t_kin = []
    lambda_vs_t_kin_wrathmall = []
    pop_dens_vs_t_kin = []

    for i, t_kin in enumerate(t_rng):
        print(t_kin, nc_h)

        lambda_vs_t_kin += [
            cooling_rate_at_steady_state(species_data, t_kin, t_rad, nc_h)
        ]

        pop_dens_vs_t_kin += [
            population_density_at_steady_state(species_data, t_kin, t_rad,
                                               nc_h)
        ]

        lambda_vs_t_kin_wrathmall += [
            cooling_rate_at_steady_state(species_data_wrathmall, t_kin, t_rad,
                                         nc_h)
        ]
        print(t_kin, pop_dens_vs_t_kin[i][0], pop_dens_vs_t_kin[i][2],
              pop_dens_vs_t_kin[i][4], pop_dens_vs_t_kin[i][6],
              pop_dens_vs_t_kin[i][8], pop_dens_vs_t_kin[i][10],
              pop_dens_vs_t_kin[i][12], pop_dens_vs_t_kin[i][14],
    fobj.write('#{:<12} {:<12} {:<12} {:<12}\n'.format(
        u.m**-3, u.Kelvin, u.Kelvin, u.Joule / u.second
    ))

    fig, axs = pylab.subplots(1)

    # the data
    for nc_H in numpy.logspace(6, 12, 7)*u.meter**-3:
        for t_rad in numpy.array([0.0], 'f8') * u.Kelvin:
            cooling_rate_vs_t_kin = []
            for t_kin in species_data.raw_data.collision_rates_t_range:

                cooling_rate = cooling_rate_at_steady_state(
                    species_data,
                    t_kin,
                    t_rad,
                    nc_H
                )

                fobj.write('{:e} {:e} {:e} {:e}\n'.format(
                    nc_H.value,
                    t_rad.value,
                    t_kin.value,
                    cooling_rate.to(u.Joule / u.second).value)
                )

                cooling_rate_vs_t_kin.append(
                    cooling_rate.to(u.Joule / u.second).value
                )

            pylab.loglog(