POSYDON-code / POSYDON

POSYDON is a next-generation single and binary-star population synthesis code incorporating full stellar structure and evolution modeling with the use of MESA.
BSD 3-Clause "New" or "Revised" License
29 stars 19 forks source link

Suport ZAMS binaries with initial eccentricity #337

Closed ka-rocha closed 1 month ago

ka-rocha commented 3 months ago

Currently ZAMS binaries are born with $e=0$. In order to allow for $e\neq0$ (for eccentric MT in the future ๐Ÿ‘€ ๐Ÿ˜Ž) we need to adjust the flow and introduce a new step HMS_HMS_RLO_step which will allow binaries to be initially evolved in detached step but then mapped to the HMS mesa grid as in the CO_HMS and CO_HeMS steps. (Made with @mkruckow, @ZepeiX)

Here is an example of some code which runs this new setup. (Along with the RLO post-processed HMS-HMS grid in the POSYDON_data folder)

from posydon.popsyn.binarypopulation import BinaryPopulation
from posydon.popsyn.io import binarypop_kwargs_from_ini

from posydon.binary_evol.flow_chart import flow_chart, initial_eccentricity_flow_chart
from posydon.binary_evol.MESA.step_mesa import HMS_HMS_RLO_step
from pprint import pprint

bpkw = binarypop_kwargs_from_ini('/projects/b1119/karocha/software/fork/POSYDON-public/posydon/popsyn/population_params_default.ini')

# New flow chart
bpkw['population_properties'].kwargs['flow'] = (initial_eccentricity_flow_chart, {})

# replace step_HMS_HMS with step_HMS_HMS_RLO
default_HMS_HMS_kwargs = bpkw['population_properties'].kwargs['step_HMS_HMS'][-1]
bpkw['population_properties'].kwargs['step_HMS_HMS_RLO'] = ( HMS_HMS_RLO_step, default_HMS_HMS_kwargs )
bpkw['population_properties'].kwargs['verbose'] = True
bpkw['population_properties'].kwargs.pop('step_HMS_HMS') # remove

# Add initial eccentricity
from posydon.binary_evol.simulationproperties import EvolveHooks
class AddInitialEccentricity( EvolveHooks ):
    def pre_evolve(self, binary):
        binary.eccentricity = np.random.uniform(0,1)
        binary.eccentricity_history[0] = binary.eccentricity
        return binary
bpkw['population_properties'].kwargs['extra_hooks'].append( (EvolveHooks, {}) )
bpkw['population_properties'].kwargs['extra_hooks'].append( (AddInitialEccentricity, {}) )
bpkw['population_properties'].all_hooks_classes = [cls(**kwargs) for (cls, kwargs) in bpkw['population_properties'].kwargs['extra_hooks']]

bpkw['number_of_binaries'] = 5_000
bpkw['metallicity'] = 1

binary_pop = BinaryPopulation(**bpkw)
binary_pop.evolve()

And the output from the population: black x's are initial_RLO after step_detached into step_HMS_HMS_RLO, blue are ZAMS, and purple show post step_HMS_HMS_RLO which have been circularized.

Screen Shot 2024-06-22 at 11 26 06 AM
ka-rocha commented 3 months ago

I've tested it for 5k binaries with uniform eccentricity. After looking through some specific models things look ok from what I can tell. Do you think we should run larger pop / some physical eccentricity distribution like thermal?

mkruckow commented 3 months ago

Do you think we should run larger pop / some physical eccentricity distribution like thermal? Those can be done in science projects.

But I'd more suggest a test, what happens if your initial conditions M1,M2,P are outside the HMS-HMS gird, but supported by the single star grid. E.g. those:

P_orb,M_1,M_2,e
10.0,4.0,1.0,0.1
10.0,300.0,75.0,0.1
10.0,100.0,2.0,0.1
10.0,100.0,99.9,0.1
0.01,100.0,25.0,0.1
10000.0,100.0,25.0,0.1

Another test would be to see how different the evolution is for a binary with e=0.

astroJeff commented 2 months ago

Update (July 18): @ka-rocha to re-test with new grids. Present results and examples next week during developers' meeting.

astroJeff commented 2 months ago

Update (Aug 1): The code looks good, but we need to check how good the matching is - from the detached step during initial evolution at HMS-HMS into the MESA binary grid. We are particularly concerned about the core masses (but rotation should also be considered). We will hold off on accepting until this check has occurred. @ka-rocha to look into possible options for saving/printing out similarity of matching grids/stars.