mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
RubarBE: refuse upstream water level settings (REGIME=1, CONDAM=2)
This commit is contained in:
1 parent
ec81a998cb
commit
ace85ccb40
2 files changed
+25
-28
No files matched your search
+21
-25
@@ -220,7 +220,7 @@ class Rubar3(CommandLineSolver):
|
|||||||
|
|
||||||
def _hydraulic_data(self, study, values):
|
def _hydraulic_data(self, study, values):
|
||||||
"""Check the single reach data needed by DONNEE, MAIL, CONDIN,
|
"""Check the single reach data needed by DONNEE, MAIL, CONDIN,
|
||||||
FROT, HYDRO, HAMONT and CONDAV, and return them. Raise
|
FROT, HYDRO and CONDAV, and return them. Raise
|
||||||
RubarExportError with a user message"""
|
RubarExportError with a user message"""
|
||||||
trad = RunSolverTranslate()
|
trad = RunSolverTranslate()
|
||||||
river = study.river
|
river = study.river
|
||||||
@@ -240,9 +240,7 @@ class Rubar3(CommandLineSolver):
|
|||||||
reach=edge.name))
|
reach=edge.name))
|
||||||
|
|
||||||
warnings = []
|
warnings = []
|
||||||
boundaries = self._check_boundaries(
|
boundaries = self._check_boundaries(river, edge, values)
|
||||||
river, edge, values, warnings
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"edge": edge,
|
"edge": edge,
|
||||||
@@ -260,9 +258,9 @@ class Rubar3(CommandLineSolver):
|
|||||||
return float(old_pamhyr_date_to_timestamp(value))
|
return float(old_pamhyr_date_to_timestamp(value))
|
||||||
return float(value)
|
return float(value)
|
||||||
|
|
||||||
def _check_boundaries(self, river, edge, values, warnings):
|
def _check_boundaries(self, river, edge, values):
|
||||||
"""Liquid boundary conditions used for CONDAM, REGIME and CONDAV.
|
"""Liquid boundary conditions used for CONDAM, REGIME and CONDAV.
|
||||||
Return {'hydro': bc, 'hamont': bc, 'condav': bc} (or None)"""
|
Return {'hydro': bc, 'condav': bc} (or None)"""
|
||||||
trad = RunSolverTranslate()
|
trad = RunSolverTranslate()
|
||||||
condam = values.get("rubarbe_condam", "")
|
condam = values.get("rubarbe_condam", "")
|
||||||
condav = values.get("rubarbe_condav", "")
|
condav = values.get("rubarbe_condav", "")
|
||||||
@@ -275,6 +273,17 @@ class Rubar3(CommandLineSolver):
|
|||||||
raise RubarExportError(trad["boundary_code_unsupported"].format(
|
raise RubarExportError(trad["boundary_code_unsupported"].format(
|
||||||
key="rubarbe_condav", value=condav))
|
key="rubarbe_condav", value=condav))
|
||||||
|
|
||||||
|
# rubar_init.f90 reads HAMONT only when REGIME=1 and the
|
||||||
|
# computation never uses its values (HIMP, TA, NT3); CONDAM=2 reads
|
||||||
|
# no upstream level at all. The upstream level would be silently
|
||||||
|
# ignored: refuse both settings.
|
||||||
|
for key, value, unsupported in (("REGIME", regime, "1"),
|
||||||
|
("CONDAM", condam, "2")):
|
||||||
|
if value == unsupported:
|
||||||
|
raise RubarExportError(
|
||||||
|
trad["upstream_level_unsupported"].format(
|
||||||
|
setting=f"{key}={value}"))
|
||||||
|
|
||||||
liquid = [
|
liquid = [
|
||||||
bc for bc in river.boundary_condition.get_tab("liquid")
|
bc for bc in river.boundary_condition.get_tab("liquid")
|
||||||
if not bc.is_deleted() and bc.bctype in self._boundary_kinds
|
if not bc.is_deleted() and bc.bctype in self._boundary_kinds
|
||||||
@@ -283,13 +292,9 @@ class Rubar3(CommandLineSolver):
|
|||||||
def at(node):
|
def at(node):
|
||||||
return [bc for bc in liquid if bc.node == node]
|
return [bc for bc in liquid if bc.node == node]
|
||||||
|
|
||||||
upstream_types = list(self._upstream_types[condam])
|
|
||||||
if regime == "1":
|
|
||||||
upstream_types.append("TZ")
|
|
||||||
upstream = self._select_boundaries(
|
upstream = self._select_boundaries(
|
||||||
at(edge.node1), upstream_types, edge.node1,
|
at(edge.node1), self._upstream_types[condam], edge.node1,
|
||||||
{"TD": f"CONDAM={condam}", "TZ": "REGIME=1"},
|
{"TD": f"CONDAM={condam}"}, f"CONDAM={condam}"
|
||||||
f"CONDAM={condam}, REGIME={regime}"
|
|
||||||
)
|
)
|
||||||
downstream = self._select_boundaries(
|
downstream = self._select_boundaries(
|
||||||
at(edge.node2), self._downstream_types[condav], edge.node2,
|
at(edge.node2), self._downstream_types[condav], edge.node2,
|
||||||
@@ -297,14 +302,8 @@ class Rubar3(CommandLineSolver):
|
|||||||
f"CONDAV={condav}"
|
f"CONDAV={condav}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# rubar_init.f90: HAMONT is read when REGIME=1, but the 2021
|
|
||||||
# code never uses it; CONDAM=2 reads no upstream level at all
|
|
||||||
if regime == "1" or condam == "2":
|
|
||||||
warnings.append(trad["upstream_level_unused"])
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"hydro": upstream.get("TD"),
|
"hydro": upstream.get("TD"),
|
||||||
"hamont": upstream.get("TZ"),
|
|
||||||
"condav": downstream.get("ZD", downstream.get("TZ")),
|
"condav": downstream.get("ZD", downstream.get("TZ")),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,9 +817,10 @@ class Rubar3(CommandLineSolver):
|
|||||||
self._write_parameters(repertory, f"condin.{name}", lines)
|
self._write_parameters(repertory, f"condin.{name}", lines)
|
||||||
|
|
||||||
def _export_boundaries(self, hydraulics, repertory, qlog, name="0"):
|
def _export_boundaries(self, hydraulics, repertory, qlog, name="0"):
|
||||||
"""HYDRO (Q, t), HAMONT (Z, t) and CONDAV ((Q, Z) for a rating
|
"""HYDRO (Q, t) and CONDAV ((Q, Z) for a rating curve, (t, Z) for
|
||||||
curve, (t, Z) for a Z(t) condition), notice annex 1. A file is
|
a Z(t) condition), notice annex 1. A file is written only when the
|
||||||
written only when the matching condition is used"""
|
matching condition is used. HAMONT is not written: REGIME=1 and
|
||||||
|
CONDAM=2 are refused (see _check_boundaries)"""
|
||||||
bcs = hydraulics["boundaries"]
|
bcs = hydraulics["boundaries"]
|
||||||
|
|
||||||
def records(bc, columns):
|
def records(bc, columns):
|
||||||
@@ -831,10 +831,6 @@ class Rubar3(CommandLineSolver):
|
|||||||
files.append(("hydro", bcs["hydro"],
|
files.append(("hydro", bcs["hydro"],
|
||||||
lambda t, q: f"{float(q)!r} {float(t)!r}\n",
|
lambda t, q: f"{float(q)!r} {float(t)!r}\n",
|
||||||
lambda n: f"{n}\n"))
|
lambda n: f"{n}\n"))
|
||||||
if bcs["hamont"] is not None:
|
|
||||||
files.append(("hamont", bcs["hamont"],
|
|
||||||
lambda t, z: f"{float(z):15.6f} {float(t):15.6f}\n",
|
|
||||||
lambda n: f"{n:>6}\n"))
|
|
||||||
if bcs["condav"] is not None:
|
if bcs["condav"] is not None:
|
||||||
bc = bcs["condav"]
|
bc = bcs["condav"]
|
||||||
if bc.bctype == "ZD":
|
if bc.bctype == "ZD":
|
||||||
|
|||||||
@@ -101,10 +101,11 @@ class RunSolverTranslate(PamhyrTranslate):
|
|||||||
"Export cancelled: the times of boundary condition {name} at "
|
"Export cancelled: the times of boundary condition {name} at "
|
||||||
"node {node} must be increasing."
|
"node {node} must be increasing."
|
||||||
)
|
)
|
||||||
self._dict["upstream_level_unused"] = _translate(
|
self._dict["upstream_level_unsupported"] = _translate(
|
||||||
"Solver",
|
"Solver",
|
||||||
"The upstream water level (REGIME=1 or CONDAM=2) is not used "
|
"Export cancelled: {setting} imposes an upstream water level, "
|
||||||
"by the current RubarBE version: the computation ignores it."
|
"which the current RubarBE version reads but does not use in "
|
||||||
|
"the computation. Choose another upstream boundary setting."
|
||||||
)
|
)
|
||||||
self._dict["missing_friction"] = _translate(
|
self._dict["missing_friction"] = _translate(
|
||||||
"Solver",
|
"Solver",
|
||||||
|
|||||||
Reference in new issue
Block a user