Sampling (sample)

The sample module contains the main functions for sampling binary systems.

Initial binary tables

InitialBinaryTable

Classes

InitialCMCTable

Classes

InitialCMCTable([data, index, columns, ...])

Independent sampler

independent

Functions

get_independent_sampler(final_kstar1, ...[, ...])

Generates an initial binary sample according to user specified models

Classes

Sample()

Multidimensional sampler

multidim

Functions

get_multidim_sampler(final_kstar1, ...)

adapted version of Maxwell Moe's IDL code that generates a population of single and binary stars

Classes

CMC related functions

cmc

Functions

get_cmc_sampler(cluster_profile, ...)

Generates an initial cluster sample according to user specified models

Classes

Elson

Functions

M_enclosed(r, gamma, rho_0)

Compute the mass enclosed in an Elson profile at radius r with slope gamma, central concentration rho_0, and assumed scale factor a = 1

phi_r(r, gamma, rho_0)

Compute the gravitational potential of an Elson profile at radius r with slope gamma, central concentration rho_0, and assumed scale factor a = 1

rho_r(r, gamma, rho_0)

Compute the density of the Elson profile at radius r Best to use the same normalized rho_0 from M_enclosed

virial_radius_analytic(gamma, r_max)

Virial radius is best calculated directly, since rmax may be pretty far from infinity.

find_rmax_vir(r_max, gamma)

This is a little tricky: because the virial radius of the Elson profile depends on the maximum radius, if the profile is very flat (e.g. gamma~2) then you need a large maximum radius to get a large number of virial radius in there.

find_sigma_sqr(r, r_max_cluster, gamma)

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

get_positions(N, r_max_cluster, gamma)

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.

get_velocities(r, r_max_cluster, gamma)

The correct way to generate velocities: generate the distribution function from rho, then use rejection sampling.

get_velocities_plummer(r, r_max_cluster)

The correct way to generate velocities

get_velocities_old(r, r_max_cluster, gamma)

Uses the spherical Jeans functions to sample the velocity dispersion for the cluster at different radii, then draws a random, isotropic velocity for each star

scale_pos_and_vel(r, vr, vt)

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

draw_r_vr_vt([N, r_max, gamma])

Draw random velocities and positions from the Elson profile.

King

Functions

calc_rho(w)

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

integrate_king_profile(w0[, tidal_boundary])

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)

virial_radius_numerical(r, rho_r, M_enclosed)

Virial radius is best calculated directly.

find_sigma_sqr(r_sample, r, rho_r, M_enclosed)

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

get_positions(N, r, M_enclosed)

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.

get_velocities(r, r_profile, psi_profile, ...)

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

scale_pos_and_vel(r, vr, vt)

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

draw_r_vr_vt([N, w_0, tidal_boundary])

Draw random velocities and positions from the King profile.