Skip to content

Commit

Permalink
updated some of the text
Browse files Browse the repository at this point in the history
  • Loading branch information
fraserwg committed Mar 26, 2021
1 parent 8a3eac5 commit 73d844a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions LinearStabilityAnalysis/LinearStabilityAnalysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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."
]
},
{
Expand All @@ -81,18 +86,21 @@
"\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",
" \"\"\"\n",
" 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",
Expand Down Expand Up @@ -227,7 +235,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Viscualise the output"
"## Visualise the output"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -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."
]
},
{
Expand Down

0 comments on commit 73d844a

Please sign in to comment.