Coverage for pySDC/projects/FastWaveSlowWave/plotgmrescounter_boussinesq.py: 100%
35 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
1import numpy as np
2from matplotlib import pyplot as plt
3from pylab import rcParams
6def plot_buoyancy(cwd=''):
7 """
8 Plotting routine for the cross section of the buoyancy
10 Args:
11 cwd (string): current working directory
12 """
14 xx = np.load(cwd + 'data/xaxis.npy')
15 uend = np.load(cwd + 'data/sdc.npy')
16 udirk = np.load(cwd + 'data/dirk.npy')
17 uimex = np.load(cwd + 'data/rkimex.npy')
18 uref = np.load(cwd + 'data/uref.npy')
19 usplit = np.load(cwd + 'data/split.npy')
21 err_split = np.linalg.norm(usplit.flatten() - uref.flatten(), np.inf) / np.linalg.norm(uref.flatten(), np.inf)
22 err_dirk = np.linalg.norm(udirk.flatten() - uref.flatten(), np.inf) / np.linalg.norm(uref.flatten(), np.inf)
23 err_imex = np.linalg.norm(uimex.flatten() - uref.flatten(), np.inf) / np.linalg.norm(uref.flatten(), np.inf)
24 err_sdc = np.linalg.norm(uend.flatten() - uref.flatten(), np.inf) / np.linalg.norm(uref.flatten(), np.inf)
26 assert err_split < 4.821e-02, 'ERROR: split error is too high, got %s' % err_split
27 assert err_dirk < 1.495e-01, 'ERROR: dirk error is too high, got %s' % err_dirk
28 assert err_imex < 1.305e-01, 'ERROR: imex error is too high, got %s' % err_imex
29 assert err_sdc < 9.548e-02, 'ERROR: sdc error is too high, got %s' % err_sdc
31 print("Estimated discretisation error split explicit: %5.3e" % err_split)
32 print("Estimated discretisation error of DIRK: %5.3e" % err_dirk)
33 print("Estimated discretisation error of RK-IMEX: %5.3e" % err_imex)
34 print("Estimated discretisation error of SDC: %5.3e" % err_sdc)
36 fs = 8
37 rcParams['figure.figsize'] = 5.0, 2.5
38 plt.figure()
39 plt.plot(xx[:, 5], udirk[2, :, 5], '--', color='g', markersize=fs - 2, label='DIRK(4)', dashes=(3, 3))
40 plt.plot(xx[:, 5], uend[2, :, 5], '-', color='b', label='SDC(4)')
41 plt.plot(xx[:, 5], uimex[2, :, 5], '--', color='r', markersize=fs - 2, label='IMEX(4)', dashes=(3, 3))
42 plt.legend(loc='lower left', fontsize=fs, prop={'size': fs})
43 plt.yticks(fontsize=fs)
44 plt.xticks(fontsize=fs)
45 plt.xlabel('x [km]', fontsize=fs, labelpad=0)
46 plt.ylabel('Bouyancy', fontsize=fs, labelpad=1)
47 filename = 'data/boussinesq.png'
48 plt.savefig(filename, bbox_inches='tight')
51if __name__ == "__main__":
52 plot_buoyancy()