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

Use simple average when computing cell-centered B #122

Merged
merged 2 commits into from
May 3, 2018
Merged

Conversation

felker
Copy link
Contributor

@felker felker commented May 3, 2018

Description

The current second-order accurate conversion from face-averaged to cell-centered B field

 void Field::CalculateCellCenteredField(const FaceField &bf, AthenaArray<Real> &bc,
             Coordinates *pco, int is, int ie, int js, int je, int ks, int ke)

references the volume centered and cell face and volume center positions to compute the weighted average coefficients, for example:

lw = (x2f_jp - x2v_j)/dx2_j;
rw = (x2v_j  - x2f_j)/dx2_j;

which should reduce to 0.5 for uniform Cartesian coordinates. However, due to floating point round-off error, x2f(j+1) - x2v(j) != dx2f(j)/2.0 e.g., so the coefficients lw, rw wont add up to 1.0 exactly. Note for uniform meshes, dx2f = dx2v exactly, but the positions are inexact.

This PR simply uses the existing uniform_limiter[3] switches in the Reconstruction class to determine if the simple averaging formula can be used to compute the cell-centered magnetic field from the face-averaged magnetic fields in each direction.

Testing and validation

mhd-rotor-2D-nx1-32-ic-Bcc1-master.pdf plots the current nx1=nx2=20 with NGHOST=2 initial condition Bcc1 for the 2D MHD rotor problem. The ghost zones are also shown. The initial condition is supposed to have uniform B1 corresponding to bx0=1.410474 requested in the athinput.rotor file, but banding of deviations appear in x1 ranging from min/max:

1.410473999999998
1.4104740000000013

Since the fixes in #98, the deviations are symmetric about the midplane.

mhd-rotor-2D-nx1-32-ic-Bcc1-fix.pdf shows the uniform Bcc1 after the adding the switch in this PR, where all zones real and ghost have

1.4104740000000000

equivalent to 0552802248421E0 in binary.

To-do

  • Fix remaining reflective symmetry violations for double precision MHD in Athena++

@felker felker added bug Broken functionality or unexpected result enhancement Improve an existing Athena++ component MHD Relating to components involving the B field labels May 3, 2018
@felker felker self-assigned this May 3, 2018
@felker felker merged commit 1748c56 into master May 3, 2018
@felker felker deleted the uniform-mesh-Bcc branch May 3, 2018 21:35
@felker felker removed their assignment May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken functionality or unexpected result enhancement Improve an existing Athena++ component MHD Relating to components involving the B field
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants