Skip to content

Fixes for 1D examples#553

Merged
bendudson merged 7 commits into
masterfrom
fix-1d-examples
Apr 24, 2026
Merged

Fixes for 1D examples#553
bendudson merged 7 commits into
masterfrom
fix-1d-examples

Conversation

@bendudson
Copy link
Copy Markdown
Collaborator

@bendudson bendudson commented Apr 23, 2026

Going through examples, to fix issue #547

  • tokamak-1D/extra/1D-hydrogen
  • tokamak-1D/extra/1D-neon
  • tokamak-1D/extra/1D-neon-source

Fix by merging in changes from 1D-threshold. The
neutral_parallel_diffusion diffusion mode is changed to "multispecies"
from the default "afn" so that neutral-neutral collisions
are included.
Just in case there are no collisions, limit the collision frequency
to a small non-zero value.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.54%. Comparing base (ce0ea3b) to head (44e652e).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
include/component.hxx 67.56% 11 Missing and 1 partial ⚠️
src/braginskii_collisions.cxx 75.00% 2 Missing ⚠️
src/neutral_parallel_diffusion.cxx 94.44% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #553      +/-   ##
==========================================
+ Coverage   47.29%   48.54%   +1.25%     
==========================================
  Files          96       96              
  Lines        9828     9842      +14     
  Branches     1428     1435       +7     
==========================================
+ Hits         4648     4778     +130     
+ Misses       4704     4574     -130     
- Partials      476      490      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

If species1 was charged and species2 was neutral then the
`ion_neutral` option was not used: These collisions were always
included. The `ion_neutral` option was used in neutral/charged
collisions.

This was caught by the new GuardedOptions system. Thanks Chris!
Updated so they run when restarted from 1D-hydrogen
Would have caught the issue with ion_neutral switch.
29.91
- log((Z1 * Z2 * (AA1 + AA2)) / (AA1 * Tlim2 + AA2 * Tlim1)
* sqrt(Nlim1 * SQ(Z1) / Tlim1 + Nlim2 * SQ(Z2) / Tlim2));
* sqrt((Nlim1 * SQ(Z1) / Tlim1) + (Nlim2 * SQ(Z2) / Tlim2)));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am hoping this change is just style preference and C++ doesn't do something bizarre to make these brackets necessary?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That is clang-tidy - it likes to make it obvious that * has precedence before + 🤷

} else {
// species1 charged, species2 neutral

if (!ion_neutral) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for spotting this. It could explain the difference we saw in the ReMKiT1D benchmark when adding neutrals!

@mikekryjak
Copy link
Copy Markdown
Collaborator

Thanks for this @bendudson. I've gone through your changes and I can see that there must have been an issue where nu was zero, but how did this happen? Surely braginskii_collisions has several collisions on by default, including the ion_neutral one which as you found was always on.

@bendudson
Copy link
Copy Markdown
Collaborator Author

Hey @mikekryjak ! The neutral_parallel_diffusion uses the "afn" collisions by default, which just include ionisation and charge exchange, not neutral-neutral collisions. The ion density went to zero at the target so the afn collision frequency went to zero. In the examples I've switched it to "multispecies" so that neutral-neutral collisions are also included.

@bendudson bendudson merged commit 8220ead into master Apr 24, 2026
6 checks passed
@bendudson bendudson deleted the fix-1d-examples branch April 24, 2026 17:42
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