aboutsummaryrefslogtreecommitdiff
path: root/symbolic/characteristics.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-07-02 14:58:36 +0200
committerAdrian Kummerlaender2019-07-02 14:59:46 +0200
commit7ee1ca337f25ab6ead86ead28c10df520cff1b63 (patch)
treec73d4f9ae857b39c45a99149a3f08fabba82e905 /symbolic/characteristics.py
parentf62fcf3e47919b1c893ac2335b9fdfb842f9595f (diff)
downloadsymlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.tar
symlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.tar.gz
symlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.tar.bz2
symlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.tar.lz
symlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.tar.xz
symlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.tar.zst
symlbm_playground-7ee1ca337f25ab6ead86ead28c10df520cff1b63.zip
Determine weights using Gauss-Hermite quadrature
Diffstat (limited to 'symbolic/characteristics.py')
-rw-r--r--symbolic/characteristics.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/symbolic/characteristics.py b/symbolic/characteristics.py
new file mode 100644
index 0000000..ca3904e
--- /dev/null
+++ b/symbolic/characteristics.py
@@ -0,0 +1,21 @@
+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))