SPH projected kernels#

This exemple shows the convergence of the projected M4 kernels

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

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

Estimated memory usage: 72 MB

Gallery generated by Sphinx-Gallery