wolfhece.mesh2d.simple_2d
Module Contents
- class wolfhece.mesh2d.simple_2d.Scenarios[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- wolfhece.mesh2d.simple_2d.domain(length: float, dx: float, slope: float) numpy.ndarray [source]
Create the domain
- Parameters:
length – Length of the domain
dx – Space step
slope – Slope of the domain
- wolfhece.mesh2d.simple_2d._init_conditions(dom: numpy.ndarray, h0: float, q0: float) numpy.ndarray [source]
Initial conditions
- Parameters:
dom – Domain
h0 – Initial water depth [m]
q0 – Initial discharge [m^2/s]
- wolfhece.mesh2d.simple_2d.get_friction_slope_2D_Manning(q: float, h: float, n: float) float [source]
Friction slope based on Manning formula
- Parameters:
q – Discharge [m^2/s]
h – Water depth [m]
n – Manning coefficient [m^(1/3)/s]
- wolfhece.mesh2d.simple_2d.compute_dt(dx: float, h: numpy.ndarray, q: numpy.ndarray, CN: float) float [source]
Compute the time step according to the Courant number anf the maximum velocity
- Parameters:
dx – Space step
h – Water depth
q – Discharge
CN – Courant number
- wolfhece.mesh2d.simple_2d.all_unk_border(dom: numpy.ndarray, h0: float, q0: float) tuple[numpy.ndarray] [source]
Initialize all arrays storing unknowns at center and borders
- Parameters:
dom – Domain
h0 – Initial water depth
q0 – Initial discharge
- wolfhece.mesh2d.simple_2d.uniform_waterdepth(slope: float, q: float, n: float)[source]
Compute the uniform water depth for a given slope, discharge and Manning coefficient
- Parameters:
slope – Slope
q – Discharge [m^2/s]
n – Manning coefficient
- wolfhece.mesh2d.simple_2d.k_abrupt_enlargment(asmall: float, alarge: float) float [source]
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
- wolfhece.mesh2d.simple_2d.k_abrupt_contraction(alarge: float, asmall: float) float [source]
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
- wolfhece.mesh2d.simple_2d.head_loss_enlargment(q: float, asmall: float, alarge: float) float [source]
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
- wolfhece.mesh2d.simple_2d.head_loss_contraction(q: float, alarge: float, asmall: float) float [source]
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
- wolfhece.mesh2d.simple_2d.head_loss_contract_enlarge(q: float, a_up: float, asmall: float, a_down: float) float [source]
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
- wolfhece.mesh2d.simple_2d.get_friction_slope_2D_Manning_semi_implicit(u: numpy.ndarray, h: numpy.ndarray, n: float) numpy.ndarray [source]
Friction slope based on Manning formula – Only semi-implicit formulea for the friction slope
- Parameters:
u – Velocity [m/s]
h – Water depth [m]
n – Manning coefficient [m^(1/3)/s]
- wolfhece.mesh2d.simple_2d.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 [source]
Solve the mass and momentum equations using a explicit Euler/Runge-Kutta scheme (only 1 step)
- Parameters:
h_t1 – Water depth at time t
h_t2 – Water depth at time t+dt (or t_star or t_doublestar if RK)
q_t1 – Discharge at time t
q_t2 – Discharge at time t+dt (or t_star or t_doublestar if RK)
h – Water depth at the mesh center
q – Discharge at the mesh center
h_border – Water depth at the mesh border
q_border – Discharge at the mesh border
z – Bed elevation
z_border – Bed elevation at the mesh border
dt – Time step
dx – Space step
CL_h – Downstream boudary condition for water depth
CL_q – Upstream boundary condition for discharge
n – Manning coefficient
u_border – Velocity at the mesh border
h_center – Water depth at the mesh center
u_center – Velocity at the mesh center
- wolfhece.mesh2d.simple_2d.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 [source]
Solve the mass and momentum equations using a explicit Euler/Runge-Kutta scheme (only 1 step)
- Parameters:
h_t1 – Water depth at time t
h_t2 – Water depth at time t+dt (or t_star or t_doublestar if RK)
q_t1 – Discharge at time t
q_t2 – Discharge at time t+dt (or t_star or t_doublestar if RK)
h – Water depth at the mesh center
q – Discharge at the mesh center
h_border – Water depth at the mesh border
q_border – Discharge at the mesh border
z – Bed elevation
z_border – Bed elevation at the mesh border
dt – Time step
dx – Space step
CL_h – Downstream boudary condition for water depth
CL_q – Upstream boundary condition for discharge
n – Manning coefficient
u_border – Velocity at the mesh border
h_center – Water depth at the mesh center
u_center – Velocity at the mesh center
- wolfhece.mesh2d.simple_2d.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 [source]
Splitting of the unknowns at border between two nodes – Based on the WOLF HECE original scheme
- wolfhece.mesh2d.simple_2d.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 [source]
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.
- wolfhece.mesh2d.simple_2d.limit_h_q(h: numpy.ndarray, q: numpy.ndarray, hmin: float = 0.0, Froudemax: float = 3.0) None [source]
Limit the water depth and the discharge
- Parameters:
h – Water depth [m]
q – Discharge [m^2/s]
hmin – Minimum water depth [m]
Froudemax – Maximum Froude number [-]
- wolfhece.mesh2d.simple_2d.problem(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float)[source]
Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order)
NO BRIDGE
- wolfhece.mesh2d.simple_2d.problem_hedge(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float)[source]
Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order)
NO BRIDGE bur HEDGE in the middle
- wolfhece.mesh2d.simple_2d.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] [source]
Solve the mass and momentum equations using a explicit Rung-Kutta scheme (2 steps - 2nd order)
WITH BRIDGE and NO OVERFLOW
- wolfhece.mesh2d.simple_2d.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]] [source]
Solve multiple steady states for a given discharge range
- wolfhece.mesh2d.simple_2d.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)[source]
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.
- wolfhece.mesh2d.simple_2d.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)[source]
Solve the mass and momentum equations using a explicit Rung-Kutta scheme (2 steps - 2nd order).
WITH BRIDGE and OVERFLOW
- wolfhece.mesh2d.simple_2d.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)[source]
- wolfhece.mesh2d.simple_2d.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)[source]
- wolfhece.mesh2d.simple_2d.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)[source]
- wolfhece.mesh2d.simple_2d.lake_at_rest()[source]
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.
- wolfhece.mesh2d.simple_2d.water_line()[source]
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
- wolfhece.mesh2d.simple_2d.water_line_noloss_noslope()[source]
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
- wolfhece.mesh2d.simple_2d.water_lines()[source]
Compute multiple water lines problems.
Evaluate the head loss due to the bridge and compare to theoretical fomula.
- wolfhece.mesh2d.simple_2d.unsteady_without_bedmotion()[source]
Compute unsteady problem without bed motion.
The downstream boundary condition rises and decreases.
- wolfhece.mesh2d.simple_2d.unsteady_with_bedmotion(problems: list[int], save_video: bool = False) list[matplotlib.animation.FuncAnimation] [source]
Unsteady problem with bed motion if overflowing occurs.
- Parameters:
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
- wolfhece.mesh2d.simple_2d.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] [source]
Unsteady problem with bed motion if overflowing occurs.
- Parameters:
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