IC: Fix `generate_growing_constante_height` method.

InitialConditions
Pierre-Antoine Rouby 2024-07-05 11:30:07 +02:00
parent 453a2084e7
commit 366baa737a
1 changed files with 35 additions and 36 deletions

View File

@ -367,53 +367,52 @@ class InitialConditions(SQLSubModel):
key=lambda p: p.kp key=lambda p: p.kp
) )
def generate_growing_constante_height(self, height: float, compute_discharge: bool): def generate_growing_constante_height(self, height: float,
compute_discharge: bool):
profiles = self._reach.reach.profiles.copy() profiles = self._reach.reach.profiles.copy()
self._sort_by_z_and_kp(profiles) self._sort_by_z_and_kp(profiles)
previous_elevation = -99999.99 previous_elevation = -99999.99
if compute_discharge: data_discharge = {}
incline = self._reach.reach.get_incline_median_mean() if not compute_discharge:
logger.debug(f"incline = {incline}") for data in self._data:
self._data = [] data_discharge[data["kp"]] = data["discharge"]
for profile in profiles:
width = profile.width_approximation() incline = self._reach.reach.get_incline_median_mean()
strickler = 25 logger.debug(f"incline = {incline}")
self._data = []
for profile in profiles:
width = profile.width_approximation()
strickler = 25
if not compute_discharge:
discharge = data_discharge[profile.kp]
else:
discharge = ( discharge = (
((width * 0.8) ((width * 0.8)
* strickler * strickler
* (height ** (5/3)) * (height ** (5/3))
* (abs(incline) ** (0.5))) * (abs(incline) ** (0.5)))
) )
elevation = max( elevation = max(
profile.z_min() + height, profile.z_min() + height,
previous_elevation previous_elevation
) )
logger.debug(f"({profile.kp}):") logger.debug(f"({profile.kp}):")
logger.debug(f" width = {width}") logger.debug(f" width = {width}")
logger.debug(f" strickler = {strickler}") logger.debug(f" strickler = {strickler}")
logger.debug(f" discharge = {discharge}") logger.debug(f" discharge = {discharge}")
new = Data(reach=self._reach, status=self._status) new = Data(reach=self._reach, status=self._status)
new["kp"] = profile.kp new["kp"] = profile.kp
new["discharge"] = discharge new["discharge"] = discharge
new["elevation"] = elevation new["elevation"] = elevation
self._data.append(new) self._data.append(new)
else:
for data, profile in zip(self._data, profiles):
elevation = max(
profile.z_min() + height,
previous_elevation
)
data["elevation"] = elevation
previous_elevation = elevation
self._generate_resort_data(profiles) self._generate_resort_data(profiles)