Skip to content

Comments

Fix MHD hyperbolic cleaning using wrong sign for left fast magnetosonic speed#1180

Open
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix/mhd-cleaning-speed
Open

Fix MHD hyperbolic cleaning using wrong sign for left fast magnetosonic speed#1180
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix/mhd-cleaning-speed

Conversation

@sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Feb 21, 2026

Summary

Severity: HIGH — wrong wave speed estimate corrupts MHD flux computation.

File: src/simulation/m_riemann_solvers.fpp, lines 655-657

The hyperbolic divergence cleaning should ensure that the fast magnetosonic speed is at least the cleaning speed in both directions. The right state correctly uses max(c_fast%R, hyper_cleaning_speed), but the left state uses min(c_fast%L, -hyper_cleaning_speed), which forces it negative.

Before

if (hyper_cleaning) then
    c_fast%L = min(c_fast%L, -hyper_cleaning_speed)  ! forces negative
    c_fast%R = max(c_fast%R, hyper_cleaning_speed)    ! correct
end if

After

if (hyper_cleaning) then
    c_fast%L = max(c_fast%L, hyper_cleaning_speed)    ! symmetric with R
    c_fast%R = max(c_fast%R, hyper_cleaning_speed)
end if

Why this went undetected

MHD with hyperbolic cleaning is a specialized feature. The asymmetric wave speed produces subtly wrong fluxes that may not cause immediate crashes.

Test plan

  • Run MHD simulation with hyperbolic cleaning enabled
  • Verify wave speed estimates are symmetric between left and right states

🤖 Generated with Claude Code

Fixes #1201

Copilot AI review requested due to automatic review settings February 21, 2026 03:23
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 21, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

Warning

Rate limit exceeded

@sbryngelson has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Feb 21, 2026
@codeant-ai
Copy link
Contributor

codeant-ai bot commented Feb 21, 2026

CodeAnt AI finished reviewing your PR.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the sign handling for left-state fast magnetosonic speed enforcement when hyperbolic cleaning is enabled, making it consistent with the right-state treatment.

Changes:

  • Replace min(c_fast%L, -hyper_cleaning_speed) with max(c_fast%L, hyper_cleaning_speed) under hyperbolic cleaning.
  • Keep right-state enforcement as max(c_fast%R, hyper_cleaning_speed) for symmetry.

cubic-dev-ai[bot]

This comment was marked as off-topic.

…ic speed

min(c_fast%L, -hyper_cleaning_speed) forces c_fast%L negative, but
fast magnetosonic speeds should be positive. Changed to max() to
match the right-state treatment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files

Development

Successfully merging this pull request may close these issues.

MHD hyperbolic cleaning uses wrong sign for left fast magnetosonic speed

1 participant