Пример #1
0
def test_evolution(interpolator,
                   convective_phase_lag = phase_lag(5.5),
                   planet_phase_lag = 0.0,
                   create_c_code='',
                   eccentricity_expansion_fname=None):
    """Run a single orbital evolution calculation and plot the results."""

    for pdisk, color, wsat_enabled in [
#            (1.4, 'r', '1'),
#            (3.0, 'g', '2'),
            (7.0, 'b', '3')
    ]:
        star = create_star(interpolator=interpolator,
                           convective_phase_lag=convective_phase_lag)
        planet = create_planet(phase_lag=planet_phase_lag)
        binary = create_system(star, planet, 2.0 * numpy.pi / pdisk)

        binary.evolve(10.0,
                      0.001,
                      1e-6,
                      None,
                      create_c_code=create_c_code,
                      eccentricity_expansion_fname=eccentricity_expansion_fname)
        plot_evolution(binary, color)

        star.delete()
        planet.delete()
        binary.delete()
def get_poet_dissipation_from_cmdline(cmdline_args,
                                      lgq_suffixes=('primary', 'secondary')):
    """
    Return keyword arguments setting the dissipation as specified on cmdline.

    Args:
        cmdline_args:    The parsed command line which should have included the
            arguments added by add_dissipation_cmdline().

    Returns:
        dict:
            Dictionary with keys given by lgq_suffixes, and values dictionaries
            of keyword arguments to pass to the POET set_dissipation methods for
            stars and planets.
    """

    default_breaks = None
    default_powers = numpy.array([0.0])

    result = dict()
    for component in lgq_suffixes:
        lgq = getattr(cmdline_args, 'lgQ_' + component)
        dependence = dict(tidal=numpy.array(
            getattr(cmdline_args, 'lgQ_' + component + '_wtide_dependence')),
                          spin=numpy.array(
                              getattr(cmdline_args, 'lgQ_' + component +
                                      '_wspin_dependence')))
        if numpy.isfinite(lgq):
            result[component] = dict()
            result[component]['reference_phase_lag'] = phase_lag(lgq)
            for dep_name in ['tidal', 'spin']:
                result[component]['_'.join(
                    (dep_name, 'frequency',
                     'breaks'))] = (numpy.copy(dependence[dep_name][1::2])
                                    if dependence[dep_name].size > 0 else
                                    default_breaks)
                result[component]['_'.join(
                    (dep_name, 'frequency',
                     'powers'))] = (numpy.copy(dependence[dep_name][::2][:])
                                    if dependence[dep_name].size > 0 else
                                    default_powers)
        else:
            result[component] = None

    return result
Пример #3
0
def test_binary_star_evolution(*,
                               interpolator,
                               convective_phase_lag=phase_lag(5.5),
                               create_c_code='',
                               eccentricity_expansion_fname=None):
    """Calculate and plot the evolution of a system of two stars."""

    pdisk = 7.0
    porb = 11.9
    star1_mass = 1.14
    star2_mass = 0.9
    feh = 0.21
    age = 6.3
    disk_lifetime = 5e-3
    eccentricity = 0.45

    primary = create_star(interpolator,
                          convective_phase_lag,
                          mass=star1_mass,
                          metallicity=feh)
    secondary = create_star(interpolator,
                            convective_phase_lag,
                            mass=star2_mass,
                            metallicity=feh,
                            interp_age=disk_lifetime)
    binary = create_system(primary,
                           secondary,
                           2.0 * numpy.pi / pdisk,
                           eccentricity,
                           porb_initial=porb,
                           disk_dissipation_age=disk_lifetime)
    binary.evolve(age,
                  0.001,
                  1e-6,
                  None,
                  create_c_code=create_c_code,
                  eccentricity_expansion_fname=eccentricity_expansion_fname)

    plot_evolution(binary, 'k')

    primary.delete()
    secondary.delete()
    binary.delete()
Пример #4
0
                                     evolution_max_time_step = 1e-2)
    target = Structure(age = 5.0,
                       Porb = 3.0,
                       Psurf = 10.0,
                       planet_formation_age = 5e-3)
    star = create_star(interpolator)
    planet = create_planet()
    initial_porb, initial_psurf = find_ic(target = target,
                                          star = star,
                                          planet = planet)
    print('IC: Porb0 = %s, P*0 = %s' % (repr(initial_porb),
                                        repr(initial_psurf)))

