Skip to content

Sampling bound dev#239

Open
Kevnroux wants to merge 3 commits into
devfrom
sampling_bound_dev
Open

Sampling bound dev#239
Kevnroux wants to merge 3 commits into
devfrom
sampling_bound_dev

Conversation

@Kevnroux

Copy link
Copy Markdown
Contributor

Summary

  • Add optional manual Monte Carlo radial sampling bounds for all dwarf profiles in mixed-dwarf generation (useManualSamplingBounds, bound1/bound2 in for_developers.lua, wired through NBodyCtx.samplingBounds into mixeddwarf).
  • When bounds are left at 0.0, keep profile-specific defaults; when set manually, recalculate each component’s mass as the enclosed mass within that bound.
  • Fix and enable the Einasto dwarf profile (density/potential, set_model_params for h/d, 99.9% mass sampling bound, enclosed-mass support) and document it in the README.
  • Fix first/second derivatives near the origin by switching to a forward stencil when r < 2h, so evaluations never probe negative radii.
  • Extend recalculate_comp_mass beyond NFW/Cored to Plummer, Hernquist, King, and Einasto; rename shared cutoff gamma storage to const_gamma_func.
  • Add plummer_einasto.lua to mixeddwarf_test, match Einasto’s KL radial window to the sampler, and fix failure counting (failed++ / test(s)).

Details

Manual sampling bounds

  • New Lua toggles in for_developers.lua:
    • useManualSamplingBounds
    • bound1 / bound2 (kpc; 0.0 means “use code defaults”)
  • Bounds are passed via NBodyCtx.samplingBounds and into predefinedModels.mixeddwarf{ samplingBounds = ... }.
  • Defaults:
    • Plummer / Hernquist: 50 * (rscale_l + rscale_d)
    • NFW / Cored: rcut + 15*rdecay if cutoff set, else 5*r200
    • King: tidal radius
    • Einasto: radius enclosing ~99.9% of the mass using the Wilson-Hilferty approximation
  • Manual bounds trigger enclosed-mass recalculation so particle masses stay consistent with the truncated sampling region.

Einasto

  • Replace the old/broken unused formulas with Retana-Montenegro et al. (2012)–style density and potential.
  • Store Einasto auxiliaries (n, h, d, const_gamma_func) on Dwarf.
  • Remove the “do not use” warning; call set_model_params if needed.
  • Add mixed-dwarf test coverage (plummer_einasto.lua) and KL bound helper for Einasto.

Numerical / mass recalculation

  • Update the near-origin first/second derivative stencils to a forward formula when r < 2h. This was needed for Einasto, which blows up if the centered stencil probes negative radii.
  • Enclosed mass can now be recomputed for additional profiles when the sampling bound changes (King via numerical dΨ/dr).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant