aboutsummaryrefslogtreecommitdiff
path: root/symbolic/generator.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-07-02 20:35:44 +0200
committerAdrian Kummerlaender2019-07-02 20:35:44 +0200
commit55fb5b62ab3381327d4b04cf1c5ab095874d29cc (patch)
tree1c64f3a3ac3e6ab4961f59d6adba6ee2e8d4495c /symbolic/generator.py
parent7ee1ca337f25ab6ead86ead28c10df520cff1b63 (diff)
downloadsymlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.tar
symlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.tar.gz
symlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.tar.bz2
symlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.tar.lz
symlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.tar.xz
symlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.tar.zst
symlbm_playground-55fb5b62ab3381327d4b04cf1c5ab095874d29cc.zip
Determine lattice speed of sound
Diffstat (limited to 'symbolic/generator.py')
-rw-r--r--symbolic/generator.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/symbolic/generator.py b/symbolic/generator.py
index 73f3940..629c991 100644
--- a/symbolic/generator.py
+++ b/symbolic/generator.py
@@ -2,7 +2,7 @@ from sympy import *
from sympy.codegen.ast import Assignment
import symbolic.optimizations as optimizations
-from symbolic.characteristics import weights
+from symbolic.characteristics import weights, c_s
def assign(names, definitions):
@@ -14,10 +14,11 @@ class LBM:
self.f_next = symarray('f_next', descriptor.q)
self.f_curr = symarray('f_curr', descriptor.q)
- if hasattr(descriptor, 'w'):
- self.w = descriptor.w
- else:
- self.w = weights(descriptor.d, descriptor.c)
+ if not hasattr(descriptor, 'w'):
+ self.descriptor.w = weights(descriptor.d, descriptor.c)
+
+ if not hasattr(descriptor, 'c_s'):
+ self.descriptor.c_s = c_s(descriptor.d, descriptor.c, self.descriptor.w)
def moments(self, optimize = True):
rho = symbols('rho')
@@ -41,10 +42,10 @@ class LBM:
f_eq = []
for i, c_i in enumerate(self.descriptor.c):
- f_eq_i = self.w[i] * rho * ( 1
- + c_i.dot(u) / self.descriptor.c_s**2
- + c_i.dot(u)**2 / (2*self.descriptor.c_s**4)
- - u.dot(u) / (2*self.descriptor.c_s**2) )
+ f_eq_i = self.descriptor.w[i] * rho * ( 1
+ + c_i.dot(u) / self.descriptor.c_s**2
+ + c_i.dot(u)**2 / (2*self.descriptor.c_s**4)
+ - u.dot(u) / (2*self.descriptor.c_s**2) )
f_eq.append(f_eq_i)
return f_eq