-
Notifications
You must be signed in to change notification settings - Fork 11
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
Tim fml notebooks #294
base: main
Are you sure you want to change the base?
Tim fml notebooks #294
Conversation
Hopefully changes in #297 fix the above issues |
…_fixes Fixed failing notebook tests, updated CI, made tests DRYer
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 think this looks really nice and I'm really excited for us to have these in Gusto. Thanks so much for doing all of this.
I have a few pernickety comments about style of some particular comments and things we can probably omit -- if you disagree with anything please feel free to ignore it. The main thing that I think would be nice is to add lint checking, which I suspect may highlight some more issues.
I've only looked at the first notebook -- I thought I'd come back to that in case you want to make any changes having used the lint checker.
I was also wondering whether we want to include the mountain notebook? Some of the routines in there aren't that obvious so it might be quite challenging as an introduction. Maybe there's something important in that case that I'm missing though that is helpful!
My final suggestion is about the names of the notebooks. I think the first one is great, the second one could do with some capitalisation to make it look consistent (i.e. Book_2_Gravity_Wave_Vertical_Slice) and finally I think the final one might be best as Book_3_Lowest_Order_Rising_Bubble (or book 4 if you keep the mountain!)
@@ -10,18 +10,24 @@ lint: | |||
@echo " Linting gusto plotting scripts" | |||
@python3 -m flake8 plotting |
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 think it would be nice to add the notebooks to the lint checker here, I think just by adding:
@echo " Linting gusto jupyter notebooks"
@python3 -m flake8 jupyter_notebooks
I expect when you run make lint
it will then throw up a bunch of things to change in the notebooks though! But that will help make sure the code is consistent everywhere. One of the main things will be to make sure that we leave a space between the #
at the start of a comment and the text after it.
"metadata": {}, | ||
"source": [ | ||
"This notebook provides an introduction to Gusto. We will go through the example of the Williamson 2 test case to demonstrate how to set up the problem and run it. This comes from the paper: \\\n", | ||
"David L. Williamson, John B. Drake, James J. Hack, Rüdiger Jakob, Paul N. Swarztrauber,\n", |
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 think it would be OK to give the reference in a shorter form since we are giving the link to it, i.e.:
"This is the second test from Williamson et al (1992), "
"\n", | ||
"The parameters we need to specify are the Coriolis force, $f$, gravitational constant, $g$, and mean depth, $H$.\n", | ||
"$\\newline$\n", | ||
"We can neglect boundary conditions, due to solving on a spherical domain. \\ \n", |
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.
There is a rogue backslash somewhere around here
"source": [ | ||
"The Williamson 2 test case solves the shallow water equations. This corresponds to the following set of momentum and continuity equations, for a velocity $\\textbf{u}$ and free surface, $\\eta$:\n", | ||
"$$\\textbf{u}_t + f \\textbf{u}^{\\perp} + g \\nabla \\eta + (\\textbf{u} \\cdot \\nabla) \\textbf{u} = 0$$\n", | ||
"$$\\eta_t + H(\\nabla \\cdot \\textbf{u}) + \\nabla [\\textbf{u} (\\eta - b)] = 0$$\n", |
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 have a very petty suggestion for how we write the shallow-water equations. I prefer to see the transport term (u.grad)u immediately after the time derivative in the momentum equation (so that you can easily see that together these are the material derivative). For the continuity equation, can we just write
\\eta_t + \\nabla \\cdot [(\\eta - b) \\textbf{u}] = 0
?
Please feel free to ignore if you disagree!
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.
Yes, I agree with grouping the terms in that way and I also think we should try to be consistent with the names in the code - i.e. we use D
for the prognostic variable, where D=H+\eta-b
.
"The parameters we need to specify are the Coriolis force, $f$, gravitational constant, $g$, and mean depth, $H$.\n", | ||
"$\\newline$\n", | ||
"We can neglect boundary conditions, due to solving on a spherical domain. \\ \n", | ||
"Williamson 2 is called 'Global Steady State Nonlinear Zonal Geostrophic Flow', so the solution should not change over time." |
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.
Maybe we could rewrite this as "The second Williamson test case models zonal geostrophic flow. This is a steady-state solution of the shallow-water equations, so the true solution does not change with time."
"source": [ | ||
"from gusto import *\n", | ||
"from firedrake import IcosahedralSphereMesh, SpatialCoordinate, as_vector\n", | ||
"from math import pi\n", |
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 wonder if we could actually just import pi
from firedrake
? I think we also might not need to do import sys
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.
yes, this is probably highlighting that the examples need a bit more tidying...
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"output = OutputParameters(dirname=\"sw_W2_ref%s_dt%s\" % (ref_level, dt),\n", |
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 actually can probably give a clearer directory name -- maybe just:
dirname="williamson_2_intro"
"source": [ | ||
"We are now ready to specify the initial conditions.\n", | ||
"Due to our choice of function spaces for the velocity and depth, the intialisations of each variable use projection \n", | ||
"and interpolation operations respectively. Williamson 2 specifies initial conditions for a 'Global Steady State Non-linear Zonal Geostrophic Zone' (do I need this detail?). \n", |
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 think you don't need this detail -- we've explained the initial condition at the top so I think it's OK to leave this out
"and interpolation operations respectively. Williamson 2 specifies initial conditions for a 'Global Steady State Non-linear Zonal Geostrophic Zone' (do I need this detail?). \n", | ||
"$$ \\textbf{u}_0 = \\frac{u_{max}}{R} [-y,x,0] $$\n", | ||
"$$ h_0 = H - \\frac{\\Omega u_{max} z^2}{g R} $$\n", | ||
"We only require a two-dimensional velocity, so the vertical component is specified to be zero. (Jemma/Tom question: Why is $R/R^2$ used in the code)???" |
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 think we are embedded in a 3D space so we are specifying all three of the Cartesian components of the velocity. I don't think we need the R/R^2
so maybe you can cancel one out! Presumably the was originally done to make it clear that the final part is sin^2(lat)
?
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#Now, construct the time-stepper. We will firstly use a semi-implicit (?) approach.\n", |
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.
Yes it's semi-implicit
!
I suggested the mountain as it demonstrates how to deform the mesh - so maybe not an introductory notebook but a more advanced one! |
Thanks Tim, these are a great start to our notebook resources! |
Ah OK! Maybe that can be the fourth then? And maybe it should be called Book_4_Flow_Over_A_Mountain |
Hi Tom and Jemma, thanks for the feedback! I've made the changes you've mentioned and have added the notebooks to the lint checker, so will see what that comes back with. |
Merge branch 'main' of https://github.com/firedrakeproject/gusto into tim_FML_notebooks
… tim_FML_notebooks
…ct/gusto into tim_FML_notebooks
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 again Tim for all your work on this! I've been through all the notebooks now and think it's looking good. I've left what seems to be a lot of comments but I think they should hopefully be very minor -- it's mainly neatening a few things that are still leftover and answering your questions.
The most major thing is that I'm wondering if it'd actually be clearer to reome the plotting code from the second notebook, and additionally the point data file?
"source": [ | ||
"The Williamson 2 test case solves the shallow water equations. This corresponds to the following set of momentum and continuity equations, for a velocity $\\textbf{u}$ and free surface, $\\eta$:\n", | ||
"$$\\textbf{u}_t + (\\textbf{u} \\cdot \\nabla) \\textbf{u} + f \\textbf{u}^{\\perp} + g \\nabla \\eta = 0$$\n", | ||
"$$\\eta_t + \\nabla \\cdot [(\\eta - b) \\textbf{u}] = 0$$\n", |
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.
Sorry to be a pain since you already changed this! I'm wondering now if we should make sure that this matches the equations used in the code. I think that means doing "depth
"metadata": {}, | ||
"source": [ | ||
"We can specify which diagnostics we wish to record over a simulation. The list of avaliable diagnostics can be found in the gusto source code: https://github.com/firedrakeproject/gusto/blob/main/gusto/diagnostics.py \\\n", | ||
"We pass these diagnostics into the State function. This will initialise all the necessary components of the test case. Gusto will update this state after each iteration of the chosen time-stepper." |
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.
It could be nice to use code formatting for State
to highlight that it's a code object. I guess this is the backwards apostrophes?
"id": "80f8c00a", | ||
"metadata": {}, | ||
"source": [ | ||
"A spatially varying Coriolis force is defined over the sphere. We then can set-up our form of the shallow water equations by passing the state and Coriolis parameter into the ShallowWaterEquations() function. We additionally specify the function space (BDM) and degree (1) that we want to use with the Compatiable Finite Element method. " |
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.
As above, it could be nice to use code formatting for the ShallowWaterEquations()
phrase to highlight that it's a code object.
"id": "1e1ae651", | ||
"metadata": {}, | ||
"source": [ | ||
"We can specify which diagnostics we wish to record over a simulation. The list of avaliable diagnostics can be found in the gusto source code: https://github.com/firedrakeproject/gusto/blob/main/gusto/diagnostics.py \\\n", |
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.
On the github page there is a rogue backslash after the hyperlink -- is it possible to remove this?
"id": "2b518722", | ||
"metadata": {}, | ||
"source": [ | ||
"After the simulation is completed, you should see that there is now a 'results' directory, with another directory holding the output. The output at the specified times is saved in a .vtu format that can be viewed using Paraview. There are five files, corresponding to the specified dump times (field_output1.vtu, field_output2.vtu, etc.), as well as one for the initial conditions (field_output0.vtu). Paraview can be downloaded from the following link: https://www.paraview.org/ \\" |
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.
On the github page there is a rogue backslash after the hyperlink -- is it possible to remove this? No worries if not or if it doesn't appear normally.
"id": "3ec4b5fe", | ||
"metadata": {}, | ||
"source": [ | ||
"# Notebook 3: Mountain Wave Test Case" |
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 suppose this is notebook 4 now -- sorry!
"id": "eb79138f", | ||
"metadata": {}, | ||
"source": [ | ||
"This notebook will go through an example of a hydrostatic flow over a mountain. This test case is outlined in the paper: Melvin, T., Dubal, M., Wood, N., Staniforth, A., & Zerroukat, M. (2010). An inherently mass‐conserving iterative semi‐implicit semi‐Lagrangian discretization of the non‐hydrostatic vertical‐slice equations. Quarterly Journal of the Royal Meteorological Society: A journal of the atmospheric sciences, applied meteorology and physical oceanography, 136(648), 799-814." |
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.
Again we can probably shorten this citation and give the link: https://doi.org/10.1002/qj.603
"id": "2fb1fb2d", | ||
"metadata": {}, | ||
"source": [ | ||
"We now invoke the smooth_z variable, I assume to smooth out the vertical profile somehow (do we want an explanation of this?? We then apply this smoothing to the defined mesh." |
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 actually think it's clearest if we remove the smoother_z
flag? But we can still use the smoother z profile. The description here could then be something like: "Now we transform the mesh to follow the defined terrain. A smoothing is applied in the vertical direction."
"outputs": [], | ||
"source": [ | ||
"supg = True\n", | ||
"if supg:\n", |
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.
As in the second book we should probably just pick to use supg
and get rid of the flag here
"id": "10e50cf7", | ||
"metadata": {}, | ||
"source": [ | ||
"What other feature do we want to demonstrate in this notebook?" |
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 think that's all good!
Hi Tom,
Sorry for the late reply - I just came back from my NZ trip.
I'll look into making those adjustments to the notebooks today. Thanks for reading through them!
Tim
________________________________
From: tommbendall ***@***.***>
Sent: Friday, 16 September 2022 4:16 pm
To: firedrakeproject/gusto ***@***.***>
Cc: Andrews, Tim ***@***.***>; Author ***@***.***>
Subject: Re: [firedrakeproject/gusto] Tim fml notebooks (PR #294)
CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe.
@tommbendall requested changes on this pull request.
Thanks again Tim for all your work on this! I've been through all the notebooks now and think it's looking good. I've left what seems to be a lot of comments but I think they should hopefully be very minor -- it's mainly neatening a few things that are still leftover and answering your questions.
The most major thing is that I'm wondering if it'd actually be clearer to reome the plotting code from the second notebook, and additionally the point data file?
________________________________
In jupyter_notebooks/Book_1_Intro_Williamson_2.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973035384&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382435974927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JKCQh11F2dsG2O8dbggCDKOXQ%2B%2F3jvHc5U%2FY9aPbUOg%3D&reserved=0>:
+ "cell_type": "markdown",
+ "id": "5371527b",
+ "metadata": {},
+ "source": [
+ "This notebook provides an introduction to Gusto. We will go through the example of the Williamson 2 test case to demonstrate how to set up the problem and run it. This is the second test from the Williamson et al (1992) paper, which can be found at: \n",
+ "https://doi.org/10.1016/S0021-9991(05)80016-6."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "664c0cba",
+ "metadata": {},
+ "source": [
+ "The Williamson 2 test case solves the shallow water equations. This corresponds to the following set of momentum and continuity equations, for a velocity $\\textbf{u}$ and free surface, $\\eta$:\n",
+ "$$\\textbf{u}_t + (\\textbf{u} \\cdot \\nabla) \\textbf{u} + f \\textbf{u}^{\\perp} + g \\nabla \\eta = 0$$\n",
+ "$$\\eta_t + \\nabla \\cdot [(\\eta - b) \\textbf{u}] = 0$$\n",
Sorry to be a pain since you already changed this! I'm wondering now if we should make sure that this matches the equations used in the code. I think that means doing "depth $D$" and the equations becoming:
$\textbf{u}_t + (\textbf{u} \cdot \nabla) \textbf{u} + f \textbf{u}^{\perp} + g \nabla(D+b) = 0$,
$D_t + \nabla \cdot (D \textbf{u}) = 0$
________________________________
In jupyter_notebooks/Book_1_Intro_Williamson_2.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973040797&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382435974927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=fRwPPNAgx8XTDQO6hJuL3v2l2CWKO4ao9knB6RjZcQ8%3D&reserved=0>:
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "output = OutputParameters(dirname=\"williamson_2_intro\",\n",
+ " dumpfreq=dumpfreq,\n",
+ " steady_state_error_fields=['u', 'D'],\n",
+ " log_level='INFO')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1e1ae651",
+ "metadata": {},
+ "source": [
+ "We can specify which diagnostics we wish to record over a simulation. The list of avaliable diagnostics can be found in the gusto source code: https://github.com/firedrakeproject/gusto/blob/main/gusto/diagnostics.py \\\n",
+ "We pass these diagnostics into the State function. This will initialise all the necessary components of the test case. Gusto will update this state after each iteration of the chosen time-stepper."
It could be nice to use code formatting for State to highlight that it's a code object. I guess this is the backwards apostrophes?
________________________________
In jupyter_notebooks/Book_1_Intro_Williamson_2.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973041077&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382435974927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=03BGnU0YZdnJEtR1gARicBaDQm8%2BkjsVUH9PrBge4aU%3D&reserved=0>:
+ " ShallowWaterPotentialEnstrophy(),\n",
+ " CourantNumber()]\n",
+ "\n",
+ "state = State(mesh,\n",
+ " dt=dt,\n",
+ " output=output,\n",
+ " parameters=parameters,\n",
+ " diagnostic_fields=diagnostic_fields)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "80f8c00a",
+ "metadata": {},
+ "source": [
+ "A spatially varying Coriolis force is defined over the sphere. We then can set-up our form of the shallow water equations by passing the state and Coriolis parameter into the ShallowWaterEquations() function. We additionally specify the function space (BDM) and degree (1) that we want to use with the Compatiable Finite Element method. "
As above, it could be nice to use code formatting for the ShallowWaterEquations() phrase to highlight that it's a code object.
________________________________
In jupyter_notebooks/Book_1_Intro_Williamson_2.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973042108&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382435974927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=s9qBuP2WWN0h3meAJOD3bG5Fr7zEOEX6mg0nMSjVLi0%3D&reserved=0>:
+ "id": "754708dd",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "output = OutputParameters(dirname=\"williamson_2_intro\",\n",
+ " dumpfreq=dumpfreq,\n",
+ " steady_state_error_fields=['u', 'D'],\n",
+ " log_level='INFO')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1e1ae651",
+ "metadata": {},
+ "source": [
+ "We can specify which diagnostics we wish to record over a simulation. The list of avaliable diagnostics can be found in the gusto source code: https://github.com/firedrakeproject/gusto/blob/main/gusto/diagnostics.py \\\n",
On the github page there is a rogue backslash after the hyperlink -- is it possible to remove this?
________________________________
In jupyter_notebooks/Book_1_Intro_Williamson_2.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973042912&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382435974927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CGl2rlUD1zPIT6D52nONgG7JoqpESMJETEq99Vow0MI%3D&reserved=0>:
+ "execution_count": null,
+ "id": "46852826",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Run the time-stepper and generate the output.\n",
+ "# Uncomment the next line if you want to actually get the output.\n",
+ "# stepper.run(t=0, tmax=tmax)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2b518722",
+ "metadata": {},
+ "source": [
+ "After the simulation is completed, you should see that there is now a 'results' directory, with another directory holding the output. The output at the specified times is saved in a .vtu format that can be viewed using Paraview. There are five files, corresponding to the specified dump times (field_output1.vtu, field_output2.vtu, etc.), as well as one for the initial conditions (field_output0.vtu). Paraview can be downloaded from the following link: https://www.paraview.org/ \\"
On the github page there is a rogue backslash after the hyperlink -- is it possible to remove this? No worries if not or if it doesn't appear normally.
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973057548&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382435974927%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=h1gYLQAqp6iBliI4WS%2F6EqYCq6z%2B8ERIzJa2T9jDf7U%3D&reserved=0>:
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3ec4b5fe",
+ "metadata": {},
+ "source": [
+ "# Notebook 2: Vertical Slice Gravity wave"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "97f52073",
+ "metadata": {},
+ "source": [
+ "In the first notebook, we looked at the shallow water equations. Gusto can also solve the Boussinesq and Euler equations in their compressible or incompressible forms. This notebook we will demonstrate running the Compressible Euler equations with a gravity wave. \\\n",
On the github page there is a rogue backslash at the end of this sentence-- is it possible to remove this?
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973067280&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=chR2wH70ZM7%2F0pykfzrer3cgxgu%2BK7ytVMvKUuUS%2Bns%3D&reserved=0>:
+ },
+ {
+ "cell_type": "markdown",
+ "id": "97f52073",
+ "metadata": {},
+ "source": [
+ "In the first notebook, we looked at the shallow water equations. Gusto can also solve the Boussinesq and Euler equations in their compressible or incompressible forms. This notebook we will demonstrate running the Compressible Euler equations with a gravity wave. \\\n",
+ "In this equation set, we simulate the evolution of the velocity $\\textbf{u}$, the dry density $\\rho$, and the (virtual dry) potential temperature $\\theta$. We will demostrate how to visualise a vertical slice of the potential temperature. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "f126f52b",
+ "metadata": {},
+ "source": [
+ "The initial conditions for this are given in the paper: Klemp, J. B., Rotunno, R., & Skamarock, W. C. (1994). On the dynamics of gravity currents in a channel. Journal of Fluid Mechanics, 269, 169-198."
I have always cited Skamarock and Klemp (1994) for this test -- I think as with the first notebook you could cite it with the DOI, i.e. "Skamarock and Klemp (1994): https://doi.org/10.1175/1520-0493(1994)122<2623:EAAOTK>2.0.CO;2<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1175%2F1520-0493(1994)122%253C2623%3AEAAOTK%253E2.0.CO%3B2&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=kAPZYgW2rA1%2F5vzDAwew3hXxlMXUNEP1eruCZN4gqXk%3D&reserved=0>
PS @jshipton<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjshipton&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ScZf3AsIaX9w1bbjlRr%2Fgk%2FM36CTLgaza%2BdwhlEG9Wo%3D&reserved=0> looking at the paper it also has a hydrostatic solution which I think looks like ours!
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973068145&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=UPZn%2FG2f%2FpVoI%2BHaFn%2BOi0oPhk360BgJce4B7DmoaME%3D&reserved=0>:
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "7779c15b",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "firedrake:WARNING OMP_NUM_THREADS is not set or is set to a value greater than 1, we suggest setting OMP_NUM_THREADS=1 to improve performance\n"
+ ]
+ }
+ ],
+ "source": [
+ "from petsc4py import PETSc\n",
I think we don't need the top two lines of code
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973072291&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OyZw%2F7pO%2Fw3bASa1Zi56XcDstJExnWKrczNRI8qF9Iw%3D&reserved=0>:
+ "execution_count": 2,
+ "id": "f5147739",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "dt = 6.\n",
+ "tmax = 3600.\n",
+ "dumpfreq = int(tmax / (2*dt))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "48ee6e88",
+ "metadata": {},
+ "source": [
+ "For this vertical slice model, we firstly define a horizontal periodic interval mesh? We then choose the number of layers and columns we want to simulate in this flow. The periodic mesh is extruded in the vertical direction for this number of layers."
Yep, it's a horizontal periodic interval mesh
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973073565&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8AH0EyiQfCtz%2B4ETHJLBMZp9HH4Zg9EYjJt0fAJXf6U%3D&reserved=0>:
+ "\n",
+ "output = OutputParameters(dirname=dirname,\n",
+ " dumpfreq=dumpfreq,\n",
+ " pddumpfreq=dumpfreq,\n",
+ " dumplist=['u'],\n",
+ " perturbation_fields=['theta', 'rho'],\n",
+ " point_data=[('theta_perturbation', points)],\n",
+ " log_level='INFO')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1e1ae651",
+ "metadata": {},
+ "source": [
+ "Now, define the parameters and diagnostics we want to record. We are interested in the temperature gradients, which is automatically computed using the Gradient() function. As always, we then initialise the 'state' that will evolve with each time-step."
You could use the code formatting for Gradient here
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973077074&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JclfIcBS69iLY0ZaMCmGyDmUinEbxImr14oeyhrzI3A%3D&reserved=0>:
+ "source": [
+ "parameters = CompressibleParameters()\n",
+ "g = parameters.g\n",
+ "Tsurf = 300.\n",
+ "\n",
+ "diagnostic_fields = [CourantNumber(), Gradient(\"u\"),\n",
+ " Gradient(\"theta_perturbation\"),\n",
+ " RichardsonNumber(\"theta\", g/Tsurf), Gradient(\"theta\")]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "80f8c00a",
+ "metadata": {},
+ "source": [
+ "As always, we initialise the 'state' that will evolve with each time-step. We will solve the Compressible Euler Equations using order 1 Continuous Galerkin finite elements (I think?)."
There is a complexity that we might want to explain here: as we are on an extruded mesh, the finite element spaces use tensor product elements. Then the family corresponds to the family of the velocity space for the base horizontal mesh -- in this case the base horizontal mesh is 1D so we have to choose "CG" as the family. But actually none of the fields are in the 2D CG space!
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973078834&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=A%2F9iXnayrIeStgt2bARj7IaEy%2BA%2FRvk786ZI0Lr67ws%3D&reserved=0>:
+ "x, z = SpatialCoordinate(mesh)\n",
+ "\n",
+ "# N^2 = (g/theta)dtheta/dz => dtheta/dz = theta N^2g => theta=theta_0exp(N^2gz)\n",
+ "Tsurf = 300.\n",
+ "thetab = Tsurf*exp(N**2*z/g)\n",
+ "\n",
+ "theta_b = Function(Vt).interpolate(thetab)\n",
+ "rho_b = Function(Vr)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "04687319",
+ "metadata": {},
+ "source": [
+ "We compute a hydrostatic Exner pressure to ensure a hydrostatic balance, then apply this to the initial state (is this correct?)"
This step takes a theta profile and computes the corresponding rho that will give hydrostatic balance
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973080186&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QDe2RV0GusmAoxzxhO%2BO6A0nOtAR4S5QgXdTkQk8KMw%3D&reserved=0>:
+ "deltaTheta = 1.0e-2\n",
+ "theta_pert = deltaTheta*sin(np.pi*z/H)/(1 + (x - L/2)**2/a**2)\n",
+ "theta0.interpolate(theta_b + theta_pert)\n",
+ "rho0.assign(rho_b)\n",
+ "u0.project(as_vector([20.0, 0.0]))\n",
+ "\n",
+ "state.set_reference_profiles([('rho', rho_b),\n",
+ " ('theta', theta_b)])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2b518722",
+ "metadata": {},
+ "source": [
+ "Set up the linear solver and the time-stepper. As per the first notebook, we use Implicit Midpoint method for the velocity field, and an explicit SSPRK3 scheme for the other variables (density and potential temperature). This time, we need to specify the use of a compressible solver."
You could also mention that for theta we are using an SUPG transport
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973082710&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ZRggO5LDhTuf3fNqdiJTeQOOcbS63FWC4zrDNNheZ8Q%3D&reserved=0>:
+ "cell_type": "markdown",
+ "id": "2b518722",
+ "metadata": {},
+ "source": [
+ "Set up the linear solver and the time-stepper. As per the first notebook, we use Implicit Midpoint method for the velocity field, and an explicit SSPRK3 scheme for the other variables (density and potential temperature). This time, we need to specify the use of a compressible solver."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "7e16a3dc",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "supg = True\n",
+ "if supg:\n",
I think in the notebook we can just use the SUPG options by default, i.e. remove the supg = True flag and then in the transported_fields list do:
SSPRK3(state, "theta", options=SUPG_options())
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973083699&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hqjPnCzriujTu61lnkdvz7qpyQTluXTatCNKGAT3fTI%3D&reserved=0>:
+ " SSPRK3(state, \"theta\", options=theta_opts)]\n",
+ "\n",
+ "# Set up linear solver\n",
+ "linear_solver = CompressibleSolver(state, eqns)\n",
+ "\n",
+ "# build time stepper\n",
+ "stepper = CrankNicolson(state, eqns, transported_fields,\n",
+ " linear_solver=linear_solver)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "a33d7329",
+ "metadata": {},
+ "source": [
+ "Next, you would solve the equations! However, they take ages to run, so we should not bother, or just run for a couple of time steps .... ."
Let's have it run for a couple of timesteps!
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973084945&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ymYNeJ4DjC%2FWbxf4MLrz%2B8egyXDoYSsAbN%2BTdKlihZY%3D&reserved=0>:
+ "cell_type": "code",
+ "execution_count": 15,
+ "id": "892d41ae",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Here's what you would do...\n",
+ "# stepper.run(t=0, tmax=tmax)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1ce2d33f",
+ "metadata": {},
+ "source": [
+ "To save you having to run this full simulation, results have already been generated and stored in the 'results/sk_nonlinear' subdirectory. We will show a visualisation of the potential temperature at the points we specified earlier \\\n",
I see another rogue slash here!
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973086459&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vmPj2CzvAXcF1EIxeXbhxEJeqSEskZQ6DPxwJzVqB8s%3D&reserved=0>:
+ "source": [
+ "# Here's what you would do...\n",
+ "# stepper.run(t=0, tmax=tmax)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "1ce2d33f",
+ "metadata": {},
+ "source": [
+ "To save you having to run this full simulation, results have already been generated and stored in the 'results/sk_nonlinear' subdirectory. We will show a visualisation of the potential temperature at the points we specified earlier \\\n",
+ "We set-up the visualisations that can be used in Jupyter notebook:"
+ ]
+ },
+ {
+ "cell_type": "code",
I think it might actually be better to remove all the plotting code from here? But keep the figure at the bottom. Then we can focus on the example rather the plotting! I guess then we wouldn't need the data to be uploaded either? What do you think?
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973092569&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3C8IDGBmPmBRi0uVVhBTEKAgKvwic1MhzIpD0KT%2B9X8%3D&reserved=0>:
+ },
+ {
+ "data": {
+ "text/plain": [
+ "<matplotlib.legend.Legend at 0x7fa8d8ece520>"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "p = Plot1DProfile(\"results/sk_nonlinear/point_data.nc\", \"theta_perturbation\", 0, [5000])\n",
+ "p.plot(same_plot='True')\n",
+ "plt.xlabel('Vertical distance (?)')\n",
I think this is horizontal distance, i.e. x / km
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973092823&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436130688%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gh4iEnk1XrsyUT9Xjieka0qgCdDMhQToGjRVjFpqyjc%3D&reserved=0>:
+ {
+ "data": {
+ "text/plain": [
+ "<matplotlib.legend.Legend at 0x7fa8d8ece520>"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "p = Plot1DProfile(\"results/sk_nonlinear/point_data.nc\", \"theta_perturbation\", 0, [5000])\n",
+ "p.plot(same_plot='True')\n",
+ "plt.xlabel('Vertical distance (?)')\n",
+ "plt.ylabel('Potential temperature')\n",
In K
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973093903&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FwLPJkEfGSC6wZYCChRCOXm0dPhose72Z0elNmiW3Z0%3D&reserved=0>:
+ "data": {
+ "text/plain": [
+ "<matplotlib.legend.Legend at 0x7fa8d8ece520>"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "p = Plot1DProfile(\"results/sk_nonlinear/point_data.nc\", \"theta_perturbation\", 0, [5000])\n",
+ "p.plot(same_plot='True')\n",
+ "plt.xlabel('Vertical distance (?)')\n",
+ "plt.ylabel('Potential temperature')\n",
+ "plt.title('A vertical slice of potential temperature')\n",
Maybe this title could be "Evolution of a gravity wave in a vertical slice"?
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973094980&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DkrjQkZR6jSci%2BNS56lC5sopd0M2J3l%2FgPnf7D9i6SI%3D&reserved=0>:
+ ],
+ "source": [
+ "p = Plot1DProfile(\"results/sk_nonlinear/point_data.nc\", \"theta_perturbation\", 0, [5000])\n",
+ "p.plot(same_plot='True')\n",
+ "plt.xlabel('Vertical distance (?)')\n",
+ "plt.ylabel('Potential temperature')\n",
+ "plt.title('A vertical slice of potential temperature')\n",
+ "plt.legend()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "ce34de02",
+ "metadata": {},
+ "source": [
+ "We can observe that we have an initial peak in the temperature perturbation at the centre of the domain, which disspates and is transported upwards during the simulation. "
I think it's actually transported outwards!
________________________________
In jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973097567&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TOlFh5XDVaKTGIwLFPVUTij0OCMIIxpdpc6Zt%2FK7ZLE%3D&reserved=0>:
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3ec4b5fe",
+ "metadata": {},
+ "source": [
+ "# Notebook 2: Vertical Slice Gravity wave"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "97f52073",
+ "metadata": {},
+ "source": [
+ "In the first notebook, we looked at the shallow water equations. Gusto can also solve the Boussinesq and Euler equations in their compressible or incompressible forms. This notebook we will demonstrate running the Compressible Euler equations with a gravity wave. \\\n",
+ "In this equation set, we simulate the evolution of the velocity $\\textbf{u}$, the dry density $\\rho$, and the (virtual dry) potential temperature $\\theta$. We will demostrate how to visualise a vertical slice of the potential temperature. "
I think one of the key things about this example is that it demonstrates running in a vertical slice domain (rather than visualising in a vertical slice). I wonder if it could be helpful to change this intro to that effect?
________________________________
In jupyter_notebooks/Book_3_Lowest_Order_Rising_Bubble.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973100823&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nlYYh4%2BCi0toGzH4tZZtAwYVIYC5s29xkXoaCEK%2F64Y%3D&reserved=0>:
@@ -0,0 +1,489 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3ec4b5fe",
+ "metadata": {},
+ "source": [
+ "# Notebook 4: Dry bf bubble"
With the change of name this should now be: "Notebook 3: Lowest Order Rising Bubble"
________________________________
In jupyter_notebooks/Book_3_Lowest_Order_Rising_Bubble.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973113131&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ysP3lZWluotHS%2B9NJ0FhkM80gIKM%2Blm4pK6%2Fez1XSuY%3D&reserved=0>:
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3ec4b5fe",
+ "metadata": {},
+ "source": [
+ "# Notebook 4: Dry bf bubble"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "5371527b",
+ "metadata": {},
+ "source": [
+ "This notebook will demonstrate the idea of implementing 'recovery' during the simulation. This is where we wish to solve for a higher order field around the object of interest, which in this case, is a dry bubble. The Compresible Euler Equations will govern the evolution of the dry bubble."
It could be good to explain here why the recovery scheme is necessary, so could we change this intro to something like:
"This notebook will demonstrate the use of the lowest-order finite element spaces. To increase the order of accuracy of the transport schemes, we use a recovered finite element method. The transported fields are recovered into a higher-order function space before the transport is performed.
We demonstrate this by solving the compressible Euler equations to simulate a rising bubble, using the dry test of Bryan and Fritsch (2002): https://doi.org/10.1175/1520-0493(2002)130<2917:ABSFMN>2.0.CO;2<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1175%2F1520-0493(2002)130%253C2917%3AABSFMN%253E2.0.CO%3B2&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=kICb%2BK%2FWUhlrTjcprYP4tU8yJxAP8b6GRgxlw5euOYU%3D&reserved=0>"
________________________________
In jupyter_notebooks/Book_3_Lowest_Order_Rising_Bubble.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973115103&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2idbbW9jjs%2Fan%2BP92yu09kiJR2mVZ8p4w5zxnIMbZXU%3D&reserved=0>:
+ ],
+ "source": [
+ "params = CompressibleParameters()\n",
+ "\n",
+ "state = State(mesh,\n",
+ " dt=dt,\n",
+ " output=output,\n",
+ " parameters=params)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "16a3fc8b",
+ "metadata": {},
+ "source": [
+ "Define the equations to solve, which are the compressible Euler equations. We neglect any diffusion options for this simulation."
Since we aren't using it, we could enirely remove the diffusion stuff?
________________________________
In jupyter_notebooks/Book_3_Lowest_Order_Rising_Bubble.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973116560&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lJcvPQRpPWtrpS0%2BjE5D9agN%2FBB68tyogyFCWfL7WXw%3D&reserved=0>:
+ {
+ "cell_type": "markdown",
+ "id": "810d8199",
+ "metadata": {},
+ "source": [
+ "Set up the time-stepping choices for the transported fields. We will use SSPRK3 for all prognostic variables."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "id": "81bfb34c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "limiter = None\n",
Similarly we could remove the limiter option if we aren't using it?
________________________________
In jupyter_notebooks/Book_3_Lowest_Order_Rising_Bubble.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973118295&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PCARmjnEey2YwdQtIO%2Bx4REPWUDN%2BRoOkw4Vg9txt%2Bg%3D&reserved=0>:
+ "cell_type": "code",
+ "execution_count": 18,
+ "id": "c929ec1f",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Here's what you would do:\n",
+ "# stepper.run(t=0, tmax=tmax)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "df6d755a",
+ "metadata": {},
+ "source": [
+ "We can input the results into Paraview and look at the temperature over the simulation. As expected, the bubble rises over time."
I think the times of the plots are probably at t=0 s, t=600 s and t=1000 s, so we should probably put this?
________________________________
In jupyter_notebooks/Book_4_Mountain_Wave_Moving_Mesh.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973127461&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=9pt2l1PHOSlKJO4P1mJraDkJ7D%2B0Hku0TnJZFQBTFqI%3D&reserved=0>:
@@ -0,0 +1,508 @@
+{
I'm wondering if it could be confusing to have "moving mesh" in the name of the file here since people might think that it's a time-evolving mesh. How about just "Mountain Wave?
________________________________
In jupyter_notebooks/Book_4_Mountain_Wave_Moving_Mesh.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973127812&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=9x%2Ft8Im0uCdiTN5AuhJQae%2BWr0I4bkNmDJb282J76I8%3D&reserved=0>:
@@ -0,0 +1,508 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3ec4b5fe",
+ "metadata": {},
+ "source": [
+ "# Notebook 3: Mountain Wave Test Case"
I suppose this is notebook 4 now -- sorry!
________________________________
In jupyter_notebooks/Book_4_Mountain_Wave_Moving_Mesh.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973132273&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=65pngEJlNwS7ab96NREAbmP0zHRaZ5UXZcA1uuh6ncE%3D&reserved=0>:
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3ec4b5fe",
+ "metadata": {},
+ "source": [
+ "# Notebook 3: Mountain Wave Test Case"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "eb79138f",
+ "metadata": {},
+ "source": [
+ "This notebook will go through an example of a hydrostatic flow over a mountain. This test case is outlined in the paper: Melvin, T., Dubal, M., Wood, N., Staniforth, A., & Zerroukat, M. (2010). An inherently mass\conserving iterative semi\implicit semi\Lagrangian discretization of the non\hydrostatic vertical\slice equations. Quarterly Journal of the Royal Meteorological Society: A journal of the atmospheric sciences, applied meteorology and physical oceanography, 136(648), 799-814."
Again we can probably shorten this citation and give the link: https://doi.org/10.1002/qj.603<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1002%2Fqj.603&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=NMugKSP0omux296KAd9S2z4WLIXd82fn1z3uS8Zevyk%3D&reserved=0>
________________________________
In jupyter_notebooks/Book_4_Mountain_Wave_Moving_Mesh.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973134726&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=B7VqK274VpVQKacOlihY8BhyPC0OLPHbei3%2BfIPqwjI%3D&reserved=0>:
+ "Vc = VectorFunctionSpace(ext_mesh, \"DG\", 2)\n",
+ "coord = SpatialCoordinate(ext_mesh)\n",
+ "x = Function(Vc).interpolate(as_vector([coord[0], coord[1]]))\n",
+ "a = 1000.\n",
+ "xc = L/2.\n",
+ "x, z = SpatialCoordinate(ext_mesh)\n",
+ "hm = 1.\n",
+ "zs = hm*a**2/((x-xc)**2 + a**2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2fb1fb2d",
+ "metadata": {},
+ "source": [
+ "We now invoke the smooth_z variable, I assume to smooth out the vertical profile somehow (do we want an explanation of this?? We then apply this smoothing to the defined mesh."
I actually think it's clearest if we remove the smoother_z flag? But we can still use the smoother z profile. The description here could then be something like: "Now we transform the mesh to follow the defined terrain. A smoothing is applied in the vertical direction."
________________________________
In jupyter_notebooks/Book_4_Mountain_Wave_Moving_Mesh.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973136924&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436286916%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=VelgrZwmysIXuSox5ePPgDh6whqR1xae%2BLyIPmHaQt4%3D&reserved=0>:
+ "cell_type": "markdown",
+ "id": "2afac417",
+ "metadata": {},
+ "source": [
+ "Set up the transport schemes"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "id": "7e16a3dc",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "supg = True\n",
+ "if supg:\n",
As in the second book we should probably just pick to use supg and get rid of the flag here
________________________________
In jupyter_notebooks/Book_4_Mountain_Wave_Moving_Mesh.ipynb<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23discussion_r973137285&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436443137%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=beLfW%2FdhTxKHOtXsvNqRXZZgvznS262mDCZZ%2Bxwn2Ss%3D&reserved=0>:
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "0a750ee1",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Here's what you would do:\n",
+ "# stepper.run(t=0, tmax=tmax)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "10e50cf7",
+ "metadata": {},
+ "source": [
+ "What other feature do we want to demonstrate in this notebook?"
I think that's all good!
―
Reply to this email directly, view it on GitHub<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffiredrakeproject%2Fgusto%2Fpull%2F294%23pullrequestreview-1110701821&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436443137%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XbbUvCbV6qlRfP5V2ZEfnaRCLz5pL3Sp1%2FI9q5CFJvM%3D&reserved=0>, or unsubscribe<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FASCMK3BY3DYT7BRMOQKOOF3V6SFOTANCNFSM57L2RPOA&data=05%7C01%7Cta440%40exeter.ac.uk%7Cd06077d9ad224d51cd5a08da97f68ca4%7C912a5d77fb984eeeaf321334d8f04a53%7C0%7C0%7C637989382436443137%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=U0H%2FOAMewuTralXd6snsEM8OI4o2BRkZzTipFJ7Ppjs%3D&reserved=0>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
… tim_FML_notebooks
… tim_FML_notebooks
… tim_FML_notebooks
… tim_FML_notebooks
Added a directory with four example notebooks to demonstrate the functionality of Gusto.