Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct tildeB sources and fluxes in ValenciaDivClean #5960

Merged
merged 1 commit into from
May 9, 2024

Conversation

norafl
Copy link
Contributor

@norafl norafl commented May 1, 2024

Proposed changes

Corrects the sources and fluxes in magnetic field evolution.

Currently, the code has made the simplification
$$\partial_i({\tilde B}^j\beta^i) = {\tilde B}^j\partial_i\beta^i,$$
which can introduce errors in handling the divergence of the magnetic field. This update removes the resulting ${\tilde B}^j\partial_i\beta^i$ from the magnetic field source terms and adds a corresponding ${\tilde B}^j\beta^i$ to the corresponding flux terms. This handling is consistent with eq. 20 of https://arxiv.org/pdf/2004.00870 and eq. 32 of https://arxiv.org/pdf/1806.04182.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@norafl norafl requested a review from nilsdeppe May 1, 2024 16:39
Copy link
Member

@wthrowe wthrowe left a comment

Choose a reason for hiding this comment

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

This still needs updates to the documentation (in src/Evolution/Systems/GrMhd/ValenciaDivClean/System.hpp as well as the Fluxes.hpp and Sources.hpp files) and the tests. I haven't checked these specific ones, but most of the tests for this sort of thing have the equations reimplemented in python, which should be the main thing that needs fixing there.

@@ -67,7 +67,7 @@ void fluxes_impl(
tilde_b_flux->get(i, j) =
tilde_b.get(j) * transport_velocity->get(i) +
get(lapse) * (get(tilde_phi) * inv_spatial_metric.get(i, j) -
spatial_velocity.get(j) * tilde_b.get(i));
transport_velocity->get(j) * tilde_b.get(i));
Copy link
Member

Choose a reason for hiding this comment

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

Should no longer be multiplied by the lapse, I believe.

get(lapse) * (get(tilde_phi) * inv_spatial_metric.get(i, j) -
spatial_velocity.get(j) * tilde_b.get(i));
get(lapse) * (get(tilde_phi) * inv_spatial_metric.get(i, j)) -
transport_velocity->get(j) * tilde_b.get(i);
Copy link
Member

Choose a reason for hiding this comment

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

Reorder these terms to match the docs, just for readability.

@@ -166,6 +167,9 @@ namespace ValenciaDivClean {
* divergence-free (no-monopole) condition \f$\Phi = \partial_i {\tilde B}^i =
* 0\f$.
*
* \note The fluxes and sources of {\tilde B} follow eq. 20 of
Copy link
Member

Choose a reason for hiding this comment

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

Need $s around the math.

@@ -166,6 +167,9 @@ namespace ValenciaDivClean {
* divergence-free (no-monopole) condition \f$\Phi = \partial_i {\tilde B}^i =
* 0\f$.
*
* \note The fluxes and sources of {\tilde B} follow eq. 20 of
* \cite Palenzuela2018 rather than eq. 89 of \cite Moesta2014
Copy link
Member

Choose a reason for hiding this comment

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

The equation numbers for both papers look wrong.

@nilsdeppe
Copy link
Member

Can you change your wording in commits to be present tense? E.g. Fix blah or Update blah. It might help to review our contributing guidelines: https://spectre-code.org/contributing_to_spectre.html and the commit message part is noted https://spectre-code.org/contributing_to_spectre.html#git-commit-messages

@norafl norafl changed the title corrected tildeB sources and fluxes in ValenciaDivClean Correct tildeB sources and fluxes in ValenciaDivClean May 6, 2024
Copy link
Member

@wthrowe wthrowe left a comment

Choose a reason for hiding this comment

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

This looks good. Two more things: code formatting, which I've commented on as a line-comment, and squashing. This PR is pretty much an atomic change, so it should be squashed into a single commit. Google "git interactive rebase" if you don't know how to do that. As noted by @nilsdeppe, make sure your resulting commit message follows our guidelines.

I think the CI error is just some random failure, so ignore that if it doesn't happen again after you push the squashed version.

spatial_velocity.get(j) * tilde_b.get(i));
tilde_b.get(j) * transport_velocity->get(i)
- transport_velocity->get(j) * tilde_b.get(i) +
get(lapse) * (get(tilde_phi) * inv_spatial_metric.get(i, j));
Copy link
Member

Choose a reason for hiding this comment

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

Run this though clang-format. Their documentation has instructions on how to use it through emacs or git: https://clang.llvm.org/docs/ClangFormat.html . (Our repo has style options configured in a top-level .clang-format file, so you shouldn't need to configure anything yourself.)

@wthrowe
Copy link
Member

wthrowe commented May 8, 2024

Formatting looks good now, but something went wrong during your rebase. Probably easiest to just sort it out in person tomorrow.

@wthrowe wthrowe marked this pull request as ready for review May 8, 2024 21:05
@wthrowe wthrowe merged commit 4768321 into sxs-collaboration:develop May 9, 2024
22 checks passed
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