Skip to content

Commit

Permalink
Re-run notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Dec 18, 2024
1 parent f3e5e4a commit 5f92dae
Show file tree
Hide file tree
Showing 7 changed files with 2,913 additions and 443 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ docs/_build/
target/
/docs/source/teamgrid.rst
/docs/source/gusto.rst

# Gusto specific
jupyter_notebooks/results
jupyter_notebooks/.ipynb_checkpoints
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ notebook_test: clean_cache

reset_notebooks:
@jupyter-nbconvert --clear-output ./jupyter_notebooks/*.ipynb
@rm -rf ./jupyter_notebooks/results
@env OMP_NUM_THREADS=1 jupyter-nbconvert \
--execute \
--ClearMetadataPreprocessor.enabled=True \
Expand Down
3,061 changes: 2,829 additions & 232 deletions jupyter_notebooks/Book_1_Intro_Williamson_2.ipynb

Large diffs are not rendered by default.

115 changes: 21 additions & 94 deletions jupyter_notebooks/Book_2_Gravity_Wave_Vertical_Slice.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'gusto'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mgusto\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mfiredrake\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m (as_vector, SpatialCoordinate, PeriodicIntervalMesh,\n\u001b[1;32m 3\u001b[0m ExtrudedMesh, exp, sin, pi, Function)\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'gusto'"
"name": "stderr",
"output_type": "stream",
"text": [
"INFO Running /home/jack/Documents/firedrake/firedrake/lib/python3.12/site-packages/ipykernel_launcher.py -f /tmp/tmpsbm8a_5l.json --HistoryManager.hist_file=:memory:\n"
]
}
],
Expand Down Expand Up @@ -81,19 +77,7 @@
"execution_count": 3,
"id": "844be5eb",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'PeriodicIntervalMesh' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [3]\u001b[0m, in \u001b[0;36m<cell line: 4>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m columns \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m150\u001b[39m \u001b[38;5;66;03m# number of columns\u001b[39;00m\n\u001b[1;32m 3\u001b[0m domain_width \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m3.0e5\u001b[39m\n\u001b[0;32m----> 4\u001b[0m m \u001b[38;5;241m=\u001b[39m \u001b[43mPeriodicIntervalMesh\u001b[49m(columns, domain_width)\n\u001b[1;32m 6\u001b[0m domain_height \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1.0e4\u001b[39m \u001b[38;5;66;03m# Height position of the model top\u001b[39;00m\n\u001b[1;32m 7\u001b[0m mesh \u001b[38;5;241m=\u001b[39m ExtrudedMesh(m, layers\u001b[38;5;241m=\u001b[39mnlayers, layer_height\u001b[38;5;241m=\u001b[39mdomain_height\u001b[38;5;241m/\u001b[39mnlayers)\n",
"\u001b[0;31mNameError\u001b[0m: name 'PeriodicIntervalMesh' is not defined"
]
}
],
"outputs": [],
"source": [
"nlayers = 10 # number of horizontal layers\n",
"columns = 150 # number of columns\n",
Expand All @@ -117,19 +101,7 @@
"execution_count": 4,
"id": "8ed9914e",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'Domain' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [4]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m domain \u001b[38;5;241m=\u001b[39m \u001b[43mDomain\u001b[49m(mesh, dt, family\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCG\u001b[39m\u001b[38;5;124m\"\u001b[39m, degree\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m 2\u001b[0m parameters \u001b[38;5;241m=\u001b[39m CompressibleParameters()\n\u001b[1;32m 3\u001b[0m eqns \u001b[38;5;241m=\u001b[39m CompressibleEulerEquations(domain, parameters)\n",
"\u001b[0;31mNameError\u001b[0m: name 'Domain' is not defined"
]
}
],
"outputs": [],
"source": [
"domain = Domain(mesh, dt, family=\"CG\", degree=1)\n",
"parameters = CompressibleParameters()\n",
Expand All @@ -149,19 +121,7 @@
"execution_count": 5,
"id": "754708dd",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'OutputParameters' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [5]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m dirname \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgravity_wave\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m----> 2\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[43mOutputParameters\u001b[49m(dirname\u001b[38;5;241m=\u001b[39mdirname,\n\u001b[1;32m 3\u001b[0m dumpfreq\u001b[38;5;241m=\u001b[39mdumpfreq)\n\u001b[1;32m 4\u001b[0m Tsurf \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m300.\u001b[39m\n\u001b[1;32m 5\u001b[0m diagnostic_fields \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 6\u001b[0m CourantNumber(), Gradient(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mu\u001b[39m\u001b[38;5;124m'\u001b[39m), Perturbation(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtheta\u001b[39m\u001b[38;5;124m'\u001b[39m),\n\u001b[1;32m 7\u001b[0m Gradient(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtheta_perturbation\u001b[39m\u001b[38;5;124m'\u001b[39m), Perturbation(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrho\u001b[39m\u001b[38;5;124m'\u001b[39m),\n\u001b[1;32m 8\u001b[0m RichardsonNumber(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtheta\u001b[39m\u001b[38;5;124m'\u001b[39m, parameters\u001b[38;5;241m.\u001b[39mg\u001b[38;5;241m/\u001b[39mTsurf), Gradient(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtheta\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 9\u001b[0m ]\n",
"\u001b[0;31mNameError\u001b[0m: name 'OutputParameters' is not defined"
]
}
],
"outputs": [],
"source": [
"dirname = 'gravity_wave'\n",
"output = OutputParameters(dirname=dirname,\n",
Expand Down Expand Up @@ -190,14 +150,17 @@
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'SUPGOptions' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [6]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m theta_opts \u001b[38;5;241m=\u001b[39m \u001b[43mSUPGOptions\u001b[49m()\n\u001b[1;32m 2\u001b[0m subcycling_options \u001b[38;5;241m=\u001b[39m SubcyclingOptions(subcycle_by_courant\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0.25\u001b[39m)\n\u001b[1;32m 4\u001b[0m transported_fields \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 5\u001b[0m SSPRK3(domain, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mu\u001b[39m\u001b[38;5;124m\"\u001b[39m, subcycling_options\u001b[38;5;241m=\u001b[39msubcycling_options),\n\u001b[1;32m 6\u001b[0m SSPRK3(\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 13\u001b[0m )\n\u001b[1;32m 14\u001b[0m ]\n",
"\u001b[0;31mNameError\u001b[0m: name 'SUPGOptions' is not defined"
"name": "stderr",
"output_type": "stream",
"text": [
"INFO Physical parameters that take non-default values:\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO \n"
]
}
],
Expand Down Expand Up @@ -243,19 +206,7 @@
"execution_count": 7,
"id": "e61d066d",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'stepper' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [7]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Initial conditions\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m u0 \u001b[38;5;241m=\u001b[39m \u001b[43mstepper\u001b[49m\u001b[38;5;241m.\u001b[39mfields(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mu\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 3\u001b[0m rho0 \u001b[38;5;241m=\u001b[39m stepper\u001b[38;5;241m.\u001b[39mfields(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrho\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 4\u001b[0m theta0 \u001b[38;5;241m=\u001b[39m stepper\u001b[38;5;241m.\u001b[39mfields(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtheta\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"\u001b[0;31mNameError\u001b[0m: name 'stepper' is not defined"
]
}
],
"outputs": [],
"source": [
"# Initial conditions\n",
"u0 = stepper.fields(\"u\")\n",
Expand Down Expand Up @@ -297,19 +248,7 @@
"execution_count": 8,
"id": "b1642c8b",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'compressible_hydrostatic_balance' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [8]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mcompressible_hydrostatic_balance\u001b[49m(eqns, theta_b, rho_b)\n",
"\u001b[0;31mNameError\u001b[0m: name 'compressible_hydrostatic_balance' is not defined"
]
}
],
"outputs": [],
"source": [
"compressible_hydrostatic_balance(eqns, theta_b, rho_b)"
]
Expand All @@ -328,19 +267,7 @@
"execution_count": 9,
"id": "46852826",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'sin' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [9]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5.0e3\u001b[39m\n\u001b[1;32m 2\u001b[0m deltaTheta \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1.0e-2\u001b[39m\n\u001b[0;32m----> 3\u001b[0m theta_pert \u001b[38;5;241m=\u001b[39m deltaTheta\u001b[38;5;241m*\u001b[39m\u001b[43msin\u001b[49m(pi\u001b[38;5;241m*\u001b[39mxz[\u001b[38;5;241m1\u001b[39m]\u001b[38;5;241m/\u001b[39mdomain_height)\u001b[38;5;241m/\u001b[39m(\u001b[38;5;241m1\u001b[39m \u001b[38;5;241m+\u001b[39m (xz[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m-\u001b[39m domain_width\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m2\u001b[39m)\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m\u001b[38;5;241m/\u001b[39ma\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m)\n\u001b[1;32m 4\u001b[0m theta0\u001b[38;5;241m.\u001b[39minterpolate(theta_b \u001b[38;5;241m+\u001b[39m theta_pert)\n\u001b[1;32m 5\u001b[0m rho0\u001b[38;5;241m.\u001b[39massign(rho_b)\n",
"\u001b[0;31mNameError\u001b[0m: name 'sin' is not defined"
]
}
],
"outputs": [],
"source": [
"a = 5.0e3\n",
"deltaTheta = 1.0e-2\n",
Expand Down
Loading

0 comments on commit 5f92dae

Please sign in to comment.