-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use total tracer in diffusive flux calculation #3646
base: main
Are you sure you want to change the base?
Conversation
Probably before merging this we also want to use the total velocities in the stress computation |
But I wonder also if we should add a feature to |
…liMA/Oceananigans.jl into glw/background-flux-divergence
Ok @hdrake @liuchihl I have added the option to include or not the background field when computing closure fluxes. They are noit included by default. If you want to include them you need to build the background_fields = BackgroundFields(; background_closure_fluxes=true, b=B) where Let me know if this seems like a good interface and also if it works. |
Looks like a good interface to me. But is it on purpose that there is only support for background fields in the @liuchihl will test it in our configurations. |
Well yes, it's substantial effort to support background fields. So we implemented it in the nonhydrostatic model first. Nobody has requested having background fields for the hydrostatic model. It's not impossible but might require some thinking if it's going to work with the more complicated turbulence closures (like CATKE or k-epsilon) that sometimes get used for hydrostatic applications. Since the nonhydrostatic model is fast (at least on one GPU) the hydrostatic model is mostly important for simulations on the sphere (although this statement needs to be evaluated more carefully for complex domains when we have a proper nonhydrostatic solver). |
@glwagner, can you help us understand how the diffusive flux calculations here interact with gradient boundary conditions? We've run some simulations and seem to be getting the expected behavior in the interior, where buoyancy tendencies are due to the convergence of both the perturbation and background diffusive fluxes. However, we are not seeing the expected behavior from the flux convergence due to boundary conditions (on the domain, not even considering immersed boundary conditions yet). My expectation was that the
which in our case should be the sum of the perturbation and background tracer fields. Instead, it seems that our solutions are behaving as though the |
Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl Lines 100 to 101 in 738d172
Contrast this with the routine for Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl Lines 103 to 107 in 738d172
These gradients are then used to compute the flux, for example Oceananigans.jl/src/ImmersedBoundaries/immersed_boundary_condition.jl Lines 117 to 122 in 738d172
I don't know exactly what it means for a gradient to be applied to the field. Can you please clarify? |
Additionally can you help me understand why you are using |
@glwagner Thanks for implementing the total tracer diffusive flux at a high level. After running several tests, I found it to work exceptionally well! I conducted a series of tests: 1) comparing 1D vs 3D, 2) with and without the Coriolis force, and 3) with and without the immersed boundary. Everything looks great! Here are some simple examples on a rotated coordinate:
nonconstantdiffusivity250days-theta.0.002_Nx4_Ny4_smallf_zlargerf.mp4
nonconstantdiffusivity8days-theta.0.2_Nx4_Ny4_immersed_3Dfields_withcrossflux.mp4The only caveat mentioned by @hdrake is that |
Flux boundary conditions are both conceptually and practically easier to implement when the boundary fluxes are zero or constant. They can be trickier when they depend on interior flow variables. In our case, for example, the boundary condition on the perturbation variable Imposing a flux boundary condition requires knowing the diffusivity |
I just meant where in the code the gradient boundary conditions get imposed, which you've shown us is in the calculation of the gradients that feed into the downgradient diffusive fluxes that are used in the diffusive flux divergence contribution to the tracer tendencies. Thanks! |
Okay great. I would only add, I think it's clearer to think of the gradient as being used to diagnose the cross-boundary flux (rather than imposed). I guess the point here is that there is actually an apparent flux of tracer into the perturbation field because of the presence of the background. So we are imagining that the background is being maintained by some large scale circulation which is ultimately the source of this apparent flux. |
Thanks @liuchihl ! |
cc @hdrake @liuchihl