.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples_simulations/example_vortex.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_simulations_example_vortex.py: ================================================================================ Stationnary vortex ================================================================================ In this example, we test the conservation of the geostrophic equilibrium by conserving a stationnary vortex. The test case is already discribed in **[10]** and **[11]** (see :ref:`References`). .. GENERATED FROM PYTHON SOURCE LINES 11-83 .. code-block:: default import os, sys from os import listdir import argparse import matplotlib.pylab as plt import freshkiss3d as fk import freshkiss3d.extra.plots as fk_plt import numpy as np import matplotlib.tri as mtri from scipy.interpolate import griddata from matplotlib import colors import matplotlib.ticker as mtick import h5py import math #sphinx_gallery_thumbnail_number = 2 parser = argparse.ArgumentParser() parser.add_argument('--nographics', action='store_true') args = parser.parse_args() fk_plt.set_rcParams() def plot_free_surface_slice(triangular_mesh, H, topography, fig, nb_l, nb_c, plt_num, time, Eta0_slice=None, label=True): # Plt options: n = 100 TG = triangular_mesh.triangulation x_slice = np.linspace(min(TG.x), max(TG.x), n) ym_slice = np.full(n, (max(TG.y) + min(TG.y)) / 2.0) NC = triangular_mesh.NV Eta = np.empty(NC, dtype='d') for C in range(NC): Eta[C] = H[C] + topography[C] Eta_slice = griddata((TG.x, TG.y), Eta, (x_slice, ym_slice), method = 'cubic') ax = fig.add_subplot(nb_l, nb_c, plt_num) ax.xaxis.set_major_formatter(mtick.FormatStrFormatter('%d')) if label: ax.plot(x_slice, Eta_slice, label='second order approximation(O2)') else: ax.plot(x_slice, Eta_slice, label='O2') if Eta0_slice is not None: if label: ax.plot(x_slice, Eta0_slice, label='initial cond (IC)') else: ax.plot(x_slice, Eta0_slice, label='IC') ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) ax.set_xlim([min(x_slice), max(x_slice)]) ax.set_ylabel("free surface (m)") ax.set_title("t = {:.1f}".format(time)) ax.legend(loc='best') return Eta_slice dir_path = os.path.abspath(os.path.dirname(sys.argv[0])) .. GENERATED FROM PYTHON SOURCE LINES 84-110 Analytic solution: ----------------------------- The hydrostatic Euler with Coriolis and constant density is given by .. math:: \begin{cases} \nabla\cdot {\bf U} = 0, \\ \rho_0\left(\frac{\partial {\bf u}}{ \partial t} + \nabla_{x,y}\cdot ( {\bf u}\otimes {\bf u}) + \frac{\partial ({\bf u}w)}{\partial z}\right) + \nabla_{x,y} p = -\rho_0\Omega {\bf u}^\perp, \\ \frac{\partial p}{\partial z} = -\rho_0 g. \end{cases} ############################################################################### First, we consider the reference case given in polar coordinates. In this case, the problem is initialized with the velocity :math:`{\bf{u}}^0` and the water height :math:`h^0`, .. math:: \begin{cases} {\bf{u}}^0(r,\theta) = {\bf{\nu}}(r) \bf{e_\theta},\\ \partial_r h^0(r) = \frac{\nu(r)}{g} \left(\Omega + \frac{\nu(r)}{r} \right), \end{cases} .. GENERATED FROM PYTHON SOURCE LINES 113-118 with: .. math:: {\bf{\nu}} (r) = (\alpha r \mathbb{1}_{r` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_vortex.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_