3@page benchmarks_exagrype_gauge_wave_with_scalar_field Gauge wave with a scalar field
7The gauge wave is a pure gauge perturbation of flat spacetime, i.e. an analytical solution of the
8Einstein equations that travels along the x-axis with speed one. It is periodic over the unit cube.
9This script evolves it with the first-order CCZ4 solver of exagrype.api (exagrype.api.FOCCZ4Solver).
10Next to CCZ4, it hosts four scalar fields which the spacetime advects
11(exagrype.api.scalarfield.ScalarField)
13@f$ \partial_t \phi + \alpha^2 \partial_x \phi = 0, @f$
15with the lapse @f$ \alpha @f$ of CCZ4 (the metric component g_xx of the gauge wave is @f$ \alpha^2 @f$).
16The coupling is a fake coupling: the spacetime advects the field, but the field does not feed back.
17The equation has a closed-form solution on the gauge wave, so the benchmark measures the
18error of the scalar field against the exact solution (see convergence-study.py).
22The coupling decides how the time integrators of the two solvers interact:
24- `--coupling outer-multiplicative`: each solver has its numerical scheme. CCZ4 completes its time
25 step, then the scalar field performs its step with the frozen spacetime of the end of the step
26 (exagrype.api.scalarfield.CCZ4WithScalarField_OuterMultiplicativeCoupling).
27 The scalar field is first order in the time step size, whatever the order of the time integrators is.
28- `--coupling inner-additive` and `--coupling inner-multiplicative`: one numerical scheme for both
29 solvers (a "generator" which one assigns to the coupled solver
30 exagrype.api.scalarfield.CCZ4WithScalarField_InnerCoupling). The solvers exchange data in
31 each stage of the time integrator, i.e. the scalar field sees the spacetime of the time level of its stage. The scalar field has the
32 order of the time integrator (four for `rk4fd4`). Additive: the stages of the solvers run in parallel.
33 Multiplicative: in each stage, the scalar field follows CCZ4.
35The numerical scheme (`--scheme`) is the same for both solvers: `fv` (Finite Volumes, explicit Euler)
36or `rk1fd4`, ..., `rk4fd4` (fourth-order Finite Differences with Runge-Kutta of order one to four).
37benchmarks/exagrype/gauge-wave-with-scalar-field/DESIGN.md documents the design.
41The script requires a Peano build with
43 --enable-exahype --enable-blockstructured --enable-loadbalancing --enable-exagrype
45and is run from this directory via
47 python3 gauge-wave-with-scalar-field.py --mode release --scheme rk4fd4 --coupling inner-additive
48 python3 gauge-wave-with-scalar-field.py --mode debug --scheme fv --coupling outer-multiplicative --mesh-size 0.1
50The debug mode visualises the task graphs. The script convergence-study.py runs all couplings
51over several mesh sizes, and estimates the convergence orders.
63parser = argparse.ArgumentParser(description=
"ExaGRyPE gauge wave with a scalar field")
66 choices=[
"release",
"debug"],
68 help=
"Build mode of the generated code. Release uses a longer simulation "
69 "and text logging; debug a very short one with visualised logging.",
73 choices=[
"fv",
"rk1fd4",
"rk2fd4",
"rk3fd4",
"rk4fd4"],
75 help=
"Numerical scheme of both solvers: Finite Volumes with explicit Euler (fv), or "
76 "fourth-order Finite Differences with Runge-Kutta of order 1 to 4 (rk1fd4, ..., rk4fd4).",
80 choices=[
"outer-multiplicative",
"inner-additive",
"inner-multiplicative"],
82 help=
"How the time integrators of CCZ4 and the scalar field interact.",
88 help=
"Edge length h of one volume or grid cell (default: 1/27, i.e. 3x3x3 mesh cells "
89 "with patches of 9x9x9 cells). The mesh is regular and is refined by factors of three "
90 "from the root cell, i.e. h is rounded to patch-size/3^k.",
96 help=
"Number of grid cells per patch and axis (default: 9). Peano refines the root "
97 "cell at least once, i.e. h can be at most patch-size/3.",
103 help=
"Final simulation time (default: 1.0 for release, 0.02 for debug)",
108 help=
"Directory for the generated code, its build and the outputs (default: the current directory)",
114 help=
"Number of threads of the generated executable (default: all cores)",
117 "--plot-along-x-axis",
119 help=
"Restrict the plots to the patches along the line y=z=0.5 and write them "
120 "with ten digits. Needed to measure the error of the scalar field, see convergence-study.py. "
121 "Four plots per simulation are written.",
123args = parser.parse_args()
129volume_size = 1.01 * args.mesh_size
131if args.mode ==
"release":
132 build_mode = peano4.api.output.CompileMode.RELEASE
134 time_in_between_plots = 0.1
135 verbosity = peano4.api.LoggerVerbosity.TEXT
137 build_mode = peano4.api.output.CompileMode.DEBUG
139 time_in_between_plots = 0.01
140 verbosity = peano4.api.LoggerVerbosity.VISUALISATION
142if args.end_time
is not None:
143 end_time = args.end_time
144if args.plot_along_x_axis:
145 time_in_between_plots = end_time / 4.0
147patch_size = args.patch_size
148finite_volumes = args.scheme ==
"fv"
149rk_order =
None if finite_volumes
else int(args.scheme[2])
154 namespace=[
"benchmarks",
"exagrype",
"gaugewavewithscalarfield"],
155 project_name=
"gauge-wave-with-scalar-field",
156 directory=args.directory,
157 executable=
"gauge-wave-with-scalar-field",
161if args.coupling ==
"outer-multiplicative":
162 coupled = scalarfield.CCZ4WithScalarField_OuterMultiplicativeCoupling()
163 for solver
in coupled.solvers:
171 Kernel = Scheme.RightHandSideKernel
172 if solver
is coupled.ccz4:
173 solver.numerical_scheme =
Scheme(
177 right_hand_side_kernel=Kernel.CentralDifferencesWithLopsidedAdvection,
178 advection_velocity=exagrype.api.FOCCZ4Solver.ADVECTION_VELOCITY,
179 advected_quantities=solver.lopsided_advection_quantities(),
182 solver.numerical_scheme =
Scheme(solver, patch_size, rk_order=rk_order)
184 coupled = scalarfield.CCZ4WithScalarField_InnerCoupling()
186 multiplicative = args.coupling ==
"inner-multiplicative"
189 scalarfield.FiniteVolumesInnerMultiplicative
191 else scalarfield.FiniteVolumesInnerAdditive
193 coupled.numerical_scheme =
Generator(patch_size)
196 scalarfield.RungeKuttaFD4InnerMultiplicative
198 else scalarfield.RungeKuttaFD4InnerAdditive
200 coupled.numerical_scheme =
Generator(patch_size, rk_order)
203scalar_field = coupled.scalar_field
206plotter_arguments = {}
207if args.plot_along_x_axis:
208 plotter_arguments[
"plotter_precision"] = 10
209for solver
in coupled.solvers:
210 solver.grid_construction = flavour.SetupSimulationOverRegularGrid(
211 solver, volume_size=volume_size
213 solver.plotter = flavour.PlotAsVTKFile(
215 first_plot_time_stamp=0.0,
216 time_in_between_plots=time_in_between_plots,
219 if args.plot_along_x_axis:
220 solver.plotter.add_plot_filter([0.0, 0.49, 0.49], [1.0, 0.02, 0.02])
222project.add_solver(coupled)
224project.compiler = peano4.api.taskgraph.compiler.FuseSteps.translate
226project.set_global_simulation_parameters(
228 offset=[0.0, 0.0, 0.0],
229 size=[1.0, 1.0, 1.0],
230 min_end_time=end_time,
231 max_end_time=end_time,
232 periodic_BC=[
True,
True,
True],
235if args.threads
is not None:
236 project.set_number_of_threads(args.threads)
238PeanoRoot = os.path.abspath(
239 os.path.join(os.path.dirname(os.path.abspath(__file__)),
"..",
"..",
"..")
241project.set_Peano4_installation(PeanoRoot, build_mode)
242peano4_project = project.generate_Peano4_project(verbosity=verbosity)
243peano4_project.generate()
244peano4_project.build(make_clean_first=
True)
Finite Volumes with a Rusanov Riemann solver and explicit Euler time stepping, realised over a block-...
Fourth-order central Finite Differences with explicit Runge-Kutta time stepping, realised over a bloc...
exahype2.api.InitPointWisely gauge_wave()
Gauge wave along the x-axis,.
This file is part of the ExaGRyPE project.
This file is part of the ExaGRyPE project.
Fourth-order Finite Differences with explicit Runge-Kutta time stepping over block-structured meshes.