-
Notifications
You must be signed in to change notification settings - Fork 222
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
Don't precompute hydrostatic pressure in NonhydrostaticModel #1910
Conversation
Heh, well the The log suggests that the problem is confined to a few grid points, since the mean is correct:
Oceananigans.jl/test/test_dynamics.jl Line 241 in 9ecddac
I am skeptical about the value of this test. In general, discretizations do not necessarily represent the balance states of the continuous systems they approximate. Thus in general this test should fail! It will succeed of course in the case that the discrete system shares a balanced state with the continuous state. I think this is flawed as a test because, while certainly formulating discrete systems that share balanced states with their continuous systems is desirable, I'm not sure it's something we want to guarantee via CI. We should be allowed to violate this prescription if the discrete system has other more important desirable properties. It could be a nice validation test though. In this particular case, the nonhydrostatic useful is most often used for simulations of vigorous turbulence in which weak flows induced by a violation of hydrostatic balance are likely irrelevant. |
The change in this PR might conceivably produce changes in the dynamics because it changes the temporal discretization of the system. In particular, the pressure correction method corresponds to a first-order backward Euler discretziation of the pressure gradient term. On the other hand, since we calculate the hydrostatic pressure analytically coincident with other terms on the right hand side, it's treated with an explicit discretization (though the discretization is still first-order for the quasi-Adams-Bashforth scheme, it can have different error properties). Which time discretization is better? I don't know... |
@tomchor since you're the main person using the tilted gravity feature, I'm wondering if you can help provide some insight into this "stratified fluid at rest" test. The main issue is that the dynamics can be "correct" but the test can fail. I feel its a bad test for this reason. |
I don't have much to add to the discussion. I agree with you that a balanced state in a continuous system doesn't necessarily translate exactly to a discrete one. When I (or Ali?) came up with this test I figured this translation error would be small enough to be acceptable, and when the test actually passed I was happy enough with that. So if this translation error is indeed large enough with the new solver that the tests don't pass I'm very much okay with changing the test. I can't, for the moment, think of another simple test to replace it though. My best guess is to do something similar to what I did for the rotated Coriolis: solve a system with gravity pointing upwards and then the same system with gravity pointing to the |
Can't we just test directly that the output of More complicated integration tests, like testing that the discrete system has a balanced state analogous to the continuous one, seem better suited for a validation test, I think. |
Yeah, if you think that's enough for CI then I'm definitely okay with that! |
…structor and x_dot_g_b
Removed the "fluid at rest" test that was failing and included another (simpler) one for tilted buoyancy along with constructors. The new test checks that The only downside is that I only included the (Constructors are tested for both models, though.) |
Thanks @tomchor !! |
@glwagner I'm trying to use this branch for my research so I tried resolving the conflicts as best as I could. I hope you don't mind. Otherwise I can always revert back! |
The errors of the JLD2 output writer [CPU]: Test Failed at /var/lib/buildkite-agent/builds/tartarus-2/clima/oceananigans/test/test_jld2_output_writer.jl:135
--
| Expression: wT == zero(FT)
| Evaluated: -1.2037062f-34 == 0.0 which is something that should be solved by replacing |
Just a note: it seems like this PR is currently changing the dynamics. For example comparing the convecting plankton example in this PR has significantly more noise than the same example for the main branch. I haven't checked every example, but this also appears to happen in the Langmuir turbulence example, and especially in the internal wave one, which looks pretty bad... It doesn't show up in all of them though. For example the wind mixing one for some reason. I'm not sure if I did something wrong when merging the main branch, or if the effects were already there before (I don't remember checking before; @glwagner did you?) |
Is this a GPU problem? Is it still there when running on CPUs? We had some
very early issues with this. Ali may remember.
…On Thu, Dec 16, 2021, 2:56 PM Tomas Chor ***@***.***> wrote:
Just a note: it seems like this PR is currently changing the dynamics. For
example comparing the convecting plankton example in this PR
<https://clima.github.io/OceananigansDocumentation/previews/PR1910/generated/convecting_plankton/>
has significantly more noise than the same example for the main branch
<https://clima.github.io/OceananigansDocumentation/stable/generated/convecting_plankton/>.
I haven't checked every example, but this also appears to happen in the Langmuir
turbulence example
<https://clima.github.io/OceananigansDocumentation/previews/PR1910/generated/langmuir_turbulence/>,
and *especially* in the internal wave one
<https://clima.github.io/OceananigansDocumentation/previews/PR1910/generated/internal_wave/>,
which looks pretty bad...
It doesn't show up in all of them though. For example the wind mixing one
<https://clima.github.io/OceananigansDocumentation/previews/PR1910/generated/ocean_wind_mixing_and_convection/>
for some reason.
I'm not sure if I did something wrong when merging the main branch, or if
the effects were already there before (I don't remember checking before;
@glwagner <https://github.com/glwagner> did you?)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1910 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKXUEQU53Y5LV3FCQU5CWUTURHVZHANCNFSM5BHC6H6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
The equality failing in the tests happens for both CPUs and GPUs. The artifacts that appear in some simulations were only tested in CPUs I think. So it seems that GPUs aren't to blame here.Both issues ( |
I may not have been around for those tests! Here we're trying a different numerical algorithm that doesn't separate the hydrostatic and non-hydrostatic pressure. The numerics is different this way --- the non-hydrostatic pressure is in some sense treated "implicitly" (eg computed at t^{n+1} in order to advance the velocity field from n to n+1). The hydrostatic pressure, before this PR, was computed explicitly, at time-step t^n. The difference between the two numerical schemes could explain the issue @tomchor's observed (or there could be another bug). |
Unfortunately the PR previews are no longer showing so I'll try to update this PR... |
Maybe we can add a keyword argument to the |
Looks like this is a bad idea, so I'm closing. |
I'm not sure it's a bad idea. I've been having some issues with spurious waves in rotated domains and I'm thinking this might be the cause. (Since we're modifying the direction gravity is acting on, but we're still integrating the pressure in the model's z direction.) I still haven't been able to test my rotated domain on this branch, so I'm not sure. But if indeed this is the culprit, it might be a good idea to have a flag that turns the hydrostatic separation off for rotated domains. |
Hmm, ok I see that. I think this PR is a little stale but when you find time to document the problem, maybe open an issue and we can proceed from there? |
This PR inserts the vertical buoyant acceleration directly into the vertical momentum equation in
NonhydrostaticModel
, rather than integrating to find the hydrostatic pressure and inserting its gradient into the horizontal momentum equations.I just did the easiest thing right because I'm curious if regression tests pass. If they do, we can refactor
NonhydrostaticModel
to eliminate hydrostatic pressure, speed up the model, and reduce its memory footprint without too much pain (🎉)If the regression tests don't pass, we will unfortunately have slightly more pain ahead of us in refactoring the regression tests. In addition to the above advantages, we also need to eliminate vertical integrals in
NonhydrostaticModel
to permit 2D distributed memory parallelization. This is becausePencilFFTs
only allows parallelization across dimensions higher than 1 (or in other words, we cannot parallelize inx
). Thus with a vertical integral, we can only parallelize easily acrossy
. If we eliminate the vertical integral, we'll be able to parallelize iny, z
.