glwagner / dedaLES

Large Eddy Simulation with dedalus
https://dedales.readthedocs.io
GNU General Public License v3.0
34 stars 11 forks source link

Closure modifications when modeled flow perturbs a background #9

Closed glwagner closed 5 years ago

glwagner commented 5 years ago

If the problem solves for a flow perturbation around a background field --- for example, if we solve for u, where the total flow field is U = u + u_background --- we may want the closure to act on the 'full' velocity field U rather than just u.

There are two ways to do this perhaps. One is to write the equations in terms of a non-u variable (u_prime, for example), and then to introduce a substitution:

problem.substitutions['u'] = "u_prime + u_background"

Another way is to allow the closure to accept keyword arguments; for example, changing the ConstantSmagorinsky definition to

class ConstantSmagorinsky(EddyViscosityClosure):
    __init__(..., u_background = "0", ...):
        self.u = f"u + {u_background})

The strain substitution, for example, would then be

def substitute_strainratetensor(self, problem):
        ...
        problem.substitutions['Sxx'] = f"{self.u}x"

Or something like that...

What is the best way to implement this functionality?

glwagner commented 5 years ago

I've started down the road toward figuring this out. The first step is to develop a model class which implements an 'arbitrary background flow' functionality. I've put this here:

https://github.com/glwagner/dedaLES/blob/ArbitraryBackgrounds/dedaLES/navier_stokes.py

Notice that this branch implements a number of breaking changes. I think we should work from this branch for now on.

I'm not sure the method used in navier_stokes.py actually works in dedalus. For example, can we write dx(ub) when ub is not a variable of the problem, but some function instead?

If not, this interface would have to change. In particular, we may have to ask the user to supply ubx = dx(ub)... ?

For steady background flows, we can possibly create a field and numerically differentiate it to supply the same functionality. If the field is unsteady, on the other hand, we need to be more clever / ask the user to specify the derivatives of the background field. Asking the user to specify these fields is a feasible solution, but it'd be nice if we could implement something more elegant.

Dedalus gurus, please advise! (I can also simply check to see if this works, but I'm running out of time today).

If we can indeed write dx(ub), our job is pretty simple.