wolfhece.mesh2d.simple_2d_f32 ============================= .. py:module:: wolfhece.mesh2d.simple_2d_f32 Module Contents --------------- .. 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_wb(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 Well-balanced version of Euler_RK (float32) Replaces the separate pressure + bed terms with the factored form: 0.5 * g * (h_r + h_l) * (eta_r - eta_l), eta = h + z This avoids catastrophic cancellation between h^2 terms and bed-slope terms in float32 arithmetic, and yields the exact well-balanced property (zero momentum flux for a lake at rest). .. 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.float32, q_right: numpy.float32, h_left: numpy.float32, h_right: numpy.float32, z_left: numpy.float32, z_right: numpy.float32, z_bridge_left: numpy.float32, z_bridge_right: numpy.float32) -> numpy.ndarray Splitting of the unknowns at border between two nodes -- Based on the WOLF HECE original scheme :param q_left: Discharge at the left-side of the border :param q_right: Discharge at the right-side of the border :param h_left: Water depth at the left-side of the border :param h_right: Water depth at the right-side of the border :param z_left: Bed elevation at the left-side of the border :param z_right: Bed elevation at the right-side of the border :param z_bridge_left: Bridge elevation at the left-side of the border :param z_bridge_right: Bridge elevation at the right-side of the border :return: Array of the unknowns according to the WOLF HECE 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, 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. :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 :param z_bridge: Bridge elevation at the mesh center :param z_bridge_border: Bridge elevation at the mesh border :param infil_exfil: Infiltration/exfiltration parameters .. 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:data:: MAX_TIME .. py:function:: problem(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float, h_init: numpy.ndarray = None, q_init: numpy.ndarray = None) Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order) **NO BRIDGE** .. py:function:: problem_wb(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float, h_init: numpy.ndarray = None, q_init: numpy.ndarray = None) Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order) **NO BRIDGE** .. py:function:: _problem_convergence(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_convergence_wb(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float) Well-balanced variant of _problem_convergence (float32) Uses Euler_RK_wb which avoids catastrophic cancellation in the pressure + bed-slope gradient by computing: 0.5 * g * (h_r + h_l) * (eta_r - eta_l), eta = h + z .. 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 but 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, 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) -> list[tuple[float, numpy.ndarray, numpy.ndarray]] Solve multiple steady states for a given discharge range