HS: Basic: Add CheckValve hydraulic structure and VAR export.

This commit is contained in:
Pierre-Antoine Rouby committed 2024-01-23 16:56:24 +01:00
1 parent 793289dd80
commit 7fd6e4469b
2 files changed
+52 -8

No files matched your search

+44 -2
View File
@@ -458,6 +458,7 @@ class Mage(CommandLineSolver):
"ND": "*",
"S1": "D", "S2": "T", "S3": "T",
"OR": "O", "OC": "B", "OV": "F",
"CV": "O", # CheckValve
"V1": "V", "V2": "W",
"BO": "A",
"UD": "X",
@@ -496,10 +497,14 @@ class Mage(CommandLineSolver):
]
)
name = bhs.name
if name == "":
name = f"HS_{bhs.id:>3}".replace(" ", "0")
f.write(
f"{sin_dict[bhs._type]} " +
f"{reach_id} {hs.input_kp:>12.3f} {param_str} " +
f"{bhs.name}\n"
f"{name}\n"
)
return files
@@ -517,7 +522,7 @@ class Mage(CommandLineSolver):
return res
def _export_SIN_parameters_5(self, bhs):
# S2, OR, V1, V2, UD
# S2, OR, V1, V2, UD, CV
return [
bhs._data[0].value,
bhs._data[1].value,
@@ -562,6 +567,42 @@ class Mage(CommandLineSolver):
return res
@timer
def _export_VAR(self, study, repertory, qlog, name="0"):
files = []
hydraulic_structures = study.river.hydraulic_structures.lst
if len(hydraulic_structures) == 0:
return files
if qlog is not None:
qlog.put("Export VAR file")
with mage_file_open(os.path.join(repertory, f"{name}.VAR"), "w+") as f:
files.append(f"{name}.VAR")
for hs in hydraulic_structures:
if hs.input_reach is None:
continue
if not hs.input_reach.is_enable():
continue
for bhs in hs.basic_structures:
logger.info(bhs._type)
if bhs._type != "CV" :
continue
name = bhs.name
if name == "":
name = f"HS_{bhs.id:>3}".replace(" ", "0")
f.write(
f"${name} clapet"
)
return files
@timer
def _export_DEV(self, study, repertory, qlog, name="0"):
files = []
@@ -835,6 +876,7 @@ class Mage8(Mage):
files = files + self._export_RUG(study, repertory, qlog, name=name)
files = files + self._export_INI(study, repertory, qlog, name=name)
files = files + self._export_SIN(study, repertory, qlog, name=name)
files = files + self._export_VAR(study, repertory, qlog, name=name)
files = files + self._export_CAS(study, repertory, qlog, name=name)
files = files + self._export_DEV(study, repertory, qlog, name=name)
self._export_REP(study, repertory, files, qlog, name=name)