Exemplo n.º 1
0
    def test3(self):
        print "Testing standard BSE example 2..."
        instance = BSE()
        instance.parameters.common_envelope_efficiency = 3.0
        instance.parameters.Eddington_mass_transfer_limit_factor = 10.0
        instance.commit_parameters()

        stars = Particles(2)
        stars[0].mass = 7.816 | units.MSun
        stars[1].mass = 4.387 | units.MSun

        orbital_period = 1964.18453 | units.day
        semi_major_axis = instance.orbital_period_to_semi_major_axis(
            orbital_period, stars[0].mass, stars[1].mass)
        instance.particles.add_particles(stars)

        binaries = Particles(1)

        binary = binaries[0]
        binary.semi_major_axis = semi_major_axis
        binary.eccentricity = 0.0
        binary.child1 = stars[0]
        binary.child2 = stars[1]

        instance.binaries.add_particles(binaries)

        from_bse_to_model = instance.particles.new_channel_to(stars)
        from_bse_to_model.copy()

        from_bse_to_model_binaries = instance.binaries.new_channel_to(binaries)
        from_bse_to_model_binaries.copy()

        previous_type1 = binary.child1.stellar_type
        previous_type2 = binary.child2.stellar_type
        results = []
        current_time = 0 | units.Myr

        while current_time < (170 | units.Myr):
            instance.update_time_steps()
            # The next line appears a bit weird, but saves time for this simple test.
            current_time = current_time + max(
                2.0 * instance.binaries[0].time_step, 0.04 | units.Myr)
            instance.evolve_model(current_time)
            from_bse_to_model.copy()
            from_bse_to_model_binaries.copy()
            if not (binary.child1.stellar_type == previous_type1
                    and binary.child2.stellar_type == previous_type2):
                results.append((binary.age, str(binary.child1.stellar_type) +
                                " and " + str(binary.child2.stellar_type)))
                previous_type1 = binary.child1.stellar_type
                previous_type2 = binary.child2.stellar_type

        print '\n'.join(map(str, results))
        self.assertEqual(len(results), 13)
        times = (38.9708 | units.Myr, 39.0897 | units.Myr, 39.1213 | units.Myr,
                 43.8025 | units.Myr, 43.9923 | units.Myr, 44.0686 | units.Myr,
                 141.7077 | units.Myr, 142.3448 | units.Myr, 142.7827
                 | units.Myr, 166.1043 | units.Myr, 166.5795 | units.Myr,
                 166.9627 | units.Myr, 166.9863 | units.Myr)
        for result, expected in zip(results, times):
            self.assertAlmostEqual(result[0].value_in(units.Myr),
                                   expected.value_in(units.Myr), 0)

        types = (
            "Hertzsprung Gap and Main Sequence star",
            "First Giant Branch and Main Sequence star",
            "Core Helium Burning and Main Sequence star",
            "First Asymptotic Giant Branch and Main Sequence star",
            "Second Asymptotic Giant Branch and Main Sequence star",
            "Oxygen/Neon White Dwarf and Main Sequence star",
            "Oxygen/Neon White Dwarf and Hertzsprung Gap",
            "Oxygen/Neon White Dwarf and First Giant Branch",
            "Oxygen/Neon White Dwarf and Core Helium Burning",
            "Oxygen/Neon White Dwarf and First Asymptotic Giant Branch",
            "Oxygen/Neon White Dwarf and Hertzsprung Gap Naked Helium star",
            "Neutron Star and Hertzsprung Gap Naked Helium star",
            "Neutron Star and Carbon/Oxygen White Dwarf",
        )

        for result, expected in zip(results, types):
            self.assertEquals(result[1], expected)

        self.assertAlmostEqual(binary.child1.mass.value_in(units.MSun), 1.304,
                               3)
        self.assertAlmostEqual(binary.child2.mass.value_in(units.MSun), 0.800,
                               3)

        instance.stop()
