wolfhece.mesh2d.simple_2d_f32

Module Contents

wolfhece.mesh2d.simple_2d_f32.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_f32._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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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_f32.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[source]

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).

wolfhece.mesh2d.simple_2d_f32.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_f32.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[source]

Splitting of the unknowns at border between two nodes – Based on the WOLF HECE original scheme

Parameters:
  • q_left – Discharge at the left-side of the border

  • q_right – Discharge at the right-side of the border

  • h_left – Water depth at the left-side of the border

  • h_right – Water depth at the right-side of the border

  • z_left – Bed elevation at the left-side of the border

  • z_right – Bed elevation at the right-side of the border

  • z_bridge_left – Bridge elevation at the left-side of the border

  • z_bridge_right – Bridge elevation at the right-side of the border

Returns:

Array of the unknowns according to the WOLF HECE scheme

wolfhece.mesh2d.simple_2d_f32.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[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.

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

  • z_bridge – Bridge elevation at the mesh center

  • z_bridge_border – Bridge elevation at the mesh border

  • infil_exfil – Infiltration/exfiltration parameters

wolfhece.mesh2d.simple_2d_f32.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_f32.MAX_TIME[source]
wolfhece.mesh2d.simple_2d_f32.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)[source]

Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order)

NO BRIDGE

wolfhece.mesh2d.simple_2d_f32.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)[source]

Solve the mass and momentum equations using a explicit Runge-Kutta scheme (2 steps - 2nd order)

NO BRIDGE

wolfhece.mesh2d.simple_2d_f32._problem_convergence(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_f32._problem_convergence_wb(dom: numpy.ndarray, z: numpy.ndarray, h0: float, q0: float, dx: float, CN: float, n: float)[source]

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

wolfhece.mesh2d.simple_2d_f32.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 but HEDGE in the middle

wolfhece.mesh2d.simple_2d_f32.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][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_f32.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]][source]

Solve multiple steady states for a given discharge range