8000 Metisse integrate kb by katiebreivik · Pull Request #674 · COSMIC-PopSynth/COSMIC · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Metisse integrate kb #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
29c2eca
offner22 primary mass dependent binary fraction (#644)
MarkGM02 Jun 21, 2024
63ac010
Update utils.py (#648)
katiebreivik Jul 15, 2024
4b8f2f8
version bump and dropping below python3.9 (#653)
katiebreivik Aug 7, 2024
3f53b18
Update build_wheels_and_publish.yml
katiebreivik Aug 7, 2024
e266209
Update build_wheels_and_publish.yml
katiebreivik Aug 7, 2024
bd7a390
Update build_wheels_and_publish.yml
katiebreivik Aug 7, 2024
d8a0607
Update build_wheels_and_publish.yml (#654)
katiebreivik Aug 7, 2024
b3f73de
Update pyproject.toml (#655)
katiebreivik Aug 7, 2024
5346657
Version bump for pip (#656)
katiebreivik Aug 7, 2024
6d4ee55
Add power law sampling options for ``porb`` and ``q`` (#651)
TomWagg Aug 12, 2024
3658fed
New ``gamma`` option for circumbinary discs (#652)
TomWagg Aug 12, 2024
baf43f3
* Modifying the init file to include the commit hash. (#659)
elenagonzalez870 Aug 12, 2024
f1be205
Created maximum wall time option (#620)
xevra Aug 12, 2024
7ad5c1f
Add debugging setup, avoid NaNs from timestep issue (#647)
TomWagg Aug 12, 2024
4ef9012
allow a gamma of -3 in error_check (#661)
TomWagg Aug 13, 2024
e777cea
fixing wheel build for pypi, hopefully
katiebreivik Aug 16, 2024
593f427
tiny version bump (#665)
katiebreivik Aug 16, 2024
91088e0
Update build_wheels_and_publish.yml
katiebreivik Aug 16, 2024
83d94fe
Update build_wheels_and_publish.yml
katiebreivik Aug 16, 2024
2c8e97c
Update build_wheels_and_publish.yml
katiebreivik Aug 16, 2024
d5a2996
Update build_wheels_and_publish.yml (#666)
katiebreivik Aug 17, 2024
4d326fa
add meson to requirements
katiebreivik Aug 17, 2024
16f6e63
Fixing linux only wheel (#667)
katiebreivik Aug 17, 2024
1720f26
Pip fix (#669)
katiebreivik Aug 20, 2024
eaf3ed4
Update build_wheels_and_publish.yml
katiebreivik Aug 20, 2024
8c735ef
Update meson.build
katiebreivik Aug 20, 2024
45efdfb
build wheels and publish fix (#670)
katiebreivik Aug 20, 2024
1c46f70
add x_86 and arch compatibility for wheels (#671)
katiebreivik Aug 20, 2024
e8295be
Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows …
dependabot[bot] Sep 9, 2024
7f0f1ca
fix merge conflicts
katiebreivik Sep 11, 2024
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
67 changes: 29 additions & 38 deletions .github/workflows/build_wheels_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ env:
CIBW_BUILD: "cp39-* cp310-*"
CIBW_SKIP: "*-win32 *musllinux*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_BEFORE_BUILD: pip install numpy --config-settings=setup-args="-Dallow-noblas=true"
CIBW_BUILD_VERBOSITY: "1"
CIBW_ENVIRONMENT_MACOS: "FC=gfortran"

jobs:
build-wheels:
build-wheels-and-dist:
name: Build ${{ matrix.python-version }} wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.9, "3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -30,51 +33,39 @@ jobs:
with:
python-version: "3.10"

- name: Setup Mac
- name: link gfortran and hdf5
if: runner.os == 'macOS'
run: |
python -m pip install numpy h5py versioneer
sudo ln -s /opt/homebrew/bin/gfortran-12 /usr/local/bin/gfortran
brew reinstall hdf5

- name: Setup Linux
if: runner.os == 'Linux'
- name: Install numpy
run: |
python -m pip install numpy h5py versioneer

- name: Build wheels
python -m pip install --upgrade pip
python -m pip install numpy h5py versioneer

- name: Install dependencies
run: |
python -m pip install cibuildwheel==2.17.0 setuptools wheel build meson-python ninja meson

- name: Build source distribution (sdist)
run: |
python -m build --sdist --outdir dist

- name: Build wheels using cibuildwheel
run: |
sudo ln -s /opt/homebrew/bin/gfortran-11 /opt/homebrew/bin/gfortran || true
python -m pip install meson ninja build
meson setup build
meson compile -C build
python -m build --wheel --outdir wheelhouse
python -m cibuildwheel --output-dir dist

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build-source-dist:
name: Build source dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.10"

- name: Build dist
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine numpy build meson ninja
pip install .
python -m build
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.tar.gz
path: ./dist/*.tar.gz

- uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl

publish:
needs: [build-wheels, build-source-dist]
needs: [build-wheels-and-dist]
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -90,7 +81,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Download builds
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.7
with:
name: artifact
path: dist
Expand Down
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# ignore files without extensions
*
!/**/
!*.*

.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -102,3 +109,9 @@ ENV/

# mypy
.mypy_cache/

*.o
binary.in
binary.dat
*.h5
fort.99
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/debug/test",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}/debug",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "make",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
]
}
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [< F438 /span>
{
"label": "make",
"type": "shell",
"command": "make test",
"options": {
"cwd": "${workspaceFolder}/cosmic/src"
},
}
]
}
4 changes: 3 additions & 1 deletion bin/cosmic-pop
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def parse_commandline():
help="Number of binaries to try before checking for "
"convergence, it will check ever Nstep binaries until "
"it reach Niter binaries", type=int, default=10000)
parser.add_argument("--max-wall-time", type=int, default=3155760,
help="Maximum wall time (seconds) for sampling binaries")
parser.add_argument("--binary_state", nargs='+', type=int)
parser.add_argument("--sampling_method")
parser.add_argument("--primary_model", help="Chooses the initial primary mass function from: salpeter55, kroupa93, kroupa01", type=str)
Expand Down Expand Up @@ -288,7 +290,7 @@ if __name__ == '__main__':
log_file.write("You have specified both qmin and m2_min.\n")
log_file.write("COSMIC will use qmin={} to determine the secondary masses in the initial sample.\n".format(args.qmin))

while (Nstep < args.Niter) & (np.max(match) > convergence['match']):
while (Nstep < args.Niter) & (np.max(match) > convergence['match']) & ((time.time() - start_time) < args.max_wall_time):
# Set random seed such that each iteration gets a unique, determinable seed
rand_seed = seed_int + Nstep
np.random.seed(rand_seed)
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ See the discussed changes in our previous releases here: https://github.com/COSM
- Add `teff_1` and `teff_2` as variables that can be used to set `timestep_conditions`
- Add in `-1` option to turn off Magnetic Braking in htmb
- Added `central_bh` and `scale_with_central_bh` as options to the CMC sampler, in order to add central massive black holes to CMC initial conditions


## 3.4.11
- Added sampling options to ``independent`` sampler to allow for custom power law distributions for ``porb`` and ``q``
66 changes: 66 additions & 0 deletions debug/create_binary_in.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pandas as pd

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': 0,
'zsun': 0.014, 'bhms_coll_flag': 0, 'don_lim': -1, 'acc_lim': -1, 'binfrac': 0.5,
'rtmsflag': 0, 'wd_mass_lim': 1, 'idum': 100}


def create_binary_in(mass0, tphysf, tb, kstar, Z, ecc, BSE_settings):
"""Create a binary.in file based on the given parameters

This follows the format in cosmic/src/test_bse.f and changes there would need to be reflected here.
"""
with open('binary.in', 'w') as f:
f.write(f'{mass0[0]} {mass0[1]} {tphysf} {tb} {kstar[0]} {kstar[1]} {Z} {ecc}\n')

lines = [
['neta', 'bwind', 'hewind', 'alpha1', 'lambdaf', 'windflag', 'rtmsflag'],
['ceflag', 'tflag', 'ifflag', 'wdflag', 'bhflag', 'remnantflag', 'mxns', 'idum'],
['pts1', 'pts2', 'pts3'],
['sigma', 'beta', 'xi', 'acc2', 'epsnov', 'eddfac', 'gamma']
]

for line in lines:
f.write(' '.join([str(BSE_settings[key]) for key in line]) + '\n')


def convert_initC_row_to_binary_in(initC_file, bin_num):
"""Convert a row from an initC file to a binary.in file

Parameters
----------
initC_file : `str`
Path to the initC file
bin_num : `int`
The binary number to convert
"""
# get binary from initC
initC = pd.read_hdf(initC_file, key="initC")
r = initC.loc[bin_num]

# update BSE settings with those in the binary
BSE_settings['idum'] = r['randomseed'].astype(int)
for key in BSE_settings:
if key in r:
BSE_settings[key] = r[key]

# create binary.in file
create_binary_in([r['mass_1'], r['mass_2']], r['tphysf'], r['porb'],
[r['kstar_1'].astype(int), r['kstar_2'].astype(int)],
r['metallicity'], r['ecc'], BSE_settings)
6 changes: 6 additions & 0 deletions docs/inifile/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,11 @@ common envelope occurs regardless of the choices below:
``-2`` : assumes material is lost from the system as
if it is a wind from the secondary

``-3`` : assumes mass is lost through the outer Lagrangian point,
forming a circumbinary disk. See Zapartas+17 Eq. 9 and
Artymowicz & Lubow (1994).


``>0`` : assumes that the lost material takes away a
fraction *gamma* of the orbital angular momentum

Expand Down Expand Up @@ -1104,6 +1109,7 @@ common envelope occurs regardless of the choices below:
eddfac = 1.0

; gamma is the angular momentum factor for mass lost during Roche-lobe overflow
; gamma=-3: assumes mass is lost through the outer Lagrangian point, forming a circumbinary disk. See Zapartas+17 Eq. 9 and Artymowicz & Lubow (1994).
; gamma=-2: assumes material is lost from the system as if it is a wind from the secondary (for super-Eddington mass transfer rates)
; gamma=-1: assumes the lost material carries with is the specific angular momentum of the primary
; gamma>0: assumes that the lost material take away a fraction (gamma) of the orbital angular momentum
Expand Down
1 change: 1 addition & 0 deletions examples/CMC_Params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ bhspinmag = 0.0
eddfac = 1.0

; gamma is the angular momentum factor for mass lost during RLO
; gamma=-3: assumes mass is lost through the outer Lagrangian point, forming a circumbinary disk. See Zapartas+17 Eq. 9 and Artymowicz & Lubow (1994).
; gamma=-2: assumes material is lost from the system as if it is a wind from the secondary (for super-Eddington mass transfer rates)
; gamma=-1: assumes the lost material carries with is the specific angular momentum of the primary
; gamma>0: assumes that the lost material take away a fraction (gamma) of the orbital angular momentum
Expand Down
1 change: 1 addition & 0 deletions examples/Params.ini
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ grflag = 1
eddfac = 1.0

; gamma is the angular momentum factor for mass lost during RLO
; gamma=-3: assumes mass is lost through the outer Lagrangian point, forming a circumbinary disk. See Zapartas+17 Eq. 9 and Artymowicz & Lubow (1994).
; gamma=-2: assumes material is lost from the system as if it is a wind from the secondary (for super-Eddington mass transfer rates)
; gamma=-1: assumes the lost material carries with is the specific angular momentum of the primary
; gamma>0: assumes that the lost material take away a fraction (gamma) of the orbital angular momentum
Expand Down
38 changes: 18 additions & 20 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('cosmic',
'c',
'fortran',
version : '3.4.13',
version : '3.4.16',
default_options: ['warning_level=0', 'optimization=3'],
)

Expand All @@ -11,23 +11,21 @@ ff = meson.get_compiler('fortran')
f_args = ff.get_supported_arguments('-fPIC')
add_project_arguments(f_args, language: 'fortran')

py3 = import('python').find_installation()

py3 = import('python').find_installation(pure: false)

numpy_include_dir = run_command(py3, ['-c', 'import numpy; print(numpy.get_include())'], check: true).stdout().strip()
f2py_include_dir = run_command(py3, ['-c', 'import numpy.f2py; print(numpy.f2py.get_include())'], check: true).stdout().strip()
inc_np = include_directories(numpy_include_dir, f2py_include_dir)

f2py_source = custom_target(
'evolvebin-target',
input : ['src/cosmic/src/evolv2.f', 'src/cosmic/src/comprad.f'],
output : ['_evolvebinmodule.c', '_evolvebin-f2pywrappers.f'],
command : [py3, '-m', 'numpy.f2py', '@INPUT@', '-m', '_evolvebin', '--lower', '@OUTDIR']
)
get_hash = run_command('python', './src/cosmic/get_commit_hash.py', check: true).stdout().strip()


lib_source = [
'src/cosmic/src/hrdiag_remnant.f',
'src/cosmic/src/assign_remnant.f',
'src/cosmic/src/benchmarkevolv2.f',
'src/cosmic/src/int64.f',
'src/cosmic/src/corerd.f',
'src/cosmic/src/comenv.f',
'src/cosmic/src/dgcore.f',
Expand Down Expand Up @@ -79,26 +77,26 @@ else
ldflags = [] # No special flags for other systems
endif


f2py_source = custom_target(
'evolvebin-target',
input : ['src/cosmic/src/evolv2.f', 'src/cosmic/src/comprad.f'],
output : ['_evolvebinmodule.c', '_evolvebin-f2pywrappers.f'],
command : [py3, '-m', 'numpy.f2py', '@INPUT@', '-m', '_evolvebin', '--lower']
)


evolvebin_module = py3.extension_module('_evolvebin',
f2py_source,
lib_source,
f2py_include_dir / 'fortranobject.c',
include_directories: inc_np,
link_args: ldflags,
install : true,
install_dir : py3.get_install_dir() / 'cosmic'
subdir : 'cosmic'
)


module_dirs = ['src/cosmic', 'src/cosmic/bse_utils',
'src/cosmic/sample', 'src/cosmic/tests']

# Install modules
foreach mod_dir: module_dirs
install_subdir(mod_dir,
install_dir: py3.get_install_dir())
endforeach


python_script = 'bin/cosmic-pop'
install_data(python_script, install_dir: get_option('bindir'))

subdir('src/cosmic')
Loading
Loading
0