Fix ADAS radiation: correct adas21 coefficients and line-radiation double count - #310
Fix ADAS radiation: correct adas21 coefficients and line-radiation double count#310nanshi1177 wants to merge 4 commits into
Conversation
nanshi1177
commented
Jul 22, 2026
- 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.
| # 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.