diff --git a/src/Model/HydraulicStructures/Basic/Types.py b/src/Model/HydraulicStructures/Basic/Types.py index 638250557d39bea34cb0b768d90c642002a78adc..ba8093bdcc93b1c43666aa3f16894bb6897113d5 100644 --- a/src/Model/HydraulicStructures/Basic/Types.py +++ b/src/Model/HydraulicStructures/Basic/Types.py @@ -34,11 +34,7 @@ class NotDefined(BasicHS): ) self._type = "ND" - self._data = [ - BHSValue("foo", float, 0.0, status=status), - BHSValue("bar", float, 42.0, status=status), - BHSValue("baz", int, 13, status=status), - ] + self._data = [] class SeuilDeversoir(BasicHS): @@ -51,8 +47,8 @@ class SeuilDeversoir(BasicHS): self._type = "S1" self._data = [ - BHSValue("Cote", 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), ] @@ -67,11 +63,11 @@ class SeuilTrapezoidal(BasicHS): self._type = "S2" self._data = [ - BHSValue("Cote", 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("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._data = [ 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("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._data = [ - BHSValue("Cote", float, 0.0, status=status), BHSValue("Largeur", float, 0.0, status=status), - BHSValue("Cote de mise en charge", float, 9999.0, - status=status), - BHSValue("Cote de mise en charge maximale", float, 9999.0, + BHSValue("Cote", float, 0.0, status=status), + BHSValue("Cote de mise en charge", float, 9999.999, 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._data = [ - BHSValue("Cote", 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), ] -class OrificeVoute(BasicHS): - def __init__(self, id: int = -1, name: str = "", - status=None): - super(OrificeVoute, self).__init__( - id=id, name=name, - status=status - ) +#class OrificeVoute(BasicHS): + #def __init__(self, id: int = -1, name: str = "", + #status=None): + #super(OrificeVoute, self).__init__( + #id=id, name=name, + #status=status + #) - self._type = "OV" - self._data = [ - BHSValue("Cote", float, 1.0, status=status), - BHSValue("Largeur", float, 1.0, status=status), - BHSValue("Haut 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), - ] + #self._type = "OV" + #self._data = [ + #BHSValue("Cote", float, 1.0, status=status), + #BHSValue("Largeur", float, 1.0, status=status), + #BHSValue("Haut 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), + #] class VanneRectangulaire(BasicHS): @@ -157,10 +153,11 @@ class VanneRectangulaire(BasicHS): self._type = "V1" self._data = [ - BHSValue("Cote", float, 1.0, status=status), - BHSValue("Ouverture", float, 1.0, status=status), BHSValue("Largeur", float, 1.0, status=status), - BHSValue("Coefficient de debit", float, 0.4, status=status), + BHSValue("Cote", float, 0.0, status=status), + BHSValue("Coefficient de debit", float, 0.4, + BHSValue("Ouverture", float, 1.0, status=status), status=status), + BHSValue("Ouverture maximale", float, 1.0, status=status), ] @@ -172,12 +169,13 @@ class VanneRectangulaireSimplifiee(BasicHS): status=status ) - self._type = "V1" + self._type = "V2" self._data = [ - BHSValue("Cote", float, 1.0, status=status), - BHSValue("Ouverture", float, 1.0, status=status), BHSValue("Largeur", float, 1.0, status=status), - BHSValue("Coefficient de debit", float, 0.4, status=status), + BHSValue("Cote", float, 0.0, status=status), + BHSValue("Coefficient de debit", float, 0.4, + BHSValue("Ouverture", float, 1.0, status=status), status=status), + BHSValue("Ouverture maximale", float, 1.0, status=status), ] @@ -224,7 +222,7 @@ BHS_types = { "S3": SeuilTriangulaire, "OR": OrificeRectangulaire, "OC": OrificeCirculaire, - "OV": OrificeVoute, + #"OV": OrificeVoute, "V1": VanneRectangulaire, "V2": VanneRectangulaireSimplifiee, "BO": Borda, diff --git a/src/Solver/Mage.py b/src/Solver/Mage.py index ea02fd377d0cad6fd40dd2e8473dd4b68377b14b..455b59781f58b603daa9cee6acdd82213f73a4e4 100644 --- a/src/Solver/Mage.py +++ b/src/Solver/Mage.py @@ -31,6 +31,77 @@ from Model.Results.River.River import River, Reach, Profile 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): f = open(filepath, mode) @@ -445,7 +516,7 @@ class Mage(CommandLineSolver): "S1":"D", "S2":"T", "S3":"T", - "OR":"D", + "OR":"O", "OC":"B", "OV":"F", "V1":"V", @@ -473,18 +544,41 @@ class Mage(CommandLineSolver): param_str = ' '.join( [ - f'{p.value:>10.3f}' - for p in bhs._data + f'{p:>10.3f}' + for p in mage_param(bhs) ] ) f.write( - f"{sin_dict[bhs.type]} " + + f"{sin_dict[bhs._type]} " + f"{reach_id} {hs.input_kp:>12.3f} {param_str} " + f"{bhs.name}\n" ) 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 def _export_REP(self, study, repertory, files, qlog, name="0"): if qlog is not None: @@ -732,6 +826,7 @@ class Mage8(Mage): files = files + self._export_INI(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_DEV(study, repertory, qlog, name=name) self._export_REP(study, repertory, files, qlog, name=name) return True