49#ifndef OPENSWMM_ENGINE_2D_EXCHANGE_LAW_HPP
50#define OPENSWMM_ENGINE_2D_EXCHANGE_LAW_HPP
54#if defined(KOKKOS_INLINE_FUNCTION)
55#define OPENSWMM_EXCHANGE_HD KOKKOS_INLINE_FUNCTION
57#define OPENSWMM_EXCHANGE_HD inline
94 const double inv_sqrt_e = 1.0 / std::sqrt(eps);
95 return (1.5 * inv_sqrt_e) * x - (0.5 * inv_sqrt_e / eps) * x * x;
110 return 1.5 / std::sqrt(eps);
112 return 0.5 / std::sqrt(x);
113 const double inv_sqrt_e = 1.0 / std::sqrt(eps);
114 return 1.5 * inv_sqrt_e - (inv_sqrt_e / eps) * x;
125 t = t < 0.0 ? 0.0 : (t > 1.0 ? 1.0 : t);
126 return t * t * (3.0 - 2.0 * t);
144 if (!(a > 0.0) || !(b > 0.0))
146 const bool a_min = a <= b;
147 const double lo = a_min ? a : b;
148 const double r = lo / (a_min ? b : a);
153 const double root = std::sqrt(std::sqrt(std::sqrt(std::sqrt(1.0 + r16))));
154 const double s = 1.0 / root;
155 const double q = lo * s;
162 const double rs = r * s;
163 double rs17 = rs * rs;
201 const double s2g = std::sqrt(2.0 *
kGravity);
203 const double eps = c.
h_eps;
206 const double hs = h2 - z;
209 const double dh = h2 - h1;
212 const double weir_free = (2.0 / 3.0) * c.
c_w * geo.
l_weir * s2g * hs *
phi(hs, eps);
213 const double weir_sub = c.
c_sw * geo.
l_weir * s2g * hs *
phi(dh, eps);
214 const double orif_free = c.
c_oi * geo.
a_orif * s2g *
phi(hs, eps);
215 const double orif_sub = c.
c_oi * geo.
a_orif * s2g *
phi(dh, eps);
216 const double qw = (1.0 - S) * weir_free + S * weir_sub;
217 const double qo = (1.0 - S) * orif_free + S * orif_sub;
219 double ww = 0.0, wo = 0.0;
222 const double dqw = S * c.
c_sw * geo.
l_weir * s2g * hs *
dphi(dh, eps);
224 r.
g = ww * dqw + wo * dqo;
227 if (h1 > h2 && h1 > z) {
228 const double head_dry = h1 - z;
231 r.
q = -k * ((1.0 - S) *
phi(head_dry, eps) + S *
phi(h1 - h2, eps));
232 r.
g = k * ((1.0 - S) *
dphi(head_dry, eps) + S *
dphi(h1 - h2, eps));
240#undef OPENSWMM_EXCHANGE_HD
#define OPENSWMM_EXCHANGE_HD
Definition ExchangeLaw.hpp:57
Definition ExchangeLaw.hpp:60
OPENSWMM_EXCHANGE_HD Result exchange(const Geometry &geo, const Coefficients &c, double h2, double h1)
Evaluate the bidirectional regularized weir/orifice exchange and damping.
Definition ExchangeLaw.hpp:198
constexpr double kGravity
m/s²
Definition ExchangeLaw.hpp:62
OPENSWMM_EXCHANGE_HD double smoothstep(double t)
Hermite smoothstep of t clamped to [0, 1].
Definition ExchangeLaw.hpp:124
OPENSWMM_EXCHANGE_HD double phi(double x, double eps)
C¹-regularised √x: √x for x ≥ ε, (3/(2√ε))x − x²/(2ε^{3/2}) below.
Definition ExchangeLaw.hpp:89
OPENSWMM_EXCHANGE_HD double softmin(double a, double b, double &wa, double &wb)
p-norm minimum, p = 16: (a^−16 + b^−16)^(−1/16) for a, b > 0, else 0. Evaluated as min / (1 + r^16)^(...
Definition ExchangeLaw.hpp:142
constexpr double kSigmaBand
submergence blend width
Definition ExchangeLaw.hpp:63
OPENSWMM_EXCHANGE_HD double dphi(double x, double eps)
dφ/dx (finite at 0).
Definition ExchangeLaw.hpp:108
Discharge coefficients and the φ regularisation head.
Definition ExchangeLaw.hpp:73
double h_eps
φ regularisation head (m)
Definition ExchangeLaw.hpp:78
double c_sw
submerged weir
Definition ExchangeLaw.hpp:75
double c_oo
orifice, sewer → surface
Definition ExchangeLaw.hpp:77
double c_oi
orifice, surface → sewer
Definition ExchangeLaw.hpp:76
double c_w
free weir
Definition ExchangeLaw.hpp:74
A coupling point's structure, SI.
Definition ExchangeLaw.hpp:66
double a_orif
orifice / open area (m²)
Definition ExchangeLaw.hpp:69
double l_weir
weir crest length (m)
Definition ExchangeLaw.hpp:68
double z_crest
crest / rim elevation (m, 2D frame)
Definition ExchangeLaw.hpp:67
Definition ExchangeLaw.hpp:181
double q
Definition ExchangeLaw.hpp:182
double g
Definition ExchangeLaw.hpp:183