Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2c0b046
docs updates for v3.3 (#414)
Jun 23, 2020
f4c28fb
Final doc tweaks! (#415)
scottcoughlin2014 Jun 23, 2020
71167c4
Merge remote-tracking branch 'upstream/develop' into cosmic-cmc-exten…
scottcoughlin2014 Jul 1, 2020
d1e5199
New stuff
scottcoughlin2014 Jul 1, 2020
320c2e3
Merge branch 'cosmic-cmc-extensions' of https://github.com/nweatherfo…
scottcoughlin2014 Jul 10, 2020
89aa899
The full skeleton is not working
scottcoughlin2014 Jul 10, 2020
2c5f78d
Fixing docs plots (#417)
Jul 14, 2020
6cd4d3d
Timestep conditions hotfix (#416)
Jul 14, 2020
9fd45cb
fixing dtp filter for bcm array
chiragchawla134 Jul 20, 2020
41ce03b
Merge pull request #418 from chiragchawla134/develop
Jul 20, 2020
e746dd4
Merge remote-tracking branch 'upstream/develop' into cosmic-cmc-exten…
scottcoughlin2014 Jul 24, 2020
c1795e3
added the Elson
carlrodriguez Jul 24, 2020
6b77386
Alright I have disentagled all CMC sampling from the rest of the COSM…
scottcoughlin2014 Jul 24, 2020
0ef1663
Merge branch 'cosmic-cmc-extensions' of https://github.com/scottcough…
scottcoughlin2014 Jul 24, 2020
5e4b2ba
Current state of code
scottcoughlin2014 Jul 24, 2020
628008c
Alright the singles table is ready to go
scottcoughlin2014 Jul 25, 2020
0c33ba5
Alright, we can make the Singles and Binaries table for CMC from cosmic
scottcoughlin2014 Jul 31, 2020
c82cf86
One quick commit
scottcoughlin2014 Aug 5, 2020
5c8d4b8
This reduces overhead when setting R, still need to reduce overhead more
scottcoughlin2014 Aug 6, 2020
868aac9
Sped up setting the radius a lot, but carl wants to see if there is m…
scottcoughlin2014 Aug 6, 2020
9c09a98
This now runs quite a lot faster
scottcoughlin2014 Aug 9, 2020
5e13e10
Alright all we need now is the normalization function from carl
scottcoughlin2014 Aug 9, 2020
9a0dc9a
added scale and normalize functions and fixed binind
carlrodriguez Aug 11, 2020
01f7517
fixed bininds
carlrodriguez Aug 13, 2020
170e806
fixing mass binaries
carlrodriguez Aug 14, 2020
1a436c7
CMC takes separation not orbital period...
scottcoughlin2014 Aug 23, 2020
2533e82
Adding a new CMC section to Params.ini
scottcoughlin2014 Aug 23, 2020
96208dd
Alright I now added some attributes and a write method to help make c…
scottcoughlin2014 Aug 25, 2020
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
2 changes: 1 addition & 1 deletion bin/cosmic-pop
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ if __name__ == '__main__':

# If dtp is not set, filter out first timestep in bcm
if np.all(dtp == IBT['tphysf'].values):
bcm = bcm.loc[bcm['tphys'] == dtp[0]]
bcm = bcm.loc[bcm['tphys'].isin(dtp)]

bcm_filter, bin_state_nums = utils.filter_bpp_bcm(bcm, bpp, filters, kstar1_range, kstar2_range)
if bcm_filter.empty:
Expand Down
14 changes: 13 additions & 1 deletion cosmic/checkstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy

CHECKSTATE_COLUMNS = numpy.array(['binstate', 'evol_type', 'mass_1', 'mass_2', 'kstar_1', 'kstar_2' ,
'sep', 'porb', 'ecc', 'rrol_1', 'rrol_2',
'sep', 'porb', 'ecc', 'rrlo_1', 'rrlo_2',
'aj_1', 'aj_2', 'tms_1', 'tms_2',
'massc_1', 'massc_2', 'rad_1', 'rad_2',
'mass0_1', 'mass0_2', 'lum_1', 'lum_2',
Expand Down Expand Up @@ -33,11 +33,22 @@ def set_checkstates(timestep_conditions=[]):
The last condition would end time resolution for the BCM array and it
would skip to only printing the final state
"""
# assume that we are not doing any special dtp setting
_evolvebin.checkstate_array.check_dtp = 0

# Set the default state for checkstate which is that there are no
# conditional states at which to set a special dtp
checkstate_array = getattr(_evolvebin.checkstate_array, 'checkstate_array')
checkstate_array[:,:] = DEFAULT_CONDITIONS

# Again we assume that no condtions exist to set a special dtp
dtp_state = getattr(_evolvebin.checkstate_params, 'dtp_state')
dtp_state[:] = DEFAULT_DTP_STATE


for index, condition in enumerate(timestep_conditions):
# we are checking for conditions
_evolvebin.checkstate_array.check_dtp = 1
conditions = parse_column_filters(condition)
for param in conditions:
# find where in the checkstate_array this param is
Expand All @@ -49,6 +60,7 @@ def set_checkstates(timestep_conditions=[]):
else:
dtp_state[index] = param[2]
continue

if param[1] == operator.eq:
checkstate_array[index, param_index*3] = param[2]
checkstate_array[index, param_index*3 +2] = param[2]
Expand Down
106 changes: 55 additions & 51 deletions cosmic/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
'ecsn', 'ecsn_mlow', 'aic', 'ussn', 'sigma', 'sigmadiv', 'bhsigmafrac', 'polar_kick_angle',
'natal_kick_array', 'qcrit_array',
'beta', 'xi', 'acc2', 'epsnov',
'eddfac', 'gamma', 'bdecayfac', 'bconst', 'ck',
'eddfac', 'gamma', 'bdecayfac', 'bconst', 'ck',
'windflag', 'qcflag', 'eddlimflag',
'fprimc_array', 'dtp', 'randomseed',
'bhspinflag','bhspinmag', 'rejuv_fac', 'rejuvflag', 'htpmb',
Expand Down Expand Up @@ -177,7 +177,7 @@ def evolve(cls, initialbinarytable, **kwargs):
is total evolution time in Myr

n_per_block : `int`, optional, default: -1
number of systems to evolve in a block with
number of systems to evolve in a block with
_evolve_multi_system, to allow larger multiprocessing
queues and reduced overhead. If less than 1 use _evolve_single_system

Expand Down Expand Up @@ -377,29 +377,30 @@ def _evolve_single_system(f):
_evolvebin.snvars.kickflag = f['kickflag']
_evolvebin.cmcpass.using_cmc = 0

[bpp, bcm, bpp_index, bcm_index, kick_info] = _evolvebin.evolv2([f['kstar_1'], f['kstar_2']],
[f['mass_1'], f['mass_2']],
f['porb'], f['ecc'], f['metallicity'], f['tphysf'], f['dtp'],
[f['mass0_1'], f['mass0_2']],
[f['rad_1'], f['rad_2']],
[f['lum_1'], f['lum_2']],
[f['massc_1'], f['massc_2']],
[f['radc_1'], f['radc_2']],
[f['menv_1'], f['menv_2']],
[f['renv_1'], f['renv_2']],
[f['omega_spin_1'], f['omega_spin_2']],
[f['B_1'], f['B_2']],
[f['bacc_1'], f['bacc_2']],
[f['tacc_1'], f['tacc_2']],
[f['epoch_1'], f['epoch_2']],
[f['tms_1'], f['tms_2']],
[f['bhspin_1'], f['bhspin_2']],
f['tphys'],
np.zeros(20),
f['kick_info'])

bcm = bcm[:bcm_index]
bpp = bpp[:bpp_index]
[bpp_index, bcm_index, kick_info] = _evolvebin.evolv2([f['kstar_1'], f['kstar_2']],
[f['mass_1'], f['mass_2']],
f['porb'], f['ecc'], f['metallicity'], f['tphysf'], f['dtp'],
[f['mass0_1'], f['mass0_2']],
[f['rad_1'], f['rad_2']],
[f['lum_1'], f['lum_2']],
[f['massc_1'], f['massc_2']],
[f['radc_1'], f['radc_2']],
[f['menv_1'], f['menv_2']],
[f['renv_1'], f['renv_2']],
[f['omega_spin_1'], f['omega_spin_2']],
[f['B_1'], f['B_2']],
[f['bacc_1'], f['bacc_2']],
[f['tacc_1'], f['tacc_2']],
[f['epoch_1'], f['epoch_2']],
[f['tms_1'], f['tms_2']],
[f['bhspin_1'], f['bhspin_2']],
f['tphys'],
np.zeros(20),
f['kick_info'])
bcm = _evolvebin.binary.bcm[:bcm_index].copy()
bpp = _evolvebin.binary.bpp[:bpp_index].copy()
_evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape)
_evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape)

bpp = np.hstack((bpp, np.ones((bpp.shape[0], 1))*f['bin_num']))
bcm = np.hstack((bcm, np.ones((bcm.shape[0], 1))*f['bin_num']))
Expand All @@ -410,7 +411,7 @@ def _evolve_single_system(f):
except Exception as e:
raise

#define multiprocessing method to process the systems in batches
#define multiprocessing method to process the systems in batches
def _evolve_multi_system(f):
try:
res_bcm = np.zeros(f.shape[0],dtype=object)
Expand Down Expand Up @@ -477,37 +478,40 @@ def _evolve_multi_system(f):
_evolvebin.snvars.kickflag = f[i]['kickflag']
_evolvebin.cmcpass.using_cmc = 0

[bpp, bcm, bpp_index, bcm_index, kick_info_out] = _evolvebin.evolv2([f[i]['kstar_1'], f[i]['kstar_2']],
[f[i]['mass_1'], f[i]['mass_2']],
f[i]['porb'], f[i]['ecc'], f[i]['metallicity'], f[i]['tphysf'], f[i]['dtp'],
[f[i]['mass0_1'], f[i]['mass0_2']],
[f[i]['rad_1'], f[i]['rad_2']],
[f[i]['lum_1'], f[i]['lum_2']],
[f[i]['massc_1'], f[i]['massc_2']],
[f[i]['radc_1'], f[i]['radc_2']],
[f[i]['menv_1'], f[i]['menv_2']],
[f[i]['renv_1'], f[i]['renv_2']],
[f[i]['omega_spin_1'], f[i]['omega_spin_2']],
[f[i]['B_1'], f[i]['B_2']],
[f[i]['bacc_1'], f[i]['bacc_2']],
[f[i]['tacc_1'], f[i]['tacc_2']],
[f[i]['epoch_1'], f[i]['epoch_2']],
[f[i]['tms_1'], f[i]['tms_2']],
[f[i]['bhspin_1'], f[i]['bhspin_2']],
f[i]['tphys'],
np.zeros(20),
f[i]['kick_info'])

bpp = bpp[:bpp_index]
bcm = bcm[:bcm_index]

[bpp_index, bcm_index, kick_info] = _evolvebin.evolv2([f[i]['kstar_1'], f[i]['kstar_2']],
[f[i]['mass_1'], f[i]['mass_2']],
f[i]['porb'], f[i]['ecc'], f[i]['metallicity'], f[i]['tphysf'], f[i]['dtp'],
[f[i]['mass0_1'], f[i]['mass0_2']],
[f[i]['rad_1'], f[i]['rad_2']],
[f[i]['lum_1'], f[i]['lum_2']],
[f[i]['massc_1'], f[i]['massc_2']],
[f[i]['radc_1'], f[i]['radc_2']],
[f[i]['menv_1'], f[i]['menv_2']],
[f[i]['renv_1'], f[i]['renv_2']],
[f[i]['omega_spin_1'], f[i]['omega_spin_2']],
[f[i]['B_1'], f[i]['B_2']],
[f[i]['bacc_1'], f[i]['bacc_2']],
[f[i]['tacc_1'], f[i]['tacc_2']],
[f[i]['epoch_1'], f[i]['epoch_2']],
[f[i]['tms_1'], f[i]['tms_2']],
[f[i]['bhspin_1'], f[i]['bhspin_2']],
f[i]['tphys'],
np.zeros(20),
f[i]['kick_info'])

bcm = _evolvebin.binary.bcm[:bcm_index].copy()
bpp = _evolvebin.binary.bpp[:bpp_index].copy()
_evolvebin.binary.bpp[:bpp_index] = np.zeros(bpp.shape)
_evolvebin.binary.bcm[:bcm_index] = np.zeros(bcm.shape)

bpp_bin_numbers = np.atleast_2d(np.array([f[i]['bin_num']] * len(bpp))).T
bcm_bin_numbers = np.atleast_2d(np.array([f[i]['bin_num']] * len(bcm))).T
kick_info_out_bin_numbers = np.atleast_2d(np.array([f[i]['bin_num']] * len(kick_info_out))).T
kick_info_bin_numbers = np.atleast_2d(np.array([f[i]['bin_num']] * len(kick_info))).T

res_bpp[i] = np.hstack((bpp, bpp_bin_numbers))
res_bcm[i] = np.hstack((bcm, bcm_bin_numbers))
res_kick_info[i] = np.hstack((kick_info_out, kick_info_out_bin_numbers))
res_kick_info[i] = np.hstack((kick_info, kick_info_bin_numbers))
res_natal_kick_array[i] = _evolvebin.snvars.natal_kick_array

return f, np.vstack(res_bpp), np.vstack(res_bcm), np.vstack(res_kick_info), np.vstack(res_natal_kick_array)
Expand Down
1 change: 1 addition & 0 deletions cosmic/sample/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# load tables
from astropy.table import (Column, Table)
from .initialbinarytable import InitialBinaryTable
from .initialcmctable import InitialCMCTable

# attach unified I/O
from . import sampler
18 changes: 18 additions & 0 deletions cosmic/sample/cmc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) Carl Rodriguez (2017 - 2020)
#
# This file is part of COSMIC
#
# COSMIC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# COSMIC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with COSMIC. If not, see <http://www.gnu.org/licenses/>
Loading