Peano
Loading...
Searching...
No Matches
fo_vs_so Namespace Reference

First-order vs. More...

Functions

 directory_of (scheme, formulation, cells)
 build (scheme, formulation, cells)
 Generate and build one solver on one grid in its own directory.
 run (scheme, formulation, cells)
 Run the executable built by build() and store its wall time.
 snapshot (scheme, formulation, cells, unknowns, snapshot_index=-1)
 Return the unknowns of one snapshot of one solver.
 gauge_wave_lapse (x, t)
 Analytical lapse, see exagrype.initialvalues.gaugeWave().
 compare_one (scheme, cells, verbose)
 Compare FO and SO on one grid.
 compare_single (scheme, formulation, cells)
 Summarise one formulation on one grid against the analytical lapse.
 compare ()

Variables

 parser = argparse.ArgumentParser(description="First-order vs. second-order CCZ4")
 choices
 default
 help
 type
 float
 arguments = parser.parse_args()
 schemes = arguments.schemes
 formulations = arguments.formulations
 build_mode = peano4.api.output.CompileMode.RELEASE
 verbosity = peano4.api.LoggerVerbosity.OFF
 grid_sizes = arguments.sizes
 end_time = arguments.end_time
float time_in_between_plots = end_time / 2.0
int patch_size = 9

Detailed Description

First-order vs.

second-order reconstructed CCZ4: gauge wave benchmark

This is the gauge wave benchmark (Gauge wave) with the fourth-order Finite Differences (exahype2.api.rkfd4), but we instantiate two solvers in one setup: exagrype.api.FOCCZ4Solver, which evolves all 58 CCZ4 unknowns, and exagrype.api.FOSOCCZ4Solver, which evolves 25 of them and obtains the 33 first derivatives from the exagrype.api.FOSOReconstructionSolver next to it (both are hosted by an exagrype.api.FOSOSolver). Both solvers use the same Runge-Kutta scheme, the same lopsided advection and no dissipation. The two do not yield identical results: The first-order solver evolves the derivatives as unknowns, whereas the second-order solver re-computes them from the 25 unknowns in each Runge-Kutta stage. The script builds and runs the code, and then quantifies the difference of the 25 evolved unknowns of both solvers, and the deviation of both from the analytical solution of the gauge wave.

Two exahype2.api.rkfd4 solvers cannot live in one project yet, as both generate the solver-independent kernel rungekutta_linear_combination into the same file (page_exagrype_fo_so_project_plan). The script therefore builds and runs each solver on its own, in a directory of its own (run-FO and run-SO), and then compares the plot files.

The gauge wave is a pure gauge perturbation of flat spacetime, i.e. an analytical solution of the Einstein equations that 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. This script uses exagrype.api, i.e. the CCZ4 solvers of the new Python API. It requires a Peano build with

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

and is run from this directory via

python3 fo_vs_so.py

Schemes, formulations and grid sizes

The benchmark covers two numerical schemes:

  • RK4FD4: fourth-order Finite Differences with classic Runge-Kutta 4 and lopsided advection (exahype2.api.rkfd4.CentralDifferencesWithRungeKutta). The second-order solver reconstructs the derivatives with the fourth-order stencil in each Runge-Kutta stage.
  • RK1FD4: the same spatial discretisation, but with first-order Runge-Kutta (explicit Euler, rk_order=1), i.e. one stage per time step.
  • FV: Finite Volumes with a Rusanov flux and explicit Euler (exahype2.api.fv.RusanovWithExplicitEuler). The second-order solver reconstructs the derivatives with second-order central differences once per time step. Neither advection nor dissipation are used, which is fine as the shift of the gauge wave is zero.

Each of the two comes in the formulations FO (exagrype.api.FOCCZ4Solver) and SO (exagrype.api.FOSOCCZ4Solver). The grid has cells x cells x cells grid points (patch size 9 and 3^k patches per axis, i.e. cells is 27, 81, ... (Peano refines to at least three patches per axis)). The grid size is compiled into the executable, so each combination is built in a directory of its own (run-scheme-formulation-cells).

python3 fo_vs_so.py                         # same as --mode=run-and-compare
python3 fo_vs_so.py --mode=build            # generate and compile all combinations
python3 fo_vs_so.py --mode=run              # generate, compile and run all combinations
python3 fo_vs_so.py --mode=run-and-compare  # run, then print the table
python3 fo_vs_so.py --mode=compare-only     # re-print the table from existing runs

The script loops sequentially, within one Python process, over all schemes, grid sizes and formulations.

The option –build-mode=debug|release selects the build (default release; debug also enables the generator logging). –schemes (default RK4FD4,RK1FD4,FV), –formulations (default FO,SO; with just one, the comparison table lists the lapse error and wall time of that formulation only), –sizes (default 27,81), –end-time (default 0.1) and –cfl (CFL constant of the Finite Volume scheme, default 0.9) override the remaining settings.

