Peano
Loading...
Searching...
No Matches
plot_kernels.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3"""!
4Plot the available kernels for visual inspection.
5"""
6
7import numpy as np
8from matplotlib import pyplot as plt
9
10
11from sph_kernels import *
12
13fig = plt.figure()
14ax1 = fig.add_subplot(2, 3, 1)
15ax2 = fig.add_subplot(2, 3, 2)
16ax3 = fig.add_subplot(2, 3, 3)
17ax4 = fig.add_subplot(2, 3, 4)
18ax5 = fig.add_subplot(2, 3, 5)
19ax6 = fig.add_subplot(2, 3, 6)
20
21
22ax1.set_title("1D")
23ax2.set_title("2D")
24ax3.set_title("3D")
25
26r = np.linspace(0.0, 4.0, 400)
27
28# h = 1.0
29h = 1.8522633292987498 # what swiftsim/theory/SPH/Kernels/kernels.py uses
30
31for kernel in sph_kernel_list:
32 if kernel not in ["wendland_C4", "wendland_C6"]:
33 vals1d = [sph_kernel_W(ri, h, kernel, 1) for ri in r]
34 ax1.plot(r, vals1d, label=kernel)
35
36 deriv1d = [sph_kernel_dWdr(ri, h, kernel, 1) for ri in r]
37 ax4.plot(r, deriv1d, label=kernel)
38
39 vals2d = [sph_kernel_W(ri, h, kernel, 2) for ri in r]
40 ax2.plot(r, vals2d, label=kernel)
41
42 deriv2d = [sph_kernel_dWdr(ri, h, kernel, 2) for ri in r]
43 ax5.plot(r, deriv2d, label=kernel)
44
45 vals3d = [sph_kernel_W(ri, h, kernel, 3) for ri in r]
46 ax3.plot(r, vals3d, label=kernel)
47
48 deriv3d = [sph_kernel_dWdr(ri, h, kernel, 3) for ri in r]
49 ax6.plot(r, deriv3d, label=kernel)
50
51
52for ax in fig.axes:
53 ax.legend()
54
55
56plt.show()