mirror of https://gitlab.com/pamhyr/pamhyr2
Merge branch 'hydraulics-structure' of gitlab-ssh.irstea.fr:theophile.terraz/pamhyr into hydraulics-structure
commit
73ae571de1
|
|
@ -34,11 +34,7 @@ class NotDefined(BasicHS):
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "ND"
|
self._type = "ND"
|
||||||
self._data = [
|
self._data = []
|
||||||
BHSValue("foo", float, 0.0, status=status),
|
|
||||||
BHSValue("bar", float, 42.0, status=status),
|
|
||||||
BHSValue("baz", int, 13, status=status),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class SeuilDeversoir(BasicHS):
|
class SeuilDeversoir(BasicHS):
|
||||||
|
|
@ -51,8 +47,8 @@ class SeuilDeversoir(BasicHS):
|
||||||
|
|
||||||
self._type = "S1"
|
self._type = "S1"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 1.0, status=status),
|
|
||||||
BHSValue("Largeur", float, 1.0, status=status),
|
BHSValue("Largeur", float, 1.0, status=status),
|
||||||
|
BHSValue("Cote", float, 1.0, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -67,11 +63,11 @@ class SeuilTrapezoidal(BasicHS):
|
||||||
|
|
||||||
self._type = "S2"
|
self._type = "S2"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 1.0, status=status),
|
|
||||||
BHSValue("Largeur", float, 1.0, status=status),
|
BHSValue("Largeur", float, 1.0, status=status),
|
||||||
BHSValue("Tangeante du demi angle", float, 1.0, status=status),
|
BHSValue("Cote", float, 1.0, status=status),
|
||||||
|
BHSValue("Cote de mise en charge", float, 9999.999, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
BHSValue("Cote de mise en charge", float, 9999.0, status=status),
|
BHSValue("Tangeante du demi angle", float, 0.0, status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,9 +82,9 @@ class SeuilTriangulaire(BasicHS):
|
||||||
self._type = "S3"
|
self._type = "S3"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 1.0, status=status),
|
BHSValue("Cote", float, 1.0, status=status),
|
||||||
BHSValue("Tangeante du demi angle", float, 1.0, status=status),
|
BHSValue("Cote de mise en charge", float, 9999.999, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
BHSValue("Cote de mise en charge", float, 9999.0, status=status),
|
BHSValue("Tangeante du demi angle", float, 0.0, status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -102,13 +98,13 @@ class OrificeRectangulaire(BasicHS):
|
||||||
|
|
||||||
self._type = "OR"
|
self._type = "OR"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 0.0, status=status),
|
|
||||||
BHSValue("Largeur", float, 0.0, status=status),
|
BHSValue("Largeur", float, 0.0, status=status),
|
||||||
BHSValue("Cote de mise en charge", float, 9999.0,
|
BHSValue("Cote", float, 0.0, status=status),
|
||||||
status=status),
|
BHSValue("Cote de mise en charge", float, 9999.999,
|
||||||
BHSValue("Cote de mise en charge maximale", float, 9999.0,
|
|
||||||
status=status),
|
status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
|
BHSValue("Cote de mise en charge maximale", float, 9999.999,
|
||||||
|
status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,29 +118,29 @@ class OrificeCirculaire(BasicHS):
|
||||||
|
|
||||||
self._type = "OC"
|
self._type = "OC"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 0.0, status=status),
|
|
||||||
BHSValue("Diametre", float, 0.0, status=status),
|
BHSValue("Diametre", float, 0.0, status=status),
|
||||||
BHSValue("hauteur envasement", float, 9999.0, status=status),
|
BHSValue("Cote", float, 0.0, status=status),
|
||||||
|
BHSValue("hauteur envasement", float, 0.0, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class OrificeVoute(BasicHS):
|
#class OrificeVoute(BasicHS):
|
||||||
def __init__(self, id: int = -1, name: str = "",
|
#def __init__(self, id: int = -1, name: str = "",
|
||||||
status=None):
|
#status=None):
|
||||||
super(OrificeVoute, self).__init__(
|
#super(OrificeVoute, self).__init__(
|
||||||
id=id, name=name,
|
#id=id, name=name,
|
||||||
status=status
|
#status=status
|
||||||
)
|
#)
|
||||||
|
|
||||||
self._type = "OV"
|
#self._type = "OV"
|
||||||
self._data = [
|
#self._data = [
|
||||||
BHSValue("Cote", float, 1.0, status=status),
|
#BHSValue("Cote", float, 1.0, status=status),
|
||||||
BHSValue("Largeur", float, 1.0, status=status),
|
#BHSValue("Largeur", float, 1.0, status=status),
|
||||||
BHSValue("Haut de la voute", float, 0.0, status=status),
|
#BHSValue("Haut de la voute", float, 0.0, status=status),
|
||||||
BHSValue("Bas de la voute", float, 0.0, status=status),
|
#BHSValue("Bas de la voute", float, 0.0, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
#BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
]
|
#]
|
||||||
|
|
||||||
|
|
||||||
class VanneRectangulaire(BasicHS):
|
class VanneRectangulaire(BasicHS):
|
||||||
|
|
@ -157,10 +153,11 @@ class VanneRectangulaire(BasicHS):
|
||||||
|
|
||||||
self._type = "V1"
|
self._type = "V1"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 1.0, status=status),
|
|
||||||
BHSValue("Ouverture", float, 1.0, status=status),
|
|
||||||
BHSValue("Largeur", float, 1.0, status=status),
|
BHSValue("Largeur", float, 1.0, status=status),
|
||||||
|
BHSValue("Cote", float, 0.0, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
|
BHSValue("Ouverture", float, 1.0, status=status),
|
||||||
|
BHSValue("Ouverture maximale", float, 1.0, status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -172,12 +169,13 @@ class VanneRectangulaireSimplifiee(BasicHS):
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
|
|
||||||
self._type = "V1"
|
self._type = "V2"
|
||||||
self._data = [
|
self._data = [
|
||||||
BHSValue("Cote", float, 1.0, status=status),
|
|
||||||
BHSValue("Ouverture", float, 1.0, status=status),
|
|
||||||
BHSValue("Largeur", float, 1.0, status=status),
|
BHSValue("Largeur", float, 1.0, status=status),
|
||||||
|
BHSValue("Cote", float, 0.0, status=status),
|
||||||
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
BHSValue("Coefficient de debit", float, 0.4, status=status),
|
||||||
|
BHSValue("Ouverture", float, 1.0, status=status),
|
||||||
|
BHSValue("Ouverture maximale", float, 1.0, status=status),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -222,7 +220,7 @@ BHS_types = {
|
||||||
"S3": SeuilTriangulaire,
|
"S3": SeuilTriangulaire,
|
||||||
"OR": OrificeRectangulaire,
|
"OR": OrificeRectangulaire,
|
||||||
"OC": OrificeCirculaire,
|
"OC": OrificeCirculaire,
|
||||||
"OV": OrificeVoute,
|
#"OV": OrificeVoute,
|
||||||
"V1": VanneRectangulaire,
|
"V1": VanneRectangulaire,
|
||||||
"V2": VanneRectangulaireSimplifiee,
|
"V2": VanneRectangulaireSimplifiee,
|
||||||
"BO": Borda,
|
"BO": Borda,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,77 @@ from Model.Results.River.River import River, Reach, Profile
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
def mage_param(bhs):
|
||||||
|
params = []
|
||||||
|
|
||||||
|
if bhs._type == "S1": # D
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
0.0,
|
||||||
|
bhs._data[2].value,
|
||||||
|
9999.999,
|
||||||
|
]
|
||||||
|
elif bhs._type == "S2": # T
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
bhs._data[4].value,
|
||||||
|
]
|
||||||
|
elif bhs._type == "S3": # T
|
||||||
|
params = [0.0,bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
]
|
||||||
|
elif bhs._type == "OR": # O
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
bhs._data[4].value,
|
||||||
|
]
|
||||||
|
elif bhs._type == "OC": # B
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
0.0,
|
||||||
|
]
|
||||||
|
elif bhs._type == "V1": # V
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
bhs._data[4].value,
|
||||||
|
]
|
||||||
|
elif bhs._type == "V2": # W
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
bhs._data[4].value,
|
||||||
|
]
|
||||||
|
elif bhs._type == "BO": # B
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
]
|
||||||
|
elif bhs._type == "UD": # X
|
||||||
|
params = [bhs._data[0].value,
|
||||||
|
bhs._data[1].value,
|
||||||
|
bhs._data[2].value,
|
||||||
|
bhs._data[3].value,
|
||||||
|
bhs._data[4].value,
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
params = [9999.999]*5
|
||||||
|
|
||||||
|
return params
|
||||||
|
|
||||||
|
|
||||||
def mage_file_open(filepath, mode):
|
def mage_file_open(filepath, mode):
|
||||||
f = open(filepath, mode)
|
f = open(filepath, mode)
|
||||||
|
|
||||||
|
|
@ -445,7 +516,7 @@ class Mage(CommandLineSolver):
|
||||||
"S1": "D",
|
"S1": "D",
|
||||||
"S2": "T",
|
"S2": "T",
|
||||||
"S3": "T",
|
"S3": "T",
|
||||||
"OR": "D",
|
"OR": "O",
|
||||||
"OC": "B",
|
"OC": "B",
|
||||||
"OV": "F",
|
"OV": "F",
|
||||||
"V1": "V",
|
"V1": "V",
|
||||||
|
|
@ -477,19 +548,42 @@ class Mage(CommandLineSolver):
|
||||||
reach_id = study.river.get_edge_id(hs.input_reach) + 1
|
reach_id = study.river.get_edge_id(hs.input_reach) + 1
|
||||||
param_str = ' '.join(
|
param_str = ' '.join(
|
||||||
[
|
[
|
||||||
f'{p.value:>10.3f}'
|
f'{p:>10.3f}'
|
||||||
for p in bhs._data
|
for p in mage_param(bhs)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
f.write(
|
f.write(
|
||||||
f"{sin_dict[bhs.type]} " +
|
f"{sin_dict[bhs._type]} " +
|
||||||
f"{reach_id} {hs.input_kp:>12.3f} {param_str} " +
|
f"{reach_id} {hs.input_kp:>12.3f} {param_str} " +
|
||||||
f"{bhs.name}\n"
|
f"{bhs.name}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def _export_DEV(self, study, repertory, qlog, name="0"):
|
||||||
|
files = []
|
||||||
|
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export DEV file")
|
||||||
|
|
||||||
|
with mage_file_open(
|
||||||
|
os.path.join(
|
||||||
|
repertory, f"{name}.DEV"
|
||||||
|
), "w+"
|
||||||
|
) as f:
|
||||||
|
reachs = study.river.enable_edges()
|
||||||
|
|
||||||
|
id = 1
|
||||||
|
for reach in reachs:
|
||||||
|
f.write(f"YD{id:3}\n")
|
||||||
|
f.write(f"YG{id:3}\n")
|
||||||
|
id += 1
|
||||||
|
files.append(f"{name}.DEV")
|
||||||
|
|
||||||
|
return files
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def _export_REP(self, study, repertory, files, qlog, name="0"):
|
def _export_REP(self, study, repertory, files, qlog, name="0"):
|
||||||
if qlog is not None:
|
if qlog is not None:
|
||||||
|
|
@ -737,6 +831,7 @@ class Mage8(Mage):
|
||||||
files = files + self._export_INI(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_SIN(study, repertory, qlog, name=name)
|
||||||
files = files + self._export_CAS(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)
|
self._export_REP(study, repertory, files, qlog, name=name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue