Skip to content
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

Merged
merged 20 commits into from
Sep 11, 2020

Conversation

BrodiePearson
Copy link
Collaborator

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.

@navidcy
Copy link
Member

navidcy commented Sep 8, 2020

thanks @BrodiePearson
I'll have a look and let you know!

@navidcy navidcy self-requested a review September 8, 2020 04:25
@navidcy navidcy added the 🤥 enhancement New feature or request label Sep 8, 2020
Copy link
Member

@glwagner glwagner left a 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!

@navidcy
Copy link
Member

navidcy commented Sep 8, 2020

I agree with @glwagner function name suggestions. I think if we'll have, e.g., an enstrophy_dissipation() function we might as well rename the current dissipation to energy_dissipation()?

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.,

function test_bqg_deterministicforcingbudgets(dev::Device=CPU(); n=256, dt=0.01, L=2π, ν=1e-7, nν=2, μ=1e-1)

function test_bqg_stochasticforcingbudgets(dev::Device=CPU(); n=256, dt=0.01, L=2π, ν=1e-7, nν=2, μ=1e-1, T=Float64)

@BrodiePearson, I can help out add some enstrophy budget tests if you'd like me to. Let me know.

@BrodiePearson
Copy link
Collaborator Author

@navidcy & @glwagner Thanks for the suggestions and comments!

I changed the diagnostic names in the 2D model to be enstrophy_dissipation, energy_work etc. I also added a tests for the enstrophy budget residual, and changed the 2D forced-dissipative example to plot the enstrophy and energy budget analyses alongside each other (see below). Let me know if you see any issues! The enstrophy budget terms and the residual are a couple of orders of magnitude larger than their energy budget counterparts because there is a factor of (forcing_wavenumber)^2 difference between the enstrophy and energy injection rates.

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.

Budget_Diagnostics

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"
Copy link
Member

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.

Copy link
Collaborator Author

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries!

@navidcy
Copy link
Member

navidcy commented Sep 9, 2020

@BrodiePearson this is great -- thanks!
I'll have a careful look soon.


isapprox(mean(abs.(residual)), 0, atol=1e-8)
isapprox(mean(abs.(residualZ)), 0, atol=1e-8)
Copy link
Member

@navidcy navidcy Sep 9, 2020

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)

Copy link
Member

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.

@navidcy
Copy link
Member

navidcy commented Sep 10, 2020

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 TwoDNavierStokes. I fixed it in #105.

Copy link
Member

@navidcy navidcy left a 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.

src/barotropicqg.jl Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
examples/twodnavierstokes_stochasticforcing.jl Outdated Show resolved Hide resolved
BrodieP added 4 commits September 10, 2020 22:39
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
@BrodiePearson
Copy link
Collaborator Author

@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.

@navidcy navidcy merged commit e8c39e4 into FourierFlows:master Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤥 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants