Skip to content
Snippets Groups Projects

Cumulant LBM

Merged Frederik Hennig requested to merge da15siwa/lbmpy:mr_cumulant_lbm into master
Viewing commit c85cb471
Show latest version
1 file
+ 28
4
Preferences
Compare changes
@@ -228,15 +228,30 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
assert len(weights) == len(self.stencil)
self._weights = weights
def get_equilibrium(self, conserved_quantity_equations=None, subexpressions=False, pre_simplification=False):
def get_equilibrium(self, conserved_quantity_equations=None, subexpressions=False, pre_simplification=False,
keep_cqc_subexpressions=True):
"""Returns equation collection, to compute equilibrium values.
The equations have the post collision symbols as left hand sides and are
functions of the conserved quantities"""
functions of the conserved quantities
Args:
conserved_quantity_equations: equations to compute conserved quantities.
subexpressions: if set to false all subexpressions of the equilibrium assignments are plugged
into the main assignments
pre_simplification: with or without pre_simplifications for the calculation of the collision
keep_cqc_subexpressions: if equilibrium is returned without subexpressions keep_cqc_subexpressions
determines if also subexpressions to calculate conserved quantities should be
plugged into the main assignments
"""
r_info_dict = {c: RelaxationInfo(info.equilibrium_value, 1)
for c, info in self._cumulant_to_relaxation_info_dict.items()}
ac = self._centered_cumulant_collision_rule(r_info_dict, conserved_quantity_equations, pre_simplification)
if not subexpressions:
return ac.new_without_subexpressions()
if keep_cqc_subexpressions:
bs = self._bound_symbols_cqc(conserved_quantity_equations)
return ac.new_without_subexpressions(subexpressions_to_keep=bs)
else:
return ac.new_without_subexpressions()
else:
return ac
@@ -252,10 +267,19 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
# ------------------------------- Internals --------------------------------------------
def _bound_symbols_cqc(self, conserved_quantity_equations=None):
f = self.pre_collision_pdf_symbols
cqe = conserved_quantity_equations
if cqe is None:
cqe = self._conserved_quantity_computation.equilibrium_input_equations_from_pdfs(f)
return cqe.bound_symbols
def _compute_weights(self):
defaults = self._conserved_quantity_computation.default_values
cqe = AssignmentCollection([Assignment(s, e) for s, e in defaults.items()])
eq_ac = self.get_equilibrium(cqe, subexpressions=False)
eq_ac = self.get_equilibrium(cqe, subexpressions=False, keep_cqc_subexpressions=False)
weights = []
for eq in eq_ac.main_assignments: