Skip to content

Commit 8163321

Browse files
committed
added option to generate pseudo-spectrum plot and convergence plot using the high(er) order upwind finite difference stencils investigated in the paper by DeSterck et al., 2021, NLAA
1 parent c0b7c01 commit 8163321

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

scripts/pseudo-spectrum/figure_13-16.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from solution_dedalus import solution_dedalus
1313
from solution_linear import solution_linear
1414

15-
from get_matrix import get_upwind, get_centered, get_diffusion
15+
from get_matrix import get_upwind, get_centered, get_diffusion, get_desterck
1616
from impeuler import impeuler
1717
from intexact import intexact
1818
from trapezoidal import trapezoidal
@@ -29,9 +29,9 @@
2929
except:
3030
print("No or wrong command line argument provided, creating figure 13. Use 13, 14, 15 or 16 as command line argument.")
3131
figure = 5
32-
assert 13<= figure <= 16 or figure==0, "Figure should be 13, 14, 15 or 16"
32+
assert 13<= figure <= 16 or figure==0 or figure==-1, "Figure should be 13, 14, 15 or 16"
3333

34-
if figure==13 or figure==14 or figure==0:
34+
if figure==13 or figure==14 or figure==0 or figure==-1:
3535
par = parameter(dedalus = False)
3636
ndof_c = 24
3737
elif figure==15:
@@ -91,7 +91,19 @@
9191
para = parareal(0.0, Tend, nslices, impeuler, impeuler, nfine, ncoarse, tol, maxiter, u0fine, u0coarse)
9292
filename = 'figure_00.pdf'
9393
D = A_f*A_f.H - A_f.H*A_f
94-
print("Normality number of the system matrix (this should be zero): %5.3f" % np.linalg.norm(D.todense()))
94+
print("Normality number of the system matrix (this should be zero): %5.3f" % np.linalg.norm(D.todense()))
95+
elif figure==-1:
96+
p = 5
97+
xaxis_f = np.linspace(0.0, 1.0, ndof_f+1)[0:ndof_f]
98+
dx_f = xaxis_f[1] - xaxis_f[0]
99+
xaxis_c = np.linspace(0.0, 1.0, ndof_c+1)[0:ndof_c]
100+
dx_c = xaxis_c[1] - xaxis_c[0]
101+
A_f = get_desterck(ndof_f, dx_f, p)
102+
A_c = get_desterck(ndof_c, dx_c, p)
103+
u0fine = solution_linear(np.zeros(ndof_f), A_f)
104+
u0coarse = solution_linear(np.zeros(ndof_c), A_c)
105+
para = parareal(0.0, Tend, nslices, impeuler, impeuler, nfine, ncoarse, tol, maxiter, u0fine, u0coarse)
106+
filename = ('figure_conv_desterck_%i.pdf' % p)
95107
else:
96108
sys.exit("Wrong value for figure")
97109

scripts/pseudo-spectrum/figure_9-12.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from solution_linear import solution_linear
1010
from integrator_dedalus import integrator_dedalus
1111
from solution_dedalus import solution_dedalus
12-
from get_matrix import get_upwind, get_centered, get_diffusion
12+
from get_matrix import get_upwind, get_centered, get_diffusion, get_desterck
1313
import numpy as np
1414
import scipy.sparse as sparse
1515
from scipy.linalg import svdvals
@@ -27,9 +27,9 @@
2727
except:
2828
print("No or wrong command line argument provided, creating figure 9. Use 9, 10, 11 or 12 as command line argument.")
2929
figure = 5
30-
assert (9<= figure <= 12) or figure==0, "Figure should be 9, 10, 11 or 12"
30+
assert (9<= figure <= 12) or figure==0 or figure==-1, "Figure should be 9, 10, 11 or 12"
3131

32-
if figure==9 or figure==10 or figure==0:
32+
if figure==9 or figure==10 or figure==0 or figure==-1:
3333
par = parameter(dedalus = False)
3434
ndof_c = 24
3535
elif figure==11:
@@ -88,6 +88,18 @@
8888
u0coarse = solution_linear(np.zeros(ndof_c), A_c)
8989
para = parareal(0.0, Tend, nslices, impeuler, impeuler, nfine, ncoarse, tol, maxiter, u0fine, u0coarse)
9090
filename = 'figure_00.pdf'
91+
elif figure==-1:
92+
p = 5
93+
xaxis_f = np.linspace(0.0, 1.0, ndof_f+1)[0:ndof_f]
94+
dx_f = xaxis_f[1] - xaxis_f[0]
95+
xaxis_c = np.linspace(0.0, 1.0, ndof_c+1)[0:ndof_c]
96+
dx_c = xaxis_c[1] - xaxis_c[0]
97+
A_f = get_desterck(ndof_f, dx_f, p)
98+
A_c = get_desterck(ndof_c, dx_c, p)
99+
u0fine = solution_linear(np.zeros(ndof_f), A_f)
100+
u0coarse = solution_linear(np.zeros(ndof_c), A_c)
101+
para = parareal(0.0, Tend, nslices, impeuler, impeuler, nfine, ncoarse, tol, maxiter, u0fine, u0coarse)
102+
filename = ('figure_desterck_%i.pdf' % p)
91103
else:
92104
sys.exit("Wrong value for figure")
93105

0 commit comments

Comments
 (0)