Skip to content

Unfreeze density or density_thermal as needed#292

Merged
bclyons12 merged 11 commits intomasterfrom
unfreeze_density
Mar 4, 2026
Merged

Unfreeze density or density_thermal as needed#292
bclyons12 merged 11 commits intomasterfrom
unfreeze_density

Conversation

@bclyons12
Copy link
Collaborator

Summary

  • Update enforce_quasi_neutrality! to set density or density_thermal as appropriate depending on whether density_fast is present, instead of blanket-unfreezing all density fields upfront
  • Raise an error when quasi-neutrality enforcement would result in negative ion thermal density
  • Add targeted unfreeze! calls in fast_particles_profiles!, bundle_DT!, new_impurity_fraction!, and scale_ion_densities_to_target_zeff! so that density expressions remain correct after density_thermal modifications

Test plan

  • Verify enforce_quasi_neutrality! correctly updates density vs density_thermal based on presence of density_fast
  • Confirm error is raised for negative density cases
  • Run existing IMAS test suite

🤖 Generated with Claude Code

- Sets `density` or `density_thermal` as appropriate
- Errors if ion density is negative
@nanshi1177
Copy link
Contributor

nanshi1177 commented Feb 21, 2026

image for any shot

@bclyons12
Copy link
Collaborator Author

@nanshi1177 Give that a try

Use `=` instead of `.=` to assign density_fast = 0, so that
setproperty! is called and IMAS actually stores the value.
The previous `.=` operated on a temporary returned by getproperty
and was silently discarded, leaving density_fast unstored and
causing a circular expression loop between density_fast and
density_thermal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nanshi1177
Copy link
Contributor

I think this is ready to merge.

@bclyons12
Copy link
Collaborator Author

Does it fix the problem in ProjectTorreyPines/FUSE.jl#1057 as well, or is that a separate issue?

@nanshi1177
Copy link
Contributor

Does it fix the problem in ProjectTorreyPines/FUSE.jl#1057 as well, or is that a separate issue?

I believe the QN issue has been solved. I have test several shots in reconstruction mode and it works well. However,PR#1057 isn't ready to merge yet. There is an additional fix in flux_matcher_actro.jl that I am concerned might cause issues in predictive mode. I am currently looking into this.

bclyons12 and others added 2 commits February 24, 2026 11:55
…imary field

- Reduce max_fast_frac from 0.9 to 0.8 to prevent fast ion pressure from
  destabilizing equilibrium/QED near axis
- Clamp density_thermal to non-negative in fast_particles_profiles!
- Account for fast ion charge in scale_ion_densities_to_target_zeff
- Use assignment (=) instead of in-place (.=) for ion.density_thermal in
  scale_ion_densities_to_target_zeff! so data is properly stored

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bclyons12 and others added 5 commits March 2, 2026 13:56
Then `max` no longer needed
- Add comment to explain

This reverts commit aaff6c3.
…nce into electrons instead of erroring

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bclyons12 bclyons12 merged commit d29e058 into master Mar 4, 2026
2 checks passed
@bclyons12 bclyons12 deleted the unfreeze_density branch March 4, 2026 20:15
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