Subsections


19.4 Usage

To include the effects of gravity in your FLASH executable, include the option

-with-unit=physics/Gravity
on your command line when you configure the code with setup. The default implementation is Constant, which can be overridden by including the entire path to the specific implementation in the command line or Config file. The other available implementations are Gravity/GravityMain/Planepar, Gravity/GravityMain/Pointmass and Gravity/GravityMain/Poisson. The Gravity unit provides accessor functions to get gravitational acceleration and potential. However, none of the external field implementations of Section Sec:GravityExternal explicitly compute the potential, hence they inherit the null implementation from the API for accessing potential. The gravitation acceleration can be obtained either on the whole domain, a single block or a single row at a time.

When building an application that solves the Possion equation for the gravitational potential, additional storage is needed in unk for holding the last, as well as (usually) the previous, gravitational potential field; and, depending on the Poisson solver used, additional variables may be needed. The variables GPOT_VAR and GPOT_VAR, and others as needed, will be automatically defined in Flash.h in those cases. See Gravity_potentialListOfBlocks for more information.


19.4.1 Tree Gravity Unit Usage

Calculation of gravitational potential can be enabled by compiling in this unit and setting the runtime parameter useGravity true. The constant of gravity can be set independently by runtime parameter grv_bhNewton; if it is not positive, the constant Newton from the FLASH PhysicalConstants database is used. If parameters gr_bhPhysMACTW or gr_bhPhysMACComm are set, the gravity unit MAC is used and it can be chosen by setting grv_bhMAC to either ApproxPartialErr or MaxPartialErr. If the first one is used, the order of the multipole approximation is given by grv_bhMPDegree.

The maximum allowed partial error in gravitational acceleration is set with the runtime parameter grv_bhAccErr. It has either the meaning of an error in absolute acceleration or in relative acceleration normalized by the acceleration from the previous time-step. The latter is used if grv_bhUseRelAccErr is set to True, and in this case the first call of the tree solver calculates the potential using purely geometrical MAC (because the acceleration from the previous time-step does not exist).

Boundary conditions are set by the runtime parameter grav_boundary_type and they can be isolated, periodic or mixed. In the case of mixed boundary conditions, runtime parameters grav_boundary_type_x, grav_boundary_type_y and grav_boundary_type_z specify along which coordinate boundary conditions are periodic and isolated (possible values are periodic or isolated). Arbitrary combination of these values is permitted, thus suitable for problems with planar resp. linear symmetry. It should work for computational domain with arbitrary dimensions. The highest accuracy is reached with blocks of cubic physical dimensions.

If runtime parameter grav_boundary_type is periodic or mixed, then the Ewald field for appropriate symmetry is calculated at the beginning of the simulation. Parameter grv_bhEwaldSeriesN controls the range of indices $ i_1,i_2,i_3$ in (eq. 19.13). There are two implementations of the Ewald method: the new one (default) requires less memory and it should be faster and of comparable accuracy as the old one. The default implementation computes Ewald field minus the singular $ 1/r$ term and its partial derivatives on a single cubic grid, and the Ewald field is then approximated by the first order Taylor formula. Parameter grv_bhEwaldNPer controls number of grid points in the $ x$ direction in the case of periodic or in periodic direction(s) in the case of mixed boundary conditions. Since an elongated computational domain is often desired when grav_boundary_type is mixed, the cubic grid would lead to a huge field of data. In this case, the amount of necessary grid points is reduced by using an analytical estimate to the Ewald field sufficiently far away of the symmetry plane or axis.

