PrincetonUniversity / athena

Athena++ radiation GRMHD code and adaptive mesh refinement (AMR) framework
https://www.athena-astro.app
BSD 3-Clause "New" or "Revised" License
220 stars 120 forks source link

MHD shearing box has artifacts with SMR #571

Open c-white opened 5 months ago

c-white commented 5 months ago

Summary

The combination of MHD, SMR, and shear-periodic boundary conditions produces some artifacts and isn't fully supported right now. I propose the following, from short-term to long-term:

Discussed in https://github.com/PrincetonUniversity/athena/discussions/569

Originally posted by **jonosquire** March 7, 2024 I have been trying to run an MHD shearing box with static mesh refinement and been running into issues. I add SMR in the vertical direction only for the usual shearing domain with shear_periodic boundary conditions in x. After a short time (~0.5 orbits), the integrator goes unstable with the timestep dropping to zero because of a very large radial magnetic field that develops in the 2-3 cells around the refinement location at the radial boundaries. Just 1 level of refinement causes the issue, but the blowup/instability occurs faster if higher levels are added. In order to diagnose the issue I have tried (in various combinations): the vl2, rk2, and rk3 time integrators with various conservative CFLs; order 2, 2c and 3 reconstruction; different initial conditions (from the strat.cpp pgen) and different field strengths; different orbital advection schemes (including no orbital advection); setting qshear=0 (still with the shear_periodic BCs); different mesh refinement locations, meshblock configurations and resolutions; different sound speeds and density floors. The problem persists with all of these. Turning off the magnetic field (pure hydro shearing box), or using periodic (rather than shear_periodic) boundary conditions in x1 removes the issue, and the grid setup appears to be as expected with all of the meshblocks at the same z facing the x1 shear-periodic boundaries having the same level. Has anybody come across similar problems? I'm at a loss for what to try at this point – is there an issue with with shear_periodic BCs and SMR? I've attached an input file that should reproduce the issue with the strat.cpp pgen in the current athena version (this is effectively the default input file with different units, a finer grid, and the SMR added). I've also attached a screenshot showing the radial field blowup at the boundary (the colormap is saturated; the points right on the boundary at z=+-2.5 continue growing to infinity). Thanks in advance for the help. [athinput.strat.txt](https://github.com/PrincetonUniversity/athena/files/14521746/athinput.strat.txt) Screenshot 2024-03-07 at 5 45 45 PM
felker commented 4 months ago

I can't think about how/where to add the more nuanced error condition you mentioned in https://github.com/PrincetonUniversity/athena/pull/578#issuecomment-2061999722 .

I plan on minting a release today. If you aren't able to add the runtime warning today, I can either add a dumb warning in bvals.cpp that just checks the global setting of pmy_mesh_->shear_periodic and MHD+SMR and emits a warning, or we can delay it until a future release

c-white commented 4 months ago

I think a simple shear+mhd+refinement warning should suffice for now.

felker commented 4 months ago

to be absolutely clear, this issue should be renamed to "MHD shearing box has artifacts with refinement at shear boundaries", right? That is, both AMR and SMR are liable to refine at the shear boundaries unless you are careful

AMR+shear+hydro/MHD is already forbidden in the code, so it is covered by another safety check. But we need to add an exclusion for SMR+shear+MHD while continuing to allow SMR+shear+hydro