Skip to content
Snippets Groups Projects

WIP: Fluctuating Equations non-normalized

3 unresolved threads
Files
3
+ 12
5
@@ -178,7 +178,7 @@ from lbmpy.fieldaccess import (
@@ -178,7 +178,7 @@ from lbmpy.fieldaccess import (
AAEvenTimeStepAccessor, AAOddTimeStepAccessor, CollideOnlyInplaceAccessor, EsoTwistEvenTimeStepAccessor,
AAEvenTimeStepAccessor, AAOddTimeStepAccessor, CollideOnlyInplaceAccessor, EsoTwistEvenTimeStepAccessor,
EsoTwistOddTimeStepAccessor, PdfFieldAccessor, PeriodicTwoFieldsAccessor, StreamPullTwoFieldsAccessor,
EsoTwistOddTimeStepAccessor, PdfFieldAccessor, PeriodicTwoFieldsAccessor, StreamPullTwoFieldsAccessor,
StreamPushTwoFieldsAccessor)
StreamPushTwoFieldsAccessor)
from lbmpy.fluctuatinglb import fluctuation_correction, method_with_rescaled_equilibrium_values
from lbmpy.fluctuatinglb import fluctuation_correction, fluctuating_variance_equations
from lbmpy.methods import create_mrt3, create_mrt_orthogonal, create_mrt_raw, create_srt, create_trt, create_trt_kbc
from lbmpy.methods import create_mrt3, create_mrt_orthogonal, create_mrt_raw, create_srt, create_trt, create_trt_kbc
from lbmpy.methods.creationfunctions import create_generic_mrt
from lbmpy.methods.creationfunctions import create_generic_mrt
from lbmpy.methods.cumulantbased import CumulantBasedLbMethod
from lbmpy.methods.cumulantbased import CumulantBasedLbMethod
@@ -309,9 +309,6 @@ def create_lb_collision_rule(lb_method=None, optimization={}, **kwargs):
@@ -309,9 +309,6 @@ def create_lb_collision_rule(lb_method=None, optimization={}, **kwargs):
if rho_in is not None and isinstance(rho_in, Field):
if rho_in is not None and isinstance(rho_in, Field):
rho_in = rho_in.center
rho_in = rho_in.center
if params['fluctuating']:
lb_method = method_with_rescaled_equilibrium_values(lb_method)
if u_in is not None:
if u_in is not None:
density_rhs = sum(lb_method.pre_collision_pdf_symbols) if rho_in is None else rho_in
density_rhs = sum(lb_method.pre_collision_pdf_symbols) if rho_in is None else rho_in
eqs = [Assignment(cqc.zeroth_order_moment_symbol, density_rhs)]
eqs = [Assignment(cqc.zeroth_order_moment_symbol, density_rhs)]
@@ -326,13 +323,22 @@ def create_lb_collision_rule(lb_method=None, optimization={}, **kwargs):
@@ -326,13 +323,22 @@ def create_lb_collision_rule(lb_method=None, optimization={}, **kwargs):
collision_rule = simplification(collision_rule)
collision_rule = simplification(collision_rule)
if params['fluctuating']:
if params['fluctuating']:
variances = SymbolGen("variance") if params['fluctuating'] is True else params['fluctuating']
variances = [v for v, _ in zip(iter(SymbolGen("variance")), lb_method.moments)] if params['fluctuating'] is True else params['fluctuating']
correction = fluctuation_correction(lb_method, random_symbol(collision_rule.subexpressions, dim=lb_method.dim),
correction = fluctuation_correction(lb_method, random_symbol(collision_rule.subexpressions, dim=lb_method.dim),
variances)
variances)
 
for i, corr in enumerate(correction):
for i, corr in enumerate(correction):
collision_rule.main_assignments[i] = Assignment(collision_rule.main_assignments[i].lhs,
collision_rule.main_assignments[i] = Assignment(collision_rule.main_assignments[i].lhs,
collision_rule.main_assignments[i].rhs + corr)
collision_rule.main_assignments[i].rhs + corr)
 
temperature = sp.Symbol("fluctuating_temperature") if params["temperature"] is None else params["temperature"]
    • I don't like the name "fluctuating_temperature". Of course it is the temperature of the fluctuating LB, but the name sounds like it's a bool that specifies whether you want the temperature to fluctuate or not. Why not just name it "temperature"? It's unlikely any future modification will ever require specifying separate temperatures for the LB method and for the fluctuation algorithm, so the distinction is not needed.

      • I agree with you its not that great. I just didn't want to assume that its the only temperature that will ever be introduced, hence the qualifier. If you also agree that we can just name it "temperature" I'm fine with that.

      • I'm a bit hesitant to just name it temperature. How about passing a dict as the fluctuating parameter if additional options are required?

        Is it correct that one can either pass variance values or temperature values? Could the user also just call create_lb_*(fluctuating=variance_expressions_from_temperature(temperature))

      • Please register or sign in to reply
Please register or sign in to reply
 
variance_equations = fluctuating_variance_equations(method=lb_method,
 
temperature=temperature,
 
c_s_sq=params["c_s_sq"],
 
variances=variances)
Please register or sign in to reply
 
collision_rule.subexpressions += variance_equations
 
collision_rule.topological_sort(sort_subexpressions=True, sort_main_assignments=False)
 
if params['entropic']:
if params['entropic']:
if params['smagorinsky']:
if params['smagorinsky']:
raise ValueError("Choose either entropic or smagorinsky")
raise ValueError("Choose either entropic or smagorinsky")
@@ -528,6 +534,7 @@ def update_with_default_parameters(params, opt_params=None, fail_on_unknown_para
@@ -528,6 +534,7 @@ def update_with_default_parameters(params, opt_params=None, fail_on_unknown_para
'omega_output_field': None,
'omega_output_field': None,
'smagorinsky': False,
'smagorinsky': False,
'fluctuating': False,
'fluctuating': False,
 
'temperature': None,
'output': {},
'output': {},
'velocity_input': None,
'velocity_input': None,
Loading