Peano
Loading...
Searching...
No Matches
aderdg-grmhd.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import peano4, exahype2
4
5from numpy import pi
6
7from GRMHD import max_eigenvalue, flux, ncp
8
9# available_precisions = {
10# "bf16", "fp16", "fp32", "fp64"
11# }
12
13available_scenarios = ["AlfvenWave", "MichelSphericalAccretion"]
14
15parser = exahype2.ArgumentParser("ExaHyPE 2 - ADER-DG GRMHD Testing Script")
16# parser.add_argument("-pr", "--precision", default="fp64", help="|".join(available_precisions))
17parser.add_argument(
18 "-s", "--scenario", default="AlfvenWave", help="|".join(available_scenarios)
19)
20parser.set_defaults(
21 min_depth=1,
22 degrees_of_freedom=6,
23 number_of_snapshots=0,
24)
25args = parser.parse_args()
26
27order = args.degrees_of_freedom - 1
28max_h = 1.1 * 6.0 / (3.0**args.min_depth)
29min_h = max_h * 3.0 ** (-args.amr_levels)
30
31polynomials = exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
32
33if args.scenario == "MichelSphericalAccretion":
34 dimensions = 3
35 offset = [2.2, 2.2, 2.2]
36 size = [6.0, 6.0, 6.0]
37 end_time = 1.0
38 periodic_bc = False
39 function_name = "initialAccretionDisc3D"
40elif args.scenario == "AlfvenWave":
41 dimensions = 2
42 offset = [0.0, 0.0]
43 size = [2 * pi, 2 * pi]
44 end_time = 16.45
45 periodic_bc = True
46 function_name = "AlfvenWaveTest"
47
48if args.build_mode == "Debug":
49 end_time = 0.1
50
51initial = (
52 """
53 GRMHD::InitialData::"""
54 + function_name
55 + """(
56 x, 0.,
57 Q
58 );
59"""
60)
61
62boundary_condition = (
63 """
64 GRMHD::InitialData::"""
65 + function_name
66 + """(
67 x, t,
68 Qoutside
69 );
70"""
71)
72
73analytical_solution = (
74 """
75 GRMHD::InitialData::"""
76 + function_name
77 + """(
78 x, t,
79 solution
80 );
81"""
82)
83
84project = exahype2.Project(
85 namespace=["tests", "exahype2", "aderdg"],
86 project_name=args.scenario,
87 directory=".",
88 executable="ExaHyPE",
89)
90
91solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
92 name="ADERDGSolver",
93 order=order,
94 min_cell_h=min_h,
95 max_cell_h=max_h,
96 time_step_relaxation=0.9,
97 unknowns={
98 "rho": 1,
99 "vel": 3,
100 "E": 1,
101 "B": 3,
102 "psi": 1,
103 "lapse": 1,
104 "shift": 3,
105 "gij": 6,
106 },
107 auxiliary_variables=0, # TODO: true?
108)
109
110solver.add_kernel_optimisations(
111 polynomials=polynomials,
112 is_linear=False,
113 # precision=args.precision
114)
115
116solver.set_implementation(
117 initial_conditions=initial,
118 boundary_conditions=boundary_condition,
119 max_eigenvalue=max_eigenvalue,
120 flux=flux,
121 ncp=ncp,
122)
123
124solver.add_user_solver_includes(
125 """
126#include "InitialData.h"
127#include "PDE.h"
128"""
129)
130
131exahype2.solvers.aderdg.ErrorMeasurement(
132 solver,
133 error_measurement_implementation=analytical_solution,
134 output_file_name="Error_"
135 + args.scenario
136 + "_md_"
137 + str(args.min_depth)
138 + "_o_"
139 + str(order),
140)
141
142project.add_solver(solver)
143
144if args.number_of_snapshots <= 0:
145 time_in_between_plots = 0.0
146else:
147 time_in_between_plots = end_time / args.number_of_snapshots
148 project.set_output_path(args.output)
149
150project.set_global_simulation_parameters(
151 dimensions=dimensions,
152 offset=offset[0:dimensions],
153 size=size[0:dimensions],
154 min_end_time=end_time,
155 max_end_time=end_time,
156 first_plot_time_stamp=0.0,
157 time_in_between_plots=time_in_between_plots,
158 periodic_BC=[periodic_bc, periodic_bc, periodic_bc][0:dimensions],
159)
160
161project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
162project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
163project = project.generate_Peano4_project(verbose=False)
164project.build(make_clean_first=True)