|
10 | 10 |
|
11 | 11 | from pylab import rcParams |
12 | 12 | import matplotlib.pyplot as plt |
| 13 | +from matplotlib.patches import Polygon |
13 | 14 | from subprocess import call |
14 | 15 |
|
15 | 16 | if __name__ == "__main__": |
16 | 17 |
|
17 | 18 | N_s = 100 |
18 | 19 | N_f = 400 |
19 | | - |
20 | | - lambda_s = 1j*np.linspace(0.0, 2.0, N_s) |
21 | | - lambda_f = 1j*np.linspace(2.0, 8.0, N_f) |
| 20 | + |
| 21 | + lam_s_max = 5.0 |
| 22 | + lam_f_max = 12.0 |
| 23 | + lambda_s = 1j*np.linspace(0.0, lam_s_max, N_s) |
| 24 | + lambda_f = 1j*np.linspace(0.0, lam_f_max, N_f) |
22 | 25 |
|
23 | 26 | pparams = {} |
24 | 27 | # the following are not used in the computation |
25 | 28 | pparams['lambda_s'] = np.array([0.0]) |
26 | 29 | pparams['lambda_f'] = np.array([0.0]) |
27 | 30 | pparams['u0'] = 1.0 |
28 | 31 | swparams = {} |
29 | | - swparams['collocation_class'] = collclass.CollGaussLobatto |
30 | | - swparams['num_nodes'] = 4 |
31 | | - K = 5 |
| 32 | + swparams['collocation_class'] = collclass.CollGaussLegendre |
| 33 | + swparams['num_nodes'] = 2 |
| 34 | + K = 3 |
| 35 | + do_coll_update = True |
32 | 36 |
|
33 | 37 | # |
34 | 38 | # ...this is functionality copied from test_imexsweeper. Ideally, it should be available in one place. |
|
61 | 65 | Mat_sweep = np.linalg.matrix_power(Pinv.dot(RHS), K) |
62 | 66 | for k in range(0,K): |
63 | 67 | Mat_sweep = Mat_sweep + np.linalg.matrix_power(Pinv.dot(RHS),k).dot(Pinv) |
| 68 | + if do_coll_update: |
64 | 69 | stab_fh = 1.0 + (lambda_fast + lambda_slow)*level.sweep.coll.weights.dot(Mat_sweep.dot(np.ones(nnodes))) |
| 70 | + else: |
| 71 | + q = np.zeros(nnodes) |
| 72 | + q[nnodes-1] = 1.0 |
| 73 | + stab_fh = q.dot(Mat_sweep.dot(np.ones(nnodes))) |
| 74 | + # |
65 | 75 | stab[j,i] = stab_fh |
66 | 76 |
|
67 | 77 | ### |
|
70 | 80 | fig = plt.figure() |
71 | 81 | #pcol = plt.pcolor(lambda_s.imag, lambda_f.imag, np.absolute(stab), vmin=0.99, vmax=2.01) |
72 | 82 | #pcol.set_edgecolor('face') |
73 | | - levels = np.array([0.95, 0.99, 1.01, 1.05]) |
| 83 | + levels = np.array([0.25, 0.5, 0.75, 0.9, 1.1]) |
74 | 84 | # levels = np.array([1.0]) |
75 | | - CS1 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), levels, colors='k',linestyles='dashed') |
76 | | - CS2 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), [1.0], colors='k') |
77 | | - plt.clabel(CS1, fontsize=fs-2) |
78 | | - plt.clabel(CS2, fontsize=fs-2) |
79 | | - #plt.plot([0, 2], [0, 2], color='k', linewidth=1) |
80 | | - plt.gca().set_xticks([0.0, 1.0, 2.0, 3.0]) |
| 85 | + CS1 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), levels, colors='k', linestyles='dashed') |
| 86 | + CS2 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), [1.0], colors='k') |
| 87 | + plt.clabel(CS1, inline=True, fmt='%3.2f', fontsize=fs-2) |
| 88 | + manual_locations = [(1.5, 2.5)] |
| 89 | + plt.clabel(CS2, inline=True, fmt='%3.2f', fontsize=fs-2, manual=manual_locations) |
| 90 | + plt.gca().add_patch(Polygon([[0, 0], [lam_s_max,0], [lam_s_max,lam_s_max]], visible=True, fill=True, facecolor='.75',edgecolor='k', linewidth=1.0, zorder=11)) |
| 91 | + #plt.plot([0, 2], [0, 2], color='k', linewidth=1, zorder=12) |
| 92 | + plt.gca().set_xticks(np.arange(0, int(lam_s_max)+1)) |
| 93 | + plt.gca().set_yticks(np.arange(0, int(lam_f_max)+2, 2)) |
81 | 94 | plt.gca().tick_params(axis='both', which='both', labelsize=fs) |
82 | | - plt.xlim([np.min(lambda_s.imag), np.max(lambda_s.imag)]) |
| 95 | + plt.xlim([0.0, lam_s_max]) |
| 96 | + plt.ylim([0.0, lam_f_max]) |
83 | 97 | plt.xlabel('$\Delta t \lambda_{slow}$', fontsize=fs, labelpad=2.0) |
84 | 98 | plt.ylabel('$\Delta t \lambda_{fast}$', fontsize=fs) |
85 | 99 | plt.title(r'$M=%1i$, $K=%1i$' % (swparams['num_nodes'],K), fontsize=fs) |
| 100 | + #plt.show() |
86 | 101 | filename = 'sdc-fwsw-stability-K'+str(K)+'-M'+str(swparams['num_nodes'])+'.pdf' |
87 | 102 | fig.savefig(filename, bbox_inches='tight') |
88 | 103 | call(["pdfcrop", filename, filename]) |
|
0 commit comments