-
Notifications
You must be signed in to change notification settings - Fork 0
n-density dry model #60
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
Conversation
…bbott/JULES.jl into thabbott/multiple_components
Pretty epic PR! Super cool to see the three gas thermal bubble and the difference between energy and entropy. For entropy, I'm not familiar with the spurious mixing issue but it seems really bad with the three gas thermal bubble. Even with the single gas case (both energy and entropy) you get numerical artifacts but that could just be the advection scheme. Quick test would be to see if increasing the resolution reduces those numerical artifacts. But in general, good advection scheme seems pretty important. Just skimmed through the changes but I won't review yet as it's a WIP. If there's a bug with entropy hopefully we'll find it during review or pair programming.
Hmmm, yeah this might warrant us taking a slightly different approach than for incompressible models. I think a big benefit of having them be part of One solution could be to define
True. Maybe
Ah sorry yeah the boundary conditions in But yeah we definitely want to avoid hard-coding in boundary conditions like that! Hmmm, this one seems like it could be a bit tricky if we really need boundary conditions and halo filling on diagnostic fields. Filling halos on the fly or on demand for lazy computations could be expensive. It would be nice if we can get away with just imposing boundary conditions on prognostic fields so that lazy evaluations of the diagnostic variables will never have to worry about boundary conditions. Hmmm, looking into Worse case even if we had to "fill in halo regions" for lazy diagnostic fields I think we can do it generally and there will be a performance hit but it should be rather negligible.
True. I guess we don't have easy output writers built in yet (#38) but should be easy to output/load a few fields for the purposes of regression testing. Been thinking of moving diagnostics and output writers out of the model and into a
Pair programming could be a good idea, especially to settle on design choices. I'll try to push through a couple of upstream issues: CliMA/Oceananigans.jl#606 so it'll be much easier to add boundary conditions on all fields here, and CliMA/Oceananigans.jl#447 so we can start using diagnostics and output writers (and get rid of the time stepping loop). But maybe more importantly, I can work on adding lazy fields (#59) which seem like they might be a much needed abstraction for a |
I think if you include a list like
(but without the code block) in your original comment then those issues will be automatically closed when this PR is merged. |
I think the solutions in this branch might be more oscillatory than
Something like this seems good to me---I agree that keeping the thermodynamic variable and densities in the list of tracers is convenient, and this would give a straightforward and relatively low-cost way to access them when we need them individually.
It might make sense to store all the lazy diagnostic fields in another struct called something like
The problem comes from the fact that energy includes kinetic energy and halos for the vertical velocity field aren't filled the same way as other variables at the top and bottom boundaries. So even though the energy gradient is zero at boundaries the temperature and pressure gradients aren't. Calculating diffusive fluxes using lazy field with its own boundary condition might let us do something like struct LazyGradient{B}
scalar :: Field
bc :: B
end
getindex(A::LazyGradient, inds...) = gradient(i, j, k, A.scalar.grid, A.scalar, A.bc)
function gradient(i, j, k, grid, scalar, bc::AllPeriodic)
xcomp = ∂x(i, j, k, grid, scalar)
ycomp = ∂y(i, j, k, grid, scalar)
zcomp = ∂z(i, j, k, grid, scalar)
return (xcomp, ycomp, zcomp)
end
function gradient(i, j, k, grid, scalar, bc::NoGradientZ)
xcomp = ∂x(i, j, k, grid, scalar)
ycomp = ∂y(i, j, k, grid, scalar)
zcomp = (k == 1 || k == grid.Nz) ? 0.0 : ∂z(i, j, k, grid, scalar)
return (xcomp, ycomp, zcomp)
end This doesn't require extra halo filling but also handles the case where halo filling doesn't do what we'd like it to.
Sounds good to me! |
Of course it took longer than expected but I've made some changes to Oceananigans.jl that will benefit JULES so I'll update JULES to use the latest version and start with building up some lazy fields. A quick summary:
|
… into ar/multiple-components
Co-Authored-By: Tristan Abbott <[email protected]>
Co-Authored-By: Tristan Abbott <[email protected]>
Consolidate verification experiments, add regression tests, standardize operators, and add lazy fields
Codecov Report
@@ Coverage Diff @@
## master #60 +/- ##
=======================================
Coverage 94.91% 94.91%
=======================================
Files 11 11
Lines 295 295
=======================================
Hits 280 280
Misses 15 15 Continue to review full report at Codecov.
|
I have an implementation of an n-density dry model that seems to be working reasonably well using energy as the prognostic thermodynamic variable ...
Energy, one gas
Energy, three gases
... but that doesn't work particularly well with entropy ...
Entropy, one gas
Entropy, three gases
I think the issue is representing entropy production by mixing, which is hard to compute accurately. The rate of entropy production by mixing depends non-linearly on mass mixing rates and the entropy of a specific constituent blow up at low densities, and those two things together make me suspect that it will be hard to model mass diffusion when using entropy as the thermodynamic variable without producing spurious energy/pressure/temperature sources. (It's also possible there's a bug in the code I wrote...)
I'm labeling this as work in progress (and think we should hold off on merging for now) because the code is getting a little clunky. Some additions to the code I think would be useful include:
model.tracers
)diffusive_pressure_flux_z
incompressible_operators.jl
, which is currently there because I couldn't figure out any other way to ensure the flux was zero at the top and bottom boundaries). Abstraction for velocity fields without extra memory allocations #59 could also address this.@ali-ramadhan, let me know if you're interesting in working on any of these additions. (Might be worth doing some pair programming so we make sure we're both happy with the resulting code.)
It also might be worth adding some regression tests before we start working on any of the above so that we have a way of making sure we're not changing model behavior (apart from fixes to any bugs we find) while refactoring.
Resolves #49
Resolves #52
Resolves #54
Resolves #55
Resolves #56
Resolves #57
Resolves #58
Resolves #59