aboutsummaryrefslogtreecommitdiff
path: root/boltzgen/lbm/lattice/characteristics.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-11-02 17:18:32 +0100
committerAdrian Kummerlaender2019-11-02 17:18:32 +0100
commit24847cbb2567f508a7c30b39c6fb7ba6379d1adc (patch)
treeae70f1e36e80609d424f7e3b1b489083accfda33 /boltzgen/lbm/lattice/characteristics.py
parente2b00f4ec963060be98939c7b0d12d6c00e50a02 (diff)
downloadboltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.tar
boltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.tar.gz
boltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.tar.bz2
boltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.tar.lz
boltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.tar.xz
boltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.tar.zst
boltzgen-24847cbb2567f508a7c30b39c6fb7ba6379d1adc.zip
Restructure LBM model / lattice distinction
Diffstat (limited to 'boltzgen/lbm/lattice/characteristics.py')
-rw-r--r--boltzgen/lbm/lattice/characteristics.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/boltzgen/lbm/lattice/characteristics.py b/boltzgen/lbm/lattice/characteristics.py
new file mode 100644
index 0000000..b68afeb
--- /dev/null
+++ b/boltzgen/lbm/lattice/characteristics.py
@@ -0,0 +1,27 @@
+from sympy import *
+
+# copy of `sympy.integrals.quadrature.gauss_hermite` sans evaluation
+def gauss_hermite(n):
+ x = Dummy("x")
+ p = hermite_poly(n, x, polys=True)
+ p1 = hermite_poly(n-1, x, polys=True)
+ xi = []
+ w = []
+ for r in p.real_roots():
+ xi.append(r)
+ w.append(((2**(n-1) * factorial(n) * sqrt(pi))/(n**2 * p1.subs(x, r)**2)))
+ return xi, w
+
+# determine weights of a d-dimensional LBM model on velocity set c
+# (only works for velocity sets that result into NSE-recovering LB models when
+# plugged into Gauss-Hermite quadrature without any additional arguments
+# i.e. D2Q9 and D3Q27 but not D3Q19)
+def weights(d, c):
+ _, omegas = gauss_hermite(3)
+ return list(map(lambda c_i: Mul(*[ omegas[1+c_i[iDim]] for iDim in range(0,d) ]) / pi**(d/2), c))
+
+# determine lattice speed of sound using directions and their weights
+def c_s(d, c, w):
+ speeds = set([ sqrt(sum([ w[i] * c_i[j]**2 for i, c_i in enumerate(c) ])) for j in range(0,d) ])
+ assert len(speeds) == 1 # verify isotropy
+ return speeds.pop()