Skip to content

Commit d19a4ee

Browse files
committed
Added order plot for 3D RBC
1 parent 8773225 commit d19a4ee

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

pySDC/projects/GPU/analysis_scripts/RBC3D_order.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def compute_errors(args, dts, Tend):
4242
i = prob.index(comp)
4343
e_comp = np.max(np.abs(e[i])) / np.max(np.abs(ref[i]))
4444
e_comp = MPI.COMM_WORLD.allreduce(e_comp, op=MPI.MAX)
45-
errors[comp].append(e_comp)
45+
errors[comp].append(float(e_comp))
4646
errors['dt'].append(dt)
4747

4848
path = get_path(args)
@@ -52,7 +52,7 @@ def compute_errors(args, dts, Tend):
5252
print(f'Saved errors to {path}', flush=True)
5353

5454

55-
def plot_error_all_components(args):
55+
def plot_error_all_components(args): # pragma: no cover
5656
setup_mpl()
5757
fig, ax = plt.subplots()
5858
with open(get_path(args), 'rb') as file:
@@ -71,7 +71,7 @@ def plot_error_all_components(args):
7171
ax.set_ylabel(r'$e$')
7272

7373

74-
def compare_order(Ra):
74+
def compare_order(Ra): # pragma: no cover
7575
setup_mpl()
7676
fig, ax = plt.subplots(figsize=figsize_by_journal('Nature_CS', 1, 0.6))
7777
ls = {'SD': '-', 'RK': '--', 'Eu': '-.'}
@@ -115,12 +115,13 @@ def run(args, dt, Tend):
115115
config = get_config(args)
116116
config.Tend = n_freefall_times.get(type(config).__name__, 3)
117117

118-
desc = config.get_description()
118+
desc = config.get_description(res=args['res'])
119119
prob = desc['problem_class'](**desc['problem_params'])
120120

121121
ic_config_name = type(config).__name__
122122
for name in ['RK', 'Euler', 'O3', 'O4', 'SDC23', 'SDC34', 'SDC44']:
123-
ic_config_name = ic_config_name.replace(name, '')
123+
ic_config_name = ic_config_name.replace(name, 'SDC34')
124+
124125
ic_config = get_config({**args, 'config': ic_config_name})
125126
config.ic_config['config'] = type(ic_config)
126127
config.ic_config['res'] = ic_config.res

pySDC/projects/GPU/tests/test_RBC_3D_analysis.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def get_config(args):
2626
return config
2727

2828

29-
def generate_simulation_file(path):
29+
def generate_simulation_file(path, args=None):
3030
from pySDC.projects.GPU.run_experiment import run_experiment
3131

32-
args = get_args(path)
32+
args = {**get_args(path), **args} if args is not None else get_args(path)
3333
config = get_config(args)
3434

3535
run_experiment(args, config)
@@ -112,3 +112,24 @@ def _get_Nu(_t):
112112
tI, NuI = interpolate_NuV_to_reference_times(data, ref_data, order=4)
113113
assert not np.allclose(NuI, ref_data['Nu']['V'])
114114
assert np.allclose(tI, ref_data['t'])
115+
116+
117+
def test_order_computation(tmp_sim_data, tmp_path):
118+
from pySDC.projects.GPU.analysis_scripts.RBC3D_order import compute_errors, get_path
119+
from pySDC.projects.GPU.configs.RBC3D_configs import RBC3DG4R4SDC34Ra1e5
120+
import numpy as np
121+
import pickle
122+
123+
args = get_args(tmp_path)
124+
125+
generate_simulation_file(tmp_path, args={'config': args['config'].replace('SDC23', 'SDC34')})
126+
RBC3DG4R4SDC34Ra1e5.res = args['res']
127+
RBC3DG4R4SDC34Ra1e5.dt = args['dt']
128+
129+
dts = [1e-2, 5e-4]
130+
compute_errors(args, dts, np.max(dts))
131+
132+
with open(get_path(args), 'rb') as file:
133+
errors = pickle.load(file)
134+
for comp in ['T', 'p']:
135+
assert max(errors[comp]) < 1e-12

0 commit comments

Comments
 (0)