Skip to content

Fix ADAS radiation: correct adas21 coefficients and line-radiation double count - #310

Open
nanshi1177 wants to merge 4 commits into
masterfrom
fix-adas21-line-radiation
Open

Fix ADAS radiation: correct adas21 coefficients and line-radiation double count#310
nanshi1177 wants to merge 4 commits into
masterfrom
fix-adas21-line-radiation

Conversation

@nanshi1177

Copy link
Copy Markdown
Contributor
  • adas21: the 12th Chebyshev coefficient was a duplicate of the 11th for all 20 species; corrected to the proper values (~3% for C, ~6% for Ar).
  • line_radiation_source!: clear any pre-existing line_radiation source (e.g. a lumped qline from an ODS) before recomputing per-impurity contributions, so it is not double-counted.

…uble count

adas21: the 12th Chebyshev coefficient was a duplicate of the 11th for all 20 species; corrected to the proper values (~3% for C, ~6% for Ar). line_radiation_source!: clear any pre-existing line_radiation source (e.g. a lumped qline from an ODS) before recomputing per-impurity contributions, so it is not double-counted.
@nanshi1177
nanshi1177 requested a review from jmcclena July 22, 2026 20:41
Comment thread src/physics/radiation.jl Outdated
# from a previous call) would otherwise survive and be double-counted by `radiation_losses`
# / `total_power_inside`. `deleteat!(..., :line_radiation)` matches by identifier index, so it
# catches such sources regardless of their name.
deleteat!(dd.core_sources.source, :line_radiation)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello @nanshi1177 :)

I am not sure this is correct, since core_sources.source entries carry time-dependent profiles_1d, so deleting the whole source would wipe the time history in time dependent simulations, not just refresh the current slice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @omeneghini-pf , good point! Thanks for the reminder. I was only thinking about the single-time-slice case and didn't consider the time-dependent side. The problem with deleteat!(dd.core_sources.source, :line_radiation) is that it matches by index, and the lumped qline and the per-impurity line C/line Ar/… all share index 10. So on repeated calls (each time step), it doesn't just remove the stale qline, it also deletes the per-impurity sources, wiping their accumulated profiles_1d time-slice history.
So instead of deleting everything at index 10, I narrowed it to delete only the foreign line-radiation sources, those whose identifier.name is not one of the per-impurity names being (re)written this call.

Comment thread src/physics/fast.jl

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fast_particles_profiles! unconditionally folds density_fast into density_thermal and zeros it, then rebuilds from sources carrying ion.particles + fast_particles_energy (NBI/fusion). With no such source (e.g. an input.gacode/ODS whose fast ions are a precomputed profile), the rebuild loop does nothing, so the prescribed density_fast/pressure_fast is silently destroyed at init and on every flux-matcher iteration.

Add a guard that returns early when no source can rebuild fast ions. The check mirrors the rebuild-entry condition exactly, so it only skips the destructive fold in cases where the rebuild would be a no-op; when a
beam/fusion source is present, behavior is unchanged.

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.

2 participants