Commit 01253c94 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

Fixed forcing subexpressions

parent a759b049
Pipeline #33896 failed with stages
in 12 minutes and 47 seconds
...@@ -17,6 +17,8 @@ from lbmpy.moments import (moments_up_to_order, get_order, ...@@ -17,6 +17,8 @@ from lbmpy.moments import (moments_up_to_order, get_order,
exponent_to_polynomial_representation, extract_monomials, MOMENT_SYMBOLS, exponent_to_polynomial_representation, extract_monomials, MOMENT_SYMBOLS,
statistical_quantity_symbol) statistical_quantity_symbol)
from lbmpy.forcemodels import Luo, Simple
# Local Imports # Local Imports
from .cumulant_transform import ( from .cumulant_transform import (
...@@ -141,6 +143,11 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod): ...@@ -141,6 +143,11 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
AbstractConservedQuantityComputation) AbstractConservedQuantityComputation)
super(CenteredCumulantBasedLbMethod, self).__init__(stencil) super(CenteredCumulantBasedLbMethod, self).__init__(stencil)
if force_model is not None:
assert (isinstance(force_model, CenteredCumulantForceModel)
or isinstance(force_model, Simple)
or isinstance(force_model, Luo)), "Given force model currently not supported."
for m in moments_up_to_order(1, dim=self.dim): for m in moments_up_to_order(1, dim=self.dim):
if exponent_to_polynomial_representation(m) not in cumulant_to_relaxation_info_dict.keys(): if exponent_to_polynomial_representation(m) not in cumulant_to_relaxation_info_dict.keys():
raise ValueError(f'No relaxation info given for conserved cumulant {m}!') raise ValueError(f'No relaxation info given for conserved cumulant {m}!')
...@@ -231,6 +238,9 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod): ...@@ -231,6 +238,9 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
self.set_first_moment_relaxation_rate(relaxation_rate) self.set_first_moment_relaxation_rate(relaxation_rate)
def set_force_model(self, force_model): def set_force_model(self, force_model):
assert (isinstance(force_model, CenteredCumulantForceModel)
or isinstance(force_model, Simple)
or isinstance(force_model, Luo)), "Given force model currently not supported."
self._force_model = force_model self._force_model = force_model
def _repr_html_(self): def _repr_html_(self):
...@@ -370,7 +380,7 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod): ...@@ -370,7 +380,7 @@ class CenteredCumulantBasedLbMethod(AbstractLbMethod):
cqe = self._conserved_quantity_computation.equilibrium_input_equations_from_pdfs(f, False) cqe = self._conserved_quantity_computation.equilibrium_input_equations_from_pdfs(f, False)
forcing_subexpressions = AssignmentCollection([]) forcing_subexpressions = AssignmentCollection([])
if include_force_terms and self._force_model is not None: if self._force_model is not None:
forcing_subexpressions = AssignmentCollection(self._force_model.subs_dict_force) forcing_subexpressions = AssignmentCollection(self._force_model.subs_dict_force)
# 1) Extract Monomial Cumulants for the higher-order polynomials # 1) Extract Monomial Cumulants for the higher-order polynomials
......
...@@ -262,15 +262,14 @@ class CentralMomentBasedLbMethod(AbstractLbMethod): ...@@ -262,15 +262,14 @@ class CentralMomentBasedLbMethod(AbstractLbMethod):
if cqe is None: if cqe is None:
cqe = self._conserved_quantity_computation.equilibrium_input_equations_from_pdfs(f, False) cqe = self._conserved_quantity_computation.equilibrium_input_equations_from_pdfs(f, False)
if self._force_model is None:
include_force_terms = False
moment_space_forcing = False
forcing_subexpressions = AssignmentCollection([]) forcing_subexpressions = AssignmentCollection([])
if include_force_terms: moment_space_forcing = False
moment_space_forcing = self.force_model.has_central_moment_space_forcing if self._force_model is not None:
if include_force_terms:
moment_space_forcing = self.force_model.has_central_moment_space_forcing
forcing_subexpressions = AssignmentCollection(self._force_model.subs_dict_force) forcing_subexpressions = AssignmentCollection(self._force_model.subs_dict_force)
else:
include_force_terms = False
# 1) Get Forward Transformation from PDFs to central moments # 1) Get Forward Transformation from PDFs to central moments
pdfs_to_c_transform = self.central_moment_transform_class( pdfs_to_c_transform = self.central_moment_transform_class(
......
...@@ -239,7 +239,7 @@ class MomentBasedLbMethod(AbstractLbMethod): ...@@ -239,7 +239,7 @@ class MomentBasedLbMethod(AbstractLbMethod):
moment_space_forcing = self._forceModel.has_moment_space_forcing moment_space_forcing = self._forceModel.has_moment_space_forcing
forcing_subexpressions = [] forcing_subexpressions = []
if include_force_terms: if self._forceModel is not None:
forcing_subexpressions = AssignmentCollection(self._forceModel.subs_dict_force).all_assignments forcing_subexpressions = AssignmentCollection(self._forceModel.subs_dict_force).all_assignments
rho = self.zeroth_order_equilibrium_moment_symbol rho = self.zeroth_order_equilibrium_moment_symbol
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment