Skip to content

Commit 1030f7e

Browse files
committed
better testing of (outdated) standard_integrators
1 parent 184b9eb commit 1030f7e

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

pySDC/implementations/problem_classes/acoustic_helpers/standard_integrators.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,10 @@ def __init__(self, M_fast, M_slow, order):
1515
assert np.shape(M_slow)[0] == np.shape(M_slow)[1], "A_slow must be square"
1616
assert np.shape(M_fast)[0] == np.shape(M_slow)[0], "A_fast and A_slow must be of the same size"
1717

18-
assert order in [1, 2, 3, 4, 5], "Order must be between 1 and 5"
18+
assert order in [1, 2, 3, 4, 5], "Order must be between 2 and 5"
1919
self.order = order
2020

21-
if self.order == 1:
22-
self.A = np.array([[0, 0], [0, 1]])
23-
self.A_hat = np.array([[0, 0], [1, 0]])
24-
self.b = np.array([0, 1])
25-
self.b_hat = np.array([1, 0])
26-
self.nstages = 2
27-
28-
elif self.order == 2:
21+
if self.order == 2:
2922
self.A = np.array([[0, 0], [0, 0.5]])
3023
self.A_hat = np.array([[0, 0], [0.5, 0]])
3124
self.b = np.array([0, 1])

pySDC/projects/FastWaveSlowWave/plot_dispersion.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ def findomega(stab_fh):
3434
return sol
3535

3636

37-
def compute_and_plot_dispersion():
37+
def compute_and_plot_dispersion(Nsamples=15, K=3):
38+
"""
39+
Function to compute and plot the dispersion relation
40+
41+
Args:
42+
Nsamples: number of samples for testing
43+
K: number of iterations as well as order
44+
"""
3845
problem_params = dict()
3946
# SET VALUE FOR lambda_slow AND VALUES FOR lambda_fast ###
4047
problem_params['lambda_s'] = np.array([0.0])
@@ -61,9 +68,6 @@ def compute_and_plot_dispersion():
6168
description['level_params'] = level_params # pass level parameters
6269
description['step_params'] = dict() # pass step parameters
6370

64-
# SET NUMBER OF ITERATIONS ###
65-
K = 3
66-
6771
# ORDER OF DIRK/IMEX IS EQUAL TO NUMBER OF ITERATIONS AND THUS ORDER OF SDC ###
6872
dirk_order = K
6973

@@ -83,7 +87,6 @@ def compute_and_plot_dispersion():
8387
nnodes = L.sweep.coll.num_nodes
8488
dt = L.params.dt
8589

86-
Nsamples = 15
8790
k_vec = np.linspace(0, np.pi, Nsamples + 1, endpoint=False)
8891
k_vec = k_vec[1:]
8992
phase = np.zeros((3, Nsamples))

pySDC/projects/FastWaveSlowWave/runmultiscale_acoustic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ def compute_and_plot_solutions():
126126
x_0 = 0.75
127127
# x_1 = 0.25
128128

129+
assert np.isclose(np.linalg.norm(uend[1, :], np.inf), 8.489e-01, 1E-03)
130+
assert np.isclose(np.linalg.norm(pnew_dirk, np.inf), 1.003e+00, 1E-03)
131+
assert np.isclose(np.linalg.norm(pnew_imex, np.inf), 2.762e+21, 1E-03)
132+
129133
print('Maximum pressure in SDC: %5.3e' % np.linalg.norm(uend[1, :], np.inf))
130134
print('Maximum pressure in DIRK: %5.3e' % np.linalg.norm(pnew_dirk, np.inf))
131135
print('Maximum pressure in RK-IMEX: %5.3e' % np.linalg.norm(pnew_imex, np.inf))

pySDC/tests/test_projects/test_fwsw/test_fwsw.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ def test_dispersion():
5252
compute_and_plot_dispersion()
5353
assert os.path.isfile('data/phase-K3-M3.png'), 'ERROR: phase plot has not been created'
5454
assert os.path.isfile('data/ampfactor-K3-M3.png'), 'ERROR: phase plot has not been created'
55+
56+
compute_and_plot_dispersion(Nsamples=3, K=4)
57+
compute_and_plot_dispersion(Nsamples=3, K=5)

0 commit comments

Comments
 (0)