Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion dev-tools/script_data/1Zsun_binaries_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

target_rows = 12
line_length = 140
columns_to_show = ['step_names', 'state', 'event', 'S1_state', 'S1_mass', 'S2_state', 'S2_mass', 'orbital_period']
columns_to_show = ['step_names', 'state', 'event', 'S1_state', 'S1_mass', 'S2_state', 'S2_mass', 'orbital_period', 'time']

def load_inlist(verbose):

Expand Down Expand Up @@ -759,6 +759,76 @@ def evolve_binaries(verbose):
properties = sim_prop)
evolve_binary(binary)

########################################
# double CO step
########################################
# NS + WD example
star1 = SingleStar(**{'mass': 7.939736047577677,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 0.0, 0.0, 0.0]})
star2 = SingleStar(**{'mass': 6.661421823348241,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 0.0, 0.0, 0.0]})

binary = BinaryStar(star1, star2,
**{'time': 0.0, 'state': 'detached', 'event': 'ZAMS',
'orbital_period': 28.576933942881404, 'eccentricity': 0.0},
properties = sim_prop)
evolve_binary(binary)
# BH + NS example
star1 = SingleStar(**{'mass': 22.69609546427504,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 2.051704135150374, 1.73468853754093, 3.299716078528058]})
star2 = SingleStar(**{'mass': 16.39690317352072,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 5.934599002039066, 2.4331072903106974, 1.9933166215820504]})

binary = BinaryStar(star1, star2,
**{'time': 0.0, 'state': 'detached', 'event': 'ZAMS',
'orbital_period': 70.37960820393167, 'eccentricity': 0.0},
properties = sim_prop)
evolve_binary(binary)
# WD + WD example
star1 = SingleStar(**{'mass': 6.661421823348241,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 0.0, 0.0, 0.0]})
star2 = SingleStar(**{'mass': 6.661421823348241,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 0.0, 0.0, 0.0]})

binary = BinaryStar(star1, star2,
**{'time': 0.0, 'state': 'detached', 'event': 'ZAMS',
'orbital_period': 28.576933942881404, 'eccentricity': 0.0},
properties = sim_prop)
evolve_binary(binary)
# NS + NS example
star1 = SingleStar(**{'mass': 16.458995075687447,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 3.661376360771944, 0.7219969332243381, 4.919284439555057]})
star2 = SingleStar(**{'mass': 12.580980419413521,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 4.944467687452352, 1.2845384190953326, 1.6806849171480245]})

binary = BinaryStar(star1, star2,
**{'time': 0.0, 'state': 'detached', 'event': 'ZAMS',
'orbital_period': 247.4244399689946, 'eccentricity': 0.0},
properties = sim_prop)
evolve_binary(binary)

# BH + BH
star1 = SingleStar(**{'mass': 31.077951593283725,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 1.9047595342945016, 0.7097181927314352, 2.892753852818733]})
star2 = SingleStar(**{'mass': 27.8239810278115,
'state': 'H-rich_Core_H_burning',
'natal_kick_array': [0.0, 4.004970175991886, 2.2544428565691472, 3.420828590003044]})

