DSphModel#

jeanspy.model_jax.DSphModel

See methods and properties for individual lookup pages, or the alphabetical API dictionary to search all classes. The full class contract and existing member anchors are retained below.

class jeanspy.model_jax.DSphModel(submodels=None)[source]#

Bases: jeanspy.model_jax.Model

Spherical JAX Jeans model for LOS variance on fixed quadrature grids.

Compose a tracer whose density_2d/density_3d accept re_pc, a halo with enclosed_mass, and an anisotropy with consistent beta/f/kernel methods. Physical parameters are supplied explicitly on each call. NumPyro likelihoods and sampling are implemented separately in jeanspy.sampler_numpyro.

Notes

Inputs and units. Compose StellarModel, DMModel and AnisotropyModel; params supplies all physical scalars. R_pc is scalar or nonempty 1-D pc. solver is auto/kernel/abel; jit controls cached compilation. n_u/n_kernel set outer/kernel rules; n_r sets Abel grid; u_max sets radial extent; dm_mass_n_steps sets mass integration independently.

Returns and shape. Always a 1-D array of LOS variances in (km/s)^2, length one for scalar R_pc.

Validity. Finite R>0. Kernel auto selects constant/Osipkov-Merritt; general Baes uses Abel. The published preliminary accuracy envelope is not a universal error bound; refine each new domain.

Errors. Invalid shape/solver/options raise ValueError; invalid dynamic radii or physical values yield NaN.

Backend. JAX arrays on the configured CPU/GPU, with dtype set before import.

Differentiation. Physical parameters on the supported JAX mass/kernel paths; static quadrature and solver choices are not differentiated. Abel-grid boundaries and finite integration extent affect accuracy.

Examples. examples/docs_jax_spherical.py

Parameters:

submodels (Dict[str, jeanspy.model_jax.Model])

required_param_names: tuple[str, ...] = ('vmem_kms',)#
required_models: Mapping[str, type[jeanspy.model_jax.Model]] = {'AnisotropyModel': <class 'jeanspy.model_jax.AnisotropyModel'>, 'DMModel': <class 'jeanspy.model_jax.DMModel'>, 'StellarModel': <class 'jeanspy.model_jax.StellarModel'>}#
sigmalos2_kernel(R_pc, *, params, n_u=None, u_max=None, n_kernel=None, kernel_backend='jax', u_min_eps=1e-06, kernel_outer_transform='sqrtlog', dm_mass_method='auto', dm_mass_n_steps=None)[source]#

Kernel-based sigma_los^2(R) implementation.

With u=r/R, this computes

sigma_los^2(R) = 2 * int_1^infty du

[nu(uR)/Sigma(R)] [G M(uR)] K(u)/u.

kernel_outer_transform='sqrtlog' uses log(u)=x^2. Since K(u) ~ sqrt(u-1) at the lower endpoint, the transformed integrand is smooth in x. 'log' selects a uniform-log(u) grid.

The default sqrtlog grid is tuned to a maximum relative-error target of 1e-3 on the documented Plummer+NFW dSph stress benchmark. For more extended or otherwise tail-sensitive models, increase u_max before increasing n_u; then double n_u to verify convergence.

Notes

Inputs and units. Positive R_pc in pc, scalar or nonempty 1-D array; params contains physical scalars. n_u controls the outer rule on 1 <= u <= u_max; n_kernel controls numerical inner kernels where applicable. kernel_backend selects jax/scipy for constant anisotropy. dm_mass_n_steps controls numerical halo mass integration.

Returns and shape. Always a one-dimensional array of variances in (km/s)^2, length one for scalar input.

Parameters:
Return type:

jax.Array

sigmalos2_abel(R_pc, *, params, n_r=None, u_max=None, r_min_factor=0.5, dm_mass_method='auto', dm_mass_n_steps=None)[source]#

Compute sigma_los^2(R) via a 1D Jeans solve and two Abel transforms.

Notes

Inputs and units. Positive R_pc in pc, scalar or nonempty 1-D array; params contains physical scalars. n_r controls the logarithmic radial grid; r_min_factor sets its inner radius relative to min(R). u_max sets the outer radius relative to max(R), enlarged to cover the supplied halo/tracer/anisotropy scales. dm_mass_n_steps controls numerical halo mass integration. This route requires a finite grid extent; an explicit infinite r_t_pc produces nonfinite results.

Returns and shape. Always a one-dimensional array of variances in (km/s)^2, length one for scalar input.

Parameters:
Return type:

jax.Array

sigmalos2(R_pc, *, params, solver='auto', jit=None, n_u=None, n_r=None, n_kernel=None, u_max=None, kernel_backend='jax', u_min_eps=1e-06, kernel_outer_transform='sqrtlog', r_min_factor=0.5, dm_mass_method='auto', dm_mass_n_steps=None)[source]#

Compute sigma_los^2(R) via the requested solver.

solver may be 'abel', 'kernel', or 'auto'. When set to 'auto' the choice is made based on the anisotropy model: Baes –> Abel, constant/Osipkov-Merritt –> kernel (see benchmarks).

jit controls whether a cached jax.jit wrapper is used around the selected solver. None defaults to the cached JIT path.

R_pc must be a scalar or a nonempty 1-D array. Results are always 1-D (length one for a scalar). Only finite R_pc > 0 are supported; invalid elements return NaN in eager and JIT execution without contaminating other elements. R=0 needs a model-dependent central-limit solver.

dm_mass_method controls the dark-matter enclosed-mass solver and must be one of "auto", "analytic", or "numeric". The default "auto" follows the DM model’s autodiff-safe choice: analytic for NFW and numeric for Zhao. dm_mass_n_steps sets the numerical mass resolution independently of the outer Jeans grid. Analytic mass methods ignore this resolution.

For the kernel solver, the documented 1e-3 accuracy target applies to the sampled Plummer+NFW stress envelope described in the README. Outside that envelope, test convergence by increasing u_max first and then doubling n_u. The Abel solver has a separate radial-grid convergence control, n_r.

Notes

Inputs and units. Positive R_pc in pc, scalar or nonempty 1-D array; params contains physical scalars. Use the signature’s static numerical/solver options; n_u and n_kernel apply to the kernel route, n_r to the Abel grid, and dm_mass_n_steps to the mass integral. u_max controls the outer radial extent for both solvers.

Returns and shape. Always a one-dimensional array of variances in (km/s)^2, length one for scalar input.

Parameters:
Return type:

jax.Array

sampling_identity()#

Model configuration without the derived compilation cache.

submodels: Dict[str, jeanspy.model_jax.Model]#