Skip to content

Commit 5ca9d6c

Browse files
author
Daniel Ruprecht
committed
setting k=0 in plot_stability now plots stability domain of collocation solution
1 parent 15f42ba commit 5ca9d6c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

examples/fwsw/plot_stability.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
N_s = 100
1919
N_f = 400
2020

21-
lam_s_max = 5.0
22-
lam_f_max = 12.0
21+
lam_s_max = 12.0
22+
lam_f_max = 24.0
2323
lambda_s = 1j*np.linspace(0.0, lam_s_max, N_s)
2424
lambda_f = 1j*np.linspace(0.0, lam_f_max, N_f)
2525

@@ -30,8 +30,8 @@
3030
pparams['u0'] = 1.0
3131
swparams = {}
3232
swparams['collocation_class'] = collclass.CollGaussLegendre
33-
swparams['num_nodes'] = 2
34-
K = 3
33+
swparams['num_nodes'] = 3
34+
K = 0
3535
do_coll_update = True
3636

3737
#
@@ -58,13 +58,19 @@
5858
for j in range(0,N_f):
5959
lambda_fast = lambda_f[j]
6060
lambda_slow = lambda_s[i]
61-
LHS = np.eye(nnodes) - step.status.dt*( lambda_fast*QI + lambda_slow*QE )
62-
RHS = step.status.dt*( (lambda_fast+lambda_slow)*Q - (lambda_fast*QI + lambda_slow*QE) )
61+
if K is not 0:
6362

64-
Pinv = np.linalg.inv(LHS)
65-
Mat_sweep = np.linalg.matrix_power(Pinv.dot(RHS), K)
66-
for k in range(0,K):
67-
Mat_sweep = Mat_sweep + np.linalg.matrix_power(Pinv.dot(RHS),k).dot(Pinv)
63+
LHS = np.eye(nnodes) - step.status.dt*( lambda_fast*QI + lambda_slow*QE )
64+
RHS = step.status.dt*( (lambda_fast+lambda_slow)*Q - (lambda_fast*QI + lambda_slow*QE) )
65+
66+
Pinv = np.linalg.inv(LHS)
67+
Mat_sweep = np.linalg.matrix_power(Pinv.dot(RHS), K)
68+
for k in range(0,K):
69+
Mat_sweep = Mat_sweep + np.linalg.matrix_power(Pinv.dot(RHS),k).dot(Pinv)
70+
71+
else:
72+
# Compute stability function of collocation solution
73+
Mat_sweep = np.linalg.inv(np.eye(nnodes)-step.status.dt*(lambda_fast + lambda_slow)*Q)
6874
if do_coll_update:
6975
stab_fh = 1.0 + (lambda_fast + lambda_slow)*level.sweep.coll.weights.dot(Mat_sweep.dot(np.ones(nnodes)))
7076
else:

0 commit comments

Comments
 (0)