.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Analytic_Solutions_Height/plot_as_h_u_ritter.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_Analytic_Solutions_Height_plot_as_h_u_ritter.py: Analytical solution of a dam-break problem on a dry bed without friction (Ritter) =========================================================================================== This example presents the classical one-dimensional analytical solution proposed by Ritter (1892) for the dam-break problem on a dry, horizontal bed without friction. Model Assumptions ----------------- - Instantaneous dam break at position :math:`x = x_0` and at time :math:`t = 0`. - The domain is initially dry for :math:`x > x_0`, with a finite volume of still water (with height :math:`h_0`) on the left of the dam (:math:`0 < x \leq x_0`). - The bed is flat and horizontal (no slope). - No bed friction is considered. - The fluid is incompressible and inviscid, subject only to gravity. - The solution is valid until the rarefaction wave reaches the left boundary of the water column. Initial Conditions ------------------ .. math:: h(x, 0) = \begin{cases} h_0 > 0 & \text{for } 0 < x \leq x_0, \\\\ 0 & \text{for } x_0 < x, \end{cases} .. math:: u(x, 0) = 0 where :math:`x_0` is the initial dam location and :math:`h_0` is the height of the water column. Analytical Solution ------------------- The water height and velocity profiles at any time t are given by: .. math:: h(x, t) = \begin{cases} h_0 & \text{if } x \leq x_A(t), \\\\ \frac{4}{9g} \left( \sqrt{g h_0} - \frac{x - x_0}{2t} \right)^2 & \text{if } x_A(t) < x \leq x_B(t), \\\\ 0 & \text{if } x_B(t) < x, \end{cases} .. math:: u(x,t) = \begin{cases} 0 & \text{if } x \leq x_A(t), \\\\ \frac{2}{3} \left( \frac{x - x_0}{t} + \sqrt{g h_0} \right) & \text{if } x_A(t) < x \leq x_B(t), \\\\ 0 & \text{if } x_B(t) < x, \end{cases} where the positions of the rarefaction wave front and the dry front are: .. math:: \begin{cases} x_A(t) = x_0 - t \sqrt{g h_0}, \\\\ x_B(t) = x_0 + 2 t \sqrt{g h_0} \end{cases} Implementation -------------- .. GENERATED FROM PYTHON SOURCE LINES 71-73 First import required packages and define the spatial domain for visualization. For following examples we will use a 1D space from -25 to 45 m. .. GENERATED FROM PYTHON SOURCE LINES 73-78 .. code-block:: Python import numpy as np from tilupy.analytic_sol import Ritter_dry x = np.linspace(-25, 45, 1000) .. GENERATED FROM PYTHON SOURCE LINES 79-80 ------------------- .. GENERATED FROM PYTHON SOURCE LINES 83-84 **Case 1**: Ritter's solution with dam at :math:`x_0 = 0 m` and initial height :math:`h_0 = 0.5 m` .. GENERATED FROM PYTHON SOURCE LINES 84-87 .. code-block:: Python case_1 = Ritter_dry(x_0=0, h_0=0.5) .. GENERATED FROM PYTHON SOURCE LINES 88-89 Compute and plot fluid height at times :math:`t = {0, 2, 4, 6, 8, 10} s`. .. GENERATED FROM PYTHON SOURCE LINES 89-93 .. code-block:: Python case_1.compute_h(x, [0, 2, 4, 6, 8]) ax = case_1.plot(show_h=True, linestyles=["", ":", "-.", "--", "-"]) .. image-sg:: /auto_examples/Analytic_Solutions_Height/images/sphx_glr_plot_as_h_u_ritter_001.png :alt: Flow height for t=[0, 2, 4, 6, 8] :srcset: /auto_examples/Analytic_Solutions_Height/images/sphx_glr_plot_as_h_u_ritter_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 94-95 Compute and plot fluid velocity at times :math:`t = {0, 2, 4, 6, 8, 10} s`. .. GENERATED FROM PYTHON SOURCE LINES 95-98 .. code-block:: Python case_1.compute_u(x, [0, 2, 4, 6, 8]) ax = case_1.plot(show_u=True, linestyles=["", ":", "-.", "--", "-"]) .. image-sg:: /auto_examples/Analytic_Solutions_Height/images/sphx_glr_plot_as_h_u_ritter_002.png :alt: Flow velocity for t=[0, 2, 4, 6, 8] :srcset: /auto_examples/Analytic_Solutions_Height/images/sphx_glr_plot_as_h_u_ritter_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 99-100 ------------------- .. GENERATED FROM PYTHON SOURCE LINES 103-105 **Case 2**: Specific example from SWASHES benchmark database Dam at :math:`x_0 = 5 m`, initial height :math:`h_0 = 0.005 m`, domain length :math:`L = 10 m`, solution at :math:`t = 6 s`. .. GENERATED FROM PYTHON SOURCE LINES 105-111 .. code-block:: Python x = np.linspace(0, 10, 1000) case_2 = Ritter_dry(x_0=5, h_0=0.005) case_2.compute_h(x, 6.0) ax = case_2.plot(show_h=True, linestyles=["-"]) .. image-sg:: /auto_examples/Analytic_Solutions_Height/images/sphx_glr_plot_as_h_u_ritter_003.png :alt: Flow height for t=[6.0] :srcset: /auto_examples/Analytic_Solutions_Height/images/sphx_glr_plot_as_h_u_ritter_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 112-113 ------------------- .. GENERATED FROM PYTHON SOURCE LINES 116-121 Original reference: ID Poisson. Swashes. ID Poisson, [online]. Available at: https://www.idpoisson.fr/swashes/ ; accessed June 2025. Ritter, A., 1892, Die Fortpflanzung der Wasserwellen, Zeitschrift des Vereines Deutscher Ingenieure, vol. 36(33), p. 947–954. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.154 seconds) .. _sphx_glr_download_auto_examples_Analytic_Solutions_Height_plot_as_h_u_ritter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_as_h_u_ritter.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_as_h_u_ritter.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_as_h_u_ritter.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_