The Basic Knowledge of AMRVAC – 1. Equation & Dimension

In this note, I will introduce basically what you should do to play with AMRVAC. As a highly modularized code, for most cases, users only need to write/modify two files according to their own questions, namely, the mod_usr.t and amrvac.par file. mod_usr.t is the user code for this problem (defining e.g. initial conditions) while amrvac.par is a text file saving all kinds parameters.

I choose to explain mod_usr.t file first. A typical mod_usr.t file start with the following lines:

module mod_usr
  use mod_EQUATION
  implicit none
contains
  subroutine usr_init()
    call set_coordinate_system("DIMENSION")
    usr_init_one_grid   => initonegrid_usr
    call EQUATION_activate()
  end subroutine usr_init

where EQUATION and DIMENSION should be substitute according to you physical problem.

Equations

Let’s start with EQUATION here. It simply means what equations could be solved by AMRVAC. In summary, AMRVAC can solve conservative hyperbolic equations in the form of:
\partial U/\partial t + \nabla \cdot F(U) = S(U).
By default, the equations are kind of idea, means that the source term S(U) = 0.
In detail, AMRVAC has implemented several physics modules. I will just introduce three mostly used modules here, which means AMRVAC can solve the following equations:
1. Scalar Equation:
\frac{\partial }{{\partial t}}\rho + \nabla \cdot \left( {\rho \bm{v}} \right) = 0
Here, \rho is density and velocity \bm{v} is a constant which could be set in the amrvac.par file. This equation is actually only used for all kinds of tests.
Set the code to solve this question by setting EQUATION to rho, which means, call rho_activate() in the above code.
2. Hydrodynamic Equations:
\frac{\partial }{{\partial t}}\left[ {\begin{array}{c}\rho \\{\rho \bm{v}}\\E\end{array}} \right] + \nabla \cdot \left[ {\begin{array}{c}{\rho \bm{v}}\\{p\bm{vv} + p\bm{I}}\\{\bm{v}(E + p)}\end{array}} \right] = 0
\rho and \bm{v} are same with scalar equation. \bm{I} is unit matrix. e is the energy per volume which is connected to the thermal pressure p = \left( {\gamma - 1} \right)\left( {e - \rho {\bm{v}^2}/2} \right), where \gamma is the adiabatic index whose default value is 5/3.
Set the code to solve hydrodynamic equations by setting EQUATION to hd, which means, call hd_activate() in the above code.
3. Magnetohydrodynamic Equations:
\frac{\partial }{{\partial t}}\left[ {\begin{array}{c}\rho\\{\rho \bm{v}}\\E\\\bm{B}\end{array}} \right] + \nabla \cdot \left[{\begin{array}{c}{\rho \bm{v}}\\{\rho \bm{vv} + {p_{tot}}\bm{I} - \bm{BB}/{\mu _0}}\\{\bm{v}\left( {E + {p_{tot}}} \right) - \bm{B}\left( {\bm{v} \cdot \textbf{\textit{B}}} \right)/{\mu _0}}\\{\bm{vB} - \bm{Bv}}\end{array}} \right] = 0
Most symbols have the same meaning with previous equations. \bm{B} is the magnetic flux density, \mu_0 is vacuum permeability, total pressure {p_{tot}} = p + {\bm{B}^2}/2 is composed of thermal pressure and magnetic pressure, so that connection between volumetric energy density and p = \left( {\gamma - 1} \right)\left( {e - \rho {\bm{v}^2}/2 - {\bm{B}^2}/2} \right).
Set the code to solve magnetohydrodynamic equations by setting EQUATION to mhd, which means, call mhd_activate() in the above code.
So, just choose proper equations due to you questions. For example, if it is a question that magnetic field is not at all important, then you can choose a hydrodynamic one.

Dimensions

Basically, you can choose any one of the Cartesian, cylindrical, or spherical coordinate to solve the problem. Since for 2D problems of cylindrical coordinate, the second dimension could be either the \phi direction, which is actually similar with spherical coordinate or the z direction, which is actually similar with Cartesian coordinate, we divide it into 2 types. See the table below for details

DIMENSION 1st dim 2nd dim 3rd dim typeaxial
Cartesian x y z slab
Cylindrical r z \phi cylindrical
Polar r \phi z cylindrical
Spherical r \theta \phi spherical

However, I do not recommend you to use sometding like Cylindrical to substitute DIMENSION directly. You’d better tell AMRVAC tde dimension of your problem explicitly, see tde table below for details.

DIMENSION ndim ndir DIMENSION ndim ndir
Cartesian_1D 1 1 Cartesian_1.5D 1 2
Cartesian_1.75D 1 3 Cartesian_2D 2 2
Cartesian_2.5D 2 3 Cartesian_3D 3 3
Cylindrical_2D 2 2 Cylindrical_2.5D 2 3
Cylindrical_3D 3 3 Polar_1.5D 1 2
Polar_2D 2 2 Polar_2.5D 2 3
Polar_3D 3 3 Spherical_2D 2 2
Spherical_2.5D 2 3 Spherical_3D 3 3

ndim means the geometry dimension of the problem, while ndir means the directions of velocity \bm{v} or \bm{B}, they can be different according to your model. For example, you are solving a 2D problem in the x-y plane while you have a guide field here. Then, you need a third component of magnetic field in your problem which means you need to choose 2.5D model.

Then, before going on to the next part of mod_usr.t, I have to introduce the Syntax used in AMRVAC, called LAZY.
See you next part.

发表评论

邮箱地址不会被公开。 必填项已用*标注