posydon.binary_evol
posydon.binary_evol.binarystar
The binary object describes current and past state of the binary.
The binary object is composed of two star objects and contains the current and past states of the binary. Only parameters in the BINARYPROPERTIES list are stored in the history.
The current parameter value of the star object is accessed as, e.g. binary.orbital_period while its past history with binary.orbital_period_history.
The two stars are accessed as, e.g. binary.star_1.mass while their past history with binary.star_1.mass_history.
- class posydon.binary_evol.binarystar.BinaryStar(star_1=None, star_2=None, index=None, properties=None, **binary_kwargs)[source]
Bases:
object
A class containing the state and history of a stellar binary.
Initialize a binary star.
- Parameters:
properties (SimulationProperties) – Instance of the SimulationProperties class (default: None)
star_1 (SingleStar) – The first star of the binary.
star_2 (Star) – The second star of the binary.
**binary_kwargs (dictionary) – List of initialization parameters for a binary
- classmethod from_df(dataframe, **kwargs)[source]
Convert a binary from a pandas DataFrame to BinaryStar instance.
- Parameters:
- Return type:
New instance of BinaryStar
- classmethod from_oneline_df(oneline_df, **kwargs)[source]
Convert a oneline DataFrame into a BinaryStar.
The oneline DataFrame is expected to have initial-final values from history and any individual values that don’t have histories.
- static from_run(run, history=False, profiles=False)[source]
Create a BinaryStar object from a PSyGrid run.
- reset(properties=None)[source]
Reset the binary to its ZAMS state.
- Parameters:
properties (SimulationProperties) – Instance of the SimulationProperties class (default: None)
- restore(i=0)[source]
Restore the BinaryStar() object to its i-th state, keeping the binary history before the i-th state.
- Parameters:
i (int) – The index of the binary object history to reset the binary to. By default 0, i.e. the star will be restored to its initial state.
- to_df(**kwargs)[source]
Return history parameters from the binary in a DataFrame.
Includes star 1 and 2 (S1, S2) data and an extra column ‘binary_index’.
- Parameters:
extra_columns (dict( 'name':dtype, .... )) – Extra binary parameters to return in DataFrame that are not included in BINARYPROPERTIES. All columns must have an associated pandas data type. Can be used in combination with only_select_columns. Assumes names have no suffix.
ignore_columns (list) – Names of binary parameters to ignore. Assumes names have _history suffix.
only_select_columns (list) – Names of the only columns to include. Assumes names have _history suffix. Can be used in combination with extra_columns.
null_value (float) – Replace all None values with something else (for saving). Default is np.nan.
include_S1 (bool) – Choose to include star 1 or 2 data to the DataFrame. The default is to include both.
include_S2 (bool) – Choose to include star 1 or 2 data to the DataFrame. The default is to include both.
S1_kwargs (dict) – kwargs to pass to each star’s ‘to_df’ method (extra/ignore columns)
S2_kwargs (dict) – kwargs to pass to each star’s ‘to_df’ method (extra/ignore columns)
- Return type:
pandas DataFrame
posydon.binary_evol.flow_chart
Module setting the default evolution flow and allowing alterations.
This file contains the offical POSYDON flow chart binary evolution. To support future development and deal with complexity it is build dynamically.
- posydon.binary_evol.flow_chart.flow_chart(FLOW_CHART=None, CHANGE_FLOW_CHART=None)[source]
Generate the flow chart.
Default step nomenclature: - step_SN : StepSN in posydon/bianry_evol/SN/step_SN.py - step_HMS_HMS : MS_MS_step in posydon/binary_evol/mesa_step.py - step_CO_HMS_RLO : CO_HMS_RLO_step in posydon/binary_evol/mesa_step.py - step_CO_HeMS : CO_HeMS_step in posydon/binary_evol/mesa_step.py - step_detached : detached_step in posydon/binary_evol/detached_step.py - step_CE : StepCEE in posydon/binary_evol/CE/step_CEE.py - step_dco : DoubleCO in posydon/binary_evol/double_CO.py - step_end
- Parameters:
FLOW_CHART (dict) – Flow chart that maps the tuple (star_1_state, star_1_state, binary_state, binary_event) to a step.
CHANGE_FLOW_CHART (dict) –
Flow chart to change the default FLOW_CHART. E.g. CHANGE_FLOW_CHART = {(‘NS’, ‘NS’, ‘detached’, None) : ‘step_end’,
(‘NS’, ‘HeMS’, ‘RLO1’, ‘pRLO1’) : ‘step_my_RLO1’}
- Returns:
Flow chart.
- Return type:
posydon.binary_evol.simulationproperties
Simulation properties for the population class.
This class contains the simulation properties, e.g. flow, steps and max_time.
- class posydon.binary_evol.simulationproperties.EvolveHooks[source]
Bases:
object
Base class for hooking into binary evolution.
Add any new output columns to the hooks constructor. Example for extra binary columns:
self.extra_binary_col_names = [“column_name_1”, “column_name_2”]
- Example for extra star columns:
self.extra_star_col_names = [“column_name_1”, “column_name_2”]
- class posydon.binary_evol.simulationproperties.PrintStepInfoHooks[source]
Bases:
EvolveHooks
Simple example for adding extra print info.
Add any new output columns to the hooks constructor. Example for extra binary columns:
self.extra_binary_col_names = [“column_name_1”, “column_name_2”]
- Example for extra star columns:
self.extra_star_col_names = [“column_name_1”, “column_name_2”]
- class posydon.binary_evol.simulationproperties.SimulationProperties(properties=None, **kwargs)[source]
Bases:
object
Class describing the properties of a population synthesis simulation.
Construct the simulation properties object.
- Parameters:
- load_steps(verbose=False)[source]
Instantiate step classes and set as instance attributes.
- Parameters:
verbose (bool) – Print extra information.
- Return type:
None
- post_evolve(binary)[source]
Finalize the evolution of the binary.
The method is called after a binary exits the evolution loop. Uses all extra hooks classes or extra functions.
- Parameters:
binary (instance of <class, BinaryStar>) – The binary after evolution is ended.
- Returns:
binary
- Return type:
instance of <class, BinaryStar>
- post_step(binary, step_name)[source]
Finalize step.
The method is called after every evolution step; uses all extra hooks classes or extra functions (except for undefined next step errors).
- Parameters:
binary (instance of <class, BinaryStar>) – The binary before evolution starts.
step_name (str) – The name of the step about to be called (as defined in the flow).
- Returns:
binary
- Return type:
instance of <class, BinaryStar>
- pre_evolve(binary)[source]
Functions called before a binary evolves.
Uses all extra hooks classes or extra functions.
- Parameters:
binary (instance of <class, BinaryStar>) – The binary before evolution starts.
- Returns:
binary
- Return type:
instance of <class, BinaryStar>
- pre_step(binary, step_name)[source]
Prepare for step.
The method is called before every evolution step; uses all extra hooks classes or extra functions (except for undefined next step errors).
- Parameters:
binary (instance of <class, BinaryStar>) – The binary before evolution starts.
step_name (str) – The name of the step about to be called (as defined in the flow).
- Returns:
binary
- Return type:
instance of <class, BinaryStar>
- class posydon.binary_evol.simulationproperties.StepNamesHooks[source]
Bases:
EvolveHooks
Add history column ‘step_name’ to each binary.
Name of evolutionary step as defined in SimulationProperties.
>>> pop.to_df(extra_columns={'step_names': str})
Add any new output columns to the hooks constructor. Example for extra binary columns:
self.extra_binary_col_names = [“column_name_1”, “column_name_2”]
- Example for extra star columns:
self.extra_star_col_names = [“column_name_1”, “column_name_2”]
- class posydon.binary_evol.simulationproperties.TimingHooks[source]
Bases:
EvolveHooks
Add history column ‘step_times’ (time taken by step) to each binary.
Example
>>> pop.to_df(extra_columns={'step_times': float})
Add any new output columns to the hooks constructor. Example for extra binary columns:
self.extra_binary_col_names = [“column_name_1”, “column_name_2”]
- Example for extra star columns:
self.extra_star_col_names = [“column_name_1”, “column_name_2”]
posydon.binary_evol.singlestar
The star object describe the star current and past state.
The star object contains the current and past states of the star. Only parameters in the STARPROPERTIES list are stored in the history. The current parameter value of the star object is accessed as, e.g. star.mass, while his past history with star.mass_history.
- class posydon.binary_evol.singlestar.SingleStar(**kwargs)[source]
Bases:
object
Class describing a single star.
Initialize the star.
- Parameters:
**kwargs (dict) – List of initialization parameters for a star.
- static from_run(run, history=False, profile=False, which_star=None)[source]
Create a SingleStar object from a single-star grid run.
- restore(i=0, hooks=None)[source]
Restore the SingleStar() object to its i-th state, keeping the star history before the i-th state.
- Parameters:
i (int) – Index of the star object history to reset the star to. By default i == 0, i.e. the star will be restored to its initial state.
hooks (list) – List of extra hooks associated with the SimulationProperties() of the BinaryStar() object containing this SingleStar(), if applicable. This parameter is automatically set when restoring a BinaryStar() object.
- to_df(**kwargs)[source]
Return history parameters from the star in a DataFrame.
By default all parameters in STARPROPERTIES are included.
- Parameters:
extra_columns (dict( 'name':dtype, .... )) – Extra star history parameters to return in DataFrame that are not included in STARPROPERTIES. All columns must have an associated pandas data type. Can be used in combination with only_select_columns. Assumes names have no suffix.
ignore_columns (list) – Names of STARPROPERTIES parameters to ignore. Assumes names have _history suffix.
only_select_columns (list) – Names of the only columns to include. Can be used in combination with extra_columns. Assumes names have _history suffix.
include_profile (bool) – Include the star’s profile in the dataframe (NOT RECOMMENDED)
null_value (float, optional) – Replace all None values with something else (for saving). Default is np.nan.
prefix (str, optional) – Prefix to all column names. (e.g. ‘star_1’, ‘S1’) Default has no prefix.
- Return type:
pandas DataFrame
posydon.binary_evol.step_end
Class defining the default step at the end of evolution of a binary.