The old implementation (from Flash4.2) is still present and is enabled by adding bhtreeEwaldV42=1 on the setup command line. The Ewald field is then stored in a nested set of grids, the first of them corresponds in size to full computational domain, and each following grid is half the size (in each direction) of the previous grid. Number of nested grids is controlled by runtime parameter grv_bhEwaldNRefV42. If grv_bhEwaldNRefV42 is too low to cover origin (where is the Ewald field discontinuous), then the run is terminated. Each grid is composed of grv_bhEwaldFieldNxV42 $ \times$ grv_bhEwaldFieldNyV42 $ \times$ grv_bhEwaldFieldNzV42 points. When evaluation of the Ewald Field at particular point is needed at any time during a run, the field value is found by interpolation in a suitable level of the grid. Linear or semi-quadratic interpolation can be chosen by runtime parameter grv_bhLinearInterpolOnlyV42 (option true corresponds to linear interpolation). Semi-quadratic interpolation is recommended only in the case when there are periodic boundary conditions in two directions.

The external gravitational field can be switched on by setting grv_useExternalPotential true. The parameter grv_bhExtrnPotFile gives the name of the file with the external potential and grv_bhExtrnPotType specifies the field symmetry: spherical for the spherical symmetry and planez for the planar symmetry with field being a function of the z-coordinate. Parameters grv_bhExtrnPotCenterY, grv_bhExtrnPotCenterX and grv_bhExtrnPotCenterZ specify the position (in the simulation coordinate system) of the external field origin (the point where the radial or z-coordinate is zero).


Table 19.1: Tree gravity unit parameters controlling the accuracy of calculation.
Variable Type Default Description
grv_bhNewton real -1.0 constant of gravity; if $ <$ 0, it is obtained
from internal physical constants database
grv_bhMAC string "ApproxPartialErr" MAC, other option: "MaxPartialErr"
grv_bhMPDegree integer 2 degree of multipole in error estimate in APE MAC
grv_bhUseRelAccErr logical .false. if .true., grv_bhAccErr has meaning of
relative error, otherwise absolute
grv_bhAccErr real 0.1 maximum allowed error in gravitational
acceleration


Table 19.2: Tree gravity unit parameters controlling the boundary conditions.
Variable Type Default Description
grav_boundary_type string "isolated" or "periodic" or "mixed"
grav_boundary_type_x string "isolated" or "periodic"
grav_boundary_type_y string "isolated" or "periodic"
grav_boundary_type_z string "isolated" or "periodic"
grv_bhEwaldAlwaysGenerate boolean true whether Ewald field should be regenerated
grv_bhEwaldSeriesN integer $ 10$ number of terms in the Ewald series
grv_bhEwaldNPer integer 32 number of points+1 of the Taylor expansion
grv_bhEwaldFName string "ewald_coeffs" file with coefficients of the Ewald field Taylor expansion
grv_bhEwaldFieldNxV42 integer $ 32$ size of the Ewald field grid in x-direction
grv_bhEwaldFieldNyV42 integer $ 32$ size of the Ewald field grid in y-direction
grv_bhEwaldFieldNzV42 integer $ 32$ size of the Ewald field grid in z-direction
grv_bhEwaldNRefV42 integer -1 number of refinement levels (nested grids) for the Ewald
field; if $ <$ 0, determined automatically
grv_bhLinearInterpolOnlyV42 logical .true. if .false., semi-quadratic interpolation is used for
interpolation in the Ewald field
grv_bhEwaldFNameAccV42 string "ewald_field_acc" file with the Ewald field for acceleration
grv_bhEwaldFNamePotV42 string "ewald_field_pot" file with coefficients of the Ewald field for potential

Tree gravity unit parameters controlling the external gravitational field.

Variable Type Default Description
grv_bhUseExternalPotential logical .false. whether to use external field
grv_bhUsePoissonPotential logical .true. whether to use gravitational field calculated by the
tree solver
grv_bhExtrnPotFile string "external_potential.dat" file containing the external gravitational field
grv_bhExtrnPotType string "planez" type of the external field: planar or spherical symmetry
grv_bhExtrnPotCenterX real 0.0 x-coordinate of the center of the external field
grv_bhExtrnPotCenterY real 0.0 y-coordinate of the center of the external field
grv_bhExtrnPotCenterZ real 0.0 z-coordinate of the center of the external field