|
1 | 1 | from pySDC.implementations.problem_classes.RayleighBenard import RayleighBenard |
2 | 2 | import numpy as np |
3 | 3 | import matplotlib.pyplot as plt |
4 | | -from pySDC.helpers.plot_helper import figsize_by_journal |
| 4 | +from pySDC.helpers.plot_helper import figsize_by_journal, setup_mpl |
5 | 5 |
|
6 | 6 |
|
7 | | -P = RayleighBenard(nx=3, nz=5, Dirichlet_recombination=True, left_preconditioner=True) |
8 | | -dt = 1.0 |
| 7 | +def plot_preconditioners(): # pragma: no cover |
| 8 | + P = RayleighBenard(nx=3, nz=5, Dirichlet_recombination=True, left_preconditioner=True) |
| 9 | + dt = 1.0 |
9 | 10 |
|
| 11 | + A = P.M + dt * P.L |
| 12 | + A_b = P.put_BCs_in_matrix(P.M + dt * P.L) |
| 13 | + A_r = P.spectral.put_BCs_in_matrix(A) @ P.Pr |
| 14 | + A_l = P.Pl @ P.spectral.put_BCs_in_matrix(A) @ P.Pr |
10 | 15 |
|
11 | | -A = P.M + dt * P.L |
12 | | -A_b = P.put_BCs_in_matrix(P.M + dt * P.L) |
13 | | -A_r = P.spectral.put_BCs_in_matrix(A) @ P.Pr |
14 | | -A_l = P.Pl @ P.spectral.put_BCs_in_matrix(A) @ P.Pr |
| 16 | + fig, axs = plt.subplots(1, 4, figsize=figsize_by_journal('TUHH_thesis', 1, 0.4), sharex=True, sharey=True) |
15 | 17 |
|
16 | | -fig, axs = plt.subplots(1, 4, figsize=figsize_by_journal('TUHH_thesis', 1, 0.4), sharex=True, sharey=True) |
| 18 | + for M, ax in zip([A, A_b, A_r, A_l], axs): |
| 19 | + ax.imshow((M / abs(M)).real + (M / abs(M)).imag, rasterized=False, cmap='Spectral') |
17 | 20 |
|
18 | | -for M, ax in zip([A, A_b, A_r, A_l], axs): |
19 | | - ax.imshow((M / abs(M)).real + (M / abs(M)).imag, rasterized=False, cmap='Spectral') |
| 21 | + for ax in axs: |
| 22 | + ax.set_xticks([]) |
| 23 | + ax.set_yticks([]) |
| 24 | + fig.savefig('plots/RBC_matrix.pdf', bbox_inches='tight', dpi=300) |
| 25 | + plt.show() |
20 | 26 |
|
21 | | -for ax in axs: |
22 | | - ax.set_xticks([]) |
23 | | - ax.set_yticks([]) |
24 | | -fig.savefig('plots/RBC_matrix.pdf', bbox_inches='tight', dpi=300) |
25 | | -plt.show() |
| 27 | + |
| 28 | +def plot_ultraspherical(): |
| 29 | + from pySDC.helpers.spectral_helper import ChebychevHelper, UltrasphericalHelper |
| 30 | + |
| 31 | + N = 16 |
| 32 | + cheby = ChebychevHelper(N=N) |
| 33 | + ultra = UltrasphericalHelper(N=N) |
| 34 | + |
| 35 | + D_cheby = cheby.get_differentiation_matrix() |
| 36 | + I_cheby = cheby.get_Id() |
| 37 | + |
| 38 | + fig, axs = plt.subplots(2, 3, figsize=figsize_by_journal('TUHH_thesis', 0.9, 0.65), sharex=True, sharey=True) |
| 39 | + |
| 40 | + axs[0, 0].imshow(D_cheby / abs(D_cheby)) |
| 41 | + axs[1, 0].imshow(I_cheby / abs(I_cheby)) |
| 42 | + |
| 43 | + for i in range(2): |
| 44 | + D_ultra = ultra.get_differentiation_matrix(p=i + 1) |
| 45 | + I_ultra = ultra.get_basis_change_matrix(0, i + 1) |
| 46 | + axs[0, i + 1].imshow(D_ultra / abs(D_ultra)) |
| 47 | + axs[1, i + 1].imshow(I_ultra / abs(I_ultra)) |
| 48 | + axs[1, i + 1].set_xlabel(rf'$T \rightarrow C^{{({{{i+1}}})}}$') |
| 49 | + for ax in axs.flatten(): |
| 50 | + ax.set_xticks([]) |
| 51 | + ax.set_yticks([]) |
| 52 | + |
| 53 | + axs[0, 0].set_ylabel('Differentiation') |
| 54 | + axs[1, 0].set_ylabel('Left preconditioner') |
| 55 | + axs[1, 0].set_xlabel(r'$T \rightarrow T$') |
| 56 | + |
| 57 | + axs[0, 0].set_title('first derivative') |
| 58 | + axs[0, 1].set_title('first derivative') |
| 59 | + axs[0, 2].set_title('second derivative') |
| 60 | + fig.savefig('plots/ultraspherical_matrix.pdf', bbox_inches='tight', dpi=300) |
| 61 | + plt.show() |
| 62 | + |
| 63 | + |
| 64 | +if __name__ == '__main__': |
| 65 | + setup_mpl() |
| 66 | + plot_ultraspherical() |
0 commit comments