RubarBE: export an empty upstream solid boundary condition as a supply at equilibrium (negative Qs in hydros), like Mage 'default'

This commit is contained in:
Dylan Jeannin committed 2026-10-20 15:14:15 +02:00
1 parent b1cf45497b
commit a2f215984b
2 files changed
+22 -12

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ __old__
mage8/
adists/
rubarbe/
rubar/
linux/
windows/
+21 -12
View File
@@ -194,7 +194,8 @@ class Rubar3(CommandLineSolver):
self._export_stricklers(hydraulics, repertory, qlog, name=name)
self._export_boundaries(hydraulics, repertory, qlog, name=name)
if solid is not None:
self._export_hydros(solid, repertory, qlog, name=name)
self._export_hydros(solid, hydraulics["tinit"], repertory, qlog,
name=name)
if trased:
self._export_condins(geometry, hydraulics["tinit"], repertory,
qlog, name=name)
@@ -432,13 +433,14 @@ class Rubar3(CommandLineSolver):
}
@staticmethod
def _ignore_empty(bcs, node, warnings):
def _ignore_empty(bcs, node, warnings, meaningful=()):
"""A boundary condition without value carries no data: it is
ignored with a warning. Return (kept, ignored)"""
ignored with a warning, except for the types where an empty
condition has a meaning. Return (kept, ignored)"""
trad = RunSolverTranslate()
kept, ignored = [], []
for bc in bcs:
if len(bc) == 0:
if len(bc) == 0 and bc.bctype not in meaningful:
warnings.append(trad["boundary_empty_ignored"].format(
name=bc.name, node=node.name))
ignored.append(bc)
@@ -447,10 +449,10 @@ class Rubar3(CommandLineSolver):
return kept, ignored
def _select_boundaries(self, bcs, expected, node, required_by, setting,
warnings):
warnings, meaningful=()):
trad = RunSolverTranslate()
selected = {}
bcs, ignored = self._ignore_empty(bcs, node, warnings)
bcs, ignored = self._ignore_empty(bcs, node, warnings, meaningful)
for bc in bcs:
kind = self._boundary_kinds[bc.bctype]
@@ -487,7 +489,9 @@ class Rubar3(CommandLineSolver):
at the upstream node when TRASED is enabled and CONDAM=1 (CONDAM=2
is refused), and has no downstream solid condition (rubar_init.f90,
inits). Without sediment transport the solid conditions are
ignored. Return the condition or None"""
ignored. At the upstream node, an empty solid condition means a
supply at equilibrium in Pamhyr2 (Mage 'default'), written as a
negative Qs (_export_hydros). Return the condition or None"""
if not trased:
return None
trad = RunSolverTranslate()
@@ -509,7 +513,7 @@ class Rubar3(CommandLineSolver):
selected = self._select_boundaries(
[bc for bc in solid if bc.node == edge.node1], expected,
edge.node1, {"SL": f"TRASED=O, CONDAM={condam}"},
f"CONDAM={condam}", warnings
f"CONDAM={condam}", warnings, meaningful=("SL",)
)
bc = selected.get("SL")
if bc is None:
@@ -1083,16 +1087,21 @@ class Rubar3(CommandLineSolver):
lines = [header(len(bc))] + records(bc, columns)
self._write_parameters(repertory, f"{filename}.{name}", lines)
def _export_hydros(self, bc, repertory, qlog, name="0"):
def _export_hydros(self, bc, tinit, repertory, qlog, name="0"):
"""HYDROS: number of points, then Qs, t, D, S (notice annex 1).
Qs is a solid discharge (kg/s) or a concentration (kg/m3)
according to UNISOL, D and S are those of the condition"""
according to UNISOL, D and S are those of the condition. An
empty condition (supply at equilibrium) is written as a single
negative Qs: RubarBE then takes the transport capacity of the
upstream section at each time step (notice §3.6; rubarbe.f90,
'si Hydros.etude contient un Qs<0')"""
if qlog is not None:
qlog.put("Export HYDROS file")
d50, sigma = float(bc.d50), float(bc.sigma)
lines = [f"{len(bc)}\n"] + [
data = [(t, qs) for t, qs in bc.data] or [(tinit, -1.0)]
lines = [f"{len(data)}\n"] + [
f"{float(qs)!r} {float(t)!r} {d50!r} {sigma!r}\n"
for t, qs in bc.data
for t, qs in data
]
self._write_parameters(repertory, f"hydros.{name}", lines)