tilupy.analytic_sol =================== .. py:module:: tilupy.analytic_sol Classes ------- .. autoapisummary:: tilupy.analytic_sol.Depth_result tilupy.analytic_sol.Ritter_dry tilupy.analytic_sol.Stoker_SWASHES_wet tilupy.analytic_sol.Stoker_SARKHOSH_wet tilupy.analytic_sol.Mangeney_dry tilupy.analytic_sol.Dressler_dry tilupy.analytic_sol.Chanson_dry tilupy.analytic_sol.Shape_result tilupy.analytic_sol.Coussot_shape tilupy.analytic_sol.Front_result Module Contents --------------- Classes ^^^^^^^ .. py:class:: Depth_result(theta: float = None) Bases: :py:obj:`abc.ABC` Abstract base class representing simulation results for flow depth and velocity. This class defines a common interface for analytical solution that compute flow height h(x,t) and flow velocity u(x,t). :param theta: Angle of the surface, in radian, by default 0. :type theta: float, optional .. attribute:: _g = 9.81 Gravitational constant. :type: float .. attribute:: _theta Angle of the surface, in radian. :type: float .. attribute:: _x Spatial coordinates. :type: float or np.ndarray .. attribute:: _t Time instant. :type: float or np.ndarray .. attribute:: _h Flow height depending on space at a moment. :type: np.ndarray .. attribute:: _u Flow velocity depending on space at a moment. :type: np.ndarray .. py:method:: compute_h(x: float | numpy.ndarray, t: float | numpy.ndarray) -> None :abstractmethod: Virtual function that compute the flow height :attr:`_h` at given space and time. :param x: Spatial coordinates. :type x: float or np.ndarray :param t: Time instant. :type t: float or np.ndarray .. py:method:: compute_u(x: float | numpy.ndarray, t: float | numpy.ndarray) -> None :abstractmethod: Virtual function that compute the flow velocity :attr:`_u` at given space and time. :param x: Spatial coordinates. :type x: float or np.ndarray :param t: Time instant. :type t: float or np.ndarray .. py:property:: h Accessor of h(x,t) solution. :returns: Attribute :attr:`_h`. If None, no solution computed. :rtype: numpy.ndarray .. py:property:: u Accessor of u(x,t) solution. :returns: Attribute :attr:`_u`. If None, no solution computed. :rtype: numpy.ndarray .. py:property:: x Accessor of the spatial distribution of the computed solution. :returns: Attribute :attr:`_x`. If None, no solution computed. :rtype: numpy.ndarray .. py:property:: t Accessor of the time instant of the computed solution. :returns: Attribut :attr:`_t`. If None, no solution computed. :rtype: float or numpy.ndarray .. py:method:: plot(show_h: bool = False, show_u: bool = False, show_surface: bool = False, linestyles: list[str] = None, x_unit: str = 'm', h_unit: str = 'm', u_unit: str = 'm/s', show_plot: bool = True, figsize: tuple = None) -> matplotlib.axes._axes.Axes Plot the simulation results. :param show_h: If True, plot the flow height (:attr:`_h`) curve. :type show_h: bool, optional :param show_u: If True, plot the flow velocity (:attr:`_u`) curve. :type show_u: bool, optional :param show_surface: If True, plot the slop of the surface. :type show_surface: bool, optional :param linestyles: List of linestyle to applie to the graph, must have the same since as the numbre of curve to plot or it will not be taken into account (-1), by default None. If None, copper colormap will be applied. :type linestyles: list[str], optional :param x_unit: Space unit. :type x_unit: str :param h_unit: Height unit. :type h_unit: str :param u_unit: Velocity unit. :type u_unit: str :param show_plot: If True, show the resulting plot. By default True. :type show_plot: bool, optional :param figsize: Size of the wanted plot, by default None. :type figsize: tuple, optional :returns: Resulting plot. :rtype: matplotlib.axes._axes.Axes :raises ValueError: If no solution computed (:attr:`_h` and :attr:`_u` are None). .. py:class:: Ritter_dry(h_0: float, x_0: float = 0) Bases: :py:obj:`Depth_result` Dam-break solution on a dry domain using shallow water theory. This class implements the 1D analytical Ritter's solution of an ideal dam break on a dry domain. The dam break is instantaneous, over an horizontal and flat surface with no friction. It computes the flow height (took verticaly) and velocity over space and time, based on the equation implemanted in SWASHES, based on Ritter's equation. Ritter, A., 1892, Die Fortpflanzung der Wasserwellen, Zeitschrift des Vereines Deutscher Ingenieure, vol. 36(33), p. 947-954. :param x_0: Initial dam location (position along x-axis), by default 0. :type x_0: float, optional :param h_0: Initial water depth to the left of the dam. :type h_0: float .. attribute:: _x0 Initial dam location (position along x-axis). :type: float .. attribute:: _h0 Initial water depth to the left of the dam. :type: float .. py:method:: xa(t: float) -> float Position of the rarefaction wave front (left-most edge) : .. math:: x_A(t) = x_0 - t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the front edge of the rarefaction wave. :rtype: float .. py:method:: xb(t: float) -> float Position of the contact discontinuity: .. math:: x_B(t) = x_0 + 2 t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the contact wave (end of rarefaction). :rtype: float .. py:method:: compute_h(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow height h(x, t) at given time and positions. .. 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} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or nd.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._h`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:method:: compute_u(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow velocity u(x, t) at given time and positions. .. 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} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._u`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:class:: Stoker_SWASHES_wet(x_0: float, h_0: float, h_r: float, h_m: float = None) Bases: :py:obj:`Depth_result` Dam-break solution on a wet domain using shallow water theory. This class implements the 1D analytical Stoker's solution of an ideal dam break on a wet domain. The dam break is instantaneous, over an horizontal and flat surface with no friction. It computes the flow height (took verticaly) and velocity over space and time, based on the equation implemanted in SWASHES, based on Stoker's equation. Delestre, O., Lucas, C., Ksinant, P.-A., Darboux, F., Laguerre, C., Vo, T.-N.-T., James, F. & Cordier, S., 2013, SWASHES: a compilation of shallow water analytic solutions for hydraulic and environmental studies, International Journal for Numerical Methods in Fluids, v. 72(3), p. 269-300, doi:10.1002/fld.3741. Stoker, J.J., 1957, Water Waves: The Mathematical Theory with Applications, Pure and Applied Mathematics, vol. 4, Interscience Publishers, New York, USA. :param x_0: Initial dam location (position along x-axis). :type x_0: float :param h_0: Water depth to the left of the dam. :type h_0: float :param h_r: Water depth to the right of the dam. :type h_r: float :param h_m: Intermediate height used to compute the critical speed cm. If not provided, it will be computed numerically via the 'compute_cm()' method. :type h_m: float, optional .. attribute:: _x0 Initial dam location (position along x-axis). :type: float .. attribute:: _h0 Water depth to the left of the dam. :type: float .. attribute:: _hr Water depth to the right of the dam. :type: float .. attribute:: _cm Critical velocity. :type: float .. py:method:: xa(t: float) -> float Position of the rarefaction wave front (left-most edge) : .. math:: x_A(t) = x_0 - t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the front edge of the rarefaction wave. :rtype: float .. py:method:: xb(t: float) -> float Position of the contact discontinuity: .. math:: x_B(t) = x_0 + t \left( 2 \sqrt{g h_0} - 3 c_m \right) :param t: Time instant. :type t: float :returns: Position of the contact wave (end of rarefaction). :rtype: float .. py:method:: xc(t: float) -> float Position of the shock wave front (right-most wave): .. math:: x_C(t) = x_0 + t \cdot \frac{2 c_m^2 \left( \sqrt{g h_0} - c_m \right)}{c_m^2 - g h_r} :param t: Time instant. :type t: float :returns: Position of the shock front. :rtype: float .. py:method:: equation_cm(cm) -> float Equation of the critical velocity cm: .. math:: -8.g.hr.cm^{2}.(g.h0 - cm^{2})^{2} + (cm^{2} - g.hr)^{2} . (cm^{2} + g.hr) = 0 :param cm: Trial value for :attr:`_cm`. :type cm: float :returns: Residual of the equation. Zero when :attr:`_cm` satisfies the system. :rtype: float .. py:method:: compute_cm() -> None Solves the non-linear equation to compute the critical velocity :attr:`_cm`. Uses numerical root-finding to find a valid value of cm that separates the flow regimes. Sets :attr:`_cm` if a valid solution is found. .. py:method:: compute_h(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow height h(x, t) at given time and positions. .. 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), \\\\ \frac{c_m^2}{g} & \text{if } x_B(t) < x \leq x_C(t), \\\\ h_r & \text{if } x_C(t) < x, \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._h`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:method:: compute_u(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow velocity u(x, t) at given time and positions. .. 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), \\\\ 2 \left( \sqrt{g h_0} - c_m \right) & \text{if } x_B(t) < x \leq x_C(t), \\\\ 0 & \text{if } x_C(t) < x, \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._u`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:class:: Stoker_SARKHOSH_wet(h_0: float, h_r: float) Bases: :py:obj:`Depth_result` Dam-break solution on a wet domain using shallow water theory. This class implements the 1D analytical Stoker's solution of an ideal dam break on a wet domain. The dam break is instantaneous, over an horizontal and flat surface with no friction. It computes the flow height (took verticaly) and velocity over space and time, based on the equation implemanted in SWASHES, based on Stoker's equation. Sarkhosh, P., 2021, Stoker solution package, version 1.0.0, Zenodo. https://doi.org/10.5281/zenodo.5598374 Stoker, J.J., 1957, Water Waves: The Mathematical Theory with Applications, Pure and Applied Mathematics, vol. 4, Interscience Publishers, New York, USA. :param h_0: Initial water depth to the left of the dam. :type h_0: float :param h_r: Initial water depth to the right of the dam. :type h_r: float .. attribute:: _h0 Water depth to the left of the dam. :type: float .. attribute:: _hr Water depth to the right of the dam. :type: float .. attribute:: _cm Shock front speed. :type: float .. attribute:: _hm Height of the shock front. :type: float .. py:method:: xa(t: float) -> float Position of the rarefaction wave front (left-most edge) : .. math:: x_A(t) = x_0 - t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the front edge of the rarefaction wave. :rtype: float .. py:method:: xb(hm: float, t: float) -> float Position of the contact discontinuity: .. math:: x_B(t) = t \left( 2 \sqrt{g h_0} - 3 \sqrt{g h_m} \right) :param hm: Height of the shock front. :type hm: float :param t: Time instant. :type t: float :returns: Position of the contact wave (end of rarefaction). :rtype: float .. py:method:: xc(cm: float, t: float) -> float Position of the shock wave front (right-most wave): .. math:: x_C(t) = c_m t :param cm: Shock front speed. :type cm: float :param t: Time instant. :type t: float :returns: Position of the shock front. :rtype: float .. py:method:: compute_cm() -> float Compute the shock front speed using Newton-Raphson's method to find the solution of: .. math:: c_m h_r - h_r \left( \sqrt{1 + \frac{8 c_m^2}{g h_r}} - 1 \right) \left( \frac{c_m}{2} - \sqrt{g h_0} + \sqrt{\frac{g h_r}{2} \left( \sqrt{1 + \frac{8 c_m^2}{g h_r}} - 1 \right)} \right) = 0 :returns: Speed of the shock front. :rtype: float .. py:method:: compute_h(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow height h(x, t) at given time and positions. .. math:: h(x, t) = \begin{cases} h_0 & \text{if } x \leq x_A(t), \\\\ \frac{\left( 2 \sqrt{g h_0} - \frac{x}{t} \right)^2}{9 g} & \text{if } x_A(t) < x \leq x_B(t), \\\\ h_m = \frac{1}{2} h_r \left( \sqrt{1 + \frac{8 c_m^2}{g h_r}} - 1 \right) & \text{if } x_B(t) < x \leq x_C(t), \\\\ h_r & \text{if } x_C(t) < x \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._h`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:method:: compute_u(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow velocity u(x, t) at given time and positions. .. math:: u(x,t) = \begin{cases} 0 & \text{if } x \leq x_A(t), \\\\ \frac{2}{3} \left( \frac{x}{t} + \sqrt{g h_0} \right) & \text{if } x_A(t) < x \leq x_B(t), \\\\ 2 \sqrt{g h_0} - 2 \sqrt{g h_m} & \text{if } x_B(t) < x \leq x_C(t), \\\\ 0 & \text{if } x_C(t) < x, \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._u`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:class:: Mangeney_dry(x_0: float, h_0: float, theta: float, delta: float) Bases: :py:obj:`Depth_result` Dam-break solution on an inclined dry domain with friction using shallow water theory. This class implements the 1D analytical Stoker's solution of an ideal dam break on a dry domain. The dam break is instantaneous, over an inclined and flat surface with friction. It computes the flow height (took normal to the surface) and velocity over space and time with an infinitely-long fluid mass on an infinite surface. Mangeney, A., Heinrich, P., & Roche, R., 2000, Analytical solution for testing debris avalanche numerical models, Pure and Applied Geophysics, vol. 157, p. 1081-1096. :param x_0: Initial dam location (position along x-axis), by default 0. :type x_0: float :param h_0: Initial water depth. :type h_0: float :param theta: Angle of the surface, in degree. :type theta: float :param delta: Dynamic friction angle (20°-40° for debris avalanche), in degree. :type delta: float .. attribute:: _x0 Initial dam location (position along x-axis). :type: float .. attribute:: _h0 Initial water depth. :type: float .. attribute:: _delta Dynamic friction angle, in radian. :type: float .. attribute:: _c0 Initial wave propagation speed. :type: float .. attribute:: _m Constant horizontal acceleration of the front. :type: float .. py:method:: xa(t: float) -> float Edge of the quiet area: .. math:: x_A(t) = x_0 + \frac{1}{2}mt^2 - c_0 t :param t: Time instant. :type t: float :returns: Position of the edge of the quiet region. :rtype: float .. py:method:: xb(t: float) -> float Front of the flow: .. math:: x_B(t) = x_0 + \frac{1}{2}mt^2 + 2 c_0 t :param t: Time instant. :type t: float :returns: Position of the front edge of the fluid. :rtype: float .. py:method:: compute_c0() -> float Compute the initial wave propagation speed defined by: .. math:: c_0 = \sqrt{g h_0 \cos{\theta}} :returns: Value of the initial wave propagation speed. :rtype: float .. py:method:: compute_m() -> float Compute the constant horizontal acceleration of the front defined by: .. math:: m = g \sin{\theta} - g \cos{\theta} \tan{\delta} :returns: Value of the constant horizontal acceleration of the front. :rtype: float .. py:method:: compute_h(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow height h(x, t) at given time and positions. .. math:: h(x, t) = \begin{cases} h_0 & \text{if } x \leq x_A(t), \\\\ \frac{1}{9g cos(\theta)} \left(2 c_0 - \frac{x-x_0}{t} + \frac{1}{2} m t \right)^2 & \text{if } x_A(t) < x \leq x_B(t), \\\\ 0 & \text{if } x_B(t) < x, \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._h`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:method:: compute_u(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow velocity u(x, t) at given time and positions. .. math:: u(x,t) = \begin{cases} 0 & \text{if } x \leq x_A(t), \\\\ \frac{2}{3} \left( \frac{x-x_0}{t} + c_0 + mt \right) & \text{if } x_A(t) < x \leq x_B(t), \\\\ 0 & \text{if } x_B(t) < x, \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._u`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:class:: Dressler_dry(x_0: float, h_0: float, C: float = 40) Bases: :py:obj:`Depth_result` Dam-break solution on a dry domain with friction using shallow water theory. This class implements the 1D analytical Dressler's solution of an ideal dam break on a dry domain with friction. The dam break is instantaneous, over an horizontal and flat surface with friction. It computes the flow height (took verticaly) and velocity over space and time, based on the equation implemanted in SWASHES, based on Dressler's equation. Dressler, R.F., 1952, Hydraulic resistance effect upon the dam‑break functions, Journal of Research of the National Bureau of Standards, vol. 49(3), p. 217-225. :param x_0: Initial dam location (position along x-axis). :type x_0: float :param h_0: Water depth to the left of the dam. :type h_0: float :param C: Chézy coefficient, by default 40. :type C: float, optional .. attribute:: _x0 Initial dam location (position along x-axis). :type: float .. attribute:: _h0 Water depth to the left of the dam. :type: float .. attribute:: _c Chézy coefficient, by default 40. :type: float, optional .. attribute:: _xt Position of the tip area, by default None. :type: float .. attribute:: _ht Depth of the tip area, by default None. :type: float, optional .. attribute:: _ut Velocity of the tip area, by default None. :type: float, optional .. py:method:: xa(t: float) -> float Position of the rarefaction wave front (left-most edge) : .. math:: x_A(t) = x_0 - t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the front edge of the rarefaction wave. :rtype: float .. py:method:: xb(t: float) -> float Position of the contact discontinuity: .. math:: x_B(t) = x_0 + 2 t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the contact wave (end of rarefaction). :rtype: float .. py:method:: alpha1(x: float, t: float) -> float Correction coefficient for the height: .. math:: \alpha_1(\xi) = \frac{6}{5(2-\xi)} - \frac{2}{3} + \frac{4 \sqrt{3}}{135} (2-\xi)^{3/2}), \\\\ with :math:`\xi = \frac{x-x_0}{t\sqrt{g h_0}}` :param x: Spatial position. :type x: float :param t: Time instant. :type t: float :returns: Correction coefficient. :rtype: float .. py:method:: alpha2(x: float, t: float) -> float Correction coefficient for the velocity: .. math:: \alpha_2(\xi) = \frac{12}{2-(2-\xi)} - \frac{8}{3} + \frac{8 \sqrt{3}}{189} (2-\xi)^{3/2}) - \frac{108}{7(2 - \xi)}, \\\\ with :math:`\xi = \frac{x-x_0}{t\sqrt{g h_0}}` :param x: Spatial position. :type x: float :param t: Time instant. :type t: float :returns: Correction coefficient. :rtype: float .. py:method:: compute_u(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Call :meth:`compute_h`. .. py:method:: compute_h(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow height h(x, t) and velocity u(x, t) at given time and positions. .. math:: h(x, t) = \begin{cases} h_0 & \text{if } x \leq x_A(t), \\\\ \frac{1}{g} \left( \frac{2}{3} \sqrt{g h_0} - \frac{x - x_0}{3t} + \frac{g^{2}}{C^2} \alpha_1 t \right)^2 & \text{if } x_A(t) < x \leq x_t(t), \\\\ \frac{-b-\sqrt{b^2 - 4 a (c-x(t))}}{2 a} & \text{if } x_t(t) < x \leq x_B(t), \\\\ 0 & \text{if } x_B(t) < x, \end{cases} with :math:`r = \left. \frac{dx}{dh} \right|_{h = h_t}`, :math:`c = x_B(t)`, :math:`a = \frac{r h_t + c - x_t}{h_t^2}`, :math:`b = r - 2 a h_t`. :math:`x_t` and :math:`h_t` being the position and the flow depth at the beginning of the tip area. .. math:: u(x,t) = \begin{cases} 0 & \text{if } x \leq x_A(t), \\\\ u_{co} = \frac{2\sqrt{g h_0}}{3} + \frac{2(x - x_0)}{3t} + \frac{g^2}{C^2} \alpha_2 t & \text{if } x_A(t) < x \leq x_t(t), \\\\ \max_{x \in [x_A(t), x_t(t)]} u_{co}(x, t) & \text{if } x_t(t) < x \leq x_B(t), \\\\ 0 & \text{if } x_B(t) < x, \end{cases} :param x: Spatial positions. :type x: float | np.ndarray :param T: Time instant. :type T: float | np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._h`, :attr:`tilupy.analytic_sol.Depth_result._u`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:class:: Chanson_dry(h_0: float, x_0: float, f: float) Bases: :py:obj:`Depth_result` Dam-break solution on a dry domain with friction using shallow water theory. This class implements the 1D analytical Chanson's solution of an ideal dam break on a dry domain with friction. The dam break is instantaneous, over an horizontal and flat surface with friction. It computes the flow height (took verticaly) and velocity over space and time, based on the equation implemanted in SWASHES, based on Chanson's equation. Chanson, H., 2005, Applications of the Saint-Venant Equations and Method of Characteristics to the Dam Break Wave Problem. https://espace.library.uq.edu.au/view/UQ:9438 :param x_0: Initial dam location (position along x-axis). :type x_0: float :param h_0: Water depth to the left of the dam. :type h_0: float :param f: Darcy friction factor. :type f: float .. attribute:: _x0 Initial dam location (position along x-axis). :type: float .. attribute:: _h0 Water depth to the left of the dam. :type: float .. attribute:: _f Darcy friction factor. :type: float, optional .. py:method:: xa(t: float) -> float Position of the rarefaction wave front (left-most edge) : .. math:: x_A(t) = x_0 - t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the front edge of the rarefaction wave. :rtype: float .. py:method:: xb(t: float) -> float Position of the tip of the flow: .. math:: x_B(t) = x_0 + \left( \frac{3}{2} \frac{U(t)}{\sqrt{g h_0}} - 1 \right) t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the flow tip. :rtype: float .. py:method:: xc(t: float) -> float Position of the contact discontinuity: .. math:: x_C(t) = x_0 + \left( \frac{3}{2} \frac{U(t)}{\sqrt{g h_0}} - 1 \right) t \sqrt{\frac{g}{h_0}} + \frac{4}{f\frac{U(t)^2}{g h_0}} \left( 1 - \frac{U(t)}{2 \sqrt{g h_0}} \right)^4 :param t: Time instant. :type t: float :returns: Position of the contact wave (wave front). :rtype: float .. py:method:: compute_cf(t: float) -> float Compute the celerity of the wave front by resolving: .. math:: \left( \frac{U}{\sqrt{g h_0}} \right)^3 - 8 \left( 0.75 - \frac{3 f t \sqrt{g}}{8 \sqrt{h_0}} \right) \left( \frac{U}{\sqrt{g h_0}} \right)^2 + 12 \left( \frac{U}{\sqrt{g h_0}} \right) - 8 = 0 :param t: Time instant :type t: float :returns: Value of the front wave velocity. :rtype: float .. py:method:: compute_h(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None Compute the flow height h(x, t) at given time and positions. .. 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), \\\\ \sqrt{\frac{f}{4} \frac{U(t)^2}{g h_0} \frac{x_C(t)-x}{h_0}} & \text{if } x_B(t) < x \leq x_C(t), \\\\ 0 & \text{if } x_C(t) < x \end{cases} :param x: Spatial positions. :type x: float or np.ndarray :param T: Time instant. :type T: float or np.ndarray .. rubric:: Notes Updates the internal :attr:`tilupy.analytic_sol.Depth_result._h`, :attr:`tilupy.analytic_sol.Depth_result._x`, :attr:`tilupy.analytic_sol.Depth_result._t` attributes with the computed result. .. py:method:: compute_u(x: float | numpy.ndarray, T: float | numpy.ndarray) -> None No solution .. py:class:: Shape_result(theta: float = 0) Bases: :py:obj:`abc.ABC` Abstract base class representing shape results of a simulated flow. This class defines a common interface for flow simulation that compute the geometry of the final shape of a flow simulation. :param theta: Angle of the surface, in radian, by default 0. :type theta: float, optional .. attribute:: _g = 9.81 Gravitational constant. :type: float .. attribute:: _theta Angle of the surface, in radian. :type: float .. attribute:: _x Spatial coordinates. :type: float or np.ndarray .. attribute:: _h Flow height depending on space. :type: np.ndarray .. py:property:: h Accessor of the shape h of the flow. :returns: Attribute :attr:`_h`. If None, no solution computed. :rtype: numpy.ndarray .. py:property:: x Accessor of the spatial distribution of the computed solution. :returns: Attribute :attr:`_x`. If None, no solution computed. :rtype: numpy.ndarray .. py:property:: y Accessor of the lateral spatial distribution of the computed solution. :returns: Attribute :attr:`_y`. If None, no solution computed. :rtype: numpy.ndarray .. py:class:: Coussot_shape(rho: float, tau: float, theta: float = 0, h_final: float = 1, H_size: int = 100) Bases: :py:obj:`Shape_result` Shape solution on an inclined dry domain without friction. This class implements the final shape of a simulated flow. The flow is over an inclined and flat surface without friction with a finite volume of fluid. It computes the spatial coordinates from the flow lenght and height. Coussot, P., Proust, S., & Ancey, C., 1996, Rheological interpretation of deposits of yield stress fluids, Journal of Non-Newtonian Fluid Mechanics, v. 66(1), p. 55-70, doi:10.1016/0377-0257(96)01474-7. :param rho: Fluid density. :type rho: float :param tau: Threshold constraint. :type tau: float :param theta: Angle of the surface, in degree, by default 0. :type theta: float, optional :param h_final: The final flow depth, by default 1. :type h_final: float, optional :param H_size: Number of value wanted in the H array, by default 100. :type H_size: int, optional .. attribute:: _rho Fluid density. :type: float .. attribute:: _tau Threshold constraint. :type: float .. attribute:: _D Normalized distance of the front from the origin. :type: float or numpy.ndarray .. attribute:: _H Normalized fluid depth. :type: float or numpy.ndarray .. attribute:: _d Distance of the front from the origin. :type: float or numpy.ndarray .. attribute:: _h Fluid depth. :type: float or numpy.ndarray .. attribute:: _H_size Number of point in H-axis. :type: int .. py:method:: h_to_H(h: float) -> float Normalize the fluid depth by following: .. math:: H = \frac{\rho g h \sin(\theta)}{\tau_c} If :math:`\theta = 0`, the expression is: .. math:: H = \frac{\rho g h}{\tau_c} :param h: Initial fluid depth. :type h: float :returns: Normalized fluid depth. :rtype: float .. py:method:: H_to_h(H: float) -> float Find the original value of the fluid depth from the normalized one by following: .. math:: h = \frac{H \tau_c}{\rho g \sin(\theta)} If :math:`\theta = 0`, the expression is: .. math:: h = \frac{H \tau_c}{\rho g} :param H: Normalized value of the fluid depth. :type H: float :returns: True value of the fluid depth. :rtype: float .. py:method:: x_to_X(x: float) -> float Normalize the spatial coordinates by following: .. math:: X = \frac{\rho g x (\sin(\theta))^2}{\tau_c \cos(\theta)} If :math:`\theta = 0`, the expression is: .. math:: X = \frac{\rho g x}{\tau_c} :param x: Initial spatial coordinate. :type x: float :returns: Normalized spatial coordinate. :rtype: float .. py:method:: X_to_x(X: float) -> float Find the original value of the spatial coordinates from the normalized one by following: .. math:: x = \frac{X \tau_c \cos(\theta)}{\rho g (\sin(\theta))^2} If :math:`\theta = 0`, the expression is: .. math:: x = \frac{X \tau_c}{\rho g} :param X: Normalized values of the spatial coordinates. :type X: float :returns: True value of the spatial coordinate. :rtype: float .. py:method:: compute_rheological_test_front_morpho() -> None Compute the shape of the frontal lobe from the normalized fluid depth for a rheological test on an inclined surface by following : .. math:: D = - H - \ln(1 - H) If :math:`\theta = 0`, the expression is: .. math:: D = \frac{H^2}{2} .. py:method:: compute_rheological_test_lateral_morpho() -> None Compute the shape of the lateral lobe from the normalized fluid depth for a rheological test on an inclined surface by following : .. math:: D = 1 - \sqrt{1 - H^2} .. py:method:: compute_slump_test_hf(h_init: float) -> float Compute the final fluid depth for a cylindrical slump test following : .. math:: \frac{h_f}{h_i} = 1 - \frac{2 \tau_c}{\rho g h_i} \left( 1 - \ln{\frac{2 \tau_c}{\rho g h_i}} \right) N. Pashias, D. V. Boger, J. Summers, D. J. Glenister; A fifty cent rheometer for yield stress measurement. J. Rheol. 1 November 1996; 40 (6): 1179-1189. https://doi.org/10.1122/1.550780 :param h_init: Initial fluid depth. :type h_init: float :returns: Final fluid depth :rtype: float .. py:method:: translate_front(d_final: float) -> None Translate the shape of the frontal (or transversal) lobe to the wanted x (or y) coordinate. :param d_final: Final wanted coordinate. :type d_final: float .. py:method:: change_orientation_flow() -> None Swap the direction of the result. .. rubric:: Notes There must not have been any prior translation to use this method. .. py:method:: interpolate_on_d() -> None Interpolate the profile on d-axis. .. py:property:: d Accessor of the spatial distribution of the computed solution. :returns: Attribute :attr:`_d`. If None, no solution computed. :rtype: numpy.ndarray .. py:class:: Front_result(h0: float) Class computing front position of a simulated flow. This class defines multiple methods for flow simulation that compute the position of the front flow at the specified moment. :param h0: Initial fluid depth. :type h0: float .. attribute:: _g = 9.81 Gravitational constant. :type: float .. attribute:: _h0 Initial fluid depth. :type: float .. attribute:: _xf Dictionnary of spatial coordinates of the front flow for each time step (keys). :type: dictionnary .. attribute:: _labels Dictionnary of spatial coordinates computation's method for each time step (keys). :type: dictionnary .. py:method:: xf_mangeney(t: float, delta: float, theta: float = 0) -> float Mangeney's equation for a dam-break solution over an infinite inclined dry domain with friction and an infinitely-long fluid mass: .. math:: x_f(t) = \frac{1}{2}mt^2 + 2 c_0 t with :math:`c_0` the initial wave propagation speed defined by: .. math:: c_0 = \sqrt{g h_0 \cos{\theta}} and :math:`m` the constant horizontal acceleration of the front defined by: .. math:: m = g \sin{\theta} - g \cos{\theta} \tan{\delta} Mangeney, A., Heinrich, P., & Roche, R., 2000, Analytical solution for testing debris avalanche numerical models, Pure and Applied Geophysics, vol. 157, p. 1081-1096. :param t: Time instant. :type t: float :param delta: Dynamic friction angle, in degree. :type delta: float :param theta: Slope angle, in degree. :type theta: float :returns: Position of the front edge of the fluid. :rtype: float .. py:method:: xf_dressler(t: float) -> float Dressler's equation for a dam-break solution over an infinite inclined dry domain with friction: .. math:: x_f(t) = 2 t \sqrt{g h_0} :param t: Time instant. :type t: float :returns: Position of the front edge of the fluid. :rtype: float .. py:method:: xf_ritter(t: float) -> float Ritter's equation for a dam-break solution over an infinite inclined dry domain without friction: .. math:: x_f(t) = 2 t \sqrt{g h_0} Ritter A. Die Fortpflanzung der Wasserwellen. Zeitschrift des Vereines Deuscher Ingenieure August 1892; 36(33): 947-954. :param t: Time instant. :type t: float :returns: Position of the front edge of the fluid. :rtype: float .. py:method:: xf_stoker(t: float, hr: float) -> float Stoker's equation for a dam-break solution over an infinite inclined wet domain without friction: .. math:: x_f(t) =t c_m with :math:`c_m` the front wave velocity solution of: .. math:: c_m h_r - h_r \left( \sqrt{1 + \frac{8 c_m^2}{g h_r}} - 1 \right) \left( \frac{c_m}{2} - \sqrt{g h_0} + \sqrt{\frac{g h_r}{2} \left( \sqrt{1 + \frac{8 c_m^2}{g h_r}} - 1 \right)} \right) = 0 Stoker JJ. Water Waves: The Mathematical Theory with Applications, Pure and Applied Mathematics, Vol. 4. Interscience Publishers: New York, USA, 1957. Sarkhosh, P. (2021). Stoker solution package (1.0.0). Zenodo. https://doi.org/10.5281/zenodo.5598374 :param t: Time instant. :type t: float :param hr: Fluid depth at the right of the dam. :type hr: float :returns: Position of the front edge of the fluid. :rtype: float .. py:method:: xf_chanson(t: float, f: float) -> float Chanson's equation for a dam-break solution over an infinite inclined dry domain with friction: .. math:: x_f(t) = \left( \frac{3}{2} \frac{U(t)}{\sqrt{g h_0}} - 1 \right) t \sqrt{\frac{g}{h_0}} + \frac{4}{f\frac{U(t)^2}{g h_0}} \left( 1 - \frac{U(t)}{2 \sqrt{g h_0}} \right)^4 with :math:`U(t)` the front wave velocity solution of: .. math:: \left( \frac{U}{\sqrt{g h_0}} \right)^3 - 8 \left( 0.75 - \frac{3 f t \sqrt{g}}{8 \sqrt{h_0}} \right) \left( \frac{U}{\sqrt{g h_0}} \right)^2 + 12 \left( \frac{U}{\sqrt{g h_0}} \right) - 8 = 0 Chanson, Hubert. (2005). Analytical Solution of Dam Break Wave with Flow Resistance: Application to Tsunami Surges. 137. :param t: Time instant. :type t: float :param f: Darcy friction coefficient. :type f: float :returns: Position of the front edge of the fluid. :rtype: float .. py:method:: compute_cf(t: float) -> float Compute the celerity of the wave front by resolving: :param t: Time instant :type t: float :returns: Value of the front wave velocity. :rtype: float .. py:method:: show_fronts_over_methods(x_unit: str = 'm') -> None Plot the front distance from the initial position for each method. :param x_unit: X-axis unit, by default "m" :type x_unit: str, optional .. py:method:: show_fronts_over_time(x_unit: str = 'm') -> None Plot the front distance from the initial position over time for each method. :param x_unit: X-axis unit, by default "m" :type x_unit: str, optional