-
Notifications
You must be signed in to change notification settings - Fork 207
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
Compressible model #1079
Compressible model #1079
Conversation
Prototyping and testing a `CompressibleModel`
WENO-5 advection
… ar/thermal-bubble
Dry rising thermal bubble verification experiment
Some cleanup
Codecov Report
@@ Coverage Diff @@
## master #1079 +/- ##
=======================================
Coverage 57.47% 57.47%
=======================================
Files 161 161
Lines 3800 3800
=======================================
Hits 2184 2184
Misses 1616 1616 Continue to review full report at Codecov.
|
3. Shock tubeWas too lazy to code up the analytical solution. See Wikipedia for what it should look like: https://en.wikipedia.org/wiki/Sod_shock_tube With With |
4. Inviscid dry rising thermal bubbleWENO-5 doing pretty well with ν = κ = 0, some nice Kelvin-Helmholtz instabilities. See YouTube: https://www.youtube.com/watch?v=_CgyNHLlpvA |
5. Viscous rising thermal bubble with 3 different gas speciesA simulation of a warm thermal bubble rising through a viscous compressible fluid made up of three gases with different density profiles. Credit to @thabbott for getting this to work! See YouTube: https://www.youtube.com/watch?v=mpdRlLd1PTM |
6. Nonlinear density currentBasically the rising thermal bubble in reverse. See YouTube: https://www.youtube.com/watch?v=guk77zjHR6k |
7. Dry convectionJust playing around to see if time-stepping a larger 3D model on a GPU would uncover any issues (it didn't 🎉). And it was an excuse to use Makie.jl. See YouTube: https://www.youtube.com/watch?v=O0TTfkgNRCI |
Just a remark: I doubt this is inviscid 1D Burgers, i.e., ∂u/∂t + u ∂u/∂x = 0... Are you sure @ali-ramadhan that you set this up correctly? When I solve the 1D Burgers (using my own little script; not with Oceananigans.jl) I get something like: Also, @ali-ramadhan in your solution above I see noise forming for negative parts of the solution first. This might hint some biased in the scheme towards certain-sign velocities? |
Ah neat result @navidcy, thanks for posting your solution! Indeed I doubt I set it up correctly. I went back and tried to play around with the setup a bit but no luck. Perhaps I misunderstood how to reduce down to Burgers equation but might try again a bit later with fresh eyes... Out of curiosity what numerical method did you use? That's a super clean shock!
Yeah that weirded me out as well. Wasn't sure what to make of it but I decided to ignore it since I wasn't solving the right equation (or the setup was just wrong). I didn't notice any discrepency between periodic advection of a square waveform with positive and negative velocities, but I only checked using my unreliable eyeball norm. It's using the same advection schemes as Oceananigans.jl (which we've tested for convergence using positive and negative velocities). But because the prognostic variable is ρu there's an extra division by ρ since it computes fluxes of ρuu as (ρu)*(ρu)/ρ. So maybe I should be doing something like |
He's using 5th order WENO! |
I believe a lot of this work went into: https://github.com/ali-ramadhan/Atmosfoolery.jl Hopefully someday we get an atmospheric model with that name. But this repo should stay ocean focused, so I'm closing this. |
This PR adds a GPU-enabled
CompressibleModel
, developed with @thabbott and @RaphaelRR in a separate repository (https://github.com/ali-ramadhan/Atmosfoolery.jl). This is a large PR and I'm not even sure if it makes sense to merge it into Oceananigans.jl. The main purpose of opening this PR is to document progress made and ultimately decide on what to do with this feature. I don't think I can continue working on it.Description
The compressible model implements the conservative Scheme by Satoh (2003), suitable for compressible non-hydrostatic models with moist processes, and is valid in the limit of a condensable gas/atmosphere with multiple moist species. Two choices of prognostic thermodynamic variables are available, internal energy and entropy, although in the Oceananigans spirit adding new thermodynamic variables is pretty easy!
@thabbott implemented the Satoh (2003) equation set. I initially implemented the Klemp et al. (2007) equation set which is only valid in the limit of a dry atmosphere with trace amounts of moist species.
An RK3 time-stepper is used that is apparently 3rd-order accurate for linear terms but only 2nd-order accurate for non-linear terms. This is because it's developed to allow for acoustic time stepping between RK stages. This split-explicit time-stepping scheme is described by Wicker & Skamarock (2002), Klemp et al. (2007), and Satoh (2003). It's essentially the same one used by the NCAR WRF model (Skamarock et al., 2019). No acoustic time stepper is implemented yet. Explicit acoustic time stepping could make sense for regular Cartesian grids while a vertically implicit acoustic time stepper would make sense for vertically stretched grids (possible with
Oceananigans.Solver.BatchedTridiagonalSolver
).Building the compressible model on top of Oceananigans.jl has allowed it to run on GPUs and make use of the same operators, grids, Coriolis terms, forcing function and boundary conditions, diagnostics, output writers, higher-order advection schemes, and user-interface niceties. Turbulent diffusivity closures may take more work to integrate and not all of them can be shared as the stress tensor is not traceless when the fluid is compressible (see #654 for more discussion).
Reasons why we may consider adding a compressible model to the Oceananigans.jl ecosystem
CompressibleModel
is to simulate a compressible ocean (with pressure as a prognostic variable) in which sound waves artificially slowed down for practical purposes. There were some discussions around this idea and @johncmarshall54 might still be interested.CompressibleModel
andIncompressibleModel
share so much common infrastructure they also share a common user interface by construction which makes it easy to switch between the two. I think this is a valueble feature. Most existing packages do not have compressible/incompressible or ocean/atmosphere capabilities within the same package.Mono-repo vs. multiple packages
I think merging this PR puts the Oceananigans.jl repo in danger of becoming a mono-repo so we should be careful.
One big reason why we haven't kept the compressible model in a separate repo is because we just don't have a good name for it yet.
A potential pathway to multiple packages would be to split out the Oceananigans.jl package into four packages: OceananigansBase.jl, OceananigansIncompressible.jl, OceananigansCompressible.jl, and Oceananigans.jl. I'm not sure which modules would go where but the idea is that users will only have to keep interfacing with Oceananigans.jl.
An added advantage of keeping everything under some Oceananigans.jl umbrella is that the name is getting more well-known (and we have a JOSS paper) so I don't think it makes sense to start a second package with a new name that nobody knows (unless it's a good name!).
That said, I would not be opposed to a mono-repo with a well-defined scope. I actually think that this is a better approach. For example, Oceananigans.jl could provide the
CompressibleModel
andIncompressibleModel
but ocean-specific modules could live in separate packages. We did this with SeawaterPolynomials.jl and could probably do it with other modules to further limit scope if we decide to pursue this approach. So this is still a multiple packages approach but for ancillary features.Tests and validation experiments
We spent quite some time ensuring the
CompressibleModel
can simulate some known atmospheric test cases. Following recent trials and tribulations I also decided to add some simple 1D tests. Here I list the tests but will post a followup comment for each test with a figure or animation. Hopefully together these tests act as a starting point to start believing that theCompressibleModel
indeed does work as expected.See comments below for movies and eyeball norms.
The four dry rising thermal bubble simulations are used for regression testing.
GPU performance benchmarks
Preliminary benchmarks show a 75~80x speedup for large models when comparing a single CPU core to a single Titan V GPU on Tartarus. Not as good as the incompressible model as some of the functions that diagnose temperature and pressure need some optimizing, especially in the case of multiple gases.
TODO
Right now everything lives in a
compressible
directory to keep it separate.There are many improvements that could be made to the
CompressibleModel
, starting first with how reference states are initialized and how initial conditions are set (see verification scripts), but this is a list of TODO items in case we decide to merge this PR.compressible
directory.References
Jahn et al. (2015): https://doi.org/10.5194/gmd-8-317-2015
Klemp et al. (2007): https://doi.org/10.1175/MWR3440.1
Satoh (2003): https://doi.org/10.1175/1520-0493(2003)131%3C1033:CSFACN%3E2.0.CO;2
Skamarock et al. (2019): https://opensky.ucar.edu/islandora/object/opensky%3A2898
Sod (1978): https://doi.org/10.1016/0021-9991(78)90023-2
Straka et al. (1993): https://doi.org/10.1002/fld.1650170103
Wicker and Skamarock (1998): https://doi.org/10.1175/1520-0493(1998)126%3C1992:ATSSFT%3E2.0.CO;2