Peano
Loading...
Searching...
No Matches
First-order vs hybrid First-order second-order CCZ4 formulation

This page has yet to be written.

See the benchmark benchmarks/exagrype/fo_vs_so. It runs the gauge wave with both solvers and prints the maximum and relative L2 difference of the 25 evolved unknowns at the end of the run.

Setup (python3 fo_vs_so.py, i.e. release build, end time 0.1): gauge wave on the periodic unit cube, 27 grid points per axis (patch size 9, 3 patches per axis), fourth-order Finite Differences with classic Runge-Kutta 4 and lopsided advection, no dissipation, adaptive time step size (CFL), end time 0.1 (about 33 time steps). Both solvers use the same numerical scheme. We compare the 25 evolved unknowns at the end of the run. The last column shows how far the first-order solution moved away from its initial condition, i.e. the scale of the dynamics.

unknown max abs. difference SO vs. FO relative L2 difference max abs. change of FO in the run
G (xx, yy, zz) 7.6e-6 / 4.1e-6 / 4.1e-6 3.4e-6 / 1.8e-6 / 1.8e-6 4.2e-2 / 2.1e-2 / 2.1e-2
K (xx, yy, zz) 7.7e-5 / 4.1e-5 / 4.1e-5 2.3e-4 1.4e-1 / 7.9e-2 / 7.9e-2
lapse 2.5e-6 1.0e-6 3.1e-2
phi 2.0e-6 8.7e-7 1.1e-2
Kex 1.3e-4 2.4e-4 2.3e-1
Z (x) 5.0e-5 7.7e-5 3.1e-1
theta 3.6e-5 (not meaningful) 1.9e-5
all others (off-diagonals, shift, b, Z_y, Z_z) 0 0 0

Reading the table. The two solvers agree to 1e-6 to 1e-4 in absolute terms, which is two to four orders of magnitude below the change of the solution within the run. The metric, the lapse and phi agree best (relative 1e-6), the extrinsic curvature and its trace worst (relative 2e-4). The remaining entries are identically zero for both (the gauge wave does not excite them). Theta (a measure of the Hamilton constraint violation) is tiny in the first-order run (it changes by 1.9e-5 at most), and the two solvers differ by 3.6e-5, i.e. by more than the first-order solver's theta moves. The relative difference is therefore not meaningful. We have no reference solution for theta yet, so we cannot say which solver is closer to the truth.

Caveats. One resolution, one end time, one test case. The comparison measures how close SO is to FO, not how accurate either of them is. A convergence study against the analytical gauge wave (Gauge wave), a longer run, and a black hole run are still missing.

Cost. In the release build with 8 OpenMP threads (machine shared with other jobs, so treat with care), one reported TimeStep phase took about 0.15 s for the first-order solver and about 0.21 s for the second-order solver on this mesh, i.e. SO is about 40% slower per step. This is expected: SO reconstructs the derivatives in an extra mesh sweep per Runge-Kutta stage, exchanges an extra halo of 33 values per stage, and gathered/scattered the 58 entries in every PDE term evaluation (it does not anymore, the kernels take the primary and the secondary entries as two pointers). We did not profile it. SO stores fewer values per stage (25 instead of 58 for the stage input, the right-hand-side estimates and the halo patch). A first, finer run (729 patches of 9^3 points) was killed by the operating system for the first-order solver (out of memory, 15 GB machine shared with other processes), while the second-order solver ran through with a resident set of about 3.5 GB. This is an observation, not a measurement.

Grid sizes and Finite Volumes

The benchmark script now takes the scheme (RK4FD4, RK1FD4 or FV), the formulation (FO or SO) and the grid size (python3 fo_vs_so.py, --build-mode=debug for debug builds). Peano refines to at least three patches per axis and then in powers of three, and a patch has 9 points per axis, i.e. valid grids are 27^3 and 81^3 points (a first attempt with 9, 18 and 45 points silently ran on the next larger grid). Setup otherwise as above: gauge wave, periodic unit cube, RK4 with lopsided advection, end time 0.1 (the last step overshoots, the time stamp is given). We also compare the lapse of both solvers against the analytical lapse \( \sqrt{1-0.1\sin(4\pi(x-t))} \). The wall time is the one of the whole run (setup, plots and about 33 (27^3) or 100 (81^3) time steps; machine shared with other jobs, 8 threads, treat with care).

scheme grid t max abs. diff. SO vs. FO (25 unknowns) max abs. diff. of the lapse rel. L2 lapse error FO rel. L2 lapse error SO wall time FO wall time SO
RK4FD4 27^3 0.102 1.3e-4 2.5e-6 1.1e-6 1.6e-6 4.8 s 5.6 s
RK4FD4 81^3 0.101 1.6e-6 3.1e-8 1.4e-8 2.2e-8 300 s 377 s

Reading the table. The 27^3 row reproduces the numbers of the first table (the largest difference is the one of Kex). Refining the grid by a factor of three reduces the difference between the two solvers by a factor of about 80, and the error of each solver against the analytical lapse by about 80 (FO) and 75 (SO), i.e. \( 3^4 \): both formulations converge with fourth order, and the SO solver stays within a factor of 1.5 of the first-order solver's error. On the finer grid, SO is about 25% slower than FO per run (about 15% on the 27^3 grid, where setup and plots matter more).

Finite Volumes

The FV variant (second-order central differences, one reconstruction task per step) builds, generates and runs, but we could not obtain a meaningful FV comparison. The reason is not the reconstruction: the Finite Volume time step kernel in 3d that exahype2.api.fv.RusanovWithExplicitEuler generates contains neither the non-conservative product, the source, nor the maximum eigenvalue. The kernel template guards these blocks with if nonconservativeProduct:, if volumetricSource:, if maxEigenvalue: (and if flux:), but the DSL parser compares the guard with the class names of the PDE terms (NonconservativeProduct, VolumetricSource, MaxEigenvalue, Flux, see exahype2.api.dslhype2.Parser._parse_if()), so the blocks are dropped. The generated kernel then only applies the Rusanov diffusion to the unknowns, and it never writes the maximum eigenvalue of the cell, so the global time step size is derived from uninitialised memory (time step sizes of 1e-280 or infinity after a few steps, for the first-order solver as well). This is a generic Finite Volume issue, independent of CCZ4, and it is why the FV runs of both formulations "worked" with an error of about 2e-2 against the analytical lapse (diffusion only) or broke down after a few steps. The fix is a rename in the kernel template (2d and 3d); it has not been applied, as it is outside of the files of this project. Once done, rerun python3 fo_vs_so.py and add the FV rows here.