:py:mod:`wolfhece.mesh2d.simple_2d` =================================== .. py:module:: wolfhece.mesh2d.simple_2d Module Contents --------------- .. py:class:: Scenarios Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.mesh2d.simple_2d.Scenarios :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: unsteady_downstream_bc :value: 0 .. py:attribute:: hydrograph :value: 1 .. py:attribute:: hydrograph_2steps :value: 2 .. py:attribute:: Gauss :value: 3 .. py:attribute:: water_lines :value: 4 .. py:function:: domain(length: float, dx: float, slope: float) -> numpy.ndarray Create the domain :param length: Length of the domain :param dx: Space step :param slope: Slope of the domain .. py:function:: _init_conditions(dom: numpy.ndarray, h0: float, q0: float) -> numpy.ndarray Initial conditions :param dom: Domain :param h0: Initial water depth [m] :param q0: Initial discharge [m^2/s] .. py:function:: get_friction_slope_2D_Manning(q: float, h: float, n: float) -> float Friction slope based on Manning formula :param q: Discharge [m^2/s] :param h: Water depth [m] :param n: Manning coefficient [m^(1/3)/s] .. py:function:: compute_dt(dx: float, h: numpy.ndarray, q: numpy.ndarray, CN: float) -> float Compute the time step according to the Courant number anf the maximum velocity :param dx: Space step :param h: Water depth :param q: Discharge :param CN: Courant number .. py:function:: all_unk_border(dom: numpy.ndarray, h0: float, q0: float) -> tuple[numpy.ndarray] Initialize all arrays storing unknowns at center and borders :param dom: Domain :param h0: Initial water depth :param q0: Initial discharge .. py:function:: uniform_waterdepth(slope: float, q: float, n: float) Compute the uniform water depth for a given slope, discharge and Manning coefficient :param slope: Slope :param q: Discharge [m^2/s] :param n: Manning coefficient .. py:function:: k_abrupt_enlargment(asmall: float, alarge: float) -> float Compute the local head loss coefficient of the abrupt enlargment :params asmall: float, area of the section 1 -- smaller section :params alarge: float, area of the section 2 -- larger section .. py:function:: k_abrupt_contraction(alarge: float, asmall: float) -> float Compute the local head loss coefficient of the abrupt contraction :params alarge: float, area of the section 1 -- larger section :params asmall: float, area of the section 2 -- smaller section .. py:function:: head_loss_enlargment(q: float, asmall: float, alarge: float) -> float Compute the head loss of the enlargment. Reference velocity is the velocity in the smaller section. :params q: float, discharge :params asmall: float, area of the section 1 -- smaller section :params alarge: float, area of the section 2 -- larger section .. py:function:: head_loss_contraction(q: float, alarge: float, asmall: float) -> float Compute the head loss of the contraction. Reference velocity is the velocity in the smaller section. :params q: float, discharge :params alarge: float, area of the section 1 -- larger section :params asmall: float, area of the section 2 -- smaller section .. py:function:: head_loss_contract_enlarge(q: float, a_up: float, asmall: float, a_down: float) -> float Compute the head loss of the contraction/enlargment. Reference velocity is the velocity in the smaller section. :params q: float, discharge :params a_up: float, area of the section 1 -- larger section :params asmall: float, area of the section 2 -- smaller section :params a_down: float, area of the section 3 -- larger section .. py:function:: get_friction_slope_2D_Manning_semi_implicit(u: numpy.ndarray, h: numpy.ndarray, n: float) -> numpy.ndarray Friction slope based on Manning formula -- Only semi-implicit formulea for the friction slope :param u: Velocity [m/s] :param h: Water depth [m] :param n: Manning coefficient [m^(1/3)/s] .. py:function:: Euler_RK(h_t1: numpy.ndarray, h_t2: numpy.ndarray, q_t1: numpy.ndarray, q_t2: numpy.ndarray, h: numpy.ndarray, q: numpy.ndarray, h_border: numpy.ndarray, q_border: numpy.ndarray, z: numpy.ndarray, z_border: numpy.ndarray, dt: float, dx: float, CL_h: float, CL_q: float, n: float, u_border: numpy.ndarray, h_center: numpy.ndarray, u_center: numpy.ndarray) -> None Solve the mass and momentum equations using a explicit Euler/Runge-Kutta scheme (only 1 step) :param h_t1: Water depth at time t :param h_t2: Water depth at time t+dt (or t_star or t_doublestar if RK) :param q_t1: Discharge at time t :param q_t2: Discharge at time t+dt (or t_star or t_doublestar if RK) :param h: Water depth at the mesh center :param q: Discharge at the mesh center :param h_border: Water depth at the mesh border :param q_border: Discharge at the mesh border :param z: Bed elevation :param z_border: Bed elevation at the mesh border :param dt: Time step :param dx: Space step :param CL_h: Downstream boudary condition for water depth :param CL_q: Upstream boundary condition for discharge :param n: Manning coefficient :param u_border: Velocity at the mesh border :param h_center: Water depth at the mesh center :param u_center: Velocity at the mesh center .. py:function:: Euler_RK_hedge(h_t1: numpy.ndarray, h_t2: numpy.ndarray, q_t1: numpy.ndarray, q_t2: numpy.ndarray, h: numpy.ndarray, q: numpy.ndarray, h_border: numpy.ndarray, q_border: numpy.ndarray, z: numpy.ndarray, z_border: numpy.ndarray, dt: float, dx: float, CL_h: float, CL_q: float, n: float, u_border: numpy.ndarray, h_center: numpy.ndarray, u_center: numpy.ndarray, theta: numpy.ndarray, theta_border: numpy.ndarray) -> None Solve the mass and momentum equations using a explicit Euler/Runge-Kutta scheme (only 1 step) :param h_t1: Water depth at time t :param h_t2: Water depth at time t+dt (or t_star or t_doublestar if RK) :param q_t1: Discharge at time t :param q_t2: Discharge at time t+dt (or t_star or t_doublestar if RK) :param h: Water depth at the mesh center :param q: Discharge at the mesh center :param h_border: Water depth at the mesh border :param q_border: Discharge at the mesh border :param z: Bed elevation :param z_border: Bed elevation at the mesh border :param dt: Time step :param dx: Space step :param CL_h: Downstream boudary condition for water depth :param CL_q: Upstream boundary condition for discharge :param n: Manning coefficient :param u_border: Velocity at the mesh border :param h_center: Water depth at the mesh center :param u_center: Velocity at the mesh center .. py:function:: splitting(q_left: numpy.float64, q_right: numpy.float64, h_left: numpy.float64, h_right: numpy.float64, z_left: numpy.float64, z_right: numpy.float64, z_bridge_left: numpy.float64, z_bridge_right: numpy.float64) -> numpy.ndarray Splitting of the unknowns at border between two nodes -- Based on the WOLF HECE original scheme .. py:function:: Euler_RK_bridge(h_t1: numpy.ndarray, h_t2: numpy.ndarray, q_t1: numpy.ndarray, q_t2: numpy.ndarray, h: numpy.ndarray, q: numpy.ndarray, h_border: numpy.ndarray, q_border: numpy.ndarray, z: numpy.ndarray, z_border: numpy.ndarray, dt: float, dx: float, CL_h: float, CL_q: float, n: float, u_border: numpy.ndarray, h_center: numpy.ndarray, u_center: numpy.ndarray, z_bridge: numpy.ndarray, z_bridge_border: numpy.ndarray, press_mode: int = 0, infil_exfil=None) -> None Solve the mass and momentum equations using a explicit Euler/Runge-Kutta scheme (only 1 step) applying source terms for infiltration/exfiltration and pressure at the roof. .. py:function:: limit_h_q(h: numpy.ndarray, q: numpy.ndarray, hmin: float = 0.0, Froudemax: float = 3.0) -> None Limit the water depth and the discharge :param h: Water depth [m] :param q: Discharge [m^2/s] :param hmin: Minimum water depth [m] :param Froudemax: Maximum Froude number [-] .. py:function:: problem(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float) Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order) **NO BRIDGE** .. py:function:: problem_hedge(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float) Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order) **NO BRIDGE bur HEDGE in the middle** .. py:function:: problem_bridge(dom: numpy.ndarray, z: numpy.ndarray, z_bridge: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float, press_mode: int = 4, h_ini: numpy.ndarray = None, q_ini: numpy.ndarray = None) -> tuple[numpy.ndarray] Solve the mass and momentum equations using a explicit Rung-Kutta scheme (2 steps - 2nd order) **WITH BRIDGE and NO OVERFLOW** .. py:function:: problem_bridge_multiple_steadystates(dom: numpy.ndarray, z: numpy.ndarray, z_bridge: numpy.ndarray, h0: float, qmin: float, qmax: float, dx: float, CN: float, n: float, press_mode: int = 4) -> list[tuple[float, numpy.ndarray, numpy.ndarray]] Solve multiple steady states for a given discharge range .. py:function:: problem_bridge_unsteady(dom: numpy.ndarray, z: numpy.ndarray, z_bridge: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float, press_mode: int = 4) Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order). **WITH BRIDGE and NO OVERFLOW** The downstream boundary condition rises temporarily. Firstly, we stabilize the flow with a constant downstream boundary condition. Then, we increase the downstream boundary condition. .. py:function:: problem_bridge_unsteady_topo(dom: numpy.ndarray, z: numpy.ndarray, z_roof: numpy.ndarray, z_deck: numpy.ndarray, z_roof_null: float, h0: float, q0: float, dx: float, CN: float, n: float, press_mode: int = 0, motion_duration: float = 300.0, scenario_bc: Literal[unsteady_downstream_bc, hydrograph, hydrograph_2steps, Gauss] = 'unsteady_downstream_bc', min_overflow: float = 0.05, updating_time_interval: float = 0.0) Solve the mass and momentum equations using a explicit Rung-Kutta scheme (2 steps - 2nd order). **WITH BRIDGE and OVERFLOW** .. py:function:: plot_bridge(ax: matplotlib.pyplot.Axes, x: numpy.ndarray, h1: numpy.ndarray, h2: numpy.ndarray, q1: numpy.ndarray, q2: numpy.ndarray, z: numpy.ndarray, z_bridge: numpy.ndarray, hu: float) .. py:function:: plot_hedge(ax: matplotlib.pyplot.Axes, x: numpy.ndarray, h1: numpy.ndarray, h2: numpy.ndarray, q1: numpy.ndarray, q2: numpy.ndarray, z: numpy.ndarray, hu: float, theta: numpy.ndarray) .. py:function:: animate_bridge_unsteady_topo(dom, poly_bridge_x, poly_bridge_y, res: list[float, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, tuple[int, int, float, float, float]], x: numpy.ndarray, z_ini: numpy.ndarray, hu: float, z_null: float, length: float, title: str = 'Bridge', motion_duration=300.0) .. py:function:: lake_at_rest() Compute Lake at rest problem The problem is a simple steady state problem with a bridge in the middle of the domain. The bridge is a simple flat bridge with a height of 2 m. No discharge and no water movement is expected. .. py:function:: water_line() Compute Water line problems Length = 500 m dx = 1 m CN = 0.4 h0 = 4 m q0 = 7 m^2/s n = 0.025 slope = 1e-4 .. py:function:: water_line_noloss_noslope() Compute Water line problems Length = 500 m dx = 1 m CN = 0.4 h0 = 4 m q0 = 7 m^2/s n = 0.0 slope = 0.0 .. py:function:: water_lines() Compute multiple water lines problems. Evaluate the head loss due to the bridge and compare to theoretical fomula. .. py:function:: unsteady_without_bedmotion() Compute unsteady problem without bed motion. The downstream boundary condition rises and decreases. .. py:function:: unsteady_with_bedmotion(problems: list[int], save_video: bool = False) -> list[matplotlib.animation.FuncAnimation] Unsteady problem with bed motion if overflowing occurs. :param problems: list of problems to solve Problems : 2 - Rectangular bridge - Length = 20 m (will compute 21, 22 and 23) 6 - Rectangular bridge - Length = 60 m (will compute 61, 62 and 63) 7 - V-shape bridge - Length = 20 m (will compute 71, 72 and 73) 8 - U-shape bridge - Length = 20 m (will compute 81, 82 and 83) 9 - Culvert - Length = 100 m (will compute 91, 92 and 93) 21 - Rectangular bridge - Length = 20 m - Unsteady downstream bc 22 - Rectangular bridge - Length = 20 m - Hydrograph 23 - Rectangular bridge - Length = 20 m - Hydrograph 2 steps 61 - Rectangular bridge - Length = 60 m - Unsteady downstream bc 62 - Rectangular bridge - Length = 60 m - Hydrograph 63 - Rectangular bridge - Length = 60 m - Hydrograph 2 steps 71 - V-shape bridge - Length = 20 m - Unsteady downstream bc 72 - V-shape bridge - Length = 20 m - Hydrograph 73 - V-shape bridge - Length = 20 m - Hydrograph 2 steps 81 - U-shape bridge - Length = 20 m - Unsteady downstream bc 82 - U-shape bridge - Length = 20 m - Hydrograph 83 - U-shape bridge - Length = 20 m - Hydrograph 2 steps 91 - Culvert - Length = 100 m - Unsteady downstream bc 92 - Culvert - Length = 100 m - Hydrograph 93 - Culvert - Length = 100 m - Hydrograph 2 steps .. py:function:: unsteady_with_bedmotion_interval(problems: list[int], save_video: bool = False, update_interval: float = 0.0, motion_duration: float = 300.0) -> list[matplotlib.animation.FuncAnimation] Unsteady problem with bed motion if overflowing occurs. :param problems: list of problems to solve Problems : 2 - Rectangular bridge - Length = 20 m (will compute 21, 22 and 23) 6 - Rectangular bridge - Length = 60 m (will compute 61, 62 and 63) 7 - V-shape bridge - Length = 20 m (will compute 71, 72 and 73) 8 - U-shape bridge - Length = 20 m (will compute 81, 82 and 83) 9 - Culvert - Length = 100 m (will compute 91, 92 and 93) 21 - Rectangular bridge - Length = 20 m - Unsteady downstream bc 22 - Rectangular bridge - Length = 20 m - Hydrograph 23 - Rectangular bridge - Length = 20 m - Hydrograph 2 steps 61 - Rectangular bridge - Length = 60 m - Unsteady downstream bc 62 - Rectangular bridge - Length = 60 m - Hydrograph 63 - Rectangular bridge - Length = 60 m - Hydrograph 2 steps 71 - V-shape bridge - Length = 20 m - Unsteady downstream bc 72 - V-shape bridge - Length = 20 m - Hydrograph 73 - V-shape bridge - Length = 20 m - Hydrograph 2 steps 81 - U-shape bridge - Length = 20 m - Unsteady downstream bc 82 - U-shape bridge - Length = 20 m - Hydrograph 83 - U-shape bridge - Length = 20 m - Hydrograph 2 steps 91 - Culvert - Length = 100 m - Unsteady downstream bc 92 - Culvert - Length = 100 m - Hydrograph 93 - Culvert - Length = 100 m - Hydrograph 2 steps .. py:function:: hedge() Compute Water line problems with hedge Length = 500 m dx = 1 m CN = 0.4 h0 = 4 m q0 = 7 m^2/s n = 0.025 slope = 1e-4 .. py:data:: anim