Hosts
- class gwGenealogy.hosts.plummer.PlummerCluster(Mcl, r_h, cluster_type=None, epsilon=None, tau_gyr=None, rt_over_rh=None, ln_lambda=2.5)[source]
Bases:
objectPlummer sphere cluster model with merger retention analysis.
- Parameters:
Mcl (float) – Cluster mass [Msun]
r_h (float) – Half-mass radius [pc]
cluster_type (str, optional) – ‘GC’ or ‘NSC’. Sets epsilon, tau_gyr, rt_over_rh defaults.
epsilon (float, optional) – Repeat-merger efficiency. Overrides cluster_type default.
tau_gyr (float, optional) – Repeat-merger timescale [Gyr]. Overrides cluster_type default.
rt_over_rh (float, optional) – Tidal radius in units of r_h. Overrides cluster_type default.
ln_lambda (float) – Coulomb logarithm (default: 2.5)
- gwGenealogy.hosts.plummer.plummer_scale_radius(r_h)[source]
Convert half-mass radius to Plummer scale radius: a = r_h / 1.305.
- gwGenealogy.hosts.plummer.plummer_potential(r, Mcl, a)[source]
Plummer gravitational potential Phi(r).
- gwGenealogy.hosts.plummer.plummer_velocity_dispersion(r, Mcl, a)[source]
Isotropic 1-D velocity dispersion sigma(r) for a Plummer sphere.
- gwGenealogy.hosts.plummer.plummer_escape_speed(Mcl, a)[source]
Central escape speed v_esc = sqrt(2 G Mcl / a).
- gwGenealogy.hosts.plummer.plummer_tidal_radius(r_h, rt_over_rh=5.0)[source]
Tidal truncation radius r_t = rt_over_rh * r_h.
- gwGenealogy.hosts.plummer.plummer_apocentre(v_kick, v_esc, a)[source]
Radial-orbit apocentre r_max in a Plummer potential.
- gwGenealogy.hosts.plummer.chandrasekhar_F(X)[source]
Chandrasekhar velocity term F(X) = erf(X) - (2X/sqrt(pi)) exp(-X^2).
- gwGenealogy.hosts.plummer.orbit_shape_factor(u, n_xi=400)[source]
Dimensionless orbit-shape factor R(u) for a radial Plummer orbit.
- gwGenealogy.hosts.plummer.dynamical_friction_time(v_kick, v_esc, Mcl, a, M_bh, ln_lambda=2.5)[source]
Orbit-averaged Chandrasekhar dynamical-friction return time.
- Parameters:
v_kick (float or array) – Kick velocities of RETAINED remnants (v_kick < v_esc) [km/s]
v_esc (float) – Central escape speed [km/s]
Mcl (float) – Cluster mass [Msun]
a (float) – Plummer scale radius [pc]
M_bh (float or array (matching v_kick)) – Remnant BH mass(es) [Msun]
ln_lambda (float) – Coulomb logarithm (default: 2.5)
- Returns:
t_DF – Return time [Myr]
- Return type:
float or array
- gwGenealogy.hosts.plummer.retained_mask(v_kick, v_esc, a, r_t)[source]
Boolean mask: bound (v_kick < v_esc) AND apocentre within tidal radius.
- gwGenealogy.hosts.star_clusters.Mcl_rh_to_vescape(Mcl, r_h)[source]
Escape velocity from cluster mass and half-mass radius (virial theorem).
v_esc = 2 * sqrt(0.4 G M_cl / r_h)
- gwGenealogy.hosts.star_clusters.Mcl_rho_to_vescape(Mcl, rho)[source]
Escape velocity from cluster mass and half-mass density (scaling relation).
v_esc = 40 km/s * (M_tot / 1e5 Msun)^(1/3) * (rho / 1e5 Msun pc^-3)^(1/6)
- gwGenealogy.hosts.star_clusters.sample_star_clusters_mapelli2021(n_samples, cluster_type='GC', sigma_M=0.4, sigma_rho=0.4, seed=None)[source]
Sample star cluster properties following Mapelli et al. (2021) Sec 2.5.
- Parameters:
- Returns:
M_cluster : total mass [Msun] rho : half-mass density [Msun pc^-3] rho_c : core density = 20*rho [Msun pc^-3] v_esc : escape velocity [km/s] t_SC : cluster lifetime [Gyr] f_bin : binary fraction
- Return type:
- gwGenealogy.hosts.star_clusters.sample_star_clusters(n_samples, M_cluster_min=1000.0, M_cluster_max=100000000.0, r_h_min=0.1, r_h_max=100.0, Z_min=0.0001, Z_max=0.02, seed=None)[source]
Sample generic star cluster properties from log-uniform priors.
- Parameters:
n_samples (int) – Number of clusters to draw.
M_cluster_min (float) – Minimum cluster mass [Msun] (default: 1e3).
M_cluster_max (float) – Maximum cluster mass [Msun] (default: 1e8).
r_h_min (float) – Minimum half-mass radius [pc] (default: 0.1).
r_h_max (float) – Maximum half-mass radius [pc] (default: 100).
Z_min (float) – Minimum metallicity (default: 1e-4).
Z_max (float) – Maximum metallicity (default: 0.02).
seed (int or None) – Random seed.
- Returns:
M_cluster : cluster mass [Msun] r_h : half-mass radius [pc] Z : metallicity v_esc : escape velocity [km/s]
- Return type:
- gwGenealogy.hosts.host_retention.sample_escape_speed(n_samples, environment, seed=None)[source]
Draw escape velocity samples from an environment’s distribution.
- gwGenealogy.hosts.host_retention.sample_multi_escape_speed(n_samples, environments=None, seed=None)[source]
Draw escape velocity samples for multiple environments.
- gwGenealogy.hosts.host_retention.escape_speed_cdf(v, environment)[source]
CDF of the escape-speed distribution for a given environment.
- Parameters:
v (float or array) – Escape speed value(s) [km/s]
environment (dict) –
Environment specification with ‘kind’ key:
{'kind': 'lognormal', 'mu': float, 'sig': float}mu and sig are base-10 log mean and std dev (v_esc ~ 10^N(mu, sig)){'kind': 'uniform', 'vmin': float, 'vmax': float}{'kind': 'gaussian', 'mean': float, 'std': float}
- Returns:
cdf
- Return type:
float or array
- gwGenealogy.hosts.host_retention.compute_environment_retention(v_kick, environment)[source]
Per-kick retention probability for a given environment.
p_ret_i = 1 - CDF(v_kick_i)
- Parameters:
v_kick (array) – Kick velocity samples [km/s]
environment (dict) – Environment specification (see
escape_speed_cdf)
- Returns:
p_ret – Individual retention probability for each kick sample
- Return type:
numpy array
- gwGenealogy.hosts.host_retention.compute_multi_environment_retention(v_kick, environments=None)[source]
Per-kick retention probabilities across multiple environments.
- Parameters:
v_kick (array) – Kick velocity samples [km/s]
environments (dict of {name: environment_dict}, optional) – Defaults to all predefined environments (GC, NSC, EG, DG)
- Returns:
dict of {name
- Return type:
numpy array of p_ret}
- gwGenealogy.hosts.host_retention.retention_curve(v_kick, v_esc_array)[source]
Retention probability as a function of escape speed.
p_ret(v_esc) = P(v_kick < v_esc), the empirical CDF of kick samples evaluated on v_esc_array.
- Parameters:
v_kick (array) – Kick velocity samples [km/s]
v_esc_array (array) – Escape speed values at which to evaluate retention [km/s]
- Returns:
p_ret – Retention probability at each v_esc value
- Return type:
numpy array
- gwGenealogy.hosts.host_retention.compute_environment_cumulative_retention(v_kick, environment, method='kde', vmax=5000.0, ngrid=5000)[source]
Integrated retention fraction P_ret for a given environment.
P_ret = ∫ p_kick(v) [1 - CDF_esc(v)] dv
- Parameters:
v_kick (array) – Kick velocity samples [km/s]
environment (dict) – Environment specification (see
escape_speed_cdf)method (str) – ‘kde’ (default): fit a KDE to the kick samples and integrate analytically. More accurate for posterior/MCMC samples. ‘mc’: Monte Carlo mean (1/N) Σ p_ret_i. Exact when samples are iid draws from the kick distribution.
vmax (float) – Upper integration limit for KDE method [km/s] (default: 5000).
ngrid (int) – Number of grid points for KDE integration (default: 5000).
- Returns:
P_ret – Integrated retention fraction
- Return type:
- gwGenealogy.hosts.host_retention.compute_multi_environment_cumulative_retention(v_kick, environments=None, method='kde', **kwargs)[source]
Integrated retention fraction P_ret across multiple environments.
- Parameters:
v_kick (array) – Kick velocity samples [km/s]
environments (dict of {name: environment_dict}, optional) – Defaults to all predefined environments.
method (str) – ‘kde’ (default) or ‘mc’. See
compute_environment_cumulative_retention.**kwargs – Additional keyword arguments passed to
compute_environment_cumulative_retention(vmax, ngrid).
- Returns:
dict of {name
- Return type:
P_ret}