King

cosmic.sample.cmc.king.calc_rho(w)[source]

Returns the density (unnormalized) given w = psi/sigma^2 Note that w(0) = w_0, the main parameter of a King profile

cosmic.sample.cmc.king.draw_r_vr_vt(N=100000, w_0=6, tidal_boundary=1e-06)[source]

Draw random velocities and positions from the King profile.

N = number of stars w_0 = King concentration parameter (-psi/sigma^2) tidal_boundary = ratio of rho/rho_0 where we truncate the tidal boundary

returns (vr,vt,r) in G=M_cluster=1 units

cosmic.sample.cmc.king.find_sigma_sqr(r_sample, r, rho_r, M_enclosed)[source]

Find the 1D velocity dispersion at a given radius r using one of the spherial Jeans equations (and assuming velocity is isotropic)

cosmic.sample.cmc.king.get_positions(N, r, M_enclosed)[source]

This one’s easy: the mass enclosed function is just the CDF of the mass density, so just invert that, and you’ve got positions.

Note that here we’ve already normalized M_enclosed to 1 at r_tidal

cosmic.sample.cmc.king.get_velocities(r, r_profile, psi_profile, M_enclosed_profile)[source]

The correct way to generate velocities: start from the distribution function and use rejection sampling.

returns (vr,vt) with same length as r

cosmic.sample.cmc.king.integrate_king_profile(w0, tidal_boundary=1e-06)[source]

Integrate a King Profile of a given w_0 until the density (or phi/sigma^2) drops below tidal_boundary limit (1e-8 times the central density by default)

Let’s define some things: The King potential is often expressed in terms of w = psi / sigma^2 (psi is phi0 - phi, so just positive potential) (note that sigma is the central velocity dispersion with an infinitely deep potential, and close otherwise)

in the center, w_0 = psi_0 / sigma^2 (the free parameter of the King profile)

The core radius is defined (King 1966) as r_c = sqrt(9 * sigma^2 / (4 pi G rho_0))

If we define new scaled quantities

r_tilda = r/r_c rho_tilda = rho/rho_o

We can rewrite Poisson’s equation, (1/r^2) d/dr (r^2 dphi/dr) = 4 pi G rho as:

d^2(r_tilda w)/dr_tilda^2 = 9 r_tilda rho_tilda

After that, all we need is initial conditions: w(0) = w_0 w’(0) = 0

returns (radii, rho, phi, M_enclosed)

cosmic.sample.cmc.king.scale_pos_and_vel(r, vr, vt)[source]

Scale the positions and velocities to be in N-body units If we add binaries we’ll do this again in initialcmctable.py

takes r, vr, and vt as input

returns (r,vr,vt) scaled to Henon units

cosmic.sample.cmc.king.virial_radius_numerical(r, rho_r, M_enclosed)[source]

Virial radius is best calculated directly. Directly integrate 4*pi*r*rho*m_enclosed over the samples binding energy, then just divide 0.5 by that.