Exemplo n.º 2
0
    def test3(self):
        print "Testing standard BSE example 2..."
        instance = BSE()
        instance.parameters.common_envelope_efficiency = 3.0
        instance.parameters.Eddington_mass_transfer_limit_factor = 10.0
        instance.commit_parameters()

        stars = Particles(2)
        stars[0].mass = 7.816 | units.MSun
        stars[1].mass = 4.387 | units.MSun

        orbital_period = 1964.18453 | units.day
        semi_major_axis = instance.orbital_period_to_semi_major_axis(orbital_period, stars[0].mass, stars[1].mass)
        instance.particles.add_particles(stars)

        binaries = Particles(1)

        binary = binaries[0]
        binary.semi_major_axis = semi_major_axis
        binary.eccentricity = 0.0
        binary.child1 = stars[0]
        binary.child2 = stars[1]

        instance.binaries.add_particles(binaries)

        from_bse_to_model = instance.particles.new_channel_to(stars)
        from_bse_to_model.copy()

        from_bse_to_model_binaries = instance.binaries.new_channel_to(binaries)
        from_bse_to_model_binaries.copy()

        previous_type1 = binary.child1.stellar_type
        previous_type2 = binary.child2.stellar_type
        results = []
        current_time = 0 | units.Myr

        while current_time < (170 | units.Myr):
            instance.update_time_steps()
            # The next line appears a bit weird, but saves time for this simple test.
            current_time = current_time + max(2.0 * instance.binaries[0].time_step, 0.04 | units.Myr)
            instance.evolve_model(current_time)
            from_bse_to_model.copy()
            from_bse_to_model_binaries.copy()
            if not (binary.child1.stellar_type == previous_type1 and binary.child2.stellar_type == previous_type2):
                results.append(
                    (binary.age, str(binary.child1.stellar_type) + " and " + str(binary.child2.stellar_type))
                )
                previous_type1 = binary.child1.stellar_type
                previous_type2 = binary.child2.stellar_type

        print "\n".join(map(str, results))
        self.assertEqual(len(results), 13)
        times = (
            38.9708 | units.Myr,
            39.0897 | units.Myr,
            39.1213 | units.Myr,
            43.8025 | units.Myr,
            43.9923 | units.Myr,
            44.0686 | units.Myr,
            141.7077 | units.Myr,
            142.3448 | units.Myr,
            142.7827 | units.Myr,
            166.1043 | units.Myr,
            166.5795 | units.Myr,
            166.9627 | units.Myr,
            166.9863 | units.Myr,
        )
        for result, expected in zip(results, times):
            self.assertAlmostEqual(result[0].value_in(units.Myr), expected.value_in(units.Myr), 0)

        types = (
            "Hertzsprung Gap and Main Sequence star",
            "First Giant Branch and Main Sequence star",
            "Core Helium Burning and Main Sequence star",
            "First Asymptotic Giant Branch and Main Sequence star",
            "Second Asymptotic Giant Branch and Main Sequence star",
            "Oxygen/Neon White Dwarf and Main Sequence star",
            "Oxygen/Neon White Dwarf and Hertzsprung Gap",
            "Oxygen/Neon White Dwarf and First Giant Branch",
            "Oxygen/Neon White Dwarf and Core Helium Burning",
            "Oxygen/Neon White Dwarf and First Asymptotic Giant Branch",
            "Oxygen/Neon White Dwarf and Hertzsprung Gap Naked Helium star",
            "Neutron Star and Hertzsprung Gap Naked Helium star",
            "Neutron Star and Carbon/Oxygen White Dwarf",
        )

        for result, expected in zip(results, types):
            self.assertEquals(result[1], expected)

        self.assertAlmostEqual(binary.child1.mass.value_in(units.MSun), 1.304, 3)
        self.assertAlmostEqual(binary.child2.mass.value_in(units.MSun), 0.800, 3)

        instance.stop()
Exemplo n.º 3
0
    def test2(self):
        print "Testing evolution of a wide binary system."
        instance = BSE()
        instance.parameters.metallicity = 0.001
        instance.parameters.common_envelope_efficiency = 3.0
        instance.parameters.Eddington_mass_transfer_limit_factor = 10.0
        instance.commit_parameters()

        stars = Particles(2)
        stars[0].mass = 3.0 | units.MSun
        stars[1].mass = 0.3 | units.MSun
        orbital_period = 2.0e5 | units.day
        semi_major_axis = instance.orbital_period_to_semi_major_axis(
            orbital_period, stars[0].mass, stars[1].mass)

        instance.particles.add_particles(stars)

        binaries = Particles(1)

        binary = binaries[0]
        binary.semi_major_axis = semi_major_axis
        binary.eccentricity = 0.5
        binary.child1 = stars[0]
        binary.child2 = stars[1]

        instance.binaries.add_particles(binaries)

        from_bse_to_model = instance.particles.new_channel_to(stars)
        from_bse_to_model.copy()

        from_bse_to_model_binaries = instance.binaries.new_channel_to(binaries)
        from_bse_to_model_binaries.copy()

        previous_type = binary.child1.stellar_type
        results = []
        current_time = 0 | units.Myr

        while current_time < (335 | units.Myr):
            instance.update_time_steps()
            # The next line appears a bit weird, but saves time for this simple test.
            current_time = current_time + max(
                2.0 * instance.binaries[0].time_step, 0.04 | units.Myr)
            instance.evolve_model(current_time)
            from_bse_to_model.copy()
            from_bse_to_model_binaries.copy()
            if not binary.child1.stellar_type == previous_type:
                results.append((binary.age, binary.child1.mass,
                                binary.child1.stellar_type))
                previous_type = binary.child1.stellar_type
        print results
        self.assertEqual(len(results), 6)

        times = (284.8516 | units.Myr, 287.0595 | units.Myr,
                 287.7848 | units.Myr, 331.1454 | units.Myr,
                 332.7407 | units.Myr, 333.4146 | units.Myr)
        for result, expected in zip(results, times):
            self.assertAlmostEqual(result[0].value_in(units.Myr),
                                   expected.value_in(units.Myr), 0)

        masses = (3.000 | units.MSun, 3.000 | units.MSun, 2.999 | units.MSun,
                  2.956 | units.MSun, 2.919 | units.MSun, 0.928 | units.MSun)
        for result, expected in zip(results, masses):
            self.assertAlmostEqual(result[1].value_in(units.MSun),
                                   expected.value_in(units.MSun), 2)

        types = (
            "Hertzsprung Gap",
            "First Giant Branch",
            "Core Helium Burning",
            "First Asymptotic Giant Branch",
            "Second Asymptotic Giant Branch",
            "Carbon/Oxygen White Dwarf",
        )

        for result, expected in zip(results, types):
            self.assertEquals(str(result[2]), expected)

        instance.stop()
Exemplo n.º 4
0
    def test2(self):
        print "Testing evolution of a wide binary system."
        instance = BSE()
        instance.parameters.metallicity = 0.001
        instance.parameters.common_envelope_efficiency = 3.0
        instance.parameters.Eddington_mass_transfer_limit_factor = 10.0
        instance.commit_parameters()

        stars = Particles(2)
        stars[0].mass = 3.0 | units.MSun
        stars[1].mass = 0.3 | units.MSun
        orbital_period = 2.0e5 | units.day
        semi_major_axis = instance.orbital_period_to_semi_major_axis(orbital_period, stars[0].mass, stars[1].mass)

        instance.particles.add_particles(stars)

        binaries = Particles(1)

        binary = binaries[0]
        binary.semi_major_axis = semi_major_axis
        binary.eccentricity = 0.5
        binary.child1 = stars[0]
        binary.child2 = stars[1]

        instance.binaries.add_particles(binaries)

        from_bse_to_model = instance.particles.new_channel_to(stars)
        from_bse_to_model.copy()

        from_bse_to_model_binaries = instance.binaries.new_channel_to(binaries)
        from_bse_to_model_binaries.copy()

        previous_type = binary.child1.stellar_type
        results = []
        current_time = 0 | units.Myr

        while current_time < (335 | units.Myr):
            instance.update_time_steps()
            # The next line appears a bit weird, but saves time for this simple test.
            current_time = current_time + max(2.0 * instance.binaries[0].time_step, 0.04 | units.Myr)
            instance.evolve_model(current_time)
            from_bse_to_model.copy()
            from_bse_to_model_binaries.copy()
            if not binary.child1.stellar_type == previous_type:
                results.append((binary.age, binary.child1.mass, binary.child1.stellar_type))
                previous_type = binary.child1.stellar_type
        print results
        self.assertEqual(len(results), 6)

        times = (
            284.8516 | units.Myr,
            287.0595 | units.Myr,
            287.7848 | units.Myr,
            331.1454 | units.Myr,
            332.7407 | units.Myr,
            333.4146 | units.Myr,
        )
        for result, expected in zip(results, times):
            self.assertAlmostEqual(result[0].value_in(units.Myr), expected.value_in(units.Myr), 0)

        masses = (
            3.000 | units.MSun,
            3.000 | units.MSun,
            2.999 | units.MSun,
            2.956 | units.MSun,
            2.919 | units.MSun,
            0.928 | units.MSun,
        )
        for result, expected in zip(results, masses):
            self.assertAlmostEqual(result[1].value_in(units.MSun), expected.value_in(units.MSun), 2)

        types = (
            "Hertzsprung Gap",
            "First Giant Branch",
            "Core Helium Burning",
            "First Asymptotic Giant Branch",
            "Second Asymptotic Giant Branch",
            "Carbon/Oxygen White Dwarf",
        )

        for result, expected in zip(results, types):
            self.assertEquals(str(result[2]), expected)

        instance.stop()