Skip to content

Instantly share code, notes, and snippets.

@aphearin
Created June 11, 2024 15:21
Show Gist options
  • Save aphearin/3b5e0f4b8524bec5ab49e6f6d62044f8 to your computer and use it in GitHub Desktop.
Save aphearin/3b5e0f4b8524bec5ab49e6f6d62044f8 to your computer and use it in GitHub Desktop.
Diffstar without a gas consumption timescale
"""
"""
from diffmah.defaults import MAH_K
from diffmah.individual_halo_assembly import _calc_halo_history_scalar
from jax import jit as jjit
from jax import nn
from jax import numpy as jnp
INDX_K = 9.0 # Main sequence efficiency transition speed
INDX_HI = -1.0
@jjit
def _sigmoid(x, x0, k, ymin, ymax):
height_diff = ymax - ymin
return ymin + height_diff * nn.sigmoid(k * (x - x0))
@jjit
def _sfr_eff_plaw(lgm, lgmcrit, lgy_at_mcrit, indx_lo):
slope = _sigmoid(lgm, lgmcrit, INDX_K, indx_lo, INDX_HI)
eff = lgy_at_mcrit + slope * (lgm - lgmcrit)
return 10**eff
@jjit
def _sfr_nolag_scalar_kern(t, mah_params, ms_params, lgt0, fb):
logmp, logtc, early, late = mah_params
all_mah_params = lgt0, logmp, logtc, MAH_K, early, late
lgt = jnp.log10(t)
res = _calc_halo_history_scalar(lgt, *all_mah_params)
dmhdt, log_mah = res
sfr_eff = _sfr_eff_plaw(log_mah, *ms_params)
dmgdt = fb * dmhdt
sfr = dmgdt * sfr_eff
return sfr
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment