Skip to content
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

Dev evolving #114

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
39 changes: 26 additions & 13 deletions holodeck/host_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ def __init__(
self._mplaw = mplaw #: Mass Power-law index
self._mref = mref #: Reference Mass (argument normalization)
self._scatter_dex = scatter_dex
self._zplaw_amp = 0.0 #: Mass-Amplitude evolution parameter (0 for no evolution)
self._zplaw_slope = 0.0 #: Mass Power-law index (0 for no evolution)

if len(kwargs) > 0:
warn = f"Unused parameters passed to {self}! {kwargs=}"
Expand Down Expand Up @@ -803,8 +805,11 @@ class MMBulge_Redshift(MMBulge_Standard):
"""Mbh-Mbulge relation with an additional redshift power-law dependence.

Provides black hole mass as a function of galaxy bulge mass and redshift with a normalization
that depends on redshift. ``zplaw=0`` (default) is identical to MMBulge_Standard.
``mamp = mamp0 * (1 + z)**zplaw``.
that depends on redshift. ``zplaw_amp=0``, ``zplaw_slope=0`` (default) is identical to MMBulge_Standard.
``mamp = mamp0 * (1 + z)**zplaw_amp``.
``mplaw = mplaw0 * (1 + z)**zplaw_slope``.
Amplitude evolution can be positive, negative, or zero.
Slope evolution can be positive or zero only for the time being.

TODO: make sure all of the inherited methods from `MMBulge_Standard` are appropriate for
redshift dependencies!! In particular, check `dmstar_dmbh`
Expand All @@ -817,17 +822,21 @@ class MMBulge_Redshift(MMBulge_Standard):
MASS_PLAW = 1.0
MASS_REF = 1.0e11 * MSOL
SCATTER_DEX = 0.0
Z_PLAW = 0.0
Z_PLAW_AMP = 0.0
Z_PLAW_SLOPE = 0.0

_PROPERTIES = ['mbulge', 'redz']

def __init__(self, *args, zplaw=None, **kwargs):
def __init__(self, *args, zplaw_amp=None, zplaw_slope=None, **kwargs):
super().__init__(*args, **kwargs)

if zplaw is None:
zplaw = self.Z_PLAW
if zplaw_amp is None:
zplaw_amp = self.Z_PLAW_AMP
if zplaw_slope is None:
zplaw_slope = self.Z_PLAW_SLOPE

self._zplaw = zplaw
self._zplaw_amp = zplaw_amp
self._zplaw_slope = zplaw_slope
return

def mbh_from_host(self, pop, scatter):
Expand All @@ -844,14 +853,16 @@ def mbh_from_mbulge(self, mbulge, redz, scatter):
redz = np.broadcast_to(redz, mbulge.T.shape).T
except:
redz = redz
zmamp = self._mamp * (1.0 + redz)**self._zplaw
mbh = _log10_relation(mbulge, zmamp, self._mplaw, scatter_dex, x0=self._mref)
zmamp = self._mamp * (1.0 + redz)**self._zplaw_amp
zmplaw = self._mplaw * (1.0 + redz)**self._zplaw_slope
mbh = _log10_relation(mbulge, zmamp, zmplaw, scatter_dex, x0=self._mref)
return mbh

def mbulge_from_mbh(self, mbh, redz, scatter):
scatter_dex = self._scatter_dex if scatter else None
zmamp = self._mamp * (1.0 + redz)**self._zplaw
mbulge = _log10_relation_reverse(mbh, zmamp, self._mplaw, scatter_dex, x0=self._mref)
zmamp = self._mamp * (1.0 + redz)**self._zplaw_amp
zmplaw = self._mplaw * (1.0 + redz)**self._zplaw_slope
mbulge = _log10_relation_reverse(mbh, zmamp, zmplaw, scatter_dex, x0=self._mref)
return mbulge


Expand All @@ -867,7 +878,8 @@ class MMBulge_Redshift_MM2013(MMBulge_Redshift):
MASS_REF = MSOL * 1e11 # 1e11 Msol
MASS_PLAW = 1.05 # 1.05 ± 0.11
SCATTER_DEX = 0.34
Z_PLAW = 0.0
Z_PLAW_AMP = 0.0
Z_PLAW_SLOPE = 0.0


class MMBulge_Redshift_KH2013(MMBulge_Redshift):
Expand All @@ -882,7 +894,8 @@ class MMBulge_Redshift_KH2013(MMBulge_Redshift):
MASS_REF = MSOL * 1e11 # 1e11 Msol
MASS_PLAW = 1.17 # 1.17 ± 0.08
SCATTER_DEX = 0.28
Z_PLAW = 0.0
Z_PLAW_AMP = 0.0
Z_PLAW_SLOPE = 0.0


def get_mmbulge_relation(mmbulge: Union[_MMBulge_Relation, Type[_MMBulge_Relation]] = None) -> _MMBulge_Relation:
Expand Down
4 changes: 2 additions & 2 deletions holodeck/sams/sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def static_binary_density(self):
# so far we have ``dn_gal / [dlog10(M_gal) dq_gal dz]``

# dn / [dM dq dz] = (dn_gal / [dM_gal dq_gal dz]) * (dM_gal/dM_bh) * (dq_gal / dq_bh)
mplaw = self._mmbulge._mplaw
mplaw = self._mmbulge._mplaw * (1.0 + redz)**self._mmbulge._zplaw_slope
dqbh_dqgal = mplaw * np.power(mstar_rat, mplaw - 1.0)
# (dMstar-pri / dMbh-pri) * (dMbh-pri/dMbh-tot) = (dMstar-pri / dMstar-tot) * (dMstar-tot/dMbh-tot)
# ==> (dMstar-tot/dMbh-tot) = (dMstar-pri / dMbh-pri) * (dMbh-pri/dMbh-tot) / (dMstar-pri / dMstar-tot)
Expand Down Expand Up @@ -1086,7 +1086,7 @@ def _ndens_mbh(self, mass_gal, mrat_gal, redz):
# this is d^3 n / [dlog10(M_gal-pri) dq_gal dz]
nd_gal = self._ndens_gal(mass_gal, mrat_gal, redz)

mplaw = self._mmbulge._mplaw
mplaw = self._mmbulge._mplaw * (1.0 + redz)**self._mmbulge._zplaw_slope
dqbh_dqgal = mplaw * np.power(mrat_gal, mplaw - 1.0)

dmstar_dmbh__pri = self._mmbulge.dmstar_dmbh(mass_gal) # [unitless]
Expand Down
Loading