mirror of https://gitlab.com/pamhyr/pamhyr2
Sediment: Add solid BC, QSO export and profile + point sediment layers export.
parent
23fb3e6fb3
commit
768a0b9f14
|
|
@ -83,7 +83,8 @@ class BoundaryCondition(SQLSubModel):
|
|||
def _get_ctor_from_type(cls, t):
|
||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
NotDefined, PonctualContribution,
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge,
|
||||
Solid,
|
||||
)
|
||||
|
||||
res = NotDefined
|
||||
|
|
@ -95,6 +96,8 @@ class BoundaryCondition(SQLSubModel):
|
|||
res = TimeOverDischarge
|
||||
elif t == "ZD":
|
||||
res = ZOverDischarge
|
||||
elif t == "SL":
|
||||
res = Solid
|
||||
return res
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
|||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
NotDefined,
|
||||
PonctualContribution,
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge,
|
||||
Solid,
|
||||
)
|
||||
|
||||
class BoundaryConditionList(SQLSubModel):
|
||||
|
|
|
|||
|
|
@ -83,3 +83,16 @@ class ZOverDischarge(BoundaryCondition):
|
|||
@property
|
||||
def _default_0(self):
|
||||
return 0.0
|
||||
|
||||
|
||||
class Solid(BoundaryCondition):
|
||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||
super(Solid, self).__init__(id=id, name=name, status=status)
|
||||
|
||||
self._type = "SL"
|
||||
self._header = ["time", "solid"]
|
||||
self._types = [TimeOverDischarge.time_convert, float]
|
||||
|
||||
@classmethod
|
||||
def compatibility(cls):
|
||||
return ["solid"]
|
||||
|
|
|
|||
|
|
@ -213,12 +213,22 @@ class AbstractSolver(object):
|
|||
# Command line executable path is between " char
|
||||
cmd = cmd.split("\"")
|
||||
exe = cmd[1].replace("\ ", " ")
|
||||
args = "\"".join(cmd[2:]).split(" ")[1:]
|
||||
args = list(
|
||||
filter(
|
||||
lambda s: s != "",
|
||||
"\"".join(cmd[2:]).split(" ")[1:]
|
||||
)
|
||||
)
|
||||
else:
|
||||
# We suppose the command line executable path as no space char
|
||||
cmd = cmd.replace("\ ", "&_&").split(" ")
|
||||
exe = cmd[0].replace("&_&", " ")
|
||||
args = list(map(lambda s: s.replace("&_&", "\ "), cmd[1:]))
|
||||
args = list(
|
||||
filter(
|
||||
lambda s: s != "",
|
||||
map(lambda s: s.replace("&_&", "\ "), cmd[1:])
|
||||
)
|
||||
)
|
||||
|
||||
logger.info(f"! {exe} {args}")
|
||||
return exe, args
|
||||
|
|
|
|||
|
|
@ -127,23 +127,47 @@ class Mage(AbstractSolver):
|
|||
with mage_file_open(os.path.join(repertory, f"{name}.ST"), "w+") as f:
|
||||
files.append(f"{name}.ST")
|
||||
|
||||
cnt_num = 1
|
||||
for profile in edge.reach.profiles:
|
||||
num = f"{profile.num:>6}"
|
||||
num = f"{cnt_num:>6}"
|
||||
c1 = f"{profile.code1:>6}"
|
||||
c2 = f"{profile.code2:>6}"
|
||||
t = f"{len(profile.points):>6}"
|
||||
kp = f"{profile.kp:>13.4f}"
|
||||
name = profile.name
|
||||
pname = profile.name
|
||||
if profile.name == "":
|
||||
pname = f"p{profile.id:>3}".replace(" ", "p")
|
||||
name = f"{pname}"
|
||||
|
||||
f.write(f"{num}{c1}{c2}{t}{kp} {name}\n")
|
||||
sediment = ""
|
||||
if profile.sl is not None:
|
||||
if not any(filter(lambda f: ".GRA" in f, files)):
|
||||
files.append("0.GRA")
|
||||
|
||||
nl = len(profile.sl)
|
||||
sediment = f" {nl:>3}"
|
||||
for l in profile.sl.layers:
|
||||
sediment += f" {l.height:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}"
|
||||
|
||||
f.write(f"{num}{c1}{c2}{t}{kp} {name} {sediment}\n")
|
||||
cnt_num += 1
|
||||
|
||||
for point in profile.points:
|
||||
x = f"{point.x:>13.4f}"
|
||||
y = f"{point.y:>13.4f}"
|
||||
z = f"{point.z:>13.4f}"
|
||||
n = point.name
|
||||
n = f"{point.name:<3}"
|
||||
|
||||
f.write(f"{x}{y}{z} {n}\n")
|
||||
sediment = ""
|
||||
prev = point.z
|
||||
if point.sl is not None:
|
||||
nl = len(point.sl)
|
||||
sediment = f"{nl:>3}"
|
||||
for l in point.sl.layers:
|
||||
prev = round(prev - l.height, 5)
|
||||
sediment += f" {prev:>10} {l.d50:>10} {l.sigma:>10} {l.critical_constraint:>10}"
|
||||
|
||||
f.write(f"{x}{y}{z} {n} {sediment}\n")
|
||||
|
||||
f.write(f" 999.9990 999.9990 999.9990\n")
|
||||
|
||||
|
|
@ -182,6 +206,7 @@ class Mage(AbstractSolver):
|
|||
AVA = []
|
||||
HYD = []
|
||||
LIM = []
|
||||
QSO = []
|
||||
|
||||
for tab in ["liquid", "solid", "suspenssion"]:
|
||||
for bound in lst.get_tab(tab):
|
||||
|
|
@ -191,10 +216,13 @@ class Mage(AbstractSolver):
|
|||
HYD.append(bound)
|
||||
elif bound.bctype == "TZ":
|
||||
LIM.append(bound)
|
||||
elif bound.bctype == "SL":
|
||||
QSO.append(bound)
|
||||
|
||||
files = files + self._export_BC("AVA", AVA, repertory, qlog)
|
||||
files = files + self._export_BC("HYD", HYD, repertory, qlog)
|
||||
files = files + self._export_BC("LIM", LIM, repertory, qlog)
|
||||
files = files + self._export_QSO(QSO, repertory, qlog)
|
||||
|
||||
return files
|
||||
|
||||
|
|
@ -332,12 +360,20 @@ class Mage(AbstractSolver):
|
|||
for file in files:
|
||||
EXT = file.split('.')[1]
|
||||
|
||||
f.write(f"{EXT} {file}\n")
|
||||
if EXT not in ["ST", "GRA"]:
|
||||
f.write(f"{EXT} {file}\n")
|
||||
|
||||
f.write("* OUTPUT\n")
|
||||
f.write(f"TRA 0.TRA\n")
|
||||
f.write(f"BIN 0.BIN\n")
|
||||
|
||||
for file in files:
|
||||
EXT = file.split('.')[1]
|
||||
|
||||
if EXT in ["GRA"]:
|
||||
f.write(f"{EXT} {file}\n")
|
||||
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None):
|
||||
self._export_ST(study, repertory, qlog)
|
||||
|
|
@ -459,11 +495,37 @@ class Mage8(Mage):
|
|||
|
||||
return files
|
||||
|
||||
@timer
|
||||
def _export_QSO(self, bounds, repertory, qlog):
|
||||
files = []
|
||||
|
||||
if len(bounds) == 0:
|
||||
return files
|
||||
|
||||
if qlog is not None:
|
||||
qlog.put(f"Export QSO file")
|
||||
|
||||
with mage_file_open(os.path.join(repertory, f"0.QSO"), "w+") as f:
|
||||
files.append(f"0.QSO")
|
||||
|
||||
for bound in bounds:
|
||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
||||
f.write(f"${name}\n")
|
||||
header = bound.header
|
||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||
|
||||
for d in bound.data:
|
||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||
|
||||
return files
|
||||
|
||||
|
||||
@timer
|
||||
def export(self, study, repertory, qlog = None):
|
||||
files = []
|
||||
|
||||
self._export_ST(study, repertory, qlog)
|
||||
files = self._export_ST(study, repertory, qlog)
|
||||
files = files + self._export_PAR(study, repertory, qlog)
|
||||
files = files + self._export_NET(study, repertory, qlog)
|
||||
files = files + self._export_bound_cond(study, repertory, qlog)
|
||||
|
|
|
|||
|
|
@ -26,5 +26,6 @@ table_headers = {
|
|||
"time": _translate("BoundaryCondition", "Time"),
|
||||
"date": _translate("BoundaryCondition", "Date"),
|
||||
"discharge": _translate("BoundaryCondition", "Discharge (m³/s)"),
|
||||
"z": _translate("BoundaryCondition", "Z (m)")
|
||||
"z": _translate("BoundaryCondition", "Z (m)"),
|
||||
"solid": _translate("BoundaryCondition", "Solid (kg/s)"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ from PyQt5.QtCore import QCoreApplication
|
|||
|
||||
from Model.BoundaryCondition.BoundaryConditionTypes import (
|
||||
NotDefined, PonctualContribution,
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge
|
||||
TimeOverZ, TimeOverDischarge, ZOverDischarge,
|
||||
Solid
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
|
@ -31,6 +32,7 @@ long_types = {
|
|||
"TZ": _translate("BoundaryCondition", "Time over Z"),
|
||||
"TD": _translate("BoundaryCondition", "Time over Discharge"),
|
||||
"ZD": _translate("BoundaryCondition", "Z over Discharge"),
|
||||
"SL": _translate("BoundaryCondition", "Solid"),
|
||||
}
|
||||
|
||||
table_headers = {
|
||||
|
|
@ -44,5 +46,6 @@ BC_types = {
|
|||
"PC": PonctualContribution,
|
||||
"TZ": TimeOverZ,
|
||||
"TD": TimeOverDischarge,
|
||||
"ZD": ZOverDischarge
|
||||
"ZD": ZOverDischarge,
|
||||
"SL": Solid,
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue