This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

CAFE-AMR: A computational MHD Solar Physics simulation tool that uses AMR

Ricardo Ochoa-Armenta and Francisco S. Guzmán
Instituto de Física y Matemáticas, Universidad Michoacana de San Nicolás de Hidalgo. Edificio C-3, Cd. Universitaria, 58040 Morelia, Michoacán, México
E-mail: [email protected]: [email protected]
(Accepted XXX. Received YYY; in original form ZZZ)
Abstract

The study of our Sun holds significant importance in Space Weather research, encompassing a diverse range of phenomena characterized by distinct temporal and spatial scales. To address these complexities, we developed CAFE-AMR, an implementation of an Adaptive Mesh Refinement (AMR) strategy coupled with a Magnetohydrodynamics (MHD) equation solver, aiming to tackle Solar Physics-related problems. CAFE-AMR employs standard fluid dynamics methods, including Finite Volume discretization, HLL and Roe class flux formulas, linear order reconstructors, second-order Runge-Kutta, and Corner Transport Upwind time stepping. In this paper, we present the core structure of CAFE-AMR, discuss and evaluate mesh refinement criteria strategies, and conduct various tests, including simulations of idealized Solar Wind models, relevant for Space Weather applications.

keywords:
methods: numerical – MHD – Sun: general
pubyear: 20XXpagerange: CAFE-AMR: A computational MHD Solar Physics simulation tool that uses AMRCAFE-AMR: A computational MHD Solar Physics simulation tool that uses AMR

1 Introduction.

Solar physics has been developed in a constant direction: much of our Sun’s present observed structure and dynamic behavior owe their existence to the magnetic field. In every shell that constitutes the solar atmosphere, being either the photosphere, the chromosphere, the corona, or the heliosphere, there are many endearing and involving questions relating the Sun’s plasma to the magnetic field.

Magnetohydrodynamics (MHD) describes fairly well several of these magnetic field dynamics features. Fortunately both, analytical and numerical advances in our understanding and use of these equations have been made. Moreover, advances regarding the improvement of the usage of computational resources while running simulations based on these equations have been equally important.

A significant breakthrough on Fluid Dynamics simulations, was made a while ago by the implementation of Adaptive Mesh Refinement (AMR) technique, presented in the well known (Berger & Oliger, 1984) and (Berger & Colella, 1989), where it was used in conjunction with the numerical shock capturing solutions of the Euler hydrodynamic equations. AMR is an approach to optimize the efficient use of resources in the solution of initial value problems involving the solution of fluid dynamics; it can be summarized as the use of more resolution, spatial or temporal, only where more structure of the functions involved in the problem demand more accuracy. Physically, AMR is a powerful tool to adequately evolve a fluid when great disparities in the spatial and temporal scales occur simultaneously, when the flow dynamics have very localized features.

A number of codes that employ the AMR strategy for solving MHD equations are available within the scientific community. Some examples are the following: MPI-AMRVAC (Porth et al., 2014): This code is specifically designed to solve MHD and Hall MHD equations, it utilizes finite volume or finite difference methods and can also handle the evolution of dust coupled with a hydrodynamic fluid. A second (Xia et al., 2018) and third (Keppens, R. et al., 2023) versions of this code have been developed; PLUTO (Mignone et al., 2007): which has been used mainly in astrophysical simulations and has gained attraction in the field of solar physics in recent years; FLASH(Fryxell et al., 2000): A widely used astrophysical code; AstroBEAR (Cunningham et al., 2009); RAMSES (Teyssier, 2002); NIRVANA (Ziegler, 2008); ATHENA(Stone et al., 2008); ENZO (Bryan et al., 2014) and BATS-R-US (Tóth et al., 2012) are codes known for their high-performance computing orientation and have been extensively used in various scientific disciplines, including astrophysics and MHD simulations. Some of these codes rely on specialized libraries such as PARAMESH (MacNeice et al., 2000) and CHOMBO (LBNL, 2019), which provide parallelized AMR drivers that can be adapted to solve initial value problems as needed. In the realm of solar physics simulation, noteworthy codes include AMR-CESE-MHD (Feng et al., 2012), ICARUS (Verbeke, C. et al., 2022), which support non cartesian grids, and SFUMATO (Matsumoto et al., 2019), all of which have been successfully used in solar wind simulations.

The AMR strategy, when integrated with parallelization schemes, significantly enhances computational efficiency. State-of-the-art computing systems often adopt a combination of technologies. For example OpenMP-MPI, as demonstrated in the BHAC GR-MHD code (Cielo et al., 2022). Also, the growing adoption of GPUs is expected to further amplify the processing power for handling vast data sets generated by computer simulations. A notable example of this trend is the H-AMR code (Liska et al., 2022).

Even though most of these codes are open source, the complexity of their modular structure might render them inaccessible. As an alternative, developing an original code based on standard numerical schemes, allows one to have an independent tool that serves as a theoretical laboratory that on the one hand helps to confirm results obtained with other codes, and on the other serves to implement the solution of new problems that would be hard to define on top of already existing codes that, due to their degree of sophistication prevent easy soft adjustments. Accessibility and control are an important motivation to build a code.

In this work we present a code, constructed from scratch, that solves the equations of the MHD using AMR based on the methods for the solution of the equations developed for the unigrid original version of CAFE (Lora-Clavijo et al., 2015; González-Avilés et al., 2015). This code is expected to join those others that are in production for Solar and Space Weather Physics. The paper structure is as follows. In section 2, an overview of resistive MHD equations and the numerical methods is presented. Section 3 is an exposition of the adaptive mesh refinement strategy. In Section 4 we describe the numerical methods we use for the solution of the MHD equations and the AMR strategy. In Section 5 we present standard and specialized tests on Solar Physics. Finally in Section 6 we present final comments.

2 MHD equations and numerical methods.

CAFE-AMR has been designed as a primer to solve time dependent initial value problems described by a set of quasilinear hyperbolic time dependent differential equations. This was in consideration of that resistive MHD equations can be written in a way to satisfy hyperbolicity criteria.

2.1 MHD equations.

The set of MHD equations we are using to describe the dynamics of a fluid element are the following:

ρt+(ρ𝐯)=0,\dfrac{\partial\rho}{\partial t}+\nabla\cdot(\rho\mathbf{v})=0, (1)
ρ𝐯t+[ρ𝐯𝐯𝐁𝐁]+pt=(𝐁)𝐁ρΦ,\dfrac{\partial\rho\mathbf{v}}{\partial t}+\nabla\cdot[\rho\mathbf{v}\mathbf{v}-\mathbf{B}\mathbf{B}]+\nabla p_{t}=\left(\nabla\cdot\mathbf{B}\right)\mathbf{B}-\rho\nabla\Phi, (2)
εt+[(ε+pt)𝐯(𝐯𝐁)𝐁]=(η𝐉×𝐁)ρ𝐯Φ𝐁(ψ),\begin{split}\dfrac{\partial\varepsilon}{\partial t}+\nabla\cdot[(\varepsilon+p_{t})\mathbf{v}-(\mathbf{v}\cdot\mathbf{B})\mathbf{B}]=-\nabla\left(\eta\mathbf{J}\times\mathbf{B}\right)\\ -\rho\mathbf{v}\cdot\nabla\Phi-\mathbf{B}\cdot(\nabla\psi),\end{split} (3)
𝐁t×(𝐯×𝐁)=×[η𝐉],\dfrac{\partial\mathbf{B}}{\partial t}-\nabla\times(\mathbf{v}\times\mathbf{B})=\nabla\times[\eta\mathbf{J}], (4)
tψ+Ch2𝐁=Ch2Cp2ψ.\partial_{t}\psi+C_{h}^{2}\nabla\cdot\mathbf{B}=-\frac{C_{h}^{2}}{C_{p}^{2}}\psi. (5)

where ρ\rho is the plasma mass density, 𝐯\mathbf{v} is the local fluid velocity, 𝐁\mathbf{B} is the magnetic field, Φ\Phi is the gravitational potential, ε\varepsilon is the total energy density, Pt=(γ1)(ε+ρ𝐯2/2+𝐁2/2P_{t}=(\gamma-1)(\varepsilon+\rho\mathbf{v}^{2}/2+\mathbf{B}^{2}/2) is the total pressure, 𝐉\mathbf{J} is the electric current density and η\eta is the resistivity.

We assume the thermal pressure pp of the plasma is given by the equation of state of an ideal gas so that the total energy density is

ε=pγ1+12ρ𝐯2+12𝐁2,\varepsilon=\frac{p}{\gamma-1}+\frac{1}{2}\rho\mathbf{v}^{2}+\frac{1}{2}\mathbf{B}^{2}, (6)

where γ\gamma is the adiabatic index.

In order to maintain the solenoidal constraint, that is 𝐁=0\nabla\cdot\mathbf{B}=0, we implement the divergence cleaning scheme proposed in (Dedner et al., 2002), where the divergence of 𝐁\mathbf{B} is related to the scalar function ψ\psi that satisfies equation (5). With this correction, numerical errors that produce a non zero divergence of the magnetic field are transported and diffused through the numerical domain, and at the same time the addition of the equation for ψ\psi maintains the hyperbolic-parabolic structure of the equations. The coefficients ChC_{h} and CpC_{p} in Eq. (5) determine the damping of the divergence of the magnetic field.

2.2 Numerical methods.

The system of equations (1), (2), (3), (4), and (5) is solved as an Initial Value Problem (IVP) defined on the domain described in Cartesian coordinates D×[0,tf]:=[xmin,xmax]×[ymin,ymax]×[zmin,zmax]×[0,tf]D\times[0,t_{f}]:=[x_{min},x_{max}]\times[y_{min},y_{max}]\times[z_{min},z_{max}]\times[0,t_{f}], provided initial and boundary conditions are given. We define a base cell centered discretization of DD as follows:

xi\displaystyle x_{i} =\displaystyle= xmin+(i12)Δx\displaystyle x_{min}+\left(i-\frac{1}{2}\right)\Delta x
yj\displaystyle y_{j} =\displaystyle= ymin+(j12)Δy\displaystyle y_{min}+\left(j-\frac{1}{2}\right)\Delta y
zk\displaystyle z_{k} =\displaystyle= zmin+(k12)Δz\displaystyle z_{min}+\left(k-\frac{1}{2}\right)\Delta z

where (xi,yj,zk)(x_{i},y_{j},z_{k}) is the center of a cell of volume ΔxΔyΔz\Delta x\Delta y\Delta z; the indices take values i=1,,Nxi=1,...,N_{x}, j=1,,Nyj=1,...,N_{y}, k=1,,Nzk=1,...,N_{z}; the spatial resolutions are defined by Δx=(xmaxxmin)/Nx\Delta x=(x_{max}-x_{min})/N_{x}, Δy=(ymaxymin)/Ny\Delta y=(y_{max}-y_{min})/N_{y} and Δz=(zmaxzmin)/Nz\Delta z=(z_{max}-z_{min})/N_{z}, with Nx,Ny,NzN_{x},N_{y},N_{z} are the numbers of cells along each direction. Time is discretized by tn=nΔtt^{n}=n\Delta t where time resolution is Δt=CFL×min[Δx,Δy,Δz]\Delta t=CFL\times\mathrm{min}[\Delta x,\Delta y,\Delta z], where CFLCFL is the Courant-Friedrichs-Lewy factor. In this domain the value of a given grid function ff at time tnt^{n} and position (xi,yj,zk)(x_{i},y_{j},z_{k}) of the numerical domain, will be represented by fi,j,knf^{n}_{i,j,k}.

For the system of equations to be solved we define the vector of conservative variables 𝐔=(ρ,ρ𝐯,ε,𝐁,ψ)T{\bf U}=(\rho,\rho{\bf v},\varepsilon,{\bf B},\psi)^{T}. The finite volume implementation uses a Godunov type of shock capturing flux computation scheme, which prescribes the evolution formula for 𝐔{\bf U} from time tnt^{n} to tn+1t^{n+1} as:

𝐔^i,j,kn+1=𝐔^i,j,kn+Δt[1Δx(𝐅i1/2,j,kn𝐅i+1/2,j,kn)+1Δy(𝐆i,j1/2,kn𝐆i,j+1/2,kn)+1Δz(𝐇i,j,k1/2n𝐇i,j,k+1/2n)+𝐒i,j,kn]\begin{split}\hat{\mathbf{U}}^{n+1}_{i,j,k}&=\hat{\mathbf{U}}^{n}_{i,j,k}\\ {}&+\Delta t\left[\frac{1}{\Delta x}\left(\mathbf{F}^{n}_{i-1/2,j,k}-\mathbf{F}^{n}_{i+1/2,j,k}\right)\right.\\ {}&+\frac{1}{\Delta y}\left(\mathbf{G}^{n}_{i,j-1/2,k}-\mathbf{G}^{n}_{i,j+1/2,k}\right)\\ {}&+\frac{1}{\Delta z}\left(\mathbf{H}^{n}_{i,j,k-1/2}-\mathbf{H}^{n}_{i,j,k+1/2}\right)\\ {}&+\left.\frac{}{}\mathbf{S}^{n}_{i,j,k}\right]\end{split} (7)

where 𝐅\mathbf{F}, 𝐆\mathbf{G}, 𝐇\mathbf{H} are the numerical fluxes across the faces of each cell perpendicular to xx, yy and zz directions respectively, as specified by the subindices i±1/2i\pm 1/2, j±1/2j\pm 1/2, k±1/2k\pm 1/2. These fluxes are calculated using either the HLLE (Harten et al., 1983) (Einfeldt, 1988) or Roe (Roe, 1981) (Powell et al., 1999) approximate Riemann solvers.

Time evolution is implemented using the method of lines; we have two second order implementations to do so. A TVD second order Runge-Kutta method consistent with cell centering in the space-time volume with an appropriate reconstructor for the inter-cell boundary values; among the reconstructors available in CAFE-AMR, in the tests below we use the linear piecewise second-order Minmod, methods. The other time evolution scheme we have worked out leans on the corner transport Upwind (Colella, 1990) that implements the GLM-MHD equations, using the schemes proposed in (Mignone & Tzeferacos, 2010).

Following the guidelines in (Dedner et al., 2002), for the hyperbolic cleaning, the divergence present in the source term is implemented directly into the equations with the addition of the exact solution for the normal component of the magnetic field of the intercell face and ψ\psi. We use the operator splitting on the parabolic part of the source term, which has an exact solution.

ψi,j,kn+1=exp[ch2cp2Δt]ψi,j,kn+1,\psi^{n+1}_{i,j,k}=\exp\left[{-\frac{c_{h}^{2}}{c_{p}^{2}}}\Delta t\right]\psi^{*n+1}_{i,j,k}, (8)

where ψi,j,kn+1\psi^{*n+1}_{i,j,k} is the evolution of ψn\psi^{n} only through the hyperbolic part of the equations. As in (Dedner et al., 2002) we use the parameter CrC_{r} to control the parabolic coefficient CpC_{p} such that

Cr=ChCpC_{r}=\frac{C_{h}}{C_{p}} (9)

this choice has the overall effect of maintaining a homogeneous decay of the function ψ\psi throughout the whole numerical domain. Throughout the tests in this work, CrC_{r} is set to 0.9. The other source terms present in the right hand side of equations (1)-(5), are calculated every time step and in cases when they contains spatial derivatives, these are computed using the centers of each cell for a point-wise second order finite difference approximation.

3 AMR

The Adaptive Mesh Refinement strategy for solving time dependent partial differential equations on rectangular grids, consist of covering the whole spatial domain with a global coarse grid, and grid patches that cover certain regions with smaller cells and in doing so defining a finer mesh on each patch. With this strategy, the numerical time integrator can be applied indistinctly to all of the patches and also the global coarse grid, so that evolution of every subdomain may be done independently.

The implementation uses the standard Berger-Oliger algorithm (Berger & Oliger, 1984) and consists of the following steps:

  1. 1.

    Select regions of DD to be refined.

  2. 2.

    Generate refined and properly nested grids in such regions.

  3. 3.

    Interpolate the numerical values of the conservative variables at each cell of the refined regions.

  4. 4.

    Once all of the refined grids have been generated, advance in time the domain DD as well as the nested grids independently until all of them are synchronized.

  5. 5.

    Inject the values of variables calculated on the refined domain into the cells of the coarse domain.

  6. 6.

    In order to maintain flux balance, correct the fluxes at the boundaries between refined and coarse regions.

This sequence may be used recursively and applied to subsequent refinement levels, that is, all the refined patches can be further refined; in this paper, we will be using the label \ell as the superscript to denote the refinement levels. The resolution ratio rr, between consecutive refinement levels \ell and +1\ell+1 is set to r=2r=2, so that for every cell of the coarse grid, there will be four cells of the fine grid for a problem defined on two space dimensions, and eight in the case of a problem in three spatial dimensions.

The reminder of this section includes a detailed description of each of these steps.

3.1 Selecting a region to refine.

The selection of the sectors within the numerical domain to be refined need a refinement criterion. There is a certain liberty to define this criterion conveniently, according to the physical scenario that will be simulated. Typically, an arbitrary number of positive finite scalar functions χ(𝐔)\chi(\mathbf{U}^{\ell}) are defined in every cell of the coarse grid, then every cell i,j,ki,j,k is flagged to be refined if this scalar function has a value greater than a certain threshold χr\chi_{r}:

χi,j,k>χr.\chi_{i,j,k}>\chi_{r}. (10)

Among others, in this code we implement two principal refinement criteria:

  • Choosing as the evaluating functions the same numerical approximation of the gradients of every conservative variable as the one used to linearly interpolate their values in a new refined grid. That is:

    χm=¯(Um),\chi_{m}=\overline{\nabla}(U_{m}), (11)

    where UmU_{m} is the mthm-th conservative variable.

  • The refinement criterion used in (Mignone et al., 2011), based on the second derivative error norm defined in (Löhner, 1987), where

    χ(𝐔)=d{x,y,z}|Δd,+1/2σΔd,1/2σ|2d{x,y,z}(|Δd,+1/2σ|+|Δd,1/2σ|+ϵσd,ref)2,\chi(\mathbf{U})=\sqrt{\frac{\sum\limits_{d\in\{x,y,z\}}|\Delta_{d,+1/2}\sigma-\Delta_{d,-1/2}\sigma|^{2}}{\sum\limits_{d\in\{x,y,z\}}(|\Delta_{d,+1/2}\sigma|+|\Delta_{d,-1/2}\sigma|+\epsilon\sigma_{d,ref})^{2}}}, (12)

    and σσ(𝐔)\sigma\equiv\sigma(\mathbf{U}) is a function of the conservative variables, Δd,±1/2σ\Delta_{d,\pm 1/2}\sigma are the undivided forward and backward finite differences along the direction dd, for example

    Δx,±1/2σ=±(σi±1σi).\Delta_{x,\pm 1/2}\sigma=\pm(\sigma_{i\pm 1}-\sigma_{i}).

    The last term that appears in the denominator is given by:

    σx,ref=|σi+1|+2|σi|+|σi1|,\sigma_{x,ref}=|\sigma_{i+1}|+2|\sigma_{i}|+|\sigma_{i-1}|,
    σy,ref=|σj+1|+2|σj|+|σj1|,\sigma_{y,ref}=|\sigma_{j+1}|+2|\sigma_{j}|+|\sigma_{j-1}|,
    σz,ref=|σk+1|+2|σk|+|σk1|,\sigma_{z,ref}=|\sigma_{k+1}|+2|\sigma_{k}|+|\sigma_{k-1}|,

    adding the σd,ref\sigma_{d,ref} term multiplied by the factor ϵ<1\epsilon<1 prevents the refinement of regions where small ripples are found.

Additionally, when a simulation uses more refinement levels, in order to properly nest them after refinement level \ell, cells are flagged according to the refinement criterion, cells in the level +1\ell+1 that contain cells of level +2\ell+2 are also flagged, and finally, level \ell cells that have flagged neighbors of the same level are flagged as well. This procedure is made recursively from the most refined grid to the coarsest one.

3.2 Generating a new refined grid

A mentioned before, the refinement factor we use this work is r=2r=2, so that a coarse cell will be covered with 2d2^{d} cells of the refined domain, where dd is the dimension of the domain. In Figure 1 it is shown how the cell volume of refinement level +1\ell+1 is 1/2d1/2^{d} of a cell in level \ell.

Refer to caption
Figure 1: Illustration of how the cell volume of refinement level +1\ell+1, that is V+1\mathrm{V}^{\ell+1} = Δx/2×Δy/2\Delta x/2\times\Delta y/2, is one quarter of the cell volume in refinement level \ell, that is V\mathrm{V}^{\ell} = ΔxΔy\Delta x\Delta y, for a refinement factor r=2r=2 and a dimension of the domain d=2d=2.

The refined cells will be centered in positions such that the region covered by them has the same boundaries as the coarse cell. For example, in two dimensions, four refined cells that cover a coarse one will have their centers at positions:

𝐫I±i,J±j+1=𝐫I,J±Δx4x^±Δy4y^,\mathbf{r}^{\ell+1}_{I\pm i,J\pm j}=\mathbf{r}^{\ell}_{I,J}\pm\frac{\Delta x}{4}\hat{x}\pm\frac{\Delta y}{4}\hat{y}, (13)

where 𝐫I,J\mathbf{r}^{\ell}_{I,J} is the coarse cell’s center.

In what follows we use DD^{\ell} to denote the domain covered with the grid of refinement level \ell.

3.3 Interpolation of data from coarse to refined grid.

Likewise in (Porth et al., 2014) and (Matsumoto, 2007), data reconstruction onto the refined grid is done by a linear interpolation, which lowers the numerical diffusion of shock discontinuities, as well as prevents the generation of spurious shocks on cells that abut on coarser ones. Explicitly, the conservative variables 𝐔\mathbf{U} in the domain D+1D^{\ell+1} are:

𝐔i,j,k+1=𝐔I,J,K+¯(𝐔I,J,K)(𝐫I,J,K𝐫i,j,k+1),\mathbf{U}^{\ell+1}_{i,j,k}=\mathbf{U}^{\ell}_{I,J,K}+\overline{\nabla}\left(\mathbf{U}^{\ell}_{I,J,K}\right)\cdot\left(\mathbf{r}^{\ell}_{I,J,K}-\mathbf{r}^{\ell+1}_{i,j,k}\right), (14)

where 𝐫i,j,k+1\mathbf{r}^{\ell+1}_{i,j,k} are the cell positions of D+1D^{\ell+1}, and 𝐫I,J,K\mathbf{r}^{\ell}_{I,J,K} the position of the cell in DD^{\ell}, where the conservative variables take values 𝐔I,J,K\mathbf{U}^{\ell}_{I,J,K}.

The approximation of the gradient operator, ¯\overline{\nabla}, acting on the arbitrary scalar function φ\varphi, is the one presented in (Matsumoto, 2007), given by:

¯(φ)=(Minmod(x+1/2φ,x1/2φ)Minmod(y+1/2φ,y1/2φ)Minmod(z+1/2φ,z1/2φ)),\overline{\nabla}\left(\varphi\right)=\begin{pmatrix}\mathrm{Minmod}\left(\partial_{x+1/2}\varphi,\partial_{x-1/2}\varphi\right)\\ \mathrm{Minmod}\left(\partial_{y+1/2}\varphi,\partial_{y-1/2}\varphi\right)\\ \mathrm{Minmod}\left(\partial_{z+1/2}\varphi,\partial_{z-1/2}\varphi\right)\end{pmatrix}, (15)

and the derivative operation follows the second order accurate centered finite differences:

x+1/2φi,j,k=1Δx(φi+1,j,kφi,j,k),\partial_{x+1/2}\varphi_{i,j,k}=\frac{1}{\Delta x}(\varphi_{i+1,j,k}-\varphi_{i,j,k}), (16)

and the Minmod function is given by

Minmod(a,b)={aif|a|<|b|,ab>0bif|b|<|a|,ab>00otherwise.\mathrm{Minmod}(a,b)=\left\{\begin{array}[]{llll}a&\mathrm{if}&|a|<|b|,&ab>0\\ b&\mathrm{if}&|b|<|a|,&ab>0\\ 0&{}&\mathrm{otherwise}\end{array}\right.. (17)

Similar formulas arise for partial derivatives along yy and zz. It is possible to use more robust linear reconstruction formulas, such as MC, or higher order WENO, as long as they preserve overall total variation diminishing properties, which will not affect the overall schemes. However, in the examples of this paper, we have chosen to only use minmod as it is sufficiently precise in regions with big discontinuities, while also being diffusive enough. This helps to prevent the growth of disturbances created by boundaries between refinement levels.

3.4 Time Evolution and Synchronization.

The AMR strategy we implement generates multiple self similar grids, each one of them evolving independently in time by the scheme (7) and only sharing information through their boundaries at the beginning of the evolution from time tnt^{n} to tn+1t^{n+1}.

The Godunov type of finite volume time evolution used for every grid has the Courant-Friedrichs-Lewy (CFL) stability condition that relates the time step Δt\Delta t with the grid resolution by

Δt=CFL×min[Δx,Δy,Δz]λmax,\Delta t=CFL\times\frac{{\min[\Delta x,\Delta y,\Delta z]}}{\lambda_{max}}, (18)

where λmax\lambda_{max} is defined as the maximum characteristic speed of the linearized version of equations (1)-(5) throughout the whole domain; the definition of this speed in three dimensional problems reads:

λmax=max[|vx|+Cfx,|vy|+Cfy,|vz|+Cfz]i,j,k\lambda_{\max}=\max[|v_{x}|+C_{fx},|v_{y}|+C_{fy},|v_{z}|+C_{fz}]_{i,j,k} (19)

where CfsC_{fs} is the maximum magnetosonic speed

Cfs=12[a+b+(a+b)24abs],C_{fs}=\sqrt{\frac{1}{2}\left[a+b+\sqrt{(a+b)^{2}-4ab_{s}}\right]}, (20)

where a=γP/ρa=\gamma P/\rho, b=B2/ρb=B^{2}/\rho, bs=Bs2/ρb_{s}=B_{s}^{2}/\rho, and s=x,y,zs=x,y,z. As stated in (Toro, 2013), the condition CFL<1.0CFL<1.0 is required to preserve stability.

Following the indications in (Berger & Oliger, 1984) and (Berger & Colella, 1989), time step size Δt+1\Delta t^{\ell+1} of refinement level +1\ell+1 is related with Δt\Delta t^{\ell} of refinement level \ell by

Δt+1=1rΔt;\Delta t^{\ell+1}=\frac{1}{r}\Delta t^{\ell}; (21)

where rr is the ratio between cell sizes of refinement level ll and that of level l+1l+1. In this code we chose a constant refinement ratio r=2r=2. To obtain (21) using (18) we get λmax\lambda_{max} among all subgrids and select the maximum. Also in this step, following (Dedner et al., 2002) we define the coefficient Ch=λmaxC_{h}=\lambda_{\max} used in equations (5) and (9) of the divergence cleaning method.

A complete evolution cycle of the system from tnt^{n} to tn+1t^{n+1} is considered as done once all of the grids synchronize at the time tn+1t^{n+1}. This requires that the domain DD^{\ell} must be evolved 22^{\ell} times to catch up with the coarsest domain. Figure 2 shows how grids of multiple refinement level advance several times to do so.

Refer to caption
Figure 2: Schematic illustration of time steps applied to each refinement level for grids with =0,1,2\ell=0,1,2 to advance from tnt^{n} to tn+1t^{n+1}. A similar scheme holds for a bigger number of refinement levels.

In (Keppens et al., 2003), it was found that choosing a non-homogeneous refinement ratio independently of the overall scheme can optimize certain aspects of the simulation, leading to faster computing times. However, our observations indicate that the gain from this approach, especially with a refinement ratio greater than 2, is outweighed by the benefits of using the recursive code structure of the fixed ratio. The recursive approach facilitated our control of proper refinement nesting and hierarchical time stepping.

Various AMR codes prove that in many physical simulations, homogeneous time step is preferred, as seen in the Nirvana code (Ziegler, 2008), which employs a single time step, not only for the better handling of simulations with non zero diffusion source terms, but also to realize faster parallelization schemes. In our tests, hierarchical time stepping yielded good results.

Except for the boundaries of the physical domain, the evolution of refined domains DD^{\ell} starts with the implementation of boundary conditions. This is done by filling ghost cells that extend the domain DD^{\ell}, filled with appropriate flux values, see e.g. (LeVeque, 2002). Filling of ghost cells depends on the kind of boundary they are extending. As shown in Figure 3, we identify three types of boundaries of domain DD^{\ell}:

  • Shared boundaries with another domain of the same refinement level \ell.

  • Shared boundary with domains of lower refinement level, which may be only of level 1\ell-1 because of how new sub grids are generated.

  • Shared boundary with the physical boundary.

Refer to caption
Refer to caption
Refer to caption
Figure 3: 2-dimensional sketch of ghost cell locations of an arbitrary domain D1D_{1} according to the type of boundary they share. Ghost cells are marked with a dot in each case. (Top) Physical boundary, (middle) shared boundary with domains of same level of refinement and (bottom) shared boundary with domains of same refinement level.

According to these types of boundaries ghost cells are filled in the following way:

  • If ghost cells have the same position as cells contained on another same refinement level grid, simply copy data values contained on those cells.

  • If ghost cells of a domain DD^{\ell} are contained on a coarse cell from a domain D1D^{\ell-1} linearly interpolate the data values.

  • If ghost cells correspond to a physical boundary, implement the appropriate boundary conditions, such as outflow or rigid, to name a few.

In the case of boundaries between consecutive refinement levels, the values of the variables at ghost cells of DD^{\ell} are constructed using linear interpolation from the values at cells in D1D^{\ell-1} in the same way as equation (14), that is

𝐔i,j,k=𝐔I,J,K+^(𝐔I,J,K1)(𝐫I,J,K1𝐫i,j,k),\mathbf{U}^{\ell}_{i,j,k}=\mathbf{U}^{*\ell}_{I,J,K}+\hat{\nabla}\left(\mathbf{U}^{*\ell-1}_{I,J,K}\right)\cdot\left(\mathbf{r}^{\ell-1}_{I,J,K}-\mathbf{r}^{\ell}_{i,j,k}\right), (22)

where it is necessary to define the coarse grid values 𝐔\mathbf{U}^{*\ell}, as

𝐔={𝐔(t)ifsynchronized,12(𝐔(t+Δt)+𝐔(t))otherwise\mathbf{U}^{*\ell}=\left\{\begin{array}[]{ccc}\mathbf{U}^{\ell}(t)&\mathrm{if}&\mathrm{synchronized},\\ \frac{1}{2}\left(\mathbf{U}^{\ell}(t+\Delta t^{\ell})+\mathbf{U}^{\ell}(t)\right)&{}\hfil&\mathrm{otherwise}\end{array}\right. (23)

and where the numerical gradient ^\hat{\nabla} is an upwind or downwind approximation depending on which face of the coarse level 1\ell-1 grid abuts on a refined one \ell. For example, if the boundary perpendicular to the +x^+\hat{x} direction of D1D^{\ell-1} is shared with the refined domain DD^{\ell}, then

^(φ)=(x1/2φMinmod(y+1/2φ,y1/2φ)Minmod(z+1/2φ,z1/2φ)),\hat{\nabla}(\varphi)=\begin{pmatrix}\partial_{x-1/2}\varphi\\ \mathrm{Minmod}\left(\partial_{y+1/2}\varphi,\partial_{y-1/2}\varphi\right)\\ \mathrm{Minmod}\left(\partial_{z+1/2}\varphi,\partial_{z-1/2}\varphi\right)\end{pmatrix}, (24)

where φ\varphi is an arbitrary scalar function; if the boundary perpendicular to the x^-\hat{x} direction is the one being shared, then x+1/2\partial_{x+1/2} is used instead. A similar formula is used when the faces are perpendicular to ±y^\pm\hat{y}, ±z^\pm\hat{z}.

3.5 Injection of refined data onto the coarser grid.

Once the variables in the coarse grid and its refinement are synchronized, the values of the conservative variables in the refined grid must be injected onto the coarse one. This is done by overwriting the data values contained in the coarse cell, with the average of the data values in the refined cells that cover it.

In three dimensions this is done using the formula

𝐔I,J,K=123i=12j=12k=12𝐔i,j,k+1,\mathbf{U}^{\ell}_{I,J,K}=\frac{1}{2^{3}}\sum_{i=1}^{2}\sum_{j=1}^{2}\sum_{k=1}^{2}\mathbf{U}^{\ell+1}_{i,j,k}, (25)

where 𝐔i,j,k+1\mathbf{U}^{\ell+1}_{i,j,k} are the data values of the refined cells that cover the coarse cell at position 𝐫I,J,K\mathbf{r}_{I,J,K}.

3.6 Flux corrections.

Finite volume methods are based on the conservation of quantities at a given cell. For example, the conservation of mass equation (1) on its finite volume form, equation (7), at cell (i,j,k)(i,j,k) can be written as:

δmi,j,k=ΔV×[ΔtΔx(Fi1/2,j,knFi+1/2,j,kn)+ΔtΔy(Gi,j1/2,knGi,j+1/2,kn)+ΔtΔz(Hi,j,k1/2nHi,j,k+1/2n)],\begin{split}\delta m_{i,j,k}&=\Delta\mathrm{V}\times\left[\frac{\Delta t}{\Delta x}\left(F^{n}_{i-1/2,j,k}-F^{n}_{i+1/2,j,k}\right)\right.\\ {}&+\frac{\Delta t}{\Delta y}\left(G^{n}_{i,j-1/2,k}-G^{n}_{i,j+1/2,k}\right)\\ {}&+\left.\frac{\Delta t}{\Delta z}\left(H^{n}_{i,j,k-1/2}-H^{n}_{i,j,k+1/2}\right)\right],\end{split} (26)

where ΔV=ΔxΔyΔz\Delta V=\Delta x\Delta y\Delta z is the cell volume, δmi,j,k=ΔV(ρi,j,k(t+Δt)ρi,j,k(t))\delta m_{i,j,k}=\Delta V(\rho_{i,j,k}(t+\Delta t)-\rho_{i,j,k}(t)) is the total mass gain over the time step Δt\Delta t and FF=ρvx\rho v^{x}, GG =ρvy\rho v^{y}, HH=ρvz\rho v^{z} are the numerical fluxes across the faces of the cell whose normal directions are respectively ±x^\pm\hat{x}, ±y^\pm\hat{y}, ±z^\pm\hat{z}.

Equation (26) establishes that each of the numerical fluxes introduces an amount of mass gain or loss across the faces of a cell. We focus our attention on the face boundary at x=xi+1/2x=x_{i+1/2} where the mass gain is

δmi+1/2,j,k(t+Δt)=Δt×ΔyΔzFi+1/2,j,k(t).\delta m_{i+1/2,j,k}(t+\Delta t)=-\Delta t\times\Delta y\Delta zF_{i+1/2,j,k}(t). (27)

Now, consider a boundary between two domains of different refinement level. When a coarse grid cell abuts on refined grid cells to the right along xx, the mass variation of equation (27) must be equal on both sides of the boundary, as in Figure 4, then the following relation should hold:

δmi+1/2,j,k(t+Δt)=qr(δmp1/2,q,r(t+Δt/2)+δmp1/2,q,r(t+Δt)),\begin{split}\delta m_{i+1/2,j,k}(t+\Delta t)=\sum_{q}\sum_{r}&\left(\delta m_{p-1/2,q,r}(t+\Delta t/2)\right.\\ +&\left.\delta m_{p-1/2,q,r}(t+\Delta t)\right),\end{split} (28)

where indices (i,j,k)(i,j,k) label the cell of DD^{\ell} and (p,q,r)(p,q,r) the cells of D+1D^{\ell+1} abutting on the coarse cell to the left.

Refer to caption
Figure 4: Illustration of a boundary between refinement levels and the mass transfer from a cell of DD^{\ell} through its face at x=xi+1/2x=x_{i+1/2}, towards its neighboring cells of D+1D^{\ell+1} during a time step. Notice that δmi+1/2,j,k\delta m_{i+1/2,j,k} has to be computed at times t+Δt/2t+\Delta t/2 and at t+Δtt+\Delta t.

By expressing (28) in terms of (27), an equivalence of the numerical fluxes of the cells in refinement level 1\ell-1 and the cells in refinement level \ell across the shared boundary is exposed:

Fi+1/2,j,k1(t)=+18mn(Fl1/2,m.n(t)+Fl1/2,m.n(t+Δt/2)),\begin{split}-F^{\ell-1}_{i+1/2,j,k}(t)=+\frac{1}{8}\sum_{m}\sum_{n}&\left(F^{\ell}_{l-1/2,m.n}(t)\right.\\ &+\left.F^{\ell}_{l-1/2,m.n}(t+\Delta t/2)\right.),\end{split} (29)

this argument must hold not only for all cell faces abutting on refined grids, but also for all the numerical fluxes of every conservative variables at these faces.

In order to enforce (29) we define a flux correction given by

δ𝐅i+1/2,j,k1(t+Δt)=𝐅i+1/2,j,k1(t)18mn(𝐅l1/2,m.n(t)+𝐅l1/2,m.n(t+Δt/2)),\begin{array}[]{ll}\delta\mathbf{F}^{\ell-1}_{i+1/2,j,k}(t+\Delta t)=&\mathbf{F}^{\ell-1}_{i+1/2,j,k}(t)-\frac{1}{8}\sum_{m}\sum_{n}\left(\mathbf{F}^{\ell}_{l-1/2,m.n}(t)\right.\\ &+\left.\mathbf{F}^{\ell}_{l-1/2,m.n}(t+\Delta t/2)\right),\end{array} (30)

that is subtracted or added, depending on which side of the shared boundary the fine cells are, once the conservative variables on the coarse cell have been updated, that is:

𝐔i,j,k1(t+Δt)𝐔i,j,k1(t+Δt)ΔtΔyΔzδ𝐅i+1/2,j,k1(t+Δt).\begin{array}[]{ll}\mathbf{U}^{\ell-1}_{i,j,k}(t+\Delta t)\rightarrow&\mathbf{U}^{\ell-1}_{i,j,k}(t+\Delta t)\\ &-\Delta t\Delta y\Delta z\delta\mathbf{F}^{\ell-1}_{i+1/2,j,k}(t+\Delta t).\end{array} (31)

Flux corrections along the y^\hat{y} and z^\hat{z} directions are implemented in a similar way.

4 Code structure

In this section we present a general overview of CAFE-AMR flow chart as well as its structure. This code is written in Fortran using f90 standard, it uses the mpich library for parallelization, and the hdf5 library to save data. Other than that, CAFE-AMR contains its own libraries and dependencies.

4.1 Data structure

This code works with a self similar block structure, as seen in Figure 5, where every block has the following data:

  • A grid discretized with a regular spacing using Nx×Ny×NzN_{x}\times N_{y}\times N_{z} cells plus ghost cells used at the boundaries.

  • The physical location of the center of the block.

  • Allocatable arrays. These may contain the values of the conservative variables, or the flux corrections given in (31) to the cells abutting on the boundaries of the block.

  • A refinement level \ell flag that indicates the physical volume of the cells on its grid as well as the time step Δt\Delta t^{\ell}.

  • Pointers to other blocks that share physical boundaries which have the same refinement levels. This blocks are referred to as neighbors.

  • Pointers to other blocks referred to as children. These specific blocks cover a quadrant, in two dimensions, or an octant, in three dimensions, contained inside the original block.

  • Pointer to another block which has a portion of its domain covered by this block. This block is referred to as father.

  • Several logical flags. They have various uses, such as defining boundary conditions and deciding whether memory will be used, to name a few.

Refer to caption
Figure 5: Self similar block structure. In this figure every quadrant of a subdomain can be covered by a block that has the same form and data structure.

All the blocks are ordered hierarchically in a QuadTree, in two dimensional problems, and an OcTree in three dimensional problems. In Figure 6 a QuadTree is represented. In this data hierarchy, the refinement of the domain is generated in the following way. First the blocks are analyzed by quadrants:

  1. 1.

    Every time a cell of a given quadrant satisfies the refinement criteria (10), the whole quadrant is flagged to be refined.

  2. 2.

    If a Block’s quadrant associated child has children of its own, the quadrant is flagged to be refined.

  3. 3.

    If a quadrant is flagged to be refined, all of its neighbors are also refined, even if they correspond to a different block.

Then all of the flagged quadrants are covered by newly generated data blocks which join the quadtree as children of the block they cover. Later on, all of the unflagged quadrants have their corresponding children deallocated.

Refer to caption
Figure 6: QuadTree data structure used to order data blocks of a two dimensional problem with two refinement levels. Every leaf of the three represents a block of data.

This whole procedure is done from the highest refinement level to the base level so that the blocks are properly nested, according the scheme in subsection 3.1. Once the refinement process has ended and all data have been interpolated, the whole neighbor pointer structure is updated. Octrees are refined in the same way.

Finally, if a data block is flagged to abut on a coarser one, a flux correction array is allocated. This array adds on the corrections in order to calculate the terms of Eq. (31). Flags that indicate whether coarse data will be interpolated to fill ghost cells in children blocks are also activated at the end.

4.2 Time evolution

As the data structure suggests, time evolution is done recursively beginning on all the blocks of a given base level to an user specified last level of refinement. The time evolution control flow that holds synchronization of all blocks is the following:

  1. 1.

    Apply physical boundary conditions at refinement level \ell.

  2. 2.

    Copy data values from same level neighbors that share a boundary into ghost cells.

  3. 3.

    Fill ghost cells values to level +1\ell+1 blocks abutting level \ell blocks by interpolation in a synchronous way following equation (23).

  4. 4.

    Advance level \ell blocks a time-step Δt\Delta t^{\ell}.

  5. 5.

    Advance recursively +1\ell+1 blocks a time-step Δt/2\Delta t^{\ell}/2.

  6. 6.

    Fill ghost cell values to level +1\ell+1 blocks abutting level \ell blocks by interpolation in an asynchronous way following equation (23).

  7. 7.

    Advance recursively +1\ell+1 blocks a time-step Δt/2\Delta t^{\ell}/2.

  8. 8.

    Inject values of children blocks into the corresponding region they cover on level \ell blocks using equation (25).

  9. 9.

    Apply numerical flux corrections on level \ell blocks following (31).

Flux corrections are implemented by first collecting in allocatable arrays, both, the cells abutting on 1\ell-1 grids and the corresponding cells on coarse blocks, afterwards these data are used to construct the terms δF1\delta F^{\ell-1} of equation (30).

5 Tests of the code

In this section we present a set of tests that illustrate the ability of the code to handle different problems and the well functioning of the AMR.

5.1 2D Kelvin-Helmholtz instability

Kelvin-Helmholtz instabilities are standard tests for hydrodynamical codes, and in the context of Solar Physics these can occur at the boundaries between different regions of the solar wind with varying velocities or densities as well as in small scale solar jets (Skirvin et al., 2023). As shown in (Mishin & Tomozov, 2016). These instabilities can lead to the formation of turbulent structures and the mixing of plasma, which can affect the propagation and properties of the solar wind. This is a MHD test, in which the discontinuities in counter-flow regions develop spiral-like shapes on, that are a challenge for an AMR method to follow.

Refer to caption
Refer to caption
Figure 7: Snapshot of the density for the 2D Kelvin-Helmholtz instability at t=0.24t=0.24. At the top we show the whole domain, with a gray area that we zoom in and show at the bottom.

The initial conditions for this test are set to:

(ρ,p,vx,vy,Bx,By)\displaystyle(\rho,p,v^{x},v^{y},B^{x},B^{y}) =\displaystyle= {(1,2.5,0.5,0,0.2,0),|y|<0.52(2,2.5,0.5,0,0.2,0),|y|0.25\displaystyle\left\{\begin{array}[]{ll}(1,2.5,-0.5,0,0.2,0),&~{}~{}|y|<0.52\\ (2,2.5,0.5,0,0.2,0),&~{}~{}|y|\geq 0.25\end{array}\right. (34)

with adiabatic index γ=1.4\gamma=1.4. In order to trigger the instability, the velocity components are perturbed as follows vx=vx+δv^{x}=v^{x}+\delta and vy=vy+δv^{y}=v^{y}+\delta, where δ=0.1cos(4πx)sin(4πy)\delta=0.1\cos(4\pi x)\sin(4\pi y).

This test is defined in the periodic domain [0.5,0.5]×[0.5,0.5][-0.5,0.5]\times[-0.5,0.5], with a base resolution of 160×160160\times 160 cells, time step resolution given by a CFL factor 0.750.75. For this test we use the Roe flux formula and the CTU time stepping scheme. We present three simulations with different refinement criteria as well as different number of refinement levels.

In a first simulation we use criterion (12) with a threshold value of χr=0.1\chi_{r}=0.1 using the density ρ\rho as the evaluating function in (10). We use five refinement levels, which gives an equivalent resolution of 5120×51205120\times 5120 cells. In Figure 7 we show a snapshot along with a zoomed region at the interface region, the addition of resolution across the interface manages to develop spiral like shapes in small spatial scales. In Figure 8 we illustrate how the AMR method follows the discontinuity even with a slim refined domain while also maintaining the overall structure of the less dynamical regions.

Refer to caption
Refer to caption
Figure 8: Snapshot of the 2D Kelvin-Helmholtz instability at t=1.0t=1.0. At the top we show the density and at the bottom the grid with its various refinement levels.

In Figure 9 we show the results of a second simulation where we use three refinement levels, giving an equivalent resolution of 1024×10241024\times 1024 cells. In this case, we compare the use of refinement criterion (11) with χr=10\chi_{r}=10 and criterion (12) with χr=0.05\chi_{r}=0.05, acting on the density ρ\rho. In the refinement structure, it is shown that, since the criterion (11) uses all of the conservative variables as evaluating functions to set the refinement regions, the refined grids are set to cover all of the mixing regions whilst in criterion (12) the refinements are located in smaller regions. This results in a difference on small scale structure of the simulation. It is important to keep in mind this in order to define appropriate refinement strategies.

Refer to caption
Refer to caption
Refer to caption
Refer to caption
Figure 9: Snapshot of the magnetic pressure (left) and the refinement structure (right) of the 2D Kelvin-Helmholtz instability with three refinement levels at t=1.0t=1.0. At the top we show the case with criterion (11) and threshold parameter χr=10\chi_{r}=10, whereas at the bottom we show the result obtained using criterion (12) with threshold parameter χr=0.05\chi_{r}=0.05.

5.2 2D Rayleigh-Taylor Instability

In presence of acceleration, when a fluid in low and high density phases, with the low density supporting the weight of the high density phase, initially in hydrostatic equilibrium, small perturbations give rise to the hydrodynamic Rayleigh-Taylor instability.

The analysis of this type of instability is used to learn how an initial linear perturbation develops a complex non-linear behavior. Rayleigh-Taylor instabilities in solar physics serve to gain insights into the physical processes responsible for solar eruptions, energy release, and the dynamics of the Sun’s atmosphere, (see e.g. Jenkins & Keppens (2022)). At first, in the linear regime, the growth rate of these instabilities depends on the wave number and frequency of the perturbation, for example the amplitude grows faster for shorter wavelengths. After the perturbation evolves into the nonlinear regime, bubbles from the low density region rise and drops from the high density shell fall, crossing the initial interface surface and the dynamics leads to the mixture of the two initial phases. Its complexity is a reason why this is a challenging test of fluid dynamics codes.

In the case of the MHD, the fluid is considered a magnetized ideal gas that responds to a magnetic field, that changes the evolution of the instability (see e.g. (Stone & Gardiner, 2007)). In this test the magnetic field is set parallel to the interface between the two fluid states and inhibits the growth rate of the instability. In order to show that CAFE-AMR can handle this problem, we present the two dimensional Rayleigh-Taylor problem.

We solve the equations on the domain x[0.5,0.5]x\in[-0.5,0.5], y[1.5,0.5]y\in[-1.5,0.5], and define the interface as the line y=0y=0. Initial conditions assume the density in lower and higher parts of the domain are ρL=1\rho_{L}=1 and ρH=4ρL\rho_{H}=4\rho_{L} respectively, the gravity constant is set to g=1.0g=-1.0 and the system is in hydrostatic equilibrium, consistently with the pressure

p(y)=100γρgy,p(y)=\frac{100}{\gamma}-\rho gy, (35)

which in turn defines the speed of sound to cs=10c_{s}=10 and a crossing time of t=0.1t=0.1 across the interface.

Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Figure 10: Snapshots of the density (top) and refinement structure (bottom) of the RT instability in the hydrodynamic limit at times t=1.5t=1.5, 2.02.0 and 3.03.0, from left to right.

We use periodic boundary conditions along the xx-direction and fixed conditions at the top and bottom of the domain. The base resolution uses 64×12864\times 128 cells and we use five refinement levels, which results in an equivalent resolution of 2048×40962048\times 4096 cells with the finest resolution. The refinement criterion used is that in Eq. (12) using hydrodynamic pressure, density and the y^\hat{y} component of the velocity as evaluating functions together with a threshold parameter χr=0.1\chi_{r}=0.1. Numerical fluxes are constructed using the Roe flux formula and the minmod limiter. Time resolution is given by a CFL factor of 0.750.75.

Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Figure 11: Snapshots of the density (top) and refinement structure (bottom) of the RT instability in the slightly magnetized case at times t=1.5t=1.5, 2.02.0 and 3.03.0, from left to right.
Refer to caption
Figure 12: Snapshot of the magnetic pressure at t=3.0t=3.0 of the RT instability test in the slightly magnetized case.

The perturbation that triggers the instability is added to the velocity field at the interface line, assuming the profile

vy(x,y)=Exp[(5.0x)2]10cosh[(10y)2],v_{y}(x,y)=-\frac{\mathrm{Exp}[-(5.0x)^{2}]}{10\mathrm{cosh}[(10y)^{2}]}, (36)

which is the 2D version of the instability presented in (Mignone et al., 2011); we also define the magnetic field to be constant along the x^\hat{x} direction, 𝐁=(Bx,0,0)\mathbf{B}=(B_{x},0,0), where

Bx=α(ρHρL)|g|.B_{x}=\alpha\sqrt{(\rho_{H}-\rho_{L})|g|}. (37)

In our test we present two cases: unmagnetized α=0\alpha=0, slightly magnetized α=0.06\alpha=0.06.

Refer to caption
Refer to caption
Refer to caption
Figure 13: Zoom in of the Rayleigh-Taylor instability test at time t=3.0t=3.0, in the slightly magnetized case. At the top we show the density profile of the lowest region where the interface is located. At the bottom there is a comparison of the density (left) and the magnetic pressure (right) in the turbulent region of the interface.

Figure 10 presents the evolution of the density and refinement structure profiles of the instability at t=1.5,2.0,3.0t=1.5,2.0,3.0 for the unmagnetized case. As the denser shell begins to fall along the vertical direction, and due to the difference in velocities of the low and high density regions, the flow develops Kelvin-Helmholtz instabilities which in turn develop further into a highly structured interface at latter times. The refinement strategy selected on this case adequately tracks the overall structure of the interface.

Figure 11 presents the density and refinement structure profiles in the slightly magnetized case α=0.06\alpha=0.06, the Kelvin-Helmholtz instabilities are suppressed because the topology of the field lines interrupts the torsion of the fluid interface, the magnetic field works against gravity and helps the denser shell to remain in the upper part which also stops the generation of KH-instabilities. In Figure 12 we show that the magnetic pressure is acting overall only at the interface surface. In Figure 13 we show that because of the augmented precision, we can capture at the lowest region of the interface there is a small scale variation in both density and magnetic pressure.

5.3 Localized Resistivity Current sheet

Solar flares are modelled as events generated magnetic reconnection (see e.g. (Priest, 2014)). In (Yokoyama & Shibata, 2001) two dimensional MHD simulations were employed to show the effect that localized magnetic resistivity has at triggering this process. The AMR strategy used to approach such simulations is advantageous as locality of phenomena is important. With this in mind, we present the localized resistivity Current Sheet (LRCS) test. This test models the generation of flares in a stratified density profile were a current sheet magnetic field is developed with the presence of a localized resistivity with Gaussian profile. The simulation is carried out on a numerical domain of (x,y)[10,10][0,20](x,y)\in[-10,10][0,20]; fixed boundary conditions at the bottom boundary and outflow boundary conditions on the other sides of the domain; we use an initial resolution of 80×8080\times 80 cells with four refinement levels giving an equivalent resolution of 1280×12801280\times 1280; the refinement criterion used is (11) with a threshold of χr=1\chi_{r}=1; numerical fluxes are constructed using the HLLE formulas with the second order CTU time stepping. A CFL=0.01CFL=0.01 factor was chosen so that time steps capture difussion time scales adequately.

Initial data is defined as follows. Density has the stratified profile

ρ(y)=ρchr+12(ρcorρchr)tanh([(yhtr)/wtr+1]),\rho(y)=\rho_{chr}+\frac{1}{2}(\rho_{cor}-\rho_{chr})\tanh{[(y-h_{tr})/w_{tr}+1]}, (38)

where ρcor=1\rho_{cor}=1, ρchr=ρcor×105\rho_{chr}=\rho_{cor}\times 10^{5}, htr=1h_{tr}=1, wtr=0.2w_{tr}=0.2. The magnetic field is defined as

Bx\displaystyle B_{x} =\displaystyle= 0,\displaystyle 0, (39)
By\displaystyle B_{y} =\displaystyle= B0tanh(x/ω),\displaystyle B_{0}\tanh(x/\omega), (40)
Bz\displaystyle B_{z} =\displaystyle= B0cosh(x/ω),\displaystyle B_{0}\cosh(x/\omega), (41)

where B0=1B_{0}=1 and ω=0.5\omega=0.5; the localized resistivity function is the same as in (Takasao et al., 2015), that is

η(x,y)=η0exp[(x2+(yhη)2)/ωη2],\eta(x,y)=\eta_{0}\exp[-(x^{2}+(y-h_{\eta})^{2})/\omega_{\eta}^{2}], (42)

where ωη=0.2\omega_{\eta}=0.2, hη=6h_{\eta}=6 and η0=1\eta_{0}=1. Pressure is initially set to P=1/γP=1/\gamma and the whole system is initially set at rest.

Refer to caption
Refer to caption
Figure 14: Snapshot of the magnetic pressure (top) and the hydrodynamic pressure (bottom) of the LRCS test at t=15t=15.

In Figure 14 it is shown that near the maximum of the resistivity there is an increase in magnetic pressure as well as a decrease in hydrodynamic pressure. The results is that matter enters to this region from the sides and is expelled along the vertical directions as illustrated with the yy component of the velocity in Figure 15. In this case we use precisely the velocity as the function to be tracked by the refinement criterion, which as seen in the plots, follows the discontinuities of vyv_{y}.

Refer to caption
Refer to caption
Figure 15: Snapshot of vyv_{y} (top) and the refinement structure (bottom) of the LRCS test at t=15t=15.

5.4 Hydrodynamic Solar Wind

Within the subject of Space Weather, the most commonly studied system is the Solar Wind, including the stationary wind.

In order to simulate this type of processes in the Solar System, we first solve the MHD equations with a null magnetic field in a cubic domain [xmax,xmax]×[ymax,ymax]×[zmax,zmax][-x_{max},x_{max}]\times[-y_{max},y_{max}]\times[-z_{max},z_{max}], with xmax=ymax=zmaxx_{max}=y_{max}=z_{max}, centered at the position of the Sun, and consider xmaxx_{max} bigger than the major semi-axis of Earth’s orbit. For the position of Earth we use Heliocentric Earth Ecliptic (HEE) coordinates, in which Earth’s position moves along the positive part of the xx-axis from perihelion to aphelion.

Solar Wind simulations are carried out in a particular domain of interest, the volume contained from a sphere of rin20Rr_{in}\sim 20R_{\odot} (see e.g. (Riley & Gosling, 1998; González-Esparza et al., 2003; Feng et al., 2021)), until the faces of the cubic numerical domain. The reason to use a sphere of radius rin20Rr_{in}\sim 20R_{\odot} as an inner boundary is that at that distance from the Sun’s surface, the characteristic speeds of the wind are all pointing outwards, and consequently the flow is in the wind regime, as opposed to the accretion regime which is possible at shorter distances. This allows the injection of the physical properties of a wind or a storm through this inner boundary without the danger of material entering back in an accretion process.

The permanent injection of plasma at the inner boundary can be simulated by maintaining the physical variables of the Solar Wind ρin,𝐯in,pin,𝐁in\rho_{in},{\bf v}_{in},p_{in},{\bf B}_{in}, with suitable values at r=rinr=r_{in}, constant in time. Notice however that in Cartesian coordinates this inner boundary is the boundary of a lego-sphere, not an actual sphere, and therefore the implementation of boundary conditions at each face of boundary cubes is delicate (Kleimann et al., 2009). What we do to overcome this problem is to fill-in the whole lego-sphere with values of the primitive variables characterizing the wind at all times with the values at r=rinr=r_{in}, then the plasma will propagate outwards and eventually will fill the interplanetary space until it settles down to the heliosphere density and velocity profile (Guzmán & Mendoza-Mendoza, 2022).

At the external boundary, namely the faces of the cubic domain, we would like the fluid to continue its way out through the solar system and then use outflow boundary conditions at the outer cubic boundary.

As a particular example we simulate the formation of one of the stationary Solar Winds cases in (González-Esparza et al., 2003), which is spherically symmetric, with no magnetic field, in a domain with inner boundary rin=17.18Rr_{in}=17.18R_{\odot}, density ρin\rho_{in}=2100cm32100~{}\mathrm{cm}^{-3}, velocity 𝐯=vrr^{\bf v}=v^{r}\hat{r}, vinr=2.5×105v^{r}_{in}=2.5\times 10^{5}m/s, temperature Tin=5×105T_{in}=5\times 10^{5}K and zero magnetic field and adiabatic index 1.41.4. We use the numerical domain to be xmax=250Rx_{max}=250R_{\odot} for the wind to expand and cover at least a volume that contains Earth’s orbit.

Translation from code to physical units. Following (Guzmán & Mendoza-Mendoza, 2022), code and physical units are defined in terms of fixed scales of the state variables, for density ρphys=ρ0ρ\rho_{phys}=\rho_{0}\rho, pressure pphys=p0pp_{phys}=p_{0}p, length lphys=l0ll_{phys}=l_{0}l, time tphys=t0tt_{phys}=t_{0}t, velocity vphys=v0vv_{phys}=v_{0}v, temperature Tphys=T0TT_{phys}=T_{0}T. Notice that there is no restriction on density scale ρ0\rho_{0}, that we choose to be one.

We define code units by fixing the length scale to one solar radius l0=R=6.9634×108ml_{0}=R_{\odot}=6.9634\times 10^{8}~{}{\rm m}, time to one hour t0=3600st_{0}=3600~{}{\rm s}, which defines the velocity scale v0=l0t0=6.9634×1083600m/s=1.93428×105m/sv_{0}=\frac{l_{0}}{t_{0}}=\frac{6.9634\times 10^{8}}{3600}~{}{\rm m/s}=1.93428\times 10^{5}{\rm m/s}. Density scale is fixed to ρ0=mHcm3=1.003573×1021kg/m3\rho_{0}=\frac{m_{H}}{cm^{3}}=1.003573\times 10^{-21}{\rm kg/m^{3}} which defines the magnetic field scale B0=v0μ0ρ0B_{0}=v_{0}\sqrt{\mu_{0}\rho_{0}}. Temperature scale is T0=mHv02/kBT_{0}=m_{H}v_{0}^{2}/k_{B} with mH=μmP=0.61.6726219×1027m_{H}=\mu m_{P}=0.6\cdot 1.6726219\times 10^{27}kg the Hydrogen molecular mass and kBk_{B} Boltzmann’s constant, and pressure and energy scales are p0=ρ0v02p_{0}=\rho_{0}v_{0}^{2} and E0=ρ0v02E_{0}=\rho_{0}v_{0}^{2}.

Initial conditions are available given for the density, velocity and temperature of the wind as follows:

ρ0(𝐱)\displaystyle\rho_{0}({\bf x}) =\displaystyle= {ρsw,ifr<rin0.01ρsw,ifr>rin\displaystyle\left\{\begin{array}[]{ll}\rho_{sw},&~{}~{}~{}{\rm if}~{}r<r_{in}\\ &\\ 0.01\rho_{sw},&~{}~{}~{}{\rm if}~{}r>r_{in}\end{array}\right. (46)
𝐯0(𝐱)\displaystyle{\bf v}_{0}({\bf x}) =\displaystyle= {(xvsw/r,yvsw/r,zvsw/r),ifr<rin0,ifr>rin\displaystyle\left\{\begin{array}[]{ll}(xv_{sw}/r,yv_{sw}/r,zv_{sw}/r),&~{}~{}~{}{\rm if}~{}r<r_{in}\\ &\\ 0,&~{}~{}~{}{\rm if}~{}r>r_{in}\end{array}\right. (50)
T0(𝐱)\displaystyle T_{0}({\bf x}) =\displaystyle= Tsw\displaystyle T_{sw} (51)

where r=x2+y2+z2r=\sqrt{x^{2}+y^{2}+z^{2}}. The pressure needed as the primitive variable instead of temperature, is calculated from p0(𝐱)=ρ0(𝐱)T0(𝐱)p_{0}({\bf x})=\rho_{0}({\bf x})T_{0}({\bf x}), then internal energy is given by the equation of state e(𝐱)=p0(𝐱)/ρ0(𝐱)/(γ1)e({\bf x})=p_{0}({\bf x})/\rho_{0}({\bf x})/(\gamma-1), and finally the total energy is E=ρ(12v2+e)E=\rho(\frac{1}{2}v^{2}+e).

The simulation uses a base resolution of 80×80×8080\times 80\times 80 cells with 3 refinement levels, producing an equivalent resolution of 640×640×640640\times 640\times 640 cells. We use the refinement criterion (11) with a threshold value χr=10\chi_{r}=10. Outflow boundary conditions are set at the borders of the numerical domain. Numerical fluxes are computed using the HLLE formula along with the mimod reconstructor. A CFL factor of 0.1250.125 was used throughout the whole simulation.

At initial time the wind variables have constant values within the sphere of radius rinr_{in}, which simulates a stationary pumping of plasma into the heliosphere. The gas fills the numerical domain with the front wave that propagates outwards until it reaches the external boundary and leaves the domain. In Figure 16 we show how the refinement criteria follows this front wave. Once the wave leaves the boundary the flow approaches a stationary state.

The result of this simulation appears in Figure 17, where we show snapshots of density, xx component of 𝐯{\bf v} and temperature of the gas along the xaxisx-axis, until the flow stabilizes in the whole domain by t1000t\sim 1000 hours. In order to have a reference of the spatial domain, in these coordinates (HEE) the average Earth location is xEarth=214.83452Rx^x_{Earth}=214.83452R_{\odot}\hat{x}.

Refer to caption
Refer to caption
Figure 16: Snapshots of density and its AMR tracking at t=234t=234hr of the hydrodynamic solar wind test, before the wind achieves a stationary state. The initial shock wave as well as the contact discontinuities are covered by finer grids.
Refer to caption
Refer to caption
Refer to caption
Figure 17: Density, radial velocity and Temperature of the Hydrodynamic Solar Wind along the xx-axis after the flow has become stationary.
Refer to caption
Refer to caption
Refer to caption
Refer to caption
Figure 18: Snapshots of the density profile on the xyxy-plane after the perturbation has been injected into the stationary solar wind configuration at time t=34,8t=34,8hr (top), t=7.50t=7.50hr, 13.9813.98hr, 19.0119.01hr (bottom).
Refer to caption
Figure 19: Refinement structure after the internal boundary perturbation has been injected into the stationary solar wind configuration at t=33,8t=33,8hr. In this figure we also overlap a threshold selection of density corresponding to the internal boundary as well as the CME perturbation.

After the wind has become stationary, we inject a toy-model of Coronal Mass Ejection (CME). We characterize the CME launched from the inner boundary at r=20Rr=20R_{\odot} by its density, velocity and widening angle θ=π/6\theta=\pi/6. The injection is implemented similarly as the stationary Solar Wind at the inner boundary provided density, velocity and temperature of the CME. As a test we inject a toy CME with the following properties ρCME=3×ρwind\rho_{\mathrm{CME}}=3\times\rho_{\mathrm{{wind}}} vr,CME=2.5×vr,windv_{r,\mathrm{CME}}=2.5\times v_{r,\mathrm{wind}} and TCME=2×TwindT_{\rm CME}=2\times T_{\mathrm{wind}}, conditions taken from (González-Esparza et al., 2003). We launch this CME centered at the solar equator, during a time window of 3 hours. In Figure 18 we show snapshots of density during the propagation of the CME. With this initial setup the initial burst propagates, its density profile smears out and widens. In Figure 19 we show that the structure of the highest refinement level tracks the perturbation.

5.5 Tilted Magnetic Dipole Solar Wind

Beyond the solar corona, the solar wind is fairly well and commonly modelled using ideal MHD. In this context, the macroscopic plasma quantities, such as density, velocity and temperature, can all be related to the topology of the field lines of the magnetic field. Current techniques applied to simulate the interplanetary heliosphere rely on this fact, for example the WSA (Arge et al., 2004) approximation and its implementation in the ENLIL model (Odstrcil, 2003).

In order to explain our implementation of the magnetic field we briefly review the bases of empirical models. The physical domain is partitioned into some basic spherical shells approximately located at given spheres: the photosphere at 1 R\mathrm{R}_{\odot}, the Solar Corona (SC) at RSC2.5R\mathrm{R}_{SC}\approx 2.5\mathrm{R}_{\odot}, the inner boundary at Rin20RR_{in}\approx 20\mathrm{R}_{\odot}, and the rest of the numerical domain that includes a volume containing at least the Earth’s orbit, of 1AU\approx 1\mathrm{AU}. The magnetic field at the photosphere is reconstructed from magnetogram synoptic maps, used as input to construct analytic expressions of the magnetic field at the Corona via the potential field source surface method (Newkirk & Altschuler, 1969). Next, the super-radial expansion factor (fsf_{s}), that refers to the variation of field strength along a magnetic flux tube is calculated, for example as done in (Shiota et al., 2014):

fs(θsc,ϕsc)=(RRsc)2Br(R,θ,ϕ)Br(Rsc,θsc,ϕsc),f_{s}(\theta_{sc},\phi_{sc})=\left(\frac{R_{\odot}}{R_{s}c}\right)^{2}\frac{B_{r}(R_{\odot},\theta_{\odot},\phi_{\odot})}{Br(R_{sc},\theta_{sc},\phi_{sc})}, (52)

where BrB_{r} is the radial component of the magnetic field. The coordinates (R,θ,ϕ)(R_{\odot},\theta_{\odot},\phi_{\odot}) of the foot point of the magnetic flux tube are located by using a first order integration of the magnetic field lines taking (Rsc,θsc,ϕsc)(R_{sc},\theta_{sc},\phi_{sc}) as the starting point; if, after a finite number of steps, the foot point is not found, a fsf_{s} default value is chosen so that the radial velocity is minimal according to (53).

Once fsf_{s} is calculated, we use the empirical Wang and Sheely formula (Wang & Sheeley, 1990; Arge & Pizzo, 2000) that gives the wind radial velocity at the inner boundary as

vr(Rin,θin,ϕin)=267.5+410fs0.4(θin,ϕin)km/s.v_{r}(R_{in},\theta_{in},\phi_{in})=267.5+\frac{410}{f_{s}^{0.4}(\theta_{in},\phi_{in})}\mathrm{km/s}. (53)

With this in mind, we have woven a test based on the empirical construction of the solar wind at the inner boundary using an analytical expression of the magnetic field.

Based on the Parker Solar Wind model (Priest, 2014), we use a constant temperature, as well as a magnetic field that fulfills conservation across radial flux tubes:

Br(Rin)=(RscRin)2Br(Rsc).B_{r}(R_{in})=\left(\frac{R_{sc}}{R_{in}}\right)^{2}B_{r}(R_{sc}). (54)

To obtain the solar wind radial velocity profile at the inner boundary in equation (53), we impose the magnetic field of a tilted dipole given by

𝐁(𝐫)=3𝐫(𝐦𝐫)r5𝐦r3,\mathbf{B}(\mathbf{r})=\frac{3\mathbf{r}(\mathbf{m}\cdot\mathbf{r})}{r^{5}}-\frac{\mathbf{m}}{r^{3}}, (55)

where 𝐦\mathbf{m} is the magnetic dipole moment. We use an inertial heliographic reference frame (Burlaga, 1995) that does not have Coriolis forces due to rotation. In this sense, the internal boundary expresses an ejected hot sphere of magnetized plasma that rotates like a solid. To apply the rotation at the internal boundary, we transform the mϕm_{\phi} component of the magnetic dipole by ϕϕ+Ωt\phi\rightarrow{\phi+\Omega_{\odot}t}, where Ω\Omega_{\odot} is the angular frequency of the Sun. This will rotate the inner magnetic field on equation (55) and, because all of the boundary quantities are connected to the magnetic field, they will also experience the same rotation.

The number density nn is given by a measure of the radial flux of number density at 1 AU in slow wind conditions (Smith, 2009),

n(Rin)=n0(R0Rin)2×v0vr(Rin),n(R_{in})=n_{0}\left(\frac{R_{0}}{R_{in}}\right)^{2}\times\frac{v_{0}}{v_{r}(R_{in})}, (56)

where n0n_{0} 8.06×106cm38.06\times 10^{6}\mathrm{cm}^{-3}, V0=267.5km/sV_{0}=267.5\mathrm{km/s}, R0=1AUR_{0}=1\mathrm{AU}. Finally the hydrodynamic pressure can be obtained from the equation of state of the ideal gas.

The simulation specifications for this test are the following: The computational domain is the cubic box of size 256R×256R×256R256R_{\odot}\times 256R_{\odot}\times 256R_{\odot}, centered at the Sun’s location. The initial resolution is given by 1283128^{3} cells with three refinement levels, which corresponds to an equivalent resolution of 102431024^{3} cells. We use outflow boundary conditions at the edges of the numerical domain and set the internal boundary at Rin=20RR_{in}=20R_{\odot}. Time stepping is handled with second order RK with a CFL factor of 0.1250.125; numerical fluxes are obtained through the HLLE approximation. The initial temperature of the system is set to 1×105K1\times 10^{5}K, with an adiabatic index of γ=5/3\gamma=5/3. The magnetic dipole strength is m=1×105m=1\times 10^{-5}T m3\mathrm{m}^{-3}, its colatitud inclination angle is θ=π/5\theta=\pi/5 and the magnetic field at the inner Boundary is given by the radial component of (55).

We use two types of refinement, a fixed one and an adaptive one. In order to minimize the effect of geometrical errors due to the inner boundary to be a lego sphere, we set a fixed mesh refinement near the boundary so that in this region we use maximum spatial and temporal resolution. The adaptive refinement is a mixture of the one proposed by (Matsumoto et al., 2019), where we refine a data block if there is a change in polarity in BrB_{r}, and, because we desire to capture the spiral-like behavior in the radial component of the velocity, we choose σ(𝐔)=vr\sigma(\mathbf{U})=v_{r} at equation (12) with a threshold χr<0.1\chi_{r}<0.1. This refinements are implemented only in regions where |z|<2Rin|z|<2R_{in} so that only the heliospheric current sheet is refined.

Quantity Normalization
Time t0=3600t_{0}=3600 s
Length L0=R=6.9634×108L_{0}=R_{\odot}=6.9634\times 10^{8} m
Velocity v0=L0/t01.93×105v_{0}=L_{0}/t_{0}\approx 1.93\times 10^{5}m/s
Temperature mHv02/kB2.73×106m_{H}v_{0}^{2}/k_{B}\approx 2.73\times 10^{6}K
Number Density N0=1×109m3N_{0}=1\times 10^{9}\mathrm{m}^{-3}
Density ρ0=mHN01.004×1018\rho_{0}=m_{H}N_{0}\approx 1.004\times 10^{-18}
Magnetic Field B0=v0μ0ρ02.1786×107B_{0}=v_{0}\sqrt{\mu_{0}\rho_{0}}\approx 2.1786\times 10^{-7} Tesla
Table 1: Normalization of constants for the tilted magnetic dipole test are mH=0.6×1.6726219×1027m_{H}=0.6\times 1.6726219\times 10^{-27}kg the mean hydrogen molecule mass, kB=1.3806488×1023k_{B}=1.3806488\times 10^{-23}J/K the Boltzmann constant, and μ0=1.256637×106N/A2\mu_{0}=1.256637\times 10^{-6}\mathrm{N/A}^{2} the magnetic permeability.

In order to simulate this scenario, we connect physical and code units according to the values in Table 1. In Figure 20 we show a meridian cut of the radial velocity, and notice that there are two regions corresponding to a slow streamer belt and a fast wind region near the poles. Figure 21 shows the rotation effect at the zenith cut of the velocity, which develops a gradient in its magnitude typically associated with co-rotating interaction regions.

Refer to caption
Figure 20: Plane cut at x=0x=0 of the radial velocity distribution at time t=200t=200h of the tilted magnetic dipole solar wind test. Velocity ranges are from 2.8×105\approx 2.8\times 10^{5}m s-1 (green) to 5.56×105\approx 5.56\times 10^{5}m s-1 (dark red).
Refer to caption
Figure 21: Projection of the radial velocity distribution at the plane z=0z=0 and time t=200t=200h of the tilted magnetic dipole solar wind test. Velocity ranges are from 2.8×105\approx 2.8\times 10^{5}m s-1 (dark green) to 3.25×105\approx 3.25\times 10^{5}m s-1 (light green).

In reference to mesh refinement, Figure 22 shows the various domains and the resolutions used in each patch, at the plane x=0x=0. The refinement tracks the slower wind at low latitudes as expected because it is also the region where there is a shift on polarity in the magnetic field.

Refer to caption
Figure 22: Plane cut at x=0x=0 of the mesh refinement on the radial velocity distribution at t=200t=200h of the tilted magnetic dipole solar wind test. The z-shaped refined zone is due to the polarity change of the radial component of the magnetic field. The vertical fringes refined outside of |z|<2Rin|z|<2R_{in} are due to the criterion based on radial velocity.
Refer to caption
Figure 23: Magnetic field lines of the tilted magnetic dipole solar wind test at t=200t=200, overlapped with the plane cut of constant azimuth angle Φ=3π/2\Phi=3\pi/2 of the radial velocity distribution.Velocity ranges are from 2.8×105\approx 2.8\times 10^{5}m s-1 (green) to 5.56×105\approx 5.56\times 10^{5}m s-1 (dark red).

At big interplanetary distances, the magnetic profile of the solar wind is dominated by the dipole moment. Figure 23 shows the magnetic field lines over the whole domain; it can be seen that near the equator, field lines are sporadic, as expected for a magnetic dipole. Certain torsion of the field lines associated with the rotation of the injected boundary can also be noticed. This simulation achieves this specification and also manages to evolve the rotating magnetized solar wind that generates the Parker spirals. This is a test case toward the real more elaborate simulations in practical forecasting, which involve specialized PFSS definitions to extend the range of heliosphere simulations even further.

The issue we are tackling on this test, in the context of solar wind simulations, is of augmenting spatial resolution not only at the internal boundary but also capturing dynamical structures at regions of interest farther away. Certainly AMR on rectilinear grids is not the only strategy. For example, in the project of sun to earth simulations (Narechania, Nishant M. et al., 2021), AMR regriding strategies are employed using hexahedral blocks, obtaining high resolution on the formation of current sheets as well as on the propagation of CME, at the cost of needing special care of the numerical fluxes at intercell boundary faces. Another case is the ICARUS code (Verbeke, C. et al., 2022), which achieves high resolution simulations using AMR on spherical grids, which do not have as complex flux formulas as the hexahedral simulations, but due to the geometry of the equations there is a need of special care of singularities of the equations at the poles. AMR on rectilinear grids do not have neither of this problems, but the issue of having a lego sphere at the internal boundary is a hard problem, it overburdens the usage of the PFSS schemes and the use of co-rotating frames might also induce non physical phenomena; major improvements on this test can be made, in this sense, by applying corrections which could mitigate this geometric problem, for example with the Immersed Boundary method (Mittal & Iaccarino, 2005) or averaging at the excision surface (Kleimann et al., 2009), as in the hydrodynamic solar wind tests from the previous section.

6 Final comments and conclusions

In this paper we have presented a new implementation that uses AMR to solve the MHD equations, with the expectation to have a theoretical laboratory to study and contribute to Space Physics at heliosphere scales.

CAFE-AMR uses simple and standard numerical methods that allow the simulation of various processes of importance, which are concentrated in a series of idealized standard test problems. These tests show the ability of CAFE-AMR to track well known features prominent in solar physics, with particular emphasis on the adaptability of refined domain patches: Standard ideal MHD tests of the Kelvin-Helmholtz and the Rayleigh-Taylor instabilities that are ubiquitous in solar physics and generate highly localized phenomena; the Localized Resistivity current sheet which simulates the evolution of solar flares in regions near the chromosphere-corona interface; heliospheric related tests include the formation and stabilization of a non-magnetized Solar Wind and CME propagation as well as the formation and stabilization of a magnetized Solar Wind which generates a rotating current sheet.

Further work will involve specific applications that include convection and radiation with the scope of modeling chromospheric events and non-ideal MHD effects. The code in this paper is expected to be enriched with the methods and scenarios involving thermal conduction Gonzalez-Avilés & Guzmán (2018); González-Avilés et al. (2020) and radiation (Rivera-Paleo & Guzmán, 2019).

Acknowledgements

Ricardo Ochoa Armenta receives support from CONACyT under CVU 785828. This research is supported by grant CIC-UMSNH-4.9 of Universidad Michoacana. The runs were carried out in the Big Mamma cluster of the Laboratorio de Inteligencia Artificial y Supercómputo, IFM-UMSNH.

Data availability

The data and code underlying this article will be shared on reasonable request to the corresponding author.

References