WIP: Fluctuating Equations non-normalized
Non normalized equations for the variances.
Still need to figure out how to get lattice spacing and whether definition for mu should contain lattice time as well.
Related to walberla/walberla!220 (merged) and implements/enhances #2 (closed)
Merge request reports
Activity
Related to walberla/walberla!220 (merged)
Edited by Felix Winterhalteradded 3 commits
- Resolved by Michael Kuron
- Resolved by Felix Winterhalter
329 326 variances = SymbolGen("variance") if params['fluctuating'] is True else params['fluctuating'] 330 327 correction = fluctuation_correction(lb_method, random_symbol(collision_rule.subexpressions, dim=lb_method.dim), 331 328 variances) 329 332 330 for i, corr in enumerate(correction): 333 331 collision_rule.main_assignments[i] = Assignment(collision_rule.main_assignments[i].lhs, 334 332 collision_rule.main_assignments[i].rhs + corr) 335 333 334 variances = SymbolGen("variance") if params['fluctuating'] is True else params['fluctuating'] 335 temperature = sp.Symbol("fluctuating_temperature") if params["temperature"] is None else params["temperature"] 336 variance_equations = fluctuating_variance_equations(method=lb_method, 337 temperature=temperature, 338 c_s_sq=params["c_s_sq"], 339 variances=variances) changed this line in version 8 of the diff
added 1 commit
- ff1b76c5 - Only generate variance equations if temperature is set
326 323 collision_rule = simplification(collision_rule) 327 324 328 325 if params['fluctuating']: 329 variances = SymbolGen("variance") if params['fluctuating'] is True else params['fluctuating'] 326 variances = [v for v, _ in zip(iter(SymbolGen("variance")), lb_method.moments)] if params['fluctuating'] is True else params['fluctuating'] 330 327 correction = fluctuation_correction(lb_method, random_symbol(collision_rule.subexpressions, dim=lb_method.dim), 331 328 variances) 329 332 330 for i, corr in enumerate(correction): 333 331 collision_rule.main_assignments[i] = Assignment(collision_rule.main_assignments[i].lhs, 334 332 collision_rule.main_assignments[i].rhs + corr) 335 333 334 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'm a bit hesitant to just name it
temperature
. How about passing a dict as thefluctuating
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))
assigned to @bauer and unassigned @winterhalter
mentioned in merge request pystencils!23 (closed)
Interface
fluctuating=None, fluctuating = { temperature: 1.8, # OR variances = [] # list of q variances for a DdQq stencil block_offsets = sp.symbols("block_offset_:3"), # default no block_offsets seed = , rng_node: Philox4Floats, }
TODO Martin - seed configurable - block offsets for walberla
Open: - block offsets in jinja templates - vectorization of Philox
Edited by Martin Bauer24 24 from lbmpy.moments import MOMENT_SYMBOLS 25 25 from pystencils.simp.assignment_collection import SymbolGen 26 from pystencils import Assignment 27 28 29 def fluctuating_variance_equations(method, temperature=sp.Symbol("fluctuating_temperature"), 30 c_s_sq=sp.Symbol("c_s") ** 2, 31 variances=SymbolGen("variance")): 32 """Produces variance equations according to (3.54) in Schiller08""" 33 normalization_factors = abs(method.moment_matrix) * sp.Matrix(method.weights) 34 relaxation_rates_sqr = [r ** 2 for r in method.relaxation_rates] 35 density = method.zeroth_order_equilibrium_moment_symbol 36 mu = temperature * density / c_s_sq 37 38 return [Assignment(v, sp.sqrt(mu * norm * (1 - rr))) 39 for v, norm, rr in zip(iter(variances), normalization_factors, relaxation_rates_sqr)] Please replace
(1 - rr)
withrr
. Our notation is different from Ulf Schiller's and @winterhalter didn't consider that.Actually I don't think thats right. rr in this case refers already to the squared relaxation rates.
From what I'm able to tell by looking at the different definitions for the relaxation rates:
lbmpy relaxation rate = - Ulf Schiller relaxation rate
Therefore the change looks a bit different. Correct me if I'm wrong though
changed this line in version 11 of the diff