wiki:SimulationData

Version 2 (modified by Jonathan, 8 years ago) ( diff )

Simulation Data

All AstroBEAR modules have at least one thing in common: initializing the problem domain. Within our code, the problem domain's data is held in InfoDef structures, which is why so many module subroutines take an InfoDef structure as a parameter. To make use of the InfoDef structure, the following statement is required at the beginning of problem.f90:

USE DataDeclarations

Anything that is defined in the InfoDef type is now available. For example, q need not be defined…just reference it by Info%q.

There are two major data arrays in InfoDef: the q array and the aux array. q holds the volume averaged data and is used by all AstroBEAR simulations while aux holds face averaged data and is used only for MHD when nDim > 1. Note that volume averaged data and cell-centered data are often used interchangeably, but there is an important distinction. Take for instance a simple function defined on the interval . Applying a Taylor expansion to and finding the average of gives

where the cell centered value is

so the cell centered value is second order accurate for the volume average and usually is a quick way to estimate the volume average. However if the function has large 2nd derivatives (or higher) this can lead to large errors in the volume average. This is often apparent when modeling discontinuities along curved boundaries. There are two ways to handle this problem:

  • Introduce smoothing to the physical model to remove large 2nd and higher derivatives
  • Better approximate the volume average either by
    • Analytical integration (often non-trivial if possible)
    • Numerical integration (ie SubSampling)

The q array takes the form q(x,y,z,variable) where variable is an index that refers to the various physical quantities such as density, momentum, energy, etc. in each cell. The order of the quantities in the variable array is dependent on the equation of state, whether or not magnetic fields are being tracked, etc… For 2D hydro (non MHD) the order of the fields is (rho, px, py, E). So if we wanted to set the energy of the cell at integer location i,j,k we would use

Info%q(i,j,k,4) = 1.0

However if we were to change the number of dimensions from 2 to 3, then the order of the fields would be rho, px, py, pz, E and the above statement would not set the energy, but the z momentum to 1.0 and leave the energy unchanged. The solution is to avoid using integer constants for the 4th array index and instead use integer variables that are adjusted based on the equations of state, number of dimensions, etc… These variables are declared in PhysicsDeclarations so we need to also add

USE PhysicsDeclarations

to the top of our module. Then we can set the energy of cell i,j,k regardless of the specifics of our problem by using

Info%q(i,j,k,iE) = 1.0

Also, if we happen to be using an isothermal equation of state, then the energy is no longer stored within the q array and the value of iE is set to 0 to indicate this. So it is generally a good idea to check the value of iE as follows

IF (iE /= 0) Info%q(i,j,k,iE)=1.0

Additional variables used to store slots are:

  • irho - density (always non-zero)
  • ivx - x momentum (always non-zero)
  • ivy - y momentum (non-zero unless 2D, 3D, MHD)
  • ivz - z momentum (non-zero unless 3D, MHD)
  • iE - Energy (non-zero unless isothermal EOS)
  • iBx - x magnetic field (non-zero unless MHD)
  • iBy - y magnetic field (non-zero unless MHD)
  • iBz - z magnetic field (non-zero unless MHD)

There are also two arrays that are sometimes useful as well

  • iB(1:3) = (/iBx, iBy, iBz/)
  • imom(1:3) = (/ivx, ivy, ivz/)

The aux array holds face-centered data, and is only used in MHD problems. If you are running a strictly hydrodynamic problem or a hydrodynamic + elliptic problem, then you will not need aux.


Note: See TracWiki for help on using the wiki.