Function Documentation

◆ build()

fo_vs_so.build ( scheme,
formulation,
cells )

Generate and build one solver on one grid in its own directory.

Parameters
schemestr RK4FD4, RK1FD4 or FV.
formulationstr FO or SO.
cellsint Grid points per axis. Has to be a multiple of the patch size.

Definition at line 264 of file fo_vs_so.py.

References directory_of(), and exagrype.api.initialvalues.gauge_wave().

Referenced by compare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare()

fo_vs_so.compare ( )

Definition at line 529 of file fo_vs_so.py.

References build(), compare(), compare_one(), compare_single(), and run().

Referenced by compare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_one()

fo_vs_so.compare_one ( scheme,
cells,
verbose )

Compare FO and SO on one grid.

Returns
dict Summary numbers, or None if one of the runs is missing.

Definition at line 451 of file fo_vs_so.py.

References directory_of(), float, gauge_wave_lapse(), and snapshot().

Referenced by compare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_single()

fo_vs_so.compare_single ( scheme,
formulation,
cells )

Summarise one formulation on one grid against the analytical lapse.

Used if only one of FO and SO is built, i.e. there is nothing to compare it to.

Returns
dict Summary numbers, or None if the run is missing.

Definition at line 500 of file fo_vs_so.py.

References directory_of(), float, gauge_wave_lapse(), and snapshot().

Referenced by compare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ directory_of()

fo_vs_so.directory_of ( scheme,
formulation,
cells )

Definition at line 260 of file fo_vs_so.py.

Referenced by build(), compare_one(), compare_single(), run(), and snapshot().

Here is the caller graph for this function:

◆ gauge_wave_lapse()

fo_vs_so.gauge_wave_lapse ( x,
t )

Analytical lapse, see exagrype.initialvalues.gaugeWave().

Definition at line 446 of file fo_vs_so.py.

Referenced by compare_one(), and compare_single().

Here is the caller graph for this function:

◆ run()

fo_vs_so.run ( scheme,
formulation,
cells )

Run the executable built by build() and store its wall time.

Parameters
schemestr RK4FD4, RK1FD4 or FV.
formulationstr FO or SO.
cellsint Grid points per axis.

Definition at line 368 of file fo_vs_so.py.

References directory_of().

Referenced by compare().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ snapshot()

fo_vs_so.snapshot ( scheme,
formulation,
cells,
unknowns,
snapshot_index = -1 )

Return the unknowns of one snapshot of one solver.

Parameters
schemestr RK4FD4, RK1FD4 or FV.
formulationstr FO or SO.
cellsint Grid points per axis.
unknownsint Number of unknowns per grid point in the plot file
snapshot_indexint Index of the snapshot, -1 is the last one.
Returns
time stamp, values, positions The values and the x coordinates of the grid points, both sorted by the offset of the patches. Values has one row per grid point.

Definition at line 393 of file fo_vs_so.py.

References directory_of().

Referenced by compare_one(), and compare_single().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ arguments

fo_vs_so.arguments = parser.parse_args()

Definition at line 238 of file fo_vs_so.py.

◆ build_mode

fo_vs_so.build_mode = peano4.api.output.CompileMode.RELEASE

Definition at line 249 of file fo_vs_so.py.

◆ choices

fo_vs_so.choices

Definition at line 199 of file fo_vs_so.py.

◆ default

fo_vs_so.default

Definition at line 200 of file fo_vs_so.py.

◆ end_time

fo_vs_so.end_time = arguments.end_time

Definition at line 255 of file fo_vs_so.py.

◆ float

fo_vs_so.float

Definition at line 234 of file fo_vs_so.py.

Referenced by compare_one(), and compare_single().

◆ formulations

fo_vs_so.formulations = arguments.formulations

Definition at line 240 of file fo_vs_so.py.

◆ grid_sizes

fo_vs_so.grid_sizes = arguments.sizes

Definition at line 254 of file fo_vs_so.py.

◆ help

fo_vs_so.help

Definition at line 201 of file fo_vs_so.py.

◆ parser

fo_vs_so.parser = argparse.ArgumentParser(description="First-order vs. second-order CCZ4")

Definition at line 196 of file fo_vs_so.py.

◆ patch_size

int fo_vs_so.patch_size = 9

Definition at line 257 of file fo_vs_so.py.

◆ schemes

fo_vs_so.schemes = arguments.schemes

Definition at line 239 of file fo_vs_so.py.

◆ time_in_between_plots

float fo_vs_so.time_in_between_plots = end_time / 2.0

Definition at line 256 of file fo_vs_so.py.

◆ type

fo_vs_so.type

Definition at line 212 of file fo_vs_so.py.

◆ verbosity

fo_vs_so.verbosity = peano4.api.LoggerVerbosity.OFF

Definition at line 250 of file fo_vs_so.py.