From 73d844ae3cba2b452ec1d59ea258a14dfbd53f56 Mon Sep 17 00:00:00 2001 From: fraserwg Date: Fri, 26 Mar 2021 15:53:07 +0000 Subject: [PATCH] updated some of the text --- .../LinearStabilityAnalysis.ipynb | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/LinearStabilityAnalysis/LinearStabilityAnalysis.ipynb b/LinearStabilityAnalysis/LinearStabilityAnalysis.ipynb index 3ae8a68..d6ed084 100644 --- a/LinearStabilityAnalysis/LinearStabilityAnalysis.ipynb +++ b/LinearStabilityAnalysis/LinearStabilityAnalysis.ipynb @@ -32,6 +32,7 @@ "import scipy\n", "from scipy.sparse.linalg import eigs\n", "import scipy.sparse as sps\n", + "from scipy.optimize import minimize_scalar\n", "import xarray as xr\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", @@ -65,7 +66,11 @@ "source": [ "## Parameters of the problem\n", "\n", - "Below we set parameters relating to the domain size (including grid spacing) and the flow itself. We also create a matrix representation of the $f\\zeta$ and $\\frac{d^2}{dx^2}$ operators." + "Below we set parameters relating to the domain size (including grid spacing) and the flow itself. We also create a matrix representation of the $f\\zeta$ and $\\frac{d^2}{dx^2}$ operators.\n", + "\n", + "When running this notebook I reccomend increasing the grid-spacing (`dx`) to something larger ($\\sim$`2e3` should still give ok results). The value of `1e2` was used here for producing publication quality figures and is overkill even for that.\n", + "\n", + "If you want to play around with different vorticity profiles this can be done by redefining `zeta` in the below code to return the absolute vorticity profile you fancy." ] }, { @@ -81,10 +86,12 @@ "\n", "N2 = 2.5e-5 # Buoyancy frequency (squared) in s^{-2}\n", "f = 1.01e-5 # Planetary vorticity in s^{-1}\n", + "A_r = 4e-4 # Viscosity in m^{2} s^{-1}\n", + "\n", "x_mid = 40e3 # Mid point of the jet in m\n", "delta_b = 30e3 # Width of the jet in m\n", "V_0 = 0.87 # Velocity of the jet in m/s\n", - "A_r = 4e-4\n", + "\n", "\n", "def zeta(x):\n", " \"\"\" returns the absolute vorticity at x in s^{-1}\n", @@ -92,7 +99,8 @@ " rel_vort = - 2 * V_0 / delta_b * np.tanh((x - x_mid) / delta_b) / np.square(np.cosh((x - x_mid) / delta_b))\n", " return rel_vort + f\n", "\n", - "x_vorticity_minima = 0.5 * np.log(2 + np.sqrt(3)) * delta_b + x_mid # Gives x at the vorticity minima\n", + "\n", + "x_vorticity_minima = minimize_scalar(zeta, bounds=[0, Lx], method='bounded', options={'xatol': dx / 10}).x # Gives x at the vorticity minima\n", "\n", "# Create a matrix representation of the curvature operator\n", "diagonals = np.array([1, -2, 1]) / np.square(dx)\n", @@ -227,7 +235,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Viscualise the output" + "## Visualise the output" ] }, { @@ -312,7 +320,7 @@ "ax.set_xticks(np.linspace(0, 400, 9))\n", "\n", "ax2 = ax.twinx()\n", - "ax2.plot(x * 1e-3, zeta(ds['lon']), 'k', lw=1.5)\n", + "ax2.plot(x * 1e-3, zeta(ds['lon']) / f, 'k', lw=1.5)\n", "ax2.set_ylabel('$\\zeta / f$')\n", "ax2.axhline(0, c='k', ls=':')\n", "\n", @@ -328,7 +336,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Plot $\\hat{\\psi}(x)$ for different wavelengths. This is not contained in the paper. Note this also takes a long time to run." + "Plot $\\hat{\\psi}(x)$ for different wavelengths. This is not contained in the paper. Note this may take a while to run." ] }, {