From accfc5b8bddeb99c4e6f154a03a42b480d5766d6 Mon Sep 17 00:00:00 2001 From: peterdgr Date: Wed, 30 Oct 2024 17:53:24 +0100 Subject: [PATCH 1/7] feat: 181 extend calculations for having berm as part of input profile Improve input profile calculations to accommodate dikes with existing berms at polderside --- .../reinforcements/koswat_soil_settings.py | 6 +- .../piping_wall_input_profile_calculation.py | 178 ++++++++++-------- .../soil/soil_input_profile_calculation.py | 176 ++++++++--------- .../vps_input_profile_calculation.py | 87 +++++---- 4 files changed, 232 insertions(+), 215 deletions(-) diff --git a/koswat/configuration/settings/reinforcements/koswat_soil_settings.py b/koswat/configuration/settings/reinforcements/koswat_soil_settings.py index 22fbb0c9..1d766774 100644 --- a/koswat/configuration/settings/reinforcements/koswat_soil_settings.py +++ b/koswat/configuration/settings/reinforcements/koswat_soil_settings.py @@ -12,9 +12,9 @@ class KoswatSoilSettings(KoswatConfigProtocol): soil_surtax_factor: SurtaxFactorEnum = SurtaxFactorEnum.NORMAAL land_purchase_surtax_factor: SurtaxFactorEnum = SurtaxFactorEnum.NORMAAL - min_bermhoogte: float = 0 - max_bermhoogte_factor: float = 0 - factor_toename_bermhoogte: float = 0 + min_bermhoogte: float = 0.5 + max_bermhoogte_factor: float = 0.4 + factor_toename_bermhoogte: float = 0.05 def is_valid(self) -> bool: return True diff --git a/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py index b8b5aed5..edf5df34 100644 --- a/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py @@ -1,28 +1,16 @@ from koswat.configuration.settings import KoswatScenario from koswat.configuration.settings.koswat_general_settings import ConstructionTypeEnum -from koswat.configuration.settings.reinforcements.koswat_piping_wall_settings import ( - KoswatPipingWallSettings, -) -from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import ( - KoswatReinforcementSettings, -) +from koswat.configuration.settings.reinforcements.koswat_soil_settings import KoswatSoilSettings +from koswat.configuration.settings.reinforcements.koswat_piping_wall_settings import KoswatPipingWallSettings +from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import KoswatReinforcementSettings from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase -from koswat.dike_reinforcements.input_profile.piping_wall.piping_wall_input_profile import ( - PipingWallInputProfile, -) -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ( - ReinforcementInputProfileCalculationBase, -) -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ( - ReinforcementInputProfileCalculationProtocol, -) +from koswat.dike_reinforcements.input_profile.piping_wall.piping_wall_input_profile import PipingWallInputProfile +from koswat.dike_reinforcements.input_profile.soil.soil_input_profile_calculation import SoilInputProfileCalculation +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ReinforcementInputProfileCalculationBase +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol - -class PipingWallInputProfileCalculation( - ReinforcementInputProfileCalculationBase, - ReinforcementInputProfileCalculationProtocol, -): +class PipingWallInputProfileCalculation(SoilInputProfileCalculation, ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario @@ -31,17 +19,12 @@ def __init__(self) -> None: self.base_profile = None self.scenario = None - def _calculate_length_piping_wall( - self, - old_data: KoswatInputProfileBase, - piping_wall_settings: KoswatPipingWallSettings, - soil_binnen_berm_breedte: float, - ) -> float: - if soil_binnen_berm_breedte == 0: + def _calculate_length_piping_wall(self, old_data: KoswatInputProfileBase, piping_wall_settings: KoswatPipingWallSettings, seepage_length: float) -> float: + if seepage_length == 0: # No wall is needed. return 0 _length_piping = ( - (soil_binnen_berm_breedte / 6) + (seepage_length / 6) + (old_data.binnen_maaiveld - old_data.aquifer) + 1 ) @@ -56,38 +39,32 @@ def _calculate_length_piping_wall( 1, ) - def _calculate_new_kruin_hoogte( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - return base_data.kruin_hoogte + scenario.d_h +# def _calculate_new_kruin_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: +# return base_data.kruin_hoogte + scenario.d_h - def _calculate_new_binnen_talud( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - """ - MAX( - Binnen_Talud_Oud, - ( - dS - -dH*Buiten_Talud_Nieuw - -(Kruin_Breedte_Nieuw-Kruin_Breedte_Oud) - +(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud)*Binnen_Talud_Oud) - /(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud+dH)) - """ - _first_part = scenario.d_h * scenario.buiten_talud - _second_part = scenario.kruin_breedte - base_data.kruin_breedte - _third_parth = ( - base_data.kruin_hoogte - base_data.binnen_maaiveld - ) * base_data.binnen_talud - _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h - _right_side = ( - scenario.d_s - _first_part - _second_part + _third_parth - ) / _dividend - return max(base_data.binnen_talud, _right_side) +# def _calculate_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: +# """ +# MAX( +# Binnen_Talud_Oud, +# ( +# dS +# -dH*Buiten_Talud_Nieuw +# -(Kruin_Breedte_Nieuw-Kruin_Breedte_Oud) +# +(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud)*Binnen_Talud_Oud) +# /(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud+dH)) +# """ +# _first_part = scenario.d_h * scenario.buiten_talud +# _second_part = scenario.kruin_breedte - base_data.kruin_breedte +# _third_parth = ( +# base_data.kruin_hoogte - base_data.binnen_maaiveld +# ) * base_data.binnen_talud +# _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h +# _right_side = ( +# scenario.d_s - _first_part - _second_part + _third_parth +# ) / _dividend +# return max(base_data.binnen_talud, _right_side) - def _determine_construction_type( - self, overgang: float, construction_length: float - ) -> ConstructionTypeEnum | None: + def _determine_construction_type(self, overgang: float, construction_length: float) -> ConstructionTypeEnum | None: if construction_length == 0: return None elif construction_length <= overgang: @@ -95,50 +72,85 @@ def _determine_construction_type( else: return ConstructionTypeEnum.DAMWAND_ONVERANKERD - def _calculate_new_input_profile( - self, - base_data: KoswatInputProfileBase, - piping_wall_settings: KoswatPipingWallSettings, - scenario: KoswatScenario, - ) -> PipingWallInputProfile: + def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_settings: KoswatSoilSettings, piping_wall_settings: KoswatPipingWallSettings, scenario: KoswatScenario) -> PipingWallInputProfile: _new_data = PipingWallInputProfile() _new_data.dike_section = base_data.dike_section _new_data.buiten_maaiveld = base_data.buiten_maaiveld + _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud + _new_data.buiten_berm_hoogte = self._calculate_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_hoogte = base_data.buiten_berm_hoogte _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) _new_data.kruin_breedte = scenario.kruin_breedte - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) - _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld - _new_data.binnen_berm_breedte = 0 - _new_data.binnen_maaiveld = base_data.binnen_maaiveld - _soil_binnen_berm_breedte = self._calculate_soil_binnen_berm_breedte( - base_data, _new_data, scenario - ) + + _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld + _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld + _berm_factor_old = _berm_height_old/_dike_height_old + + if _berm_factor_old > soil_settings.max_bermhoogte_factor: + _berm_old_is_stability = True + else: + _berm_old_is_stability = False + + _dikebase_stability_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + _berm_old_is_stability*base_data.binnen_berm_breedte + _dikebase_piping_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + base_data.binnen_berm_breedte + + _dike_height_new = _new_data.kruin_hoogte-_new_data.binnen_maaiveld + _dikebase_heigth_new = scenario.d_h*_new_data.buiten_talud + _new_data.kruin_breedte + _dike_height_new*base_data.binnen_talud + _dikebase_stability_new = _dikebase_stability_old + scenario.d_s + _dikebase_piping_equivalent = _dikebase_piping_old + scenario.d_p + _dikebase_piping_new = max(_dikebase_piping_old, _dikebase_heigth_new, _dikebase_stability_new) + + # Is a berm for piping neccesary --> Maybe there was an old one?? + if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): + _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + # extend existing berm? + if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = True) + else: + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = False) + else: + # Is measure for stability neccesary? + if _dikebase_stability_new > _dikebase_heigth_new: + # in case of existing stab berm + if _berm_old_is_stability: + _new_data.binnen_berm_breedte = _dikebase_stability_new - _dikebase_heigth_new + _new_data.binnen_berm_hoogte = _berm_factor_old * _dike_height_new + _new_data.binnen_maaiveld + _new_data.binnen_talud = base_data.binnen_talud + else: + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + else: + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = base_data.binnen_talud + + # _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) + # _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + # _new_data.binnen_berm_breedte = 0 + # _soil_binnen_berm_breedte = self._calculate_soil_binnen_berm_breedte(base_data, _new_data, scenario) + + _seepage_length = max(_dikebase_piping_equivalent - _dikebase_piping_new, 0) + _new_data.grondprijs_bebouwd = base_data.grondprijs_bebouwd _new_data.grondprijs_onbebouwd = base_data.grondprijs_onbebouwd _new_data.factor_zetting = base_data.factor_zetting _new_data.pleistoceen = base_data.pleistoceen _new_data.aquifer = base_data.aquifer - _new_data.construction_length = self._calculate_length_piping_wall( - base_data, piping_wall_settings, _soil_binnen_berm_breedte - ) - _new_data.construction_type = self._determine_construction_type( - piping_wall_settings.overgang_cbwand_damwand, _new_data.construction_length - ) + _new_data.construction_length = self._calculate_length_piping_wall(base_data, piping_wall_settings, _seepage_length) + _new_data.construction_type = self._determine_construction_type(piping_wall_settings.overgang_cbwand_damwand, _new_data.construction_length) _new_data.soil_surtax_factor = piping_wall_settings.soil_surtax_factor - _new_data.constructive_surtax_factor = ( - piping_wall_settings.constructive_surtax_factor - ) - _new_data.land_purchase_surtax_factor = ( - piping_wall_settings.land_purchase_surtax_factor - ) + _new_data.constructive_surtax_factor = piping_wall_settings.constructive_surtax_factor + _new_data.land_purchase_surtax_factor = piping_wall_settings.land_purchase_surtax_factor return _new_data def build(self) -> PipingWallInputProfile: return self._calculate_new_input_profile( self.base_profile.input_data, + self.reinforcement_settings.soil_settings, self.reinforcement_settings.piping_wall_settings, self.scenario, ) diff --git a/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py index 401da259..3b2b1cf6 100644 --- a/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py @@ -1,27 +1,13 @@ from koswat.configuration.settings import KoswatScenario -from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import ( - KoswatReinforcementSettings, -) -from koswat.configuration.settings.reinforcements.koswat_soil_settings import ( - KoswatSoilSettings, -) +from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import KoswatReinforcementSettings +from koswat.configuration.settings.reinforcements.koswat_soil_settings import KoswatSoilSettings from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ( - ReinforcementInputProfileCalculationBase, -) -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ( - ReinforcementInputProfileCalculationProtocol, -) -from koswat.dike_reinforcements.input_profile.soil.soil_input_profile import ( - SoilInputProfile, -) +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ReinforcementInputProfileCalculationBase +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol +from koswat.dike_reinforcements.input_profile.soil.soil_input_profile import SoilInputProfile - -class SoilInputProfileCalculation( - ReinforcementInputProfileCalculationBase, - ReinforcementInputProfileCalculationProtocol, -): +class SoilInputProfileCalculation(ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario @@ -30,82 +16,86 @@ def __init__(self) -> None: self.base_profile = None self.scenario = None - def _calculate_new_binnen_talud( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - """ - MAX( - Binnen_Talud_Oud, - ( - dS - -dH*Buiten_Talud_Nieuw - -(Kruin_Breedte_Nieuw-Kruin_Breedte_Oud) - +(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud)*Binnen_Talud_Oud) - /(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud+dH)) - """ - _first_part = scenario.d_h * scenario.buiten_talud - _second_part = scenario.kruin_breedte - base_data.kruin_breedte - _third_parth = ( - base_data.kruin_hoogte - base_data.binnen_maaiveld - ) * base_data.binnen_talud - _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h - _right_side = ( - scenario.d_s - _first_part - _second_part + _third_parth - ) / _dividend - return max(base_data.binnen_talud, _right_side) - - def _calculate_new_binnen_berm_hoogte( - self, - old_data: KoswatInputProfileBase, - new_data: KoswatInputProfileBase, - scenario: KoswatScenario, - ) -> float: - if new_data.binnen_berm_breedte > 0: - _max = max( - 0.5, - (old_data.binnen_berm_hoogte - old_data.binnen_maaiveld), - new_data.binnen_berm_breedte * 0.05, - ) - return ( - min( - _max, - 0.4 - * ( - (old_data.kruin_hoogte - old_data.binnen_maaiveld) - + scenario.d_h - ), - ) - + old_data.binnen_maaiveld - ) - return old_data.binnen_maaiveld - - def _calculate_new_kruin_hoogte( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: + def _calculate_new_kruin_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: return base_data.kruin_hoogte + scenario.d_h - - def _calculate_new_input_profile( - self, - base_data: KoswatInputProfileBase, - soil_settings: KoswatSoilSettings, - scenario: KoswatScenario, - ) -> KoswatInputProfileBase: + + def _calculate_new_buiten_berm_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: + if base_data.buiten_berm_hoogte > base_data.buiten_maaiveld: + return base_data.buiten_berm_hoogte + scenario.d_h + return base_data.buiten_berm_hoogte + + def _calculate_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario, _dikebase_heigth_new, _dikebase_stability_new) -> float: + _numerator = max(_dikebase_heigth_new, _dikebase_stability_new) - scenario.d_h * scenario.buiten_talud - scenario.kruin_breedte + _denominator = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h + return _numerator/_denominator + + def _calculate_new_binnen_berm_hoogte(self, old_data: KoswatInputProfileBase, new_data: KoswatInputProfileBase, scenario: KoswatScenario, soil_settings: KoswatSoilSettings, _berm_extend_existing) -> float: + if _berm_extend_existing: + _old_berm_height = old_data.binnen_berm_hoogte - old_data.binnen_maaiveld + else: + _old_berm_height = 0 + _max = max( + soil_settings.min_bermhoogte, + _old_berm_height, + new_data.binnen_berm_breedte * soil_settings.factor_toename_bermhoogte, + ) + return ( + min(_max, soil_settings.max_bermhoogte_factor * (new_data.kruin_hoogte - new_data.binnen_maaiveld)) + new_data.binnen_maaiveld + ) + + def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_settings: KoswatSoilSettings, scenario: KoswatScenario) -> KoswatInputProfileBase: _new_data = SoilInputProfile() _new_data.dike_section = base_data.dike_section _new_data.buiten_maaiveld = base_data.buiten_maaiveld + _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud - _new_data.buiten_berm_hoogte = base_data.buiten_berm_hoogte + _new_data.buiten_berm_hoogte = self._calculate_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte _new_data.kruin_breedte = scenario.kruin_breedte _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) - _new_data.binnen_maaiveld = base_data.binnen_maaiveld - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) - _new_data.binnen_berm_breedte = self._calculate_soil_binnen_berm_breedte( - base_data, _new_data, scenario - ) - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte( - base_data, _new_data, scenario - ) + + _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld + _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld + _berm_factor_old = _berm_height_old/_dike_height_old + if _berm_factor_old > soil_settings.max_bermhoogte_factor: + _berm_old_is_stability = True + else: + _berm_old_is_stability = False + + _dikebase_stability_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + _berm_old_is_stability*base_data.binnen_berm_breedte + _dikebase_piping_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + base_data.binnen_berm_breedte + + _dike_height_new = _new_data.kruin_hoogte-_new_data.binnen_maaiveld + _dikebase_heigth_new = scenario.d_h*_new_data.buiten_talud + _new_data.kruin_breedte + _dike_height_new*base_data.binnen_talud + _dikebase_stability_new = _dikebase_stability_old + scenario.d_s + _dikebase_piping_new = _dikebase_piping_old + scenario.d_p + + # Is a berm for piping neccesary? + if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): + _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + # extend existing berm? + if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = True) + else: + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = False) + else: + # Is measure for stability neccesary? + if _dikebase_stability_new > _dikebase_heigth_new: + # in case of existing stab berm + if _berm_old_is_stability: + _new_data.binnen_berm_breedte = _dikebase_stability_new - _dikebase_heigth_new + _new_data.binnen_berm_hoogte = _berm_factor_old * _dike_height_new + _new_data.binnen_maaiveld + _new_data.binnen_talud = base_data.binnen_talud + else: + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + else: + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = base_data.binnen_talud + _new_data.grondprijs_bebouwd = base_data.grondprijs_bebouwd _new_data.grondprijs_onbebouwd = base_data.grondprijs_onbebouwd _new_data.factor_zetting = base_data.factor_zetting @@ -113,14 +103,8 @@ def _calculate_new_input_profile( _new_data.aquifer = base_data.aquifer _new_data.soil_surtax_factor = soil_settings.soil_surtax_factor _new_data.constructive_surtax_factor = None - _new_data.land_purchase_surtax_factor = ( - soil_settings.land_purchase_surtax_factor - ) + _new_data.land_purchase_surtax_factor = (soil_settings.land_purchase_surtax_factor) return _new_data def build(self) -> SoilInputProfile: - return self._calculate_new_input_profile( - self.base_profile.input_data, - self.reinforcement_settings.soil_settings, - self.scenario, - ) + return self._calculate_new_input_profile(self.base_profile.input_data, self.reinforcement_settings.soil_settings, self.scenario) diff --git a/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py index f5268c80..62684be1 100644 --- a/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py @@ -1,52 +1,72 @@ from koswat.configuration.settings import KoswatScenario from koswat.configuration.settings.koswat_general_settings import ConstructionTypeEnum -from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import ( - KoswatReinforcementSettings, -) -from koswat.configuration.settings.reinforcements.koswat_vps_settings import ( - KoswatVPSSettings, -) +from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import KoswatReinforcementSettings +from koswat.configuration.settings.reinforcements.koswat_soil_settings import KoswatSoilSettings +from koswat.configuration.settings.reinforcements.koswat_vps_settings import KoswatVPSSettings from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ( - ReinforcementInputProfileCalculationProtocol, -) -from koswat.dike_reinforcements.input_profile.soil.soil_input_profile_calculation import ( - SoilInputProfileCalculation, -) -from koswat.dike_reinforcements.input_profile.vertical_piping_solution.vps_input_profile import ( - VPSInputProfile, -) +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol +from koswat.dike_reinforcements.input_profile.soil.soil_input_profile_calculation import SoilInputProfileCalculation +from koswat.dike_reinforcements.input_profile.vertical_piping_solution.vps_input_profile import VPSInputProfile - -class VPSInputProfileCalculation( - SoilInputProfileCalculation, - ReinforcementInputProfileCalculationProtocol, -): +class VPSInputProfileCalculation(SoilInputProfileCalculation, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario - def _calculate_new_input_profile( - self, - base_data: KoswatInputProfileBase, - vps_settings: KoswatVPSSettings, - scenario: KoswatScenario, - ) -> KoswatInputProfileBase: + def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_settings: KoswatSoilSettings, vps_settings: KoswatVPSSettings, scenario: KoswatScenario) -> KoswatInputProfileBase: _new_data = VPSInputProfile() _new_data.dike_section = base_data.dike_section _new_data.buiten_maaiveld = base_data.buiten_maaiveld + _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud - _new_data.buiten_berm_hoogte = base_data.buiten_berm_hoogte + _new_data.buiten_berm_hoogte = self._calculate_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte _new_data.kruin_breedte = scenario.kruin_breedte _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) - _new_data.binnen_maaiveld = base_data.binnen_maaiveld - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) - _new_data.binnen_berm_breedte = vps_settings.binnen_berm_breedte_vps - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte( - base_data, _new_data, scenario - ) + + _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld + _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld + _berm_factor_old = _berm_height_old/_dike_height_old + if _berm_factor_old > soil_settings.max_bermhoogte_factor: + _berm_old_is_stability = True + else: + _berm_old_is_stability = False + + _dikebase_stability_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + _berm_old_is_stability*base_data.binnen_berm_breedte + _dikebase_piping_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + base_data.binnen_berm_breedte + + _dike_height_new = _new_data.kruin_hoogte-_new_data.binnen_maaiveld + _dikebase_heigth_new = scenario.d_h*_new_data.buiten_talud + _new_data.kruin_breedte + _dike_height_new*base_data.binnen_talud + _dikebase_stability_new = _dikebase_stability_old + scenario.d_s + _dikebase_piping_new = max(_dikebase_piping_old, max(_dikebase_heigth_new, _dikebase_stability_new) + vps_settings.binnen_berm_breedte_vps) + + # Is a berm for piping neccesary? --> vps_settings.binnen_berm_breedte_vps + if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): + _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + # extend existing berm? + if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = True) + else: + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = False) + else: + # Is measure for stability neccesary? + if _dikebase_stability_new > _dikebase_heigth_new: + # in case of existing stab berm + if _berm_old_is_stability: + _new_data.binnen_berm_breedte = _dikebase_stability_new - _dikebase_heigth_new + _new_data.binnen_berm_hoogte = _berm_factor_old * _dike_height_new + _new_data.binnen_maaiveld + _new_data.binnen_talud = base_data.binnen_talud + else: + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + else: + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = base_data.binnen_talud + _new_data.grondprijs_bebouwd = base_data.grondprijs_bebouwd _new_data.grondprijs_onbebouwd = base_data.grondprijs_onbebouwd _new_data.factor_zetting = base_data.factor_zetting @@ -61,6 +81,7 @@ def _calculate_new_input_profile( def build(self) -> VPSInputProfile: return self._calculate_new_input_profile( self.base_profile.input_data, + self.reinforcement_settings.soil_settings, self.reinforcement_settings.vps_settings, self.scenario, ) From 16b8dda23aaddf07a34894273418cc141eaf9b65 Mon Sep 17 00:00:00 2001 From: peterdgr Date: Fri, 1 Nov 2024 09:49:47 +0100 Subject: [PATCH 2/7] feat: 181 extend calculations for having berm as part of input profile Extend calculations for having berm as part of input profile. Added stability Wall and CofferDam. --- .../cofferdam_input_profile_calculation.py | 129 ++++-------- .../piping_wall_input_profile_calculation.py | 53 +---- ...orcement_input_profile_calculation_base.py | 66 +++++-- .../soil/soil_input_profile_calculation.py | 39 +--- ...tability_wall_input_profile_calculation.py | 184 ++++++++---------- .../vps_input_profile_calculation.py | 16 +- 6 files changed, 190 insertions(+), 297 deletions(-) diff --git a/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py index 752a16ae..f1374c08 100644 --- a/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py @@ -1,29 +1,16 @@ from koswat.configuration.settings import KoswatScenario from koswat.configuration.settings.koswat_general_settings import ConstructionTypeEnum -from koswat.configuration.settings.reinforcements.koswat_cofferdam_settings import ( - KoswatCofferdamSettings, -) -from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import ( - KoswatReinforcementSettings, -) +from koswat.configuration.settings.reinforcements.koswat_soil_settings import KoswatSoilSettings +from koswat.configuration.settings.reinforcements.koswat_cofferdam_settings import KoswatCofferdamSettings +from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import KoswatReinforcementSettings from koswat.dike.koswat_input_profile_protocol import KoswatInputProfileProtocol from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase -from koswat.dike_reinforcements.input_profile.cofferdam.cofferdam_input_profile import ( - CofferDamInputProfile, -) -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ( - ReinforcementInputProfileCalculationBase, -) -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ( - ReinforcementInputProfileCalculationProtocol, -) +from koswat.dike_reinforcements.input_profile.cofferdam.cofferdam_input_profile import CofferDamInputProfile +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ReinforcementInputProfileCalculationBase +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol - -class CofferdamInputProfileCalculation( - ReinforcementInputProfileCalculationBase, - ReinforcementInputProfileCalculationProtocol, -): +class CofferdamInputProfileCalculation(ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario @@ -32,60 +19,34 @@ def __init__(self) -> None: self.base_profile = None self.scenario = None - def _calculate_new_kruin_hoogte( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - return base_data.kruin_hoogte + scenario.d_h - - def _calculate_new_binnen_talud( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - """ - ( Kruin_Breedte_Oud - + (Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud) - *Binnen_Talud_Oud-Kruin_Breedte_Nieuw) - /(Kruin_Hoogte_Oud+dH) - """ - _mid_operand = base_data.binnen_talud * ( - base_data.kruin_hoogte - base_data.binnen_maaiveld - ) - _operand = base_data.kruin_breedte + _mid_operand - scenario.kruin_breedte - _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h + def _calculate_new_buiten_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: + _operand = (base_data.kruin_hoogte - base_data.buiten_maaiveld) * base_data.buiten_talud + _dividend = base_data.kruin_hoogte - base_data.buiten_maaiveld + scenario.d_h return _operand / _dividend - def _calculate_new_buiten_talud( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - """ - Kruin_Hoogte_Oud*Buiten_Talud_Oud - /(Kruin_Hoogte_Oud+dH) - """ - _operand = ( - base_data.kruin_hoogte - base_data.buiten_maaiveld - ) * base_data.buiten_talud - _dividend = base_data.kruin_hoogte - base_data.buiten_maaiveld + scenario.d_h + def _calculate_new_binnen_berm_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: + _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld + _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld + _berm_factor_old = _berm_height_old/_dike_height_old + return base_data.binnen_berm_hoogte + _berm_factor_old * scenario.d_h + + def _calculate_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: + _operand = (base_data.kruin_hoogte - base_data.binnen_maaiveld) * base_data.binnen_talud + _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h return _operand / _dividend - def _calculate_length_coffer_dam( - self, - old_data: KoswatInputProfileProtocol, - cofferdam_settings: KoswatCofferdamSettings, - soil_binnen_berm_breedte: float, - new_kruin_hoogte: float, - ) -> float: - """ - Identical to calculation of Stability wall - """ - if soil_binnen_berm_breedte == 0: + def _calculate_length_coffer_dam(self, old_data: KoswatInputProfileProtocol, cofferdam_settings: KoswatCofferdamSettings, seepage_length: float, new_kruin_hoogte: float) -> float: + _length_stability = (new_kruin_hoogte - 0.5) - (old_data.pleistoceen - 1) + if seepage_length == 0: # Length of wall is not determined by piping. _length_piping = 0.0 else: _length_piping = ( - (soil_binnen_berm_breedte / 6) + (seepage_length / 6) + (new_kruin_hoogte - 0.5) - old_data.aquifer ) - _length_stability = (new_kruin_hoogte - 0.5) - (old_data.pleistoceen - 1) + return round( min( max( @@ -107,51 +68,37 @@ def _determine_construction_type( else: return ConstructionTypeEnum.KISTDAM - def _calculate_new_input_profile( - self, - base_data: KoswatInputProfileBase, - cofferdam_settings: KoswatCofferdamSettings, - scenario: KoswatScenario, - ) -> CofferDamInputProfile: + def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_settings: KoswatSoilSettings, cofferdam_settings: KoswatCofferdamSettings, scenario: KoswatScenario) -> CofferDamInputProfile: _new_data = CofferDamInputProfile() _new_data.dike_section = base_data.dike_section _new_data.buiten_maaiveld = base_data.buiten_maaiveld + _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte # maintain current berm waterside + _new_data.buiten_berm_hoogte = self._calculate_soil_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_talud = self._calculate_new_buiten_talud(base_data, scenario) - _new_data.buiten_berm_hoogte = base_data.buiten_berm_hoogte - _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte - _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) - _new_data.kruin_breedte = scenario.kruin_breedte - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) - _new_data.binnen_berm_breedte = 0 - _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.kruin_hoogte = self._calculate_soil_new_kruin_hoogte(base_data, scenario) + _new_data.kruin_breedte = base_data.kruin_breedte # no widening of crest allowed _new_data.binnen_maaiveld = base_data.binnen_maaiveld - _soil_binnen_berm_breedte = self._calculate_soil_binnen_berm_breedte( - base_data, _new_data, scenario - ) + _new_data.binnen_berm_breedte = base_data.binnen_berm_breedte # maintain current berm polderside + _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, scenario) + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) + + _seepage_length = scenario.d_p + _new_data.construction_length = self._calculate_length_coffer_dam(base_data, cofferdam_settings, _seepage_length, _new_data.kruin_hoogte) + _new_data.construction_type = self._determine_construction_type(_new_data.construction_length) _new_data.grondprijs_bebouwd = base_data.grondprijs_bebouwd _new_data.grondprijs_onbebouwd = base_data.grondprijs_onbebouwd _new_data.factor_zetting = base_data.factor_zetting _new_data.pleistoceen = base_data.pleistoceen _new_data.aquifer = base_data.aquifer - _new_data.construction_length = self._calculate_length_coffer_dam( - base_data, - cofferdam_settings, - _soil_binnen_berm_breedte, - _new_data.kruin_hoogte, - ) - _new_data.construction_type = self._determine_construction_type( - _new_data.construction_length - ) _new_data.soil_surtax_factor = cofferdam_settings.soil_surtax_factor - _new_data.constructive_surtax_factor = ( - cofferdam_settings.constructive_surtax_factor - ) + _new_data.constructive_surtax_factor = cofferdam_settings.constructive_surtax_factor _new_data.land_purchase_surtax_factor = None return _new_data def build(self) -> CofferDamInputProfile: return self._calculate_new_input_profile( self.base_profile.input_data, + self.reinforcement_settings.soil_settings, self.reinforcement_settings.cofferdam_settings, self.scenario, ) diff --git a/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py index edf5df34..780d00a1 100644 --- a/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/piping_wall/piping_wall_input_profile_calculation.py @@ -6,11 +6,10 @@ from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase from koswat.dike_reinforcements.input_profile.piping_wall.piping_wall_input_profile import PipingWallInputProfile -from koswat.dike_reinforcements.input_profile.soil.soil_input_profile_calculation import SoilInputProfileCalculation from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ReinforcementInputProfileCalculationBase from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol -class PipingWallInputProfileCalculation(SoilInputProfileCalculation, ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): +class PipingWallInputProfileCalculation(ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario @@ -39,31 +38,6 @@ def _calculate_length_piping_wall(self, old_data: KoswatInputProfileBase, piping 1, ) -# def _calculate_new_kruin_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: -# return base_data.kruin_hoogte + scenario.d_h - -# def _calculate_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: -# """ -# MAX( -# Binnen_Talud_Oud, -# ( -# dS -# -dH*Buiten_Talud_Nieuw -# -(Kruin_Breedte_Nieuw-Kruin_Breedte_Oud) -# +(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud)*Binnen_Talud_Oud) -# /(Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud+dH)) -# """ -# _first_part = scenario.d_h * scenario.buiten_talud -# _second_part = scenario.kruin_breedte - base_data.kruin_breedte -# _third_parth = ( -# base_data.kruin_hoogte - base_data.binnen_maaiveld -# ) * base_data.binnen_talud -# _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h -# _right_side = ( -# scenario.d_s - _first_part - _second_part + _third_parth -# ) / _dividend -# return max(base_data.binnen_talud, _right_side) - def _determine_construction_type(self, overgang: float, construction_length: float) -> ConstructionTypeEnum | None: if construction_length == 0: return None @@ -78,10 +52,9 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s _new_data.buiten_maaiveld = base_data.buiten_maaiveld _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud - _new_data.buiten_berm_hoogte = self._calculate_new_buiten_berm_hoogte(base_data, scenario) - _new_data.buiten_berm_hoogte = base_data.buiten_berm_hoogte + _new_data.buiten_berm_hoogte = self._calculate_soil_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte - _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) + _new_data.kruin_hoogte = self._calculate_soil_new_kruin_hoogte(base_data, scenario) _new_data.kruin_breedte = scenario.kruin_breedte _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld @@ -99,18 +72,19 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s _dike_height_new = _new_data.kruin_hoogte-_new_data.binnen_maaiveld _dikebase_heigth_new = scenario.d_h*_new_data.buiten_talud + _new_data.kruin_breedte + _dike_height_new*base_data.binnen_talud _dikebase_stability_new = _dikebase_stability_old + scenario.d_s - _dikebase_piping_equivalent = _dikebase_piping_old + scenario.d_p _dikebase_piping_new = max(_dikebase_piping_old, _dikebase_heigth_new, _dikebase_stability_new) - + _dikebase_piping_needed = _dikebase_piping_old + scenario.d_p + _seepage_length = max(_dikebase_piping_needed - _dikebase_piping_new, 0) + # Is a berm for piping neccesary --> Maybe there was an old one?? if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) # extend existing berm? if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = True) + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, True) else: - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = False) + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, False) else: # Is measure for stability neccesary? if _dikebase_stability_new > _dikebase_heigth_new: @@ -122,19 +96,12 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s else: _new_data.binnen_berm_breedte = 0 _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) else: _new_data.binnen_berm_breedte = 0 _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld _new_data.binnen_talud = base_data.binnen_talud - # _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) - # _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld - # _new_data.binnen_berm_breedte = 0 - # _soil_binnen_berm_breedte = self._calculate_soil_binnen_berm_breedte(base_data, _new_data, scenario) - - _seepage_length = max(_dikebase_piping_equivalent - _dikebase_piping_new, 0) - _new_data.grondprijs_bebouwd = base_data.grondprijs_bebouwd _new_data.grondprijs_onbebouwd = base_data.grondprijs_onbebouwd _new_data.factor_zetting = base_data.factor_zetting diff --git a/koswat/dike_reinforcements/input_profile/reinforcement_input_profile_calculation_base.py b/koswat/dike_reinforcements/input_profile/reinforcement_input_profile_calculation_base.py index b3dd5143..129746bc 100644 --- a/koswat/dike_reinforcements/input_profile/reinforcement_input_profile_calculation_base.py +++ b/koswat/dike_reinforcements/input_profile/reinforcement_input_profile_calculation_base.py @@ -2,31 +2,57 @@ from koswat.configuration.settings.koswat_scenario import KoswatScenario from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase - +from koswat.configuration.settings.reinforcements.koswat_soil_settings import KoswatSoilSettings class ReinforcementInputProfileCalculationBase(ABC): """ Abstract class to provide common functions to child classes """ + def _calculate_soil_new_kruin_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: + return base_data.kruin_hoogte + scenario.d_h - def _calculate_soil_binnen_berm_breedte( - self, - old_data: KoswatInputProfileBase, - new_data: KoswatInputProfileBase, - scenario: KoswatScenario, - ) -> float: - _dikebase_old = ( - (old_data.kruin_hoogte - old_data.buiten_maaiveld) * old_data.buiten_talud - + old_data.buiten_berm_breedte - + old_data.kruin_breedte - + old_data.binnen_berm_breedte - + (old_data.kruin_hoogte - old_data.binnen_maaiveld) * old_data.binnen_talud + def _calculate_soil_new_buiten_berm_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: + if base_data.buiten_berm_hoogte > base_data.buiten_maaiveld: + return base_data.buiten_berm_hoogte + scenario.d_h + return base_data.buiten_berm_hoogte + + def _calculate_soil_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario, dikebase_heigth_new: float, dikebase_stability_new: float) -> float: + _operand = max(dikebase_heigth_new, dikebase_stability_new) - scenario.d_h * scenario.buiten_talud - scenario.kruin_breedte + _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h + return _operand / _dividend + + def _calculate_soil_new_binnen_berm_hoogte_piping(self, old_data: KoswatInputProfileBase, new_data: KoswatInputProfileBase, scenario: KoswatScenario, soil_settings: KoswatSoilSettings, berm_extend_existing: bool) -> float: + if berm_extend_existing: + _old_berm_height = old_data.binnen_berm_hoogte - old_data.binnen_maaiveld + else: + _old_berm_height = 0 + _max = max( + soil_settings.min_bermhoogte, + _old_berm_height, + new_data.binnen_berm_breedte * soil_settings.factor_toename_bermhoogte, ) - _dikebase_new = ( - (new_data.kruin_hoogte - new_data.buiten_maaiveld) * new_data.buiten_talud - + new_data.buiten_berm_breedte - + new_data.kruin_breedte - + (new_data.kruin_hoogte - new_data.binnen_maaiveld) * new_data.binnen_talud + return ( + min(_max, soil_settings.max_bermhoogte_factor * (new_data.kruin_hoogte - new_data.binnen_maaiveld)) + new_data.binnen_maaiveld ) - _berm = scenario.d_p - (_dikebase_new - _dikebase_old) - return max(_berm, 0) + +# def _calculate_soil_binnen_berm_breedte( +# self, +# old_data: KoswatInputProfileBase, +# new_data: KoswatInputProfileBase, +# scenario: KoswatScenario, +# ) -> float: +# _dikebase_old = ( +# (old_data.kruin_hoogte - old_data.buiten_maaiveld) * old_data.buiten_talud +# + old_data.buiten_berm_breedte +# + old_data.kruin_breedte +# + old_data.binnen_berm_breedte +# + (old_data.kruin_hoogte - old_data.binnen_maaiveld) * old_data.binnen_talud +# ) +# _dikebase_new = ( +# (new_data.kruin_hoogte - new_data.buiten_maaiveld) * new_data.buiten_talud +# + new_data.buiten_berm_breedte +# + new_data.kruin_breedte +# + (new_data.kruin_hoogte - new_data.binnen_maaiveld) * new_data.binnen_talud +# ) +# _berm = scenario.d_p - (_dikebase_new - _dikebase_old) +# return max(_berm, 0) diff --git a/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py index 3b2b1cf6..b3da0511 100644 --- a/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py @@ -15,33 +15,6 @@ class SoilInputProfileCalculation(ReinforcementInputProfileCalculationBase, Rein def __init__(self) -> None: self.base_profile = None self.scenario = None - - def _calculate_new_kruin_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: - return base_data.kruin_hoogte + scenario.d_h - - def _calculate_new_buiten_berm_hoogte(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario) -> float: - if base_data.buiten_berm_hoogte > base_data.buiten_maaiveld: - return base_data.buiten_berm_hoogte + scenario.d_h - return base_data.buiten_berm_hoogte - - def _calculate_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario, _dikebase_heigth_new, _dikebase_stability_new) -> float: - _numerator = max(_dikebase_heigth_new, _dikebase_stability_new) - scenario.d_h * scenario.buiten_talud - scenario.kruin_breedte - _denominator = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h - return _numerator/_denominator - - def _calculate_new_binnen_berm_hoogte(self, old_data: KoswatInputProfileBase, new_data: KoswatInputProfileBase, scenario: KoswatScenario, soil_settings: KoswatSoilSettings, _berm_extend_existing) -> float: - if _berm_extend_existing: - _old_berm_height = old_data.binnen_berm_hoogte - old_data.binnen_maaiveld - else: - _old_berm_height = 0 - _max = max( - soil_settings.min_bermhoogte, - _old_berm_height, - new_data.binnen_berm_breedte * soil_settings.factor_toename_bermhoogte, - ) - return ( - min(_max, soil_settings.max_bermhoogte_factor * (new_data.kruin_hoogte - new_data.binnen_maaiveld)) + new_data.binnen_maaiveld - ) def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_settings: KoswatSoilSettings, scenario: KoswatScenario) -> KoswatInputProfileBase: _new_data = SoilInputProfile() @@ -49,10 +22,10 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s _new_data.buiten_maaiveld = base_data.buiten_maaiveld _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud - _new_data.buiten_berm_hoogte = self._calculate_new_buiten_berm_hoogte(base_data, scenario) + _new_data.buiten_berm_hoogte = self._calculate_soil_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte _new_data.kruin_breedte = scenario.kruin_breedte - _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) + _new_data.kruin_hoogte = self._calculate_soil_new_kruin_hoogte(base_data, scenario) _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld @@ -73,12 +46,12 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s # Is a berm for piping neccesary? if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) # extend existing berm? if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = True) + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, True) else: - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = False) + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, False) else: # Is measure for stability neccesary? if _dikebase_stability_new > _dikebase_heigth_new: @@ -90,7 +63,7 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s else: _new_data.binnen_berm_breedte = 0 _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) else: _new_data.binnen_berm_breedte = 0 _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld diff --git a/koswat/dike_reinforcements/input_profile/stability_wall/stability_wall_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/stability_wall/stability_wall_input_profile_calculation.py index cd4d34f3..e28d5829 100644 --- a/koswat/dike_reinforcements/input_profile/stability_wall/stability_wall_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/stability_wall/stability_wall_input_profile_calculation.py @@ -1,29 +1,16 @@ from koswat.configuration.settings import KoswatScenario from koswat.configuration.settings.koswat_general_settings import ConstructionTypeEnum -from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import ( - KoswatReinforcementSettings, -) -from koswat.configuration.settings.reinforcements.koswat_stability_wall_settings import ( - KoswatStabilityWallSettings, -) +from koswat.configuration.settings.reinforcements.koswat_reinforcement_settings import KoswatReinforcementSettings +from koswat.configuration.settings.reinforcements.koswat_soil_settings import KoswatSoilSettings +from koswat.configuration.settings.reinforcements.koswat_stability_wall_settings import KoswatStabilityWallSettings from koswat.dike.koswat_input_profile_protocol import KoswatInputProfileProtocol from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ( - ReinforcementInputProfileCalculationBase, -) -from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ( - ReinforcementInputProfileCalculationProtocol, -) -from koswat.dike_reinforcements.input_profile.stability_wall.stability_wall_input_profile import ( - StabilityWallInputProfile, -) +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ReinforcementInputProfileCalculationBase +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol +from koswat.dike_reinforcements.input_profile.stability_wall.stability_wall_input_profile import StabilityWallInputProfile - -class StabilityWallInputProfileCalculation( - ReinforcementInputProfileCalculationBase, - ReinforcementInputProfileCalculationProtocol, -): +class StabilityWallInputProfileCalculation(ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario @@ -32,26 +19,31 @@ def __init__(self) -> None: self.base_profile = None self.scenario = None - def _calculate_length_stability_wall( - self, - old_data: KoswatInputProfileProtocol, - stability_wall_settings: KoswatStabilityWallSettings, - soil_binnen_berm_breedte: float, - new_kruin_hoogte: float, - ) -> float: - """ - Identical to calculation of Cofferdam - """ - if soil_binnen_berm_breedte == 0: - # Length of wall is not determined by piping. - _length_piping = 0.0 + def _calculate_length_stability_wall(self, old_data: KoswatInputProfileProtocol, stability_wall_settings: KoswatStabilityWallSettings, seepage_length: float, stab_wall: bool, new_kruin_hoogte: float) -> float: + if stab_wall: + _length_stability = (new_kruin_hoogte - 0.5) - (old_data.pleistoceen - 1) + if seepage_length == 0: + # Length of wall is not determined by piping. + _length_piping = 0.0 + else: + _length_piping = ( + (seepage_length / 6) + + (new_kruin_hoogte - 0.5) + - old_data.aquifer + ) else: - _length_piping = ( - (soil_binnen_berm_breedte / 6) - + (new_kruin_hoogte - 0.5) - - old_data.aquifer - ) - _length_stability = (new_kruin_hoogte - 0.5) - (old_data.pleistoceen - 1) + _length_stability = 0 + if seepage_length == 0: + # Length of wall is not determined by piping. + _length_piping = 0.0 + else: + # Length of wall zoals bij kwelscherm + _length_piping = ( + (seepage_length / 6) + + (old_data.binnen_maaiveld - old_data.aquifer) + + 1 # 1 m in bestaande dijklichaam + ) + return round( min( max( @@ -64,39 +56,10 @@ def _calculate_length_stability_wall( 1, ) - def _calculate_new_kruin_hoogte( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - return base_data.kruin_hoogte + scenario.d_h - - def _calculate_new_binnen_talud( - self, base_data: KoswatInputProfileBase, scenario: KoswatScenario - ) -> float: - """ - MAX( - 2, - ( Kruin_Breedte_Oud - + - (Kruin_Hoogte_Oud-Binnen_Maaiveld_Oud) - *Binnen_Talud_Oud - -dH*Buiten_Talud_Nieuw - -Kruin_Breedte_Nieuw) - /(Kruin_Hoogte_Oud+dH)) - - """ - _first_part = ( - base_data.kruin_hoogte - base_data.binnen_maaiveld - ) * base_data.binnen_talud - _second_part = scenario.d_h * scenario.buiten_talud - _operand = ( - base_data.kruin_breedte - + _first_part - - _second_part - - scenario.kruin_breedte - ) + def _calculate_new_binnen_talud(self, base_data: KoswatInputProfileBase, scenario: KoswatScenario, stability_wall_settings: KoswatStabilityWallSettings, _dikebase_piping_old: float) -> float: + _operand = _dikebase_piping_old - scenario.d_h * scenario.buiten_talud - scenario.kruin_breedte _dividend = base_data.kruin_hoogte - base_data.binnen_maaiveld + scenario.d_h - _right_side = _operand / _dividend - return max(2, _right_side) + return max(stability_wall_settings.versteiling_binnentalud, _operand/_dividend) def _determine_construction_type( self, @@ -110,54 +73,71 @@ def _determine_construction_type( else: return ConstructionTypeEnum.DIEPWAND - def _calculate_new_input_profile( - self, - base_data: KoswatInputProfileProtocol, - stability_wall_settings: KoswatStabilityWallSettings, - scenario: KoswatScenario, - ) -> StabilityWallInputProfile: + def _calculate_new_input_profile(self, base_data: KoswatInputProfileProtocol, soil_settings: KoswatSoilSettings, stability_wall_settings: KoswatStabilityWallSettings, scenario: KoswatScenario) -> StabilityWallInputProfile: _new_data = StabilityWallInputProfile() _new_data.dike_section = base_data.dike_section _new_data.buiten_maaiveld = base_data.buiten_maaiveld + _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud - _new_data.buiten_berm_hoogte = base_data.buiten_berm_hoogte + _new_data.buiten_berm_hoogte = self._calculate_soil_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte - _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) + _new_data.kruin_hoogte = self._calculate_soil_new_kruin_hoogte(base_data, scenario) _new_data.kruin_breedte = scenario.kruin_breedte - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario) - _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld - _new_data.binnen_berm_breedte = 0 - _new_data.binnen_maaiveld = base_data.binnen_maaiveld + + _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld + _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld + _berm_factor_old = _berm_height_old/_dike_height_old + + if _berm_factor_old > soil_settings.max_bermhoogte_factor: + _berm_old_is_stability = True + else: + _berm_old_is_stability = False + + _dikebase_stability_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + _berm_old_is_stability*base_data.binnen_berm_breedte + _dikebase_piping_old = base_data.kruin_breedte + _dike_height_old*base_data.binnen_talud + base_data.binnen_berm_breedte + + _dike_height_new = _new_data.kruin_hoogte-_new_data.binnen_maaiveld + _dikebase_heigth_new = scenario.d_h*_new_data.buiten_talud + _new_data.kruin_breedte + _dike_height_new*base_data.binnen_talud + _dikebase_stability_new = _dikebase_stability_old + scenario.d_s + _dikebase_piping_new = max(_dikebase_piping_old, _dikebase_heigth_new, _dikebase_stability_new) + _dikebase_piping_needed = _dikebase_piping_old + scenario.d_p + + # stab measure fits within the current profile, no stab wall neccesary, but wall might be needed for piping + if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): + _stab_wall = False + _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + # extend existing berm? + if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, True) + else: + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, False) + else: + # stab measure doesn't fit within current profile, extend with steepening of binnen talud + _stab_wall = True + _new_data.binnen_berm_breedte = 0 + _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld + _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, stability_wall_settings, _dikebase_piping_old) + _new_data.grondprijs_bebouwd = base_data.grondprijs_bebouwd _new_data.grondprijs_onbebouwd = base_data.grondprijs_onbebouwd _new_data.factor_zetting = base_data.factor_zetting _new_data.pleistoceen = base_data.pleistoceen _new_data.aquifer = base_data.aquifer - _soil_binnen_berm_breedte = self._calculate_soil_binnen_berm_breedte( - base_data, _new_data, scenario - ) - _new_data.construction_length = self._calculate_length_stability_wall( - base_data, - stability_wall_settings, - _soil_binnen_berm_breedte, - _new_data.kruin_hoogte, - ) - _new_data.construction_type = self._determine_construction_type( - stability_wall_settings.overgang_damwand_diepwand, - _new_data.construction_length, - ) + + _dikebase_piping_realized = scenario.d_h * _new_data.buiten_talud + _new_data.kruin_breedte + _dike_height_new * _new_data.binnen_talud + _new_data.binnen_berm_breedte + _seepage_length = max(_dikebase_piping_needed - _dikebase_piping_realized, 0) + _new_data.construction_length = self._calculate_length_stability_wall(base_data, stability_wall_settings, _seepage_length, _stab_wall, _new_data.kruin_hoogte) + _new_data.construction_type = self._determine_construction_type(stability_wall_settings.overgang_damwand_diepwand, _new_data.construction_length) _new_data.soil_surtax_factor = stability_wall_settings.soil_surtax_factor - _new_data.constructive_surtax_factor = ( - stability_wall_settings.constructive_surtax_factor - ) - _new_data.land_purchase_surtax_factor = ( - stability_wall_settings.land_purchase_surtax_factor - ) + _new_data.constructive_surtax_factor = stability_wall_settings.constructive_surtax_factor + _new_data.land_purchase_surtax_factor = stability_wall_settings.land_purchase_surtax_factor return _new_data def build(self) -> StabilityWallInputProfile: return self._calculate_new_input_profile( self.base_profile.input_data, + self.reinforcement_settings.soil_settings, self.reinforcement_settings.stability_wall_settings, self.scenario, ) diff --git a/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py index 62684be1..e52d2a40 100644 --- a/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py @@ -5,11 +5,11 @@ from koswat.configuration.settings.reinforcements.koswat_vps_settings import KoswatVPSSettings from koswat.dike.koswat_profile_protocol import KoswatProfileProtocol from koswat.dike.profile.koswat_input_profile_base import KoswatInputProfileBase +from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_base import ReinforcementInputProfileCalculationBase from koswat.dike_reinforcements.input_profile.reinforcement_input_profile_calculation_protocol import ReinforcementInputProfileCalculationProtocol -from koswat.dike_reinforcements.input_profile.soil.soil_input_profile_calculation import SoilInputProfileCalculation from koswat.dike_reinforcements.input_profile.vertical_piping_solution.vps_input_profile import VPSInputProfile -class VPSInputProfileCalculation(SoilInputProfileCalculation, ReinforcementInputProfileCalculationProtocol): +class VPSInputProfileCalculation(ReinforcementInputProfileCalculationBase, ReinforcementInputProfileCalculationProtocol): base_profile: KoswatProfileProtocol reinforcement_settings: KoswatReinforcementSettings scenario: KoswatScenario @@ -20,10 +20,10 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s _new_data.buiten_maaiveld = base_data.buiten_maaiveld _new_data.binnen_maaiveld = base_data.binnen_maaiveld _new_data.buiten_talud = scenario.buiten_talud - _new_data.buiten_berm_hoogte = self._calculate_new_buiten_berm_hoogte(base_data, scenario) + _new_data.buiten_berm_hoogte = self._calculate_soil_new_buiten_berm_hoogte(base_data, scenario) _new_data.buiten_berm_breedte = base_data.buiten_berm_breedte _new_data.kruin_breedte = scenario.kruin_breedte - _new_data.kruin_hoogte = self._calculate_new_kruin_hoogte(base_data, scenario) + _new_data.kruin_hoogte = self._calculate_soil_new_kruin_hoogte(base_data, scenario) _dike_height_old = base_data.kruin_hoogte - base_data.binnen_maaiveld _berm_height_old = base_data.binnen_berm_hoogte - base_data.binnen_maaiveld @@ -44,12 +44,12 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s # Is a berm for piping neccesary? --> vps_settings.binnen_berm_breedte_vps if _dikebase_piping_new > max(_dikebase_heigth_new,_dikebase_stability_new): _new_data.binnen_berm_breedte = _dikebase_piping_new - max(_dikebase_heigth_new,_dikebase_stability_new) - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) # extend existing berm? if base_data.binnen_berm_breedte > 0 and _dikebase_piping_old > max(_dikebase_heigth_new, _dikebase_stability_new): - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = True) + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, True) else: - _new_data.binnen_berm_hoogte = self._calculate_new_binnen_berm_hoogte(base_data, _new_data, scenario, soil_settings, _berm_extend_existing = False) + _new_data.binnen_berm_hoogte = self._calculate_soil_new_binnen_berm_hoogte_piping(base_data, _new_data, scenario, soil_settings, False) else: # Is measure for stability neccesary? if _dikebase_stability_new > _dikebase_heigth_new: @@ -61,7 +61,7 @@ def _calculate_new_input_profile(self, base_data: KoswatInputProfileBase, soil_s else: _new_data.binnen_berm_breedte = 0 _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld - _new_data.binnen_talud = self._calculate_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) + _new_data.binnen_talud = self._calculate_soil_new_binnen_talud(base_data, scenario, _dikebase_heigth_new, _dikebase_stability_new) else: _new_data.binnen_berm_breedte = 0 _new_data.binnen_berm_hoogte = base_data.binnen_maaiveld From 56816c800613dc9f725b796f4f3069ba4b82d5f7 Mon Sep 17 00:00:00 2001 From: peterdgr Date: Wed, 6 Nov 2024 11:11:28 +0100 Subject: [PATCH 3/7] feat: 181 extend calculations for having berm as part of input profile Update scenario cases and base profiles --- koswat.log | 182 ++++++++++++++++++ .../acceptance_test_scenario_cases.py | 12 ++ .../koswat_input_profile_base_cases.py | 38 ++++ .../koswat_scenario_test_cases.py | 28 +++ 4 files changed, 260 insertions(+) create mode 100644 koswat.log diff --git a/koswat.log b/koswat.log new file mode 100644 index 00000000..0fe1afdf --- /dev/null +++ b/koswat.log @@ -0,0 +1,182 @@ +2024-11-06 10:47:20 AM - [koswat_handler.py:119] - root - INFO - Initialized Koswat. +2024-11-06 10:48:01 AM - [koswat_run_settings_importer.py:67] - root - INFO - Importing INI configuration from c:\KOSWAT_app\invoer\RaLi\KOSWAT_analyse_RaLi.ini +2024-11-06 10:48:01 AM - [koswat_costs_importer.py:41] - root - INFO - Importing costs settings from c:\KOSWAT_app\invoer\koswat_costs_2023.ini. +2024-11-06 10:51:37 AM - [surroundings_wrapper_collection_importer.py:77] - root - ERROR - Could not load surroundings for dike section DV_11A_2. Detailed error: No point fromt the *.shp file matches the ones in the *.csv file. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:96] - root - INFO - Importing INI configuration completed. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:99] - root - INFO - Mapping data to Koswat Settings +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_1_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_1_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_1_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_1_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2A_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2A_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_6. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_7. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_2B_8. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_3_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_3_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_3_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_3_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_3_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_4_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_4_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_4_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_4_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_4_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_5A. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_5B_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_5B_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_5B_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_6_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_6_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7A_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7A_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7A_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7A_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7A_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7B_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7B_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_7B_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_8_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_8_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9A_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9A_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9A_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9A_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9A_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_6. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_9B_7. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_10_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_10_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_10_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_10_4. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_10_5. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_11A_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_11A_2. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:153] - root - INFO - Creating scenarios for profile DV_11B_3. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:166] - root - INFO - Created sub scenario Scenario_1. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:170] - root - INFO - Finished generating koswat scenarios. A total of 60 scenarios were created. +2024-11-06 10:51:37 AM - [koswat_run_settings_importer.py:108] - root - INFO - Settings import completed. +2024-11-06 10:55:27 AM - [koswat_summary_builder.py:118] - root - INFO - Creating analysis for DV_1_1 - scenario - Scenario_1 +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement SoilReinforcementProfile +2024-11-06 10:55:27 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Grondmaatregel profiel +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement VPSReinforcementProfile +2024-11-06 10:55:27 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Verticale piping oplossing +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement PipingWallReinforcementProfile +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Kwelscherm +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement StabilityWallReinforcementProfile +2024-11-06 10:55:27 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:27 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Stabiliteitswand +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement CofferdamReinforcementProfile +2024-11-06 10:55:27 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Kistdam +2024-11-06 10:55:28 AM - [koswat_summary_location_matrix_builder.py:115] - root - INFO - Initalizing locations-reinforcements matrix. +2024-11-06 10:55:29 AM - [koswat_summary_location_matrix_builder.py:152] - root - INFO - Finalized locations-reinforcements matrix. +2024-11-06 10:55:29 AM - [order_strategy_clustering.py:70] - root - INFO - Non-compliant clusters found for Grondmaatregel profiel: 0 +2024-11-06 10:55:29 AM - [order_strategy_clustering.py:70] - root - INFO - Non-compliant clusters found for Kwelscherm: 0 +2024-11-06 10:55:29 AM - [koswat_handler.py:45] - root - INFO - Analysis created. +2024-11-06 10:55:29 AM - [koswat_handler.py:53] - root - INFO - Exporting csv results to c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1. +2024-11-06 10:55:30 AM - [raw.py:723] - pyogrio._io - INFO - Created 3 records +2024-11-06 10:55:30 AM - [raw.py:723] - pyogrio._io - INFO - Created 3 records +2024-11-06 10:55:30 AM - [raw.py:723] - pyogrio._io - INFO - Created 3 records +2024-11-06 10:55:30 AM - [koswat_handler.py:59] - root - INFO - Exported summary results to: c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1 +2024-11-06 10:55:31 AM - [koswat_handler.py:71] - root - INFO - Exported comparison plots to: c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1 +2024-11-06 10:55:32 AM - [koswat_handler.py:71] - root - INFO - Exported comparison plots to: c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1 +2024-11-06 10:55:33 AM - [koswat_handler.py:71] - root - INFO - Exported comparison plots to: c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1 +2024-11-06 10:55:34 AM - [koswat_handler.py:71] - root - INFO - Exported comparison plots to: c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1 +2024-11-06 10:55:35 AM - [koswat_handler.py:71] - root - INFO - Exported comparison plots to: c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_1\scenario_scenario_1 +2024-11-06 10:55:35 AM - [koswat_summary_builder.py:118] - root - INFO - Creating analysis for DV_1_2 - scenario - Scenario_1 +2024-11-06 10:55:35 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement SoilReinforcementProfile +2024-11-06 10:55:35 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:35 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Grondmaatregel profiel +2024-11-06 10:55:35 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement VPSReinforcementProfile +2024-11-06 10:55:35 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Verticale piping oplossing +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement PipingWallReinforcementProfile +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Kwelscherm +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement StabilityWallReinforcementProfile +2024-11-06 10:55:36 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:36 AM - [calc_library.py:18] - root - WARNING - Polygon with 'multi line', most likely due to a geometry split in two parts. Ordering of points is not supported, some calculation errors might occur as a consequence of this. +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Stabiliteitswand +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:64] - root - INFO - Building reinforcement CofferdamReinforcementProfile +2024-11-06 10:55:36 AM - [reinforcement_profile_builder_base.py:74] - root - INFO - Built reinforcement Kistdam +2024-11-06 10:55:36 AM - [koswat_summary_location_matrix_builder.py:115] - root - INFO - Initalizing locations-reinforcements matrix. +2024-11-06 10:55:37 AM - [koswat_summary_location_matrix_builder.py:152] - root - INFO - Finalized locations-reinforcements matrix. +2024-11-06 10:55:37 AM - [order_strategy_clustering.py:70] - root - INFO - Non-compliant clusters found for Grondmaatregel profiel: 0 +2024-11-06 10:55:37 AM - [order_strategy_clustering.py:70] - root - INFO - Non-compliant clusters found for Kwelscherm: 0 +2024-11-06 10:55:37 AM - [koswat_handler.py:45] - root - INFO - Analysis created. +2024-11-06 10:55:37 AM - [koswat_handler.py:53] - root - INFO - Exporting csv results to c:\KOSWAT_app\uitvoer\uitvoer_Rali_20241016\dike_DV_1_2\scenario_scenario_1. +2024-11-06 10:55:37 AM - [koswat_handler.py:109] - root - ERROR - Error while running scenario Scenario_1__DV_1_2, more details: IllegalArgumentException: point array must contain 0 or >1 elements + +2024-11-06 10:55:37 AM - [koswat_handler.py:123] - root - INFO - Finalized Koswat. diff --git a/tests/acceptance_scenarios/acceptance_test_scenario_cases.py b/tests/acceptance_scenarios/acceptance_test_scenario_cases.py index 1a9fd0d0..bc7ddbfe 100644 --- a/tests/acceptance_scenarios/acceptance_test_scenario_cases.py +++ b/tests/acceptance_scenarios/acceptance_test_scenario_cases.py @@ -7,6 +7,8 @@ from tests.acceptance_scenarios.koswat_scenario_test_cases import ( ScenarioCasesAB, ScenarioCasesC, + ScenarioCasesDijk4, + ScenarioCasesDijk5, ) from tests.acceptance_scenarios.layers_cases import LayersCases @@ -26,4 +28,14 @@ layers_cases=[LayersCases.with_acceptance_criteria], scenario_cases=ScenarioCasesC.cases, ), + AcceptanceTestScenarioCombinations( + profile_case=AcceptanceTestInputProfileCases.profile_dijk4, + layers_cases=[LayersCases.with_acceptance_criteria], + scenario_cases=ScenarioCasesDijk4.cases, + ), + AcceptanceTestScenarioCombinations( + profile_case=AcceptanceTestInputProfileCases.profile_dijk5, + layers_cases=[LayersCases.with_acceptance_criteria], + scenario_cases=ScenarioCasesDijk5.cases, + ), ] diff --git a/tests/acceptance_scenarios/koswat_input_profile_base_cases.py b/tests/acceptance_scenarios/koswat_input_profile_base_cases.py index 3f066068..c9b2c2a6 100644 --- a/tests/acceptance_scenarios/koswat_input_profile_base_cases.py +++ b/tests/acceptance_scenarios/koswat_input_profile_base_cases.py @@ -122,3 +122,41 @@ class AcceptanceTestInputProfileCases(CasesProtocol): pleistoceen=-5, aquifer=-2, ) + + profile_dijk4 = KoswatInputProfileBase( + dike_section="dijk4", + buiten_maaiveld=6.38, + buiten_talud=2.56, + buiten_berm_hoogte=6.38, + buiten_berm_breedte=0, + kruin_hoogte=11.38, + kruin_breedte=10.36, + binnen_talud=3.57, + binnen_berm_hoogte=9.06, + binnen_berm_breedte=19.23, + binnen_maaiveld=6.45, + grondprijs_bebouwd=322.63, + grondprijs_onbebouwd=13.87, + factor_zetting=1.2, + pleistoceen=3.17, + aquifer=6.06, + ) + + profile_dijk5 = KoswatInputProfileBase( + dike_section="dijk5", + buiten_maaiveld=7.64, + buiten_talud=2.99, + buiten_berm_hoogte=7.64, + buiten_berm_breedte=0, + kruin_hoogte=11.28, + kruin_breedte=2.36, + binnen_talud=2.03, + binnen_berm_hoogte=10.69, + binnen_berm_breedte=13.27, + binnen_maaiveld=6.81, + grondprijs_bebouwd=322.63, + grondprijs_onbebouwd=13.87, + factor_zetting=1.2, + pleistoceen=3.53, + aquifer=6.42, + ) diff --git a/tests/acceptance_scenarios/koswat_scenario_test_cases.py b/tests/acceptance_scenarios/koswat_scenario_test_cases.py index f3a7bfe4..6df645b6 100644 --- a/tests/acceptance_scenarios/koswat_scenario_test_cases.py +++ b/tests/acceptance_scenarios/koswat_scenario_test_cases.py @@ -441,3 +441,31 @@ class ScenarioCasesC(CasesProtocol): # kruin_breedte=10, # ), ] + +class ScenarioCasesDijk4(CasesProtocol): + cases = [ + KoswatScenario( + scenario_name="dijk4", + d_h=0.72, + d_s=10, + d_p=50, + buiten_talud=3.56, + ) + ] + +class ScenarioCasesDijk5(CasesProtocol): + cases = [ + KoswatScenario( + scenario_name="scen1", + d_h=0.62, + d_s=13.14, + d_p=50, + ), + KoswatScenario( + scenario_name="scen2", + d_h=0.62, + d_s=13.14, + d_p=50, + buiten_talud=3.00, + ) + ] From c367b7ef73612c74602078307892d50cc3f9fad9 Mon Sep 17 00:00:00 2001 From: Ardt Klapwijk Date: Wed, 6 Nov 2024 14:49:02 +0100 Subject: [PATCH 4/7] chore: fix bugs --- .../cofferdam/cofferdam_input_profile_calculation.py | 2 +- .../input_profile/soil/soil_input_profile_calculation.py | 2 +- tests/acceptance_scenarios/koswat_scenario_test_cases.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py index af7d609a..fc1fc46b 100644 --- a/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py @@ -127,7 +127,7 @@ def _calculate_new_input_profile( base_data, scenario ) _new_data.crest_width = base_data.crest_width # no widening of crest allowed - _new_data.waterside_ground_level = base_data.polderside_ground_level + _new_data.polderside_ground_level = base_data.polderside_ground_level _new_data.polderside_berm_width = ( base_data.polderside_berm_width ) # maintain current berm polderside diff --git a/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py index c6c292e1..92755ad9 100644 --- a/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/soil/soil_input_profile_calculation.py @@ -41,7 +41,7 @@ def _calculate_new_input_profile( _new_data.waterside_ground_level = base_data.waterside_ground_level _new_data.polderside_ground_level = base_data.polderside_ground_level _new_data.waterside_slope = scenario.waterside_slope - _new_data.waterside_ground_level = ( + _new_data.waterside_berm_height = ( self._calculate_soil_new_waterside_berm_height(base_data, scenario) ) _new_data.waterside_berm_width = base_data.waterside_berm_width diff --git a/tests/acceptance_scenarios/koswat_scenario_test_cases.py b/tests/acceptance_scenarios/koswat_scenario_test_cases.py index 7fc9c052..d3e623fb 100644 --- a/tests/acceptance_scenarios/koswat_scenario_test_cases.py +++ b/tests/acceptance_scenarios/koswat_scenario_test_cases.py @@ -451,7 +451,7 @@ class ScenarioCasesDijk4(CasesProtocol): d_s=10, d_p=50, waterside_slope=3.56, - ) + ), ] From 68991a7762a1f39b899f8e162f0dff271dfa8a26 Mon Sep 17 00:00:00 2001 From: Ardt Klapwijk Date: Wed, 6 Nov 2024 14:57:28 +0100 Subject: [PATCH 5/7] chore: fix vps bug --- .../vertical_piping_solution/vps_input_profile_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py index c274d750..77ae6126 100644 --- a/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/vertical_piping_solution/vps_input_profile_calculation.py @@ -74,7 +74,7 @@ def _calculate_new_input_profile( _dike_height_new = _new_data.crest_height - _new_data.polderside_ground_level _dikebase_heigth_new = ( - scenario.d_h * _new_data.polderside_slope + scenario.d_h * _new_data.waterside_slope + _new_data.crest_width + _dike_height_new * base_data.polderside_slope ) From 246930666231159eff0822ec553f2ee14a2e8983 Mon Sep 17 00:00:00 2001 From: Ardt Klapwijk Date: Wed, 6 Nov 2024 15:06:22 +0100 Subject: [PATCH 6/7] chore: fix cofferdam bug --- .../cofferdam/cofferdam_input_profile_calculation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py b/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py index fc1fc46b..5025f89f 100644 --- a/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py +++ b/koswat/dike_reinforcements/input_profile/cofferdam/cofferdam_input_profile_calculation.py @@ -67,7 +67,7 @@ def _calculate_new_polderside_slope( ) return _operand / _dividend - def _calculate_length_coffer_dam( + def _calculate_length_cofferdam( self, old_data: KoswatInputProfileProtocol, cofferdam_settings: KoswatCofferdamSettings, @@ -139,7 +139,7 @@ def _calculate_new_input_profile( ) _seepage_length = scenario.d_p - _new_data.construction_length = self._calculate_length_coffer_dam( + _new_data.construction_length = self._calculate_length_cofferdam( base_data, cofferdam_settings, _seepage_length, _new_data.crest_height ) _new_data.construction_type = self._determine_construction_type( From 93e31c3c3ef835c78f8a8ab574cc5c492abbf4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carles=20S=2E=20Soriano=20P=C3=A9rez?= Date: Fri, 8 Nov 2024 12:48:03 +0100 Subject: [PATCH 7/7] fix: 220 last row error in strategy buffering and clustering --- .../order_strategy/order_strategy.py | 10 +++-- .../order_strategy_buffering.py | 23 +++++----- .../order_strategy_clustering.py | 23 +++++----- .../test_order_strategy_buffering.py | 43 +++++++++++++++---- .../test_order_strategy_clustering.py | 29 ++++++------- tests/test_main.py | 40 +++++++++++++++++ 6 files changed, 114 insertions(+), 54 deletions(-) diff --git a/koswat/strategies/order_strategy/order_strategy.py b/koswat/strategies/order_strategy/order_strategy.py index 1b3b267d..cf788e19 100644 --- a/koswat/strategies/order_strategy/order_strategy.py +++ b/koswat/strategies/order_strategy/order_strategy.py @@ -162,11 +162,13 @@ def apply_strategy(self, strategy_input: StrategyInput) -> StrategyOutput: _strategy_reinforcements = self.get_strategy_reinforcements( strategy_input.strategy_locations, self.reinforcement_order ) - OrderStrategyBuffering.with_strategy( - self.reinforcement_order, strategy_input.reinforcement_min_buffer + OrderStrategyBuffering( + reinforcement_order=self.reinforcement_order, + reinforcement_min_buffer=strategy_input.reinforcement_min_buffer, ).apply(_strategy_reinforcements) - OrderStrategyClustering.with_strategy( - self.reinforcement_order, strategy_input.reinforcement_min_length + OrderStrategyClustering( + reinforcement_order=self.reinforcement_order, + reinforcement_min_length=strategy_input.reinforcement_min_length, ).apply(_strategy_reinforcements) return StrategyOutput( location_reinforcements=_strategy_reinforcements, diff --git a/koswat/strategies/order_strategy/order_strategy_buffering.py b/koswat/strategies/order_strategy/order_strategy_buffering.py index 4c8b193c..8dabba00 100644 --- a/koswat/strategies/order_strategy/order_strategy_buffering.py +++ b/koswat/strategies/order_strategy/order_strategy_buffering.py @@ -1,3 +1,5 @@ +from dataclasses import dataclass + from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( ReinforcementProfileProtocol, ) @@ -8,21 +10,18 @@ from koswat.strategies.strategy_step.strategy_step_enum import StrategyStepEnum +@dataclass class OrderStrategyBuffering(OrderStrategyBase): + """ + Applies buffering, through masks, to each location pre-assigned reinforcement. + The result of the `apply` method will be the locations with the best + reinforcement fit (lowest index from `reinforcement_order`) that fulfills the + `reinforcement_min_buffer` requirement. + """ + reinforcement_order: list[type[ReinforcementProfileProtocol]] reinforcement_min_buffer: float - @classmethod - def with_strategy( - cls, - reinforcement_order: list[type[ReinforcementProfileProtocol]], - reinforcement_min_buffer: float, - ): - _this = cls() - _this.reinforcement_order = reinforcement_order - _this.reinforcement_min_buffer = reinforcement_min_buffer - return _this - def _get_buffer_mask( self, location_reinforcements: list[StrategyLocationReinforcement] ) -> list[int]: @@ -42,7 +41,7 @@ def _get_buffer_mask( _upper_limit = int( min( _new_visited + self.reinforcement_min_buffer, - _len_location_reinforcements - 1, + _len_location_reinforcements, ) ) diff --git a/koswat/strategies/order_strategy/order_strategy_clustering.py b/koswat/strategies/order_strategy/order_strategy_clustering.py index ed330920..c3c5c75e 100644 --- a/koswat/strategies/order_strategy/order_strategy_clustering.py +++ b/koswat/strategies/order_strategy/order_strategy_clustering.py @@ -1,4 +1,5 @@ import logging +from dataclasses import dataclass from koswat.dike_reinforcements.reinforcement_profile.reinforcement_profile_protocol import ( ReinforcementProfileProtocol, @@ -10,21 +11,19 @@ ) +@dataclass class OrderStrategyClustering(OrderStrategyBase): + """ + Applies clustering, to the whole collection of reinforcements + (`location_reinforcements: list[StrategyLocationReinforcement]`). + The result of the `apply` method will be the locations with the best + reinforcement fit (lowest index from `reinforcement_order`) that fulfills the + `reinforcement_min_length` requirement. + """ + reinforcement_order: list[type[ReinforcementProfileProtocol]] reinforcement_min_length: float - @classmethod - def with_strategy( - cls, - reinforcement_order: list[type[ReinforcementProfileProtocol]], - reinforcement_min_length: float, - ): - _this = cls() - _this.reinforcement_order = reinforcement_order - _this.reinforcement_min_length = reinforcement_min_length - return _this - def _get_reinforcement_order_clusters( self, location_reinforcements: list[StrategyLocationReinforcement], @@ -60,7 +59,7 @@ def apply( _available_clusters = self._get_reinforcement_order_clusters( location_reinforcements ) - _reinforcements_order_max_idx = len(self.reinforcement_order) + _reinforcements_order_max_idx = len(self.reinforcement_order) - 1 for _target_idx, _reinforcement_type in enumerate( self.reinforcement_order[:-1] ): diff --git a/tests/strategies/order_strategy/test_order_strategy_buffering.py b/tests/strategies/order_strategy/test_order_strategy_buffering.py index 368eb66c..7da17cde 100644 --- a/tests/strategies/order_strategy/test_order_strategy_buffering.py +++ b/tests/strategies/order_strategy/test_order_strategy_buffering.py @@ -8,7 +8,10 @@ class TestOrderStrategyBuffering: def test_initialize(self): - _strategy = OrderStrategyBuffering() + _strategy = OrderStrategyBuffering( + reinforcement_order=[], + reinforcement_min_buffer=float("nan"), + ) assert isinstance(_strategy, OrderStrategyBuffering) assert isinstance(_strategy, OrderStrategyBase) @@ -19,11 +22,11 @@ def test_apply_given_docs_example(self, example_strategy_input: StrategyInput): example_strategy_input.strategy_locations, _reinforcement_order, ) - _strategy = OrderStrategyBuffering() - _strategy.reinforcement_order = _reinforcement_order - _strategy.reinforcement_min_buffer = ( - example_strategy_input.reinforcement_min_buffer + _strategy = OrderStrategyBuffering( + reinforcement_order=_reinforcement_order, + reinforcement_min_buffer=example_strategy_input.reinforcement_min_buffer, ) + _expected_result_idx = [0, 0, 3, 3, 3, 3, 0, 4, 4, 4] _expected_result = list( map(lambda x: _reinforcement_order[x], _expected_result_idx) @@ -47,10 +50,9 @@ def test__get_buffer_mask_given_docs_example( example_strategy_input.strategy_locations, _order_reinforcement, ) - _strategy = OrderStrategyBuffering() - _strategy.reinforcement_order = _order_reinforcement - _strategy.reinforcement_min_buffer = ( - example_strategy_input.reinforcement_min_buffer + _strategy = OrderStrategyBuffering( + reinforcement_order=_order_reinforcement, + reinforcement_min_buffer=example_strategy_input.reinforcement_min_buffer, ) # 2. Run test. @@ -58,3 +60,26 @@ def test__get_buffer_mask_given_docs_example( # 3. Verify expectations. assert _mask_result == [0, 0, 3, 3, 3, 3, 0, 4, 4, 4] + + def test__get_modified_example_last_location_gets_buffered( + self, example_strategy_input: StrategyInput + ): + """ + This test fixes the problem related to Koswat #220. + """ + # 1. Define test data. + _order_reinforcement = OrderStrategy.get_default_order_for_reinforcements() + _reinforcements = OrderStrategy.get_strategy_reinforcements( + example_strategy_input.strategy_locations, + _order_reinforcement, + )[:6] + _strategy = OrderStrategyBuffering( + reinforcement_order=_order_reinforcement, + reinforcement_min_buffer=3, + ) + + # 2. Run test. + _mask_result = _strategy._get_buffer_mask(_reinforcements) + + # 3. Verify expectations. + assert _mask_result == [3, 3, 3, 3, 3, 3] diff --git a/tests/strategies/order_strategy/test_order_strategy_clustering.py b/tests/strategies/order_strategy/test_order_strategy_clustering.py index e045be47..66ddbb2e 100644 --- a/tests/strategies/order_strategy/test_order_strategy_clustering.py +++ b/tests/strategies/order_strategy/test_order_strategy_clustering.py @@ -21,7 +21,9 @@ class TestOrderStrategyClustering: def test_initialize(self): - _strategy = OrderStrategyClustering() + _strategy = OrderStrategyClustering( + reinforcement_min_length=float("nan"), reinforcement_order=[] + ) assert isinstance(_strategy, OrderStrategyClustering) assert isinstance(_strategy, OrderStrategyBase) @@ -33,12 +35,9 @@ def test_apply_given_example_docs( ], ): # 1. Define test data. - _strategy = OrderStrategyClustering() - _strategy.reinforcement_min_length = ( - example_strategy_input.reinforcement_min_length - ) - _strategy.reinforcement_order = ( - OrderStrategy.get_default_order_for_reinforcements() + _strategy = OrderStrategyClustering( + reinforcement_min_length=example_strategy_input.reinforcement_min_length, + reinforcement_order=OrderStrategy.get_default_order_for_reinforcements(), ) # 2. Run test. @@ -65,10 +64,9 @@ def test_apply_given_cluster_with_lower_type( ], ): # 1. Define test data. - _strategy = OrderStrategyClustering() - _strategy.reinforcement_min_length = 2 - _strategy.reinforcement_order = ( - OrderStrategy.get_default_order_for_reinforcements() + _strategy = OrderStrategyClustering( + reinforcement_min_length=2, + reinforcement_order=OrderStrategy.get_default_order_for_reinforcements(), ) _location_reinforcements = example_location_reinforcements_with_buffering @@ -107,12 +105,9 @@ def test__get_reinforcement_order_clusters( ], ): # 1. Define test data. - _strategy = OrderStrategyClustering() - _strategy.reinforcement_min_length = ( - example_strategy_input.reinforcement_min_length - ) - _strategy.reinforcement_order = ( - OrderStrategy.get_default_order_for_reinforcements() + _strategy = OrderStrategyClustering( + reinforcement_min_length=example_strategy_input.reinforcement_min_length, + reinforcement_order=OrderStrategy.get_default_order_for_reinforcements(), ) # 2. Run test. diff --git a/tests/test_main.py b/tests/test_main.py index f0dd160f..f161d8da 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,11 +1,14 @@ import shutil from pathlib import Path +import pytest from click.testing import CliRunner from koswat import __main__ from tests import test_data, test_results +issues_tests = test_data.joinpath("issues") + class TestMain: def test_given_invalid_path_raises_value_error(self): @@ -47,3 +50,40 @@ def test_given_valid_input_succeeds(self): assert ( _log.read_text().find("ERROR") == -1 ), "ERROR found in the log, run was not succesful." + + @pytest.mark.skipif( + not any(issues_tests.glob("*")), + reason="Only meant to run locally with issue cases.", + ) + @pytest.mark.parametrize( + "ini_file_location", + [ + pytest.param( + issues_tests.joinpath("KOSWAT_220", "KOSWAT_analyse_RaLi.ini"), + id="Koswat 220", + ) + ], + ) + def test_given_issue_case(self, ini_file_location: Path): + # 1. Define test data. + assert ini_file_location.is_file() + # Ensure we have a clean results dir. + _log_dir = ini_file_location.parent.joinpath("log_output") + if _log_dir.exists(): + shutil.rmtree(_log_dir) + _log_dir.mkdir(parents=True) + + _cli_arg = f'--input_file "{ini_file_location}" --log_output "{_log_dir}"' + + # 2. Run test. + _run_result = CliRunner().invoke( + __main__.run_analysis, + _cli_arg, + ) + # 3. Verify final expectations. + assert _run_result.exit_code == 0 + _log: Path = next(_log_dir.glob("*.log"), None) + assert _log and _log.is_file(), "Log file was not generated." + assert ( + _log.read_text().find("ERROR") == -1 + ), "ERROR found in the log, run was not succesful."