-
Notifications
You must be signed in to change notification settings - Fork 31
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
Adds enstrophy budget diagnostics for 2D and barotropic QG #103
Conversation
thanks @BrodiePearson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let @navidcy look at the correctness of these functions. Tests would probably be good (but can be added in a subsequent PR). I've just made some comments about naming (using full English words, and English-language patterns is best in my opinion). Great contribution!
I agree with @glwagner function name suggestions. I think if we'll have, e.g., an I think that some tests would be useful. For the energy budget terms we don't test each of them separately (perhaps we should) but rather check that the budget terms add up to give the energy tendency as computed numerically, see, e.g., GeophysicalFlows.jl/test/test_barotropicqg.jl Line 127 in 27a1374
@BrodiePearson, I can help out add some enstrophy budget tests if you'd like me to. Let me know. |
@navidcy & @glwagner Thanks for the suggestions and comments! I changed the diagnostic names in the 2D model to be I did not update the BarotropicQG model any further. In another branch I have added hypo-viscosity of arbitrary power for the BarotropicQG model [in line with the 2D model capabilities], so I could bundle it in a PR for that if it would be a useful enhancement. |
Project.toml
Outdated
@@ -10,6 +10,7 @@ FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" | |||
FourierFlows = "2aec4490-903f-5c70-9b11-9bed06a700e1" | |||
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" | |||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | |||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to add Plots as a dependency of the package. When one wants to run some of the examples they should load the examples/Project.toml
. The docs also have Plots as a dependency; see docs/Project.toml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I hadn't realized those separate Project.toml
files existed (I'm new to Julia).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries!
@BrodiePearson this is great -- thanks! |
test/test_twodnavierstokes.jl
Outdated
|
||
isapprox(mean(abs.(residual)), 0, atol=1e-8) | ||
isapprox(mean(abs.(residualZ)), 0, atol=1e-8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the test is written now will only return true
or false
for the enstrophy budget.
Last two lines of the `tests should be changed to
return isapprox(mean(abs.(residual)), 0, atol=1e-8) && isapprox(mean(abs.(residualZ)), 0, atol=1e-8)
|
||
residual = dEdt - total | ||
isapprox(mean(abs.(residual)), 0, atol=1e-4) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be changed to:
residual = dEdt - total
residualZ = dZdt - totalZ
return isapprox(mean(abs.(residual)), 0, atol=1e-4) && isapprox(mean(abs.(residualZ)), 0, atol=(kf^2)*1e-4)
otherwise only the answer regarding the enstrophy budget is taken into consideration.
I'm not ignoring this @BrodiePearson. While reviewing this I realised that there was a bug in the tests for deterministic forcing energy budgets for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest splitting the test_twodnavierstokes_stochasticforcingbudgets()
to test_twodnavierstokes_stochasticforcing_energybudgets()
and test_twodnavierstokes_stochasticforcing_enstrophybudgets()
. Similarly for ...deterministicforcing_...
. But this can be also done after we merge!
This is a nice addition. Thanks @BrodiePearson. I suggest we merge and we can add some tests for the enstrophy budgets in BarotropicQG
later.
Regarding the hypoviscosity in BarotropicQG
, I have never seen anybody using hypo-viscosity in a QG setup. Do you have anything in mind? I was under the impression that hypo-viscosity was only a "trick" to dissipate energy piling up at largest scale without affecting the inertial range and that was only used in 2D turbulence simulations.
Added more accurate enstrophy dissipation. Fixed legends to fix typos and remove ambiguity. Changed enstrophy diagnostics to superscript Z notation (otherwise the drag legend was ambiguous)
Added missing CUDA statement
Added missing CUDA statement
Modification so check tests both energy and enstrophy budgets
@navidcy Thanks for catching those issues and for suggesting resolutions. I made all the suggested changes and also fixed some typos in the example figures. Feel free to make any modifications if you catch more. As for the hypo-drag, I'm using the barotropic QG model to simulate anisotropic 2D turbulence (i.e. 2D turbulence on a sphere). I'm interested in the statistics of the inverse energy and direct enstrophy cascades as a function of the flow anisotropy, and hypo-drag gets used for these types of simulation (e.g. this study). I'm planning to use the 2D and BarotropicQG models together to achieve this, and since hypo-drag was critical to get a nice isotropic inverse cascade in the 2D model I wanted to be able to run exactly comparable simulations in BarotropicQG. I'm hoping this will complement an analogous study under a range of QG conditions using the other GeophysicalFlows models. If you'd like I would be happy to discuss my plans in more detail, I think GeophysicalFlows is going to be central to my modelling efforts. |
I added three diagnostics to look at the enstrophy budget in anisotropic 2D turbulence (i.e. in the 2D and barotropic QG modules). The diagnostics are complementary to the existing energy budget diagnostics; the dissipation of enstrophy, the hypo-viscous/drag removal of enstrophy, and the rate of enstrophy production/destruction by the forcing.