示例#1
0
def test_cri_lim_exception(available_abundances):
    for abundance in available_abundances:
        normal = select_abundances(abundance, 0.02).abundance()
        cri_lim_corrected = select_abundances(abundance, 0.02).corrected_abundance_CRI_LIM()
        assert normal == cri_lim_corrected

        normal = select_abundances(abundance, 0.013).abundance()
        cri_lim_corrected = select_abundances(abundance, 0.013).corrected_abundance_CRI_LIM()
        assert normal != cri_lim_corrected
示例#2
0
def test_select_abundances():
    strings = ["ag89", "gs98", "as05", "as09", "he10", "lo19"]
    classes = [AndersGrevesse1989, GrevesseSauval1998, Asplund2005, Asplund2009, Heger2010, Lodders2019]

    for i in range(len(strings)):
        abundance_instance = select_abundances(strings[i], 0.033)
        assert type(abundance_instance) == classes[i]
        assert abundance_instance.z == 0.033
示例#3
0
def test_matrices_are_empty_if_not_enough_mass():
    m = constants.M_MIN - 0.001
    test_settings = {
        "z": 0.03,
        "abundances": abundances.select_abundances(np.random.choice(settings.valid_values["sol_ab"]), 0.03),
        "expelled": elements.Expelled(settings.default["expelled_elements_filename"]),
    }

    assert np.all([i == 0 for i in matrix.q(m, test_settings)])
    assert np.all([i == 0 for i in matrix.q_sn(m)])
示例#4
0
def test_q_with_no_yield_corrections(mocker):
    m = constants.M_MIN + np.random.rand() * 40
    expelled = elements.Expelled(settings.default["expelled_elements_filename"])
    test_settings = {
                "z": 0.02,
                "abundances": abundances.select_abundances(np.random.choice(settings.valid_values["sol_ab"]), 0.02),
                "expelled": expelled,
            }

    mocker.spy(expelled, "for_mass")
    q = matrix.q(m, test_settings)
    expelled.for_mass.assert_called_once_with(m, {})
示例#5
0
def test_q_size():
    for m in [0.8, 1, 2, 4, 6, 8, 10, 40, 90]:
        for z in [0., 0.001, 0.01, 0.02, 0.03, 0.04, 0.05]:
            test_settings = {
                "z": z,
                "abundances": abundances.select_abundances(np.random.choice(settings.valid_values["sol_ab"]), z),
                "expelled": elements.Expelled(settings.default["expelled_elements_filename"]),
            }

            q = matrix.q(m, test_settings)

            assert q.shape == (constants.Q_MATRIX_ROWS, constants.Q_MATRIX_COLUMNS)
示例#6
0
def test_cri_lim_exception(mocker):
    test_settings = {
        "z": 0.03,
        "abundances": abundances.select_abundances(np.random.choice(settings.valid_values["sol_ab"]), 0.03),
        "expelled": elements.Expelled(settings.default["expelled_elements_filename"]),
    }
    mocker.spy(abundances.Abundances, "abundance")
    mocker.spy(abundances.Abundances, "corrected_abundance_CRI_LIM")

    q = matrix.q(4, test_settings)

    abundances.Abundances.abundance.assert_called_once()
    abundances.Abundances.corrected_abundance_CRI_LIM.assert_not_called()

    test_settings["expelled"].cri_lim_yields = True

    q = matrix.q(4, test_settings)

    abundances.Abundances.corrected_abundance_CRI_LIM.assert_called_once()
示例#7
0
    def init_variables(self):
        self.initial_mass_function = select_imf(self.context["imf"],
                                                self.context)
        self.context["abundances"] = select_abundances(
            self.context["sol_ab"], float(self.context["z"]))
        self.context["expelled"] = elements.Expelled(
            expelled_elements_filename=self.
            context["expelled_elements_filename"])

        self.mass_intervals = []
        self.energies = []
        self.sn_Ia_rates = []

        self.z = self.context["z"]
        self.dtd = select_dtd(self.context["dtd_sn"])
        self.m_min = self.context["m_min"]
        self.m_max = self.context["m_max"]
        self.integration_step = self.context["integration_step"]
        self.total_time_steps = 0
        if "total_time_steps" in self.context:
            self.total_time_steps = self.context["total_time_steps"]

        self.bmaxm = constants.B_MAX / 2
示例#8
0
def test_abundance_values_presence(available_abundances):
    for abundance in available_abundances:
        abundance_values = np.array(list(select_abundances(abundance, 0.025).abundance().values()))
        assert np.all(abundance_values > 0.0)
示例#9
0
def test_elements_value_presence(available_abundances):
    for abundance in available_abundances:
        elements = np.array(list(select_abundances(abundance, 0.025).elements().values()))
        assert np.all(elements > 0.0)
        assert np.all(elements < 1.0)
示例#10
0
def test_h_he4_values(available_abundances):
    for abundance in available_abundances:
        assert select_abundances(abundance, 0.025).h() > 0.0
        assert select_abundances(abundance, 0.025).he4() > 0.0
示例#11
0
def test_feh_with_z_non_zero(available_abundances):
    for abundance in available_abundances:
        assert select_abundances(abundance, 0.025).feh() > 0.0
示例#12
0
def test_description_presence(available_abundances):
    for abundance in available_abundances:
        assert select_abundances(abundance, 0.02).description() != Abundances(0.02).description()
示例#13
0
def test_abundances_classes_presence(available_abundances):
    for abundance in available_abundances:
        assert select_abundances(abundance, 0.02) is not None