dirty work on BHS

This commit is contained in:
Theophile Terraz committed 2023-12-11 15:44:31 +01:00
commit f302e18d71
35 files changed
+682 -120

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ from Model.Tools.PamhyrDB import SQLSubModel
logger = logging.getLogger()
class Friction(SQLSubModel):
def __init__(self, name: str = "", status=None):
super(Friction, self).__init__()
+41 -26
View File
@@ -437,42 +437,57 @@ class ProfileXYZ(Profile, SQLSubModel):
return abs(rg.dist(rd))
def get_water_limits(self, z):
#==============================================================================
# détermination des points limites RG et RD pour un niveau d'eau donné
#
# irg et ird sont les premiers indices en partant des rives gauche et
# droite qui correspondent à des points sous la surface de l'eau
# ptX et ptY sont les points interpolés où le plan d'eau intersecte le profil
# known_level est le niveau d'eau pour lequel on a obtenu irg, ird, ptX et ptY
#==============================================================================
# ====================================================================
# détermination des points limites RG et RD pour un niveau
# d'eau donné
#
# irg et ird sont les premiers indices en partant des rives
# gauche et droite qui correspondent à des points sous la
# surface de l'eau ptX et ptY sont les points interpolés où
# le plan d'eau intersecte le profil known_level est le
# niveau d'eau pour lequel on a obtenu irg, ird, ptX et ptY
# ====================================================================
# initialisation
irg = -1 ; ird = -1
irg = -1
ird = -1
for i in range(self.number_points):
if self.point(i).z <= z:
irg = i
for i in reversed(range(self.number_points)):
if self.point(i).z <= z:
ird = i
# interpolation des points ptX et ptY
if (irg < self.number_points-1):
x=np.interp(z,
[self.point(irg).z,self.point(irg+1).z],
[self.point(irg).x,self.point(irg+1).x])
y=np.interp(z,
[self.point(irg).z,self.point(irg+1).z],
[self.point(irg).y,self.point(irg+1).y])
ptX=PointXYZ(x,y,z)
if (irg < self.number_points - 1):
x = np.interp(
z,
[self.point(irg).z, self.point(irg + 1).z],
[self.point(irg).x, self.point(irg + 1).x]
)
y = np.interp(
z,
[self.point(irg).z, self.point(irg + 1).z],
[self.point(irg).y, self.point(irg + 1).y]
)
ptX = PointXYZ(x, y, z)
else:
ptX = self.point(0)
if (ird > 0):
x=np.interp(z,
[self.point(ird-1).z,self.point(ird).z],
[self.point(ird-1).x,self.point(ird).x])
y=np.interp(z,
[self.point(ird).z,self.point(ird-1).z],
[self.point(ird).y,self.point(ird-1).y])
ptY=PointXYZ(x,y,z)
x = np.interp(
z,
[self.point(ird-1).z, self.point(ird).z],
[self.point(ird-1).x, self.point(ird).x]
)
y = np.interp(
z,
[self.point(ird).z, self.point(ird - 1).z],
[self.point(ird).y, self.point(ird - 1).y]
)
ptY = PointXYZ(x, y, z)
else:
ptY = self.point(self.number_points-1)
ptY = self.point(self.number_points - 1)
return ptX,ptY
return ptX, ptY
@@ -29,6 +29,7 @@ from Model.HydraulicStructures.Basic.Value import (
logger = logging.getLogger()
class BasicHS(SQLSubModel):
_sub_classes = [
BHSValue,
@@ -142,7 +143,7 @@ class BasicHS(SQLSubModel):
data['bhs_id'] = self.id
execute(
"DELETE FROM hydraulic_structures_basic_value "+
"DELETE FROM hydraulic_structures_basic_value " +
f"WHERE bhs = {bhs_id}"
)
+8 -4
View File
@@ -16,18 +16,22 @@
# -*- coding: utf-8 -*-
from Model.Except import NotImplementedMethodeError
from Model.HydraulicStructures.Basic.HydraulicStructures import (
BasicHS
)
from Model.HydraulicStructures.Basic.Value import (
BHSValue
)
class NotDefined(BasicHS):
def __init__(self, id: int = -1, name: str = "", status=None):
super(NotDefined, self).__init__(id=id, name=name, status=status)
def __init__(self, id: int = -1, name: str = "",
status=None):
super(NotDefined, self).__init__(
id=id, name=name,
status=status
)
self._type = "ND"
self._data = [
+3 -2
View File
@@ -18,11 +18,12 @@
from Model.Tools.PamhyrDB import SQLSubModel
class BHSValue(SQLSubModel):
_sub_classes = []
_id_cnt = 0
def __init__(self, name: str = "", type = float, value = 0.0,
def __init__(self, name: str = "", type=float, value=0.0,
status=None):
super(BHSValue, self).__init__()
@@ -117,7 +118,7 @@ class BHSValue(SQLSubModel):
"hydraulic_structures_basic_value(name, type, value, bhs) " +
"VALUES (" +
f"'{self._db_format(self._name)}', " +
f"'{self._db_format(self._type_to_str(self._type))}', "+
f"'{self._db_format(self._type_to_str(self._type))}', " +
f"'{self._db_format(self._value)}', " +
f"{bhs_id}" +
")"
@@ -30,6 +30,7 @@ from Model.HydraulicStructures.Basic.Types import (
logger = logging.getLogger()
class HydraulicStructure(SQLSubModel):
_sub_classes = [
BasicHS,
@@ -55,7 +56,10 @@ class HydraulicStructure(SQLSubModel):
self._enabled = True
self._data = []
HydraulicStructure._id_cnt = max(HydraulicStructure._id_cnt + 1, self.id)
HydraulicStructure._id_cnt = max(
HydraulicStructure._id_cnt + 1,
self.id
)
@classmethod
def _db_create(cls, execute):
@@ -22,6 +22,7 @@ from tools import trace, timer
from Model.Tools.PamhyrList import PamhyrModelList
from Model.HydraulicStructures.HydraulicStructures import HydraulicStructure
class HydraulicStructureList(PamhyrModelList):
_sub_classes = [
HydraulicStructure,
@@ -376,7 +376,7 @@ class InitialConditions(SQLSubModel):
* (abs(incline) ** (0.5)))
)
elevation= max(
elevation = max(
profile.z_min() + height,
previous_elevation
)
@@ -422,7 +422,7 @@ class InitialConditions(SQLSubModel):
((width * 0.8) * strickler * (abs(incline) ** (0.5)))
) ** (0.6)
elevation= max(
elevation = max(
profile.z_min() + height,
previous_elevation
)
+1 -1
View File
@@ -213,7 +213,7 @@ class Graph(object):
def is_enable_edge(self, edge):
return edge._enable
#def get_edge_id(self, reach):
# def get_edge_id(self, reach):
# for i, e in enumerate(self.enable_edges):
# if e.id == reach.id:
# return i
+5 -1
View File
@@ -94,7 +94,11 @@ class Reservoir(SQLSubModel):
new_reservoir._node = None
if node_id != -1:
new_reservoir._node = next(filter(lambda n: n.id == node_id, data["nodes"]))
new_reservoir._node = next(
filter(
lambda n: n.id == node_id, data["nodes"]
)
)
new_data = []
table = execute(
+3 -1
View File
@@ -242,7 +242,9 @@ class River(Graph, SQLSubModel):
self._parameters = {}
self._sediment_layers = SedimentLayerList(status=self._status)
self._reservoir = ReservoirList(status=self._status)
self._hydraulic_structures = HydraulicStructureList(status=self._status)
self._hydraulic_structures = HydraulicStructureList(
status=self._status
)
@classmethod
def _db_create(cls, execute):
+1 -1
View File
@@ -67,7 +67,7 @@ class PamhyrModelDict(SQLSubModel):
if key in self._dict:
v = self._dict[key]
if type(v) == types.GeneratorType:
if type(v) is types.GeneratorType:
return list(v)
return v