SPH projected kernels#

This example shows the convergence of the projected M4 kernels

 9 import matplotlib.pyplot as plt
10 import numpy as np
11
12 import shamrock

Use shamrock documentation style for matplotlib

17 shamrock.matplotlib.set_shamrock_mpl_style()

Do the plots

21 Rkern = shamrock.math.sphkernel.M4_Rkern()
22 q = np.linspace(0, Rkern, 1000)
23
24 f_M4 = [shamrock.math.sphkernel.M4_f(x) for x in q]
25
26 fint_M4_4 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 4) for x in q])
27 fint_M4_8 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 8) for x in q])
28 fint_M4_16 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 16) for x in q])
29 fint_M4_32 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 32) for x in q])
30 fint_M4_64 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 64) for x in q])
31 fint_M4_128 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 128) for x in q])
32 fint_M4_1024 = np.array([shamrock.math.sphkernel.M4_f3d_integ_z(x, 1024) for x in q])
33
34 plt.plot(q, f_M4, label="$f_{M4}(q)$")
35 plt.plot(q, fint_M4_4, label="$f_{int,M4,n=4}(q)$")
36 plt.plot(q, fint_M4_1024, label="$f_{int,M4,n=1024}(q)$")
37 plt.legend()
38 plt.xlabel(r"$q$")
39 # plt.savefig("integ_kernel.pdf")
40 # plt.savefig("integ_kernel.svg")
41 plt.figure()
42
43 plt.plot(q, np.abs(fint_M4_4 - fint_M4_1024), label="n=4")
44 plt.plot(q, np.abs(fint_M4_8 - fint_M4_1024), label="n=8")
45 plt.plot(q, np.abs(fint_M4_16 - fint_M4_1024), label="n=16")
46 plt.plot(q, np.abs(fint_M4_32 - fint_M4_1024), label="n=32")
47 plt.plot(q, np.abs(fint_M4_64 - fint_M4_1024), label="n=64")
48 plt.plot(q, np.abs(fint_M4_128 - fint_M4_1024), label="n=128")
49 plt.legend()
50
51 plt.yscale("log")
52 plt.ylabel(r"$\vert f_{int,n} - f_{int,1024} \vert $")
53 plt.xlabel(r"$q$")
54 # plt.savefig("estim_integ_kernel.pdf")
55 # plt.savefig("estim_integ_kernel.svg")
56 plt.show()
  • run sph kernels integ
  • run sph kernels integ

Total running time of the script: (0 minutes 0.813 seconds)

Estimated memory usage: 159 MB

Gallery generated by Sphinx-Gallery