Skip to content

fast_particles_profiles!: optional soft cap of the fast-ion density - #320

Open
StuartBenjamin wants to merge 3 commits into
ProjectTorreyPines:masterfrom
StuartBenjamin:fast_ion_soft_cap
Open

StuartBenjamin wants to merge 3 commits into
ProjectTorreyPines:masterfrom
StuartBenjamin:fast_ion_soft_cap

Conversation

@StuartBenjamin

@StuartBenjamin StuartBenjamin commented Oct 28, 2026 •

Copy link
Copy Markdown

Motivation: eliminate discontinuities in the density gradient, and thus bootstrap current -> bad for stability calculations

fast_particles_profiles! caps the fast-ion density at max_fast_frac × the thermal density with a hard min. Where the cap engages over part of the radius, the thermal density gets a slope break at each edge of that region, and the bootstrap current (∝ dp/dψ) jumps there.

A new keyword fast_density_knee (also on intrinsic_sources!) makes the cap soft: the density is unchanged below knee × the limit and saturates smoothly towards the limit above it. The default, 1.0, is today's hard clamp. FUSE sets it from act.ActorSources.fast_density_knee (ProjectTorreyPines/FUSE.jl#1203).

Derivation. With L the limit, x = n_fast / L and knee k < 1, the capped density is n_fast for x ≤ k and L·[k + (1 − k)·tanh((x − k)/(1 − k))] for x > k.

  • At x = k it equals k·L = n_fast (continuous), and its slope d/dn_fast = sech²(0) = 1 matches the unchanged branch (no slope break).
  • It rises monotonically and tends to L as x → ∞, so it never exceeds the limit.
  • k ≥ 1 gives min(n_fast, L), the existing clamp.

Diff: master...StuartBenjamin:IMAS.jl:fast_ion_soft_cap

🤖 Generated with Claude Code

StuartBenjamin and others added 2 commits October 13, 2026 21:47
…fast_density_knee; 1.0 is the hard clamp)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@nanshi1177 nanshi1177 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The tanh knee keeps the slope continuous at knee·limit and saturates at the limit, so a partially engaged cap no longer leaves a kink in the thermal density (and a jump in the bootstrap current). knee ≥ 1 keeps today's hard clamp.

While reviewing this I found a related issue in the same function. It's not introduced here, and I'll fix it in a separate PR once this one is merged, to avoid conflicts.

density_thermal is reset to the total ion density once, before the loop over sources. But at the end of each source, density_thermal is reduced by the fast density added so far. So for the second and later sources, limit = max_fast_frac .* cion.density_thermal is computed from the already-reduced thermal density, not from the total.

@nanshi1177
nanshi1177 requested a review from jmcclena November 6, 2026 02:58

This branch has not been deployed

No deployments
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.

3 participants