if __name__ == '__main__':
    eccentricity_expansion_fname = b"eccentricity_expansion_coef.txt"
    orbital_evolution_library.read_eccentricity_expansion_coefficients(
        eccentricity_expansion_fname
    )
    serialized_dir = '../stellar_evolution_interpolators'
    manager = StellarEvolutionManager(serialized_dir)
    interpolator = manager.get_interpolator_by_name('default')

    test_binary_star_evolution(
        interpolator=interpolator,
#                               planet_phase_lag=phase_lag(5.0),
        convective_phase_lag=phase_lag(5.0),
        create_c_code='../poet_src/debug/test_evol.cpp',
        eccentricity_expansion_fname=eccentricity_expansion_fname
    )
#    test_ic_solver()
Пример #5
0
def test_single_dissipator(interpolator, wind):
    """Compare planet-dissipative star to 2 stars, one non-dissipative."""

    tdisk = 5e-3

    star = create_star(interpolator=interpolator,
                       convective_phase_lag=phase_lag(6.0),
                       wind=wind)
    planet = create_planet(1.0)
    binary = create_binary_system(star,
                                  planet,
                                  disk_lock_frequency=2.0 * numpy.pi / 3.0,
                                  initial_semimajor=10.0,
                                  disk_dissipation_age=tdisk)
    planet_evolution = plot_evolution(binary, wsat=2.78)

    #pylint false positive, members are created after construction.
    #pylint: disable=no-member
    tdisk_index = planet_evolution.age.searchsorted(tdisk)
    initial_angmom = numpy.array([
        planet_evolution.envelope_angmom[tdisk_index],
        planet_evolution.core_angmom[tdisk_index]
    ])
    #pylint: enable=no-member

    planet.delete()
    star.delete()
    binary.delete()

    print(80 * '=')
    print('Done with planet-star evolution')
    print(80 * '=')

    primary = create_star(interpolator=interpolator,
                          convective_phase_lag=phase_lag(6.0),
                          wind=wind)
    secondary = create_star(interpolator=interpolator,
                            convective_phase_lag=0.0,
                            wind=wind)
    binary = create_binary_system(primary,
                                  secondary,
                                  disk_lock_frequency=2.0 * numpy.pi / 3.0,
                                  initial_semimajor=10.0,
                                  disk_dissipation_age=tdisk,
                                  secondary_angmom=initial_angmom)
    evolution = plot_evolution(binary,
                               wsat=2.78,
                               style=dict(orb='xr',
                                          core='xb',
                                          env='xg',
                                          sec_env=':c',
                                          sec_core=':m'))

    output_evolution(evolution)

    primary.delete()
    secondary.delete()
    binary.delete()

    print(80 * '=')
    print('Done with dissipative primary star-star evolution')
    print(80 * '=')

    primary = create_star(interpolator=interpolator,
                          convective_phase_lag=0.0,
                          wind=wind)
    secondary = create_star(interpolator=interpolator,
                            convective_phase_lag=phase_lag(6.0),
                            wind=wind)
    binary = create_binary_system(primary,
                                  secondary,
                                  disk_lock_frequency=2.0 * numpy.pi / 3.0,
                                  initial_semimajor=10.0,
                                  disk_dissipation_age=tdisk,
                                  secondary_angmom=initial_angmom)
    evolution = plot_evolution(binary,
                               wsat=2.78,
                               style=dict(orb='+r',
                                          core='oc',
                                          env='om',
                                          sec_env='+g',
                                          sec_core='+b'))

    output_evolution(evolution)

    primary.delete()
    secondary.delete()
    binary.delete()

    print(80 * '=')
    print('Done with dissipative secondary star-star evolution')
    print(80 * '=')

    pyplot.show()
Пример #6
0
    def test_primary_secondary_swap(self):
        """Compare evolutions of two stars, swapping wich one is primary."""

        def get_disk_angmom(star_mass, star_phase_lag, wind):
            """Return core & envelope angular momenta at disk dissipation."""

            star = self._create_star(convective_phase_lag=star_phase_lag,
                                     mass=star_mass,
                                     wind=wind)
            planet = self._create_planet(1.0)
            binary = self._create_binary_system(
                star,
                planet,
                disk_lock_frequency=2.0 * scipy.pi / 3.0,
                initial_semimajor=10.0,
                disk_dissipation_age=config['tdisk']
            )
            binary.evolve(config['tdisk'], 1e-2, 1e-6, None)
            disk_dissipation_state = binary.final_state()

            planet.delete()
            star.delete()
            binary.delete()

            #Pylint false positive, members added after construction.
            #pylint:disable=no-member
            return scipy.array([disk_dissipation_state.envelope_angmom,
                                disk_dissipation_state.core_angmom])
            #pylint:enable=no-member

        def get_evolution(primary_mass, secondary_mass, tdisk, star_phase_lag, wind):
            """Return the evolution for the given parameters."""

            primary = self._create_star(
                convective_phase_lag=star_phase_lag,
                mass=primary_mass,
                wind=wind
            )
            secondary = self._create_star(
                convective_phase_lag=star_phase_lag,
                mass=secondary_mass,
                wind=wind
            )
            binary = self._create_binary_system(
                primary,
                secondary,
                disk_lock_frequency=2.0 * scipy.pi / 3.0,
                initial_semimajor=10.0,
                disk_dissipation_age=tdisk,
                secondary_angmom=get_disk_angmom(secondary_mass,
                                                 star_phase_lag,
                                                 wind)
            )
            binary.evolve(10.0, 1e-2, 1e-6, None)
            evolution = binary.get_evolution()

            primary.delete()
            secondary.delete()
            binary.delete()

            return evolution

        config = dict(mass1=1.0, mass2=0.8, tdisk=5e-3)

        for star_phase_lag in [
                0.0,
                phase_lag(6.0)
        ]:
            for wind in [
                    False,
                    True
            ]:
                with self.subTest(wind=wind, phase_lag=star_phase_lag):
                    evolution1 = get_evolution(
                        primary_mass=config['mass1'],
                        secondary_mass=config['mass2'],
                        tdisk=config['tdisk'],
                        star_phase_lag=star_phase_lag,
                        wind=wind
                    )
                    evolution2 = get_evolution(
                        primary_mass=config['mass2'],
                        secondary_mass=config['mass1'],
                        tdisk=config['tdisk'],
                        star_phase_lag=star_phase_lag,
                        wind=wind
                    )
                    self._compare_evolutions(
                        evolution1,
                        evolution2,
                        primary_to_secondary=True,
                        min_age=config['tdisk'],
                        max_age=(4.59 if (star_phase_lag and wind)
                                 else scipy.inf)
                    )
Пример #7
0
    def test_star_planet_swap(self):
        """Compare evolutions with secondary planet or non-dissipative star."""

        tdisk = 5e-3

        for primary_mass in [
                1.0,
                0.8
        ]:
            for secondary_mass in [
                    1.0,
                    0.8
            ]:
                for star_phase_lag in [
                        0.0,
                        phase_lag(6.0)
                ]:
                    for wind in [
                            False,
                            True
                    ]:
                        with self.subTest(wind=wind,
                                          phase_lag=star_phase_lag,
                                          primary_mass=primary_mass,
                                          secondary_mass=secondary_mass):

                            star = self._create_star(
                                convective_phase_lag=star_phase_lag,
                                mass=primary_mass,
                                wind=wind
                            )
                            planet = self._create_planet(secondary_mass)
                            binary = self._create_binary_system(
                                star,
                                planet,
                                disk_lock_frequency=2.0 * scipy.pi / 3.0,
                                initial_semimajor=10.0,
                                disk_dissipation_age=tdisk
                            )
                            binary.evolve(10.0, 1e-2, 1e-6, None)
                            star_planet_evolution = binary.get_evolution()

                            planet.delete()
                            star.delete()
                            binary.delete()

                            #pylint false positive, members added after
                            #construction.
                            #pylint: disable=no-member
                            tdisk_index = (
                                star_planet_evolution.age.searchsorted(tdisk)
                            )
                            #pylint: enable=no-member

                            primary = self._create_star(
                                convective_phase_lag=star_phase_lag,
                                mass=primary_mass,
                                wind=wind
                            )
                            secondary = self._create_star(
                                convective_phase_lag=0.0,
                                mass=secondary_mass,
                                wind=False
                            )
                            binary = self._create_binary_system(
                                primary,
                                secondary,
                                disk_lock_frequency=2.0 * scipy.pi / 3.0,
                                initial_semimajor=10.0,
                                disk_dissipation_age=tdisk,
                                secondary_angmom=scipy.array([
                                    #pylint false positive
                                    #pylint: disable=no-member
                                    star_planet_evolution.envelope_angmom[
                                        tdisk_index
                                    ] * 1e-3,
                                    star_planet_evolution.core_angmom[
                                        tdisk_index
                                    ] * 1e-3
                                    #pylint: enable=no-member
                                ])
                            )
                            binary.evolve(10.0, 1e-2, 1e-6, None)
                            star_star_evolution = binary.get_evolution()

                            primary.delete()
                            secondary.delete()
                            binary.delete()

                            self._compare_evolutions(
                                star_planet_evolution,
                                star_star_evolution,
                                max_age=(8.49 if (star_phase_lag and wind)
                                         else scipy.inf)
                            )