binary = BinaryStar(star1, star2,
**{'time': 0.0, 'state': 'detached', 'event': 'ZAMS',
'orbital_period': 27.429155057946318, 'eccentricity': 0.0},
properties = sim_prop)
evolve_binary(binary)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Evolve binaries for validation.')
parser.add_argument('--verbose', '-v', action='store_true', default=False,
Expand Down
27 changes: 18 additions & 9 deletions docs/_source/components-overview/pop_syn/single_star.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,29 @@ The star properties are defined as follows
Additional scalar properties are added during the evolution depending on which steps the star has undergone. These properties are not stored in the history.

.. list-table:: Additional output
:header-rows: 1
:widths: 50 150
:header-rows: 1
:widths: 50 150

* - Properties
- Descriptions
* - ``natal_kick_array``
- | The natal kick array for the star if it has undergone a SN.
| contains:

* velocity
* theta
* phi
* mean anomaly

| This has been replaced with the individual properties below.
| ``natal_kick_array`` contains:

* velocity (km/s)
* azimuthal angle phi (radians)
* polar angle theta (radians)
* mean anomaly (radians)

* - ``natal_kick_velocity``
- The magnitude of the natal kick velocity in km/s.
* - ``natal_kick_phi``
- The natal kick azimuthal angle phi in radians.
* - ``natal_kick_theta``
- The natal kick polar angle theta in radians.
* - ``natal_kick_mean_anomaly``
- The natal kick mean anomaly in radians.
* - ``SN_type``
- The supernova type of the star.
* - ``f_fb``
Expand Down
12 changes: 12 additions & 0 deletions docs/_source/getting-started/installation-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Installing POSYDON
Anaconda (Recommended)
----------------------

.. important::
**Conda Version Requirements**: POSYDON requires a recent version of conda (version >= 23.1.0) with the libmamba solver for efficient dependency resolution. Older conda versions (especially those prior to v23.1.0) may take an extremely long time (hours or more) to resolve dependencies and may fail to complete installation.

To check your conda version and solver configuration:

.. code-block:: bash

conda --version
conda config --show solver

If you're using an older conda version or experiencing slow installation, please see the :ref:`troubleshooting guide <installation-issues>` for detailed instructions on updating conda or configuring the libmamba solver.

1. **Install Anaconda**

If you haven't already, download and install Anaconda from `Anaconda's official website <https://www.anaconda.com/products/distribution>`_.
Expand Down
51 changes: 40 additions & 11 deletions docs/_source/troubleshooting-faqs/installation-issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,49 @@ Common Installation Issues

From time to time, users might encounter issues during the installation of POSYDON. This page aims to address common installation problems and offer solutions. If your problem isn't covered here, please `report the issue <https://github.com/POSYDON-code/POSYDON/issues>`_ so we can assist you and possibly update this page for the benefit of others.

1. **Slow `conda` solving:**
1. **Slow `conda` solving or installation taking hours:**

`conda` can be very slow and sometimes gets stuck on "Verifying transaction" or "Executing transaction", especially when installing packages on a cluster.
It creates many small files, which can be difficult for HPC clusters to handle.
One way to speed up the installation is to use the `mamba` package manager, which is a drop-in replacement for `conda` but is much faster (`click here for more details <https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community>`_).
Please proceed at your own discretion, as this has not been fully vetted. Alternatively, you can install the `libmamba` solver to speed up the solving process for new installations in a `conda` environment.
To install the `libmamba` solver, run the following command in your `conda` environment of choice or `base` `conda` environment:
**Conda Version Requirements**: POSYDON has a complex dependency tree, and older conda versions (especially those prior to v23.1.0) use very slow dependency solvers that can take hours or may never complete the installation process. Modern conda versions (>= 23.1.0) include the libmamba solver by default, which resolves dependencies efficiently in seconds to minutes.

```bash
conda install conda-libmamba-solver
```
**Check your conda version and solver:**

This will install the `libmamba` solver, which is a drop-in replacement for the default `conda` solver.
This should speed up solving the environment and installing packages but is not guaranteed to work in all cases.
.. code-block:: bash

conda --version
conda config --show solver

**Solutions:**

a. **Update conda** (Recommended): If you have administrative access or can install conda locally, we strongly recommend updating to the latest conda version (2025 or later), which includes the fast libmamba solver by default:

.. code-block:: bash

# Update conda in your base environment
conda update -n base conda

# Or install a fresh conda distribution from https://www.anaconda.com/download

b. **Install and configure the libmamba solver** (For existing conda installations):

If you cannot update conda but have version 4.12 or later, you can install and configure the libmamba solver:

.. code-block:: bash

# Install the libmamba solver
conda install -n base conda-libmamba-solver

# Set libmamba as the default solver
conda config --set solver libmamba

# Verify the configuration
conda config --show solver

c. **Use mamba** (Alternative): Another option is to use the `mamba` package manager, which is a drop-in replacement for `conda` but is much faster (`click here for more details <https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community>`_). However, this approach has not been fully vetted with POSYDON.

.. note::
If you're on an HPC cluster with an old system-wide conda installation (e.g., conda 2021.11), you may need to install a recent conda version locally in your home directory rather than using the system version.

`conda` can also be slow and sometimes gets stuck on "Verifying transaction" or "Executing transaction", especially when installing packages on a cluster, as it creates many small files which can be difficult for HPC clusters to handle. The libmamba solver helps with this issue as well.

2. **Failed Dependencies**:
- **Description**: Sometimes, certain dependencies might fail to install or conflict with pre-existing ones.
Expand Down
6 changes: 3 additions & 3 deletions posydon/binary_evol/MESA/step_mesa.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ def update_properties_NN(self, star_1_CO=False, star_2_CO=False,
setattr(binary, 'event', binary_event)
setattr(binary, 'mass_transfer_case', MT_case)

culmulative_mt_case = self.termination_flags[1]
setattr(self.binary, f'culmulative_mt_case_{self.grid_type}', culmulative_mt_case)
cumulative_mt_case = self.termination_flags[1]
setattr(self.binary, f'cumulative_mt_case_{self.grid_type}', cumulative_mt_case)
setattr(self.binary, f'interp_class_{self.grid_type}', interpolation_class)
mt_history = self.termination_flags[2] # mass transfer history (TF12 plot label)
setattr(self.binary, f'mt_history_{self.grid_type}', mt_history)
Expand Down Expand Up @@ -930,7 +930,7 @@ def initial_final_interpolation(self, star_1_CO=False, star_2_CO=False):
setattr(self.binary, f'mt_history_{self.grid_type}', mt_history)

#TODO: add classifier for tf2
#setattr(self.binary, f'culmulative_mt_case', self.classes['termination_flags_2'])
#setattr(self.binary, f'cumulative_mt_case', self.classes['termination_flags_2'])
S1_state_inferred = cf.check_state_of_star(self.binary.star_1,
star_CO=star_1_CO)
S2_state_inferred = cf.check_state_of_star(self.binary.star_2,
Expand Down
4 changes: 2 additions & 2 deletions posydon/binary_evol/binarystar.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def __init__(self, star_1=None, star_2=None, index=None, properties=None,
setattr(self, f'interp_class_{grid_type}', None)
if not hasattr(self, f'mt_history_{grid_type}'):
setattr(self, f'mt_history_{grid_type}', None)
if not hasattr(self, f'culmulative_mt_case_{grid_type}'):
setattr(self, f'culmulative_mt_case_{grid_type}', None)
if not hasattr(self, f'cumulative_mt_case_{grid_type}'):
setattr(self, f'cumulative_mt_case_{grid_type}', None)

# SimulationProperties object - parameters & parameterizations
if isinstance(properties, SimulationProperties):
Expand Down
28 changes: 23 additions & 5 deletions posydon/grids/psygrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2006,12 +2006,30 @@ def HR(self, idx, history='history1', states=False, verbose=False,
raise TypeError('Invalid idx = {}!'.format(idx))

if states:
from posydon.binary_evol.singlestar import SingleStar
star_states = []
for run in runs:
star = SingleStar.from_run(run, history=True, profile=False)
star_states.append(check_state_of_star_history_array(
star, N=len(star.mass_history)))
# Check if this is a binary grid
if self.config["binary"]:
from posydon.binary_evol.binarystar import BinaryStar
for run in runs:
binary = BinaryStar.from_run(run, history=True, profiles=False)
# Extract the appropriate star based on history parameter
if history == 'history1':
star = binary.star_1
elif history == 'history2':
star = binary.star_2
else:
raise ValueError(
f"For binary grids with states=True, history must be "
f"'history1' or 'history2', not '{history}'"
)
star_states.append(check_state_of_star_history_array(
star, N=len(star.mass_history)))
else:
from posydon.binary_evol.singlestar import SingleStar
for run in runs:
star = SingleStar.from_run(run, history=True, profile=False)
star_states.append(check_state_of_star_history_array(
star, N=len(star.mass_history)))
else:
star_states = None

Expand Down
18 changes: 13 additions & 5 deletions posydon/popsyn/binarypopulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import psutil
from tqdm import tqdm

import posydon
from posydon.binary_evol.binarystar import BinaryStar
from posydon.binary_evol.simulationproperties import SimulationProperties
from posydon.binary_evol.singlestar import SingleStar, properties_massless_remnant
Expand Down Expand Up @@ -77,7 +78,8 @@
'orbital_separation_scheme',
'orbital_separation_min',
'orbital_separation_max',
'eccentricity_scheme']
'eccentricity_scheme',
'posydon_version']


HISTORY_MIN_ITEMSIZE = {'state': 30, 'event': 25, 'step_names': 21,
Expand All @@ -95,8 +97,8 @@
'interp_class_CO_HMS_RLO' : 15, 'interp_class_CO_HeMS_RLO' : 15,
'mt_history_HMS_HMS' : 40, 'mt_history_CO_HeMS' : 40,
'mt_history_CO_HMS_RLO' : 40, 'mt_history_CO_HeMS_RLO' : 40,
'culmulative_mt_case_HMS_HMS': 40, 'culmulative_mt_case_CO_HeMS': 40,
'culmulative_mt_case_CO_HMS_RLO': 40, 'culmulative_mt_case_CO_HeMS_RLO': 40,
'cumulative_mt_case_HMS_HMS': 40, 'cumulative_mt_case_CO_HeMS': 40,
'cumulative_mt_case_CO_HMS_RLO': 40, 'cumulative_mt_case_CO_HeMS_RLO': 40,
}

# BinaryPopulation will enforce a constant metallicity accross all steps that
Expand Down Expand Up @@ -587,7 +589,10 @@ def combine_saved_files(self, absolute_filepath, file_names, **kwargs):
# store population metadata
tmp_df = pd.DataFrame()
for c in saved_ini_parameters:
tmp_df[c] = [self.kwargs[c]]
if c == 'posydon_version':
tmp_df[c] = [posydon.__version__]
else:
tmp_df[c] = [self.kwargs[c]]
store.append('ini_parameters', tmp_df)

tmp_df = pd.DataFrame(
Expand Down Expand Up @@ -938,7 +943,10 @@ def save(self, fname, **kwargs):
# store population metadata
tmp_df = pd.DataFrame()
for c in saved_ini_parameters:
tmp_df[c] = [self.kwargs[c]]
if c == 'posydon_version':
tmp_df[c] = [posydon.__version__]
else:
tmp_df[c] = [self.kwargs[c]]
store.append('ini_parameters', tmp_df)

tmp_df = pd.DataFrame(
Expand Down
Loading
Loading