Peano
Loading...
Searching...
No Matches
Gauge wave

The gauge wave is a pure gauge perturbation of flat spacetime: an analytical solution of the Einstein equations which travels along the x-axis with speed one. It is periodic over the unit cube and hence a standard first test of any numerical relativity code. The solution is known exactly, so we can always tell what the numerical error is. If the wave shape or its amplitude changes over time, this is due to numerical effects, and the setup is convenient to assess and compare numerical schemes. The picture above shows the error of the lapse over the mesh size for five schemes. It is the outcome of the convergence study that doubles as the integration test of the numerical schemes (see below).

The script uses exagrype.api, i.e. the first-order CCZ4 solver exagrype.api.FOCCZ4Solver, and discretises it with

  • Finite Volumes with explicit Euler time stepping (--scheme fv),
  • the same with optimistic time stepping (--scheme fv-optimistic), or
  • fourth-order Finite Differences with a Runge-Kutta scheme of order one to four (--scheme rk1fd4, ..., rk4fd4).

Prepare Peano

Peano has to be built with ExaHyPE and ExaGRyPE, i.e. with

--enable-exahype --enable-blockstructured --enable-loadbalancing --enable-exagrype

The generated code is compiled with the compiler of your choice (we use the Intel compiler with its path in PATH), and the Python packages have to be on the Python path (export PYTHONPATH=$PYTHONPATH:../../../src).

Run a simulation

The script has to be told what to do. It requires a build mode and a scheme:

python3 gauge-wave.py --mode release --scheme rk4fd4
python3 gauge-wave.py --mode debug --scheme fv --mesh-size 0.1

Use --help to see all options. --mode release builds an optimised executable and runs until time 1.0; --mode debug builds with assertions and visualises the task graphs. --mesh-size is the edge length h of one grid cell. The default is 1/27, i.e. 3x3x3 mesh cells with patches of 9x9x9 grid cells. The mesh is regular and refined by factors of three, i.e. h is rounded to patch size over 3^k (the patch size can be set via --patch-size, but the root cell is refined at least once). --compiler switches between the task graph compilers (sequential, fusion which is the default, and the producer-consumer variants of both), --end-time, --threads and --directory do what they say.

The script generates the C++ code, the Makefile, and compiles the executable. Run the executable gauge-wave afterwards. To get rid of all the generated files, remove the directories celldata facedata globaldata observers tasks vertexdata repositories, the Abstract* files, the Makefile and all *.o files. You can recreate them any time by rerunning the Python script.

Convergence study (integration test)

The script convergence-study.py builds and runs the benchmark for all schemes fv, rk1fd4, ..., rk4fd4 and for the volume sizes h=1/9, 1/27 and 1/81 (patch size 9; the coarsest mesh needs patches of size 3, as Peano refines the root cell at least once) until time t=0.1. It records the maximum error of the lapse along the line y=z=0.5 in the last snapshot against the exact solution

\[ \alpha (x,t) = \sqrt{1 - A \sin (2 \pi (x-t))}, \quad A=0.1, \]

estimates the convergence order p ~ log(e(3h)/e(h))/log(3), and exits with a non-zero status if the order between the two finest meshes of a scheme falls below a threshold. It is run via the skill exahype2:integration-test (see documentation/exahype2/integration-test/SKILL.md). Whenever you change a numerical scheme, the task graph, the kernels or the code generation, this is the test to rerun.

scheme h = 1/9 h = 1/27 order h = 1/81 order
fv 1.58e-2 6.59e-3 0.79 2.34e-3 0.94
rk1fd4 1.09e-3 3.37e-4 1.06 1.10e-4 1.02
rk2fd4 1.46e-4 3.01e-6 3.53 2.39e-7 2.31
rk3fd4 1.39e-4 2.70e-6 3.59 3.34e-8 4.00
rk4fd4 1.39e-4 2.71e-6 3.58 3.39e-8 3.99

What we see:

  • The Finite Volume scheme is first order, as expected. Its error is orders of magnitude above the one of the Finite Difference schemes, which discretise in space with fourth order.
  • The order of the Finite Difference schemes is the smaller one of the spatial order (four) and the order of the time integration. With one Runge-Kutta stage (explicit Euler), the time integration error dominates from the coarsest mesh on, and the scheme is first order. As the time step size shrinks with the mesh size (CFL condition), the time error is tiny for higher orders on coarse meshes: rk2fd4, rk3fd4 and rk4fd4 yield the same error on the two coarsest meshes, and rk2fd4 leaves the fourth-order regime as soon as its second-order time error becomes visible (order 2.3 between 1/27 and 1/81). Rk3fd4 and rk4fd4 show the full fourth order.
  • The estimated orders on the coarsest meshes are not asymptotic: The wave is barely resolved with 9 volumes per wave length.
  • The error is measured at the last snapshot, whose time stamp overshoots the end time by less than one time step and differs between meshes. This biases the orders by about 0.01.
  • The study ran on an eight-core workstation. The finest meshes are the limit of what fits into 16 GB of memory: A Finite Difference run with 81 volumes per axis needs 2 to 3 GB, and the memory grows with the number of volumes, i.e. h=1/243 needs 27 times more and does not fit (the study tried and the runs were killed). The finest mesh, h=1/81, took between 3 and 11 minutes with two threads. These numbers are recorded in the table of the script, but they are not an acceptance criterion; the (to-be-written) skill exahype2:performance-test is supposed to cover that.

Postprocess/visualise the results

The convergence study uses --plot-along-x-axis, which restricts the output to the patches along the line y=z=0.5 and writes them with ten digits. Without this option, the code writes the whole solution as Peano patch files every 0.1 time units. You can convert them into vtk and visualise them via Paraview:

pvpython ../../../python/peano4/visualisation/render.py --filter-fine-grid solution-CCZ4.peano-patch-file