Skip to content
Merged
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
56 changes: 30 additions & 26 deletions cogsworth/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from copy import copy
from importlib.resources import files
import json


__all__ = ["kstar_translator", "evol_type_translator", "default_BSE_settings",
Expand Down Expand Up @@ -67,30 +66,34 @@
]


default_BSE_settings = {'xi': 1.0, 'bhflag': 1, 'neta': 0.5, 'windflag': 3, 'wdflag': 1, 'alpha1': 1.0,
'pts1': 0.001, 'pts3': 0.02, 'pts2': 0.01, 'epsnov': 0.001, 'hewind': 0.5,
'ck': 1000, 'bwind': 0.0, 'lambdaf': 0.0, 'mxns': 3.0, 'beta': -1.0, 'tflag': 1,
'acc2': 1.5, 'grflag': 1, 'remnantflag': 4, 'ceflag': 0, 'eddfac': 1.0,
'ifflag': 0, 'bconst': 3000, 'sigma': 265.0, 'gamma': -2.0, 'pisn': 45.0,
'natal_kick_array': [[-100.0, -100.0, -100.0, -100.0, 0.0],
[-100.0, -100.0, -100.0, -100.0, 0.0]], 'bhsigmafrac': 1.0,
'polar_kick_angle': 90, 'qcrit_array': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
'cekickflag': 2, 'cehestarflag': 0, 'cemergeflag': 0, 'ecsn': 2.25,
'ecsn_mlow': 1.6, 'aic': 1, 'ussn': 0, 'sigmadiv': -20.0, 'qcflag': 5,
'eddlimflag': 0, 'fprimc_array': [2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0,
2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0,
2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0,
2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0],
'bhspinflag': 0, 'bhspinmag': 0.0, 'rejuv_fac': 1.0, 'rejuvflag': 0, 'htpmb': 1,
'ST_cr': 1, 'ST_tide': 1, 'bdecayfac': 1, 'rembar_massloss': 0.5, 'kickflag': 5,
'zsun': 0.014, 'bhms_coll_flag': 0, 'don_lim': -1, 'acc_lim': -1, 'binfrac': 1.0,
'rtmsflag': 0, 'wd_mass_lim': 1, "maltsev_mode": 0, "maltsev_fallback": 0.5,
"maltsev_pf_prob": 0.1, "mm_mu_ns": 400.0, "mm_mu_bh": 200.0}


def get_default_BSE_settings():
return copy(default_BSE_settings)
"""Get a copy of the default BSE settings from the COSMIC settings JSON file"""
cosmic_settings = json.loads((files("cosmic") / "data" / "cosmic-settings.json").read_text())
defaults = {}
# loop through settings to find bse
for cat in cosmic_settings:
if cat["category"] != "bse":
continue

# go through each setting, finding the default option
for setting in cat["settings"]:
for option in setting["options"]:
if option.get("default", False):
defaults[setting["name"]] = option["name"]

# ensure array settings are converted from strings to lists
for setting in ["qcrit_array", "natal_kick_array", "fprimc_array"]:
# this one requires special handling because of the fractions
if setting == "fprimc_array":
parts = defaults[setting].strip("[]").split(",")
defaults[setting] = [float(p.split("/")[0]) / float(p.split("/")[1]) for p in parts]
else:
defaults[setting] = json.loads(defaults[setting])

# set binfrac default if not present
if "binfrac" not in defaults:
defaults["binfrac"] = 0.5
return defaults


def translate_COSMIC_tables(tab, kstars=True, evol_type=True, label_type="short", replace_columns=True):
Expand Down Expand Up @@ -151,5 +154,6 @@ def translate_COSMIC_tables(tab, kstars=True, evol_type=True, label_type="short"

def list_BSE_defaults(): # pragma: no cover
"""Print the default BSE settings cogsworth assumes for running COSMIC."""
default_BSE_settings = get_default_BSE_settings()
for k, v in default_BSE_settings.items():
print(f"{k}: {v}")
1 change: 1 addition & 0 deletions docs/modules/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This page tracks all of the changes that have been made to ``cogsworth``. We fol
3.6.1
=====
- Enhancement: Allow users to specify a directory for saving bad orbits when integrating populations by adding an `error_file_path` argument to the Population class. If set, bad orbits will be saved to this directory instead of the current working directory. If set to None, bad orbits will not be saved. This provides more flexibility in managing output files.
- Enhancement: Default BSE settings are drawn directly from the COSMIC cosmic-settings.json data file

3.6.0
=====
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ install_requires =
scipy >= 1.8
pandas >= 2.1
gala >= 1.11.0
cosmic-popsynth >= 3.6.1
requests
cosmic-popsynth >= 3.6.2

[options.package_data]
* = *.npy, *.npz
Expand Down