Skip to content

Commit

Permalink
feat: extend calculations for having berm as part of input profile (#218
Browse files Browse the repository at this point in the history
)

* feat: 181 extend calculations for having berm as part of input profile

Improve input profile calculations to accommodate dikes with existing berms at polderside

* 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.

* feat: 181 extend calculations for having berm as part of input profile

Update scenario cases and base profiles

* chore: fix bugs

* chore: fix vps bug

* chore: fix cofferdam bug

* fix: 220 last row error in strategy buffering and clustering

* feat: 181 extend calculations for having berm as part of input profile

Prevent error at export of shapefile

* feat: 181 extend calculations for having berm as part of input profile

Include dikesection names in export

* feat: 181 extend calculations for having berm as part of input profile

Use unbuild ground price for VPS

* feat: 181 extend calculations for having berm as part of input profile

Enhancements for stability wall input profile

* #181 test cases

Added test cases to reproduce bugs #233 and #235

* test: update reference data

* chore: Modified layers wrapper builder to consider the exceptional case from these bugs

* test: Updated reference data

* chore: Removed logic as it's not yet accurate

* test updated reference data

* test: Removed wrongfully added test data

* chore: Removed file that should have not been committed

* test: Removed accidentally committed issue test case

* ci: Ignored `test_data/issues` from version control as they are only meant to be run locally

* ci: Modified release template to have a different label

* test: Updated scenario test cases

* Squashed commit of the following:

commit d8529ac
Author: Ardt Klapwijk <[email protected]>
Date:   Mon Dec 16 15:38:54 2024 +0100

    test: update reference data

commit da17886
Merge: 5710c6f 2d92a4c
Author: Ardt Klapwijk <[email protected]>
Date:   Mon Dec 16 15:34:50 2024 +0100

    Merge branch 'master' into feat/181-extend-calculations-for-having-berm-as-part-of-input-profile

commit 5710c6f
Author: Peter de Grave <[email protected]>
Date:   Mon Dec 16 11:08:39 2024 +0100

    #181 test cases

    Added test cases to reproduce bugs #233 and #235

commit 5083940
Author: peterdgr <[email protected]>
Date:   Mon Dec 9 15:35:27 2024 +0100

    feat: 181 extend calculations for having berm as part of input profile

    Enhancements for stability wall input profile

commit 044f4d9
Author: peterdgr <[email protected]>
Date:   Mon Dec 9 15:34:56 2024 +0100

    feat: 181 extend calculations for having berm as part of input profile

    Use unbuild ground price for VPS

commit 78e5459
Author: peterdgr <[email protected]>
Date:   Mon Dec 9 15:34:23 2024 +0100

    feat: 181 extend calculations for having berm as part of input profile

    Include dikesection names in export

commit 850914a
Author: peterdgr <[email protected]>
Date:   Mon Dec 9 15:33:19 2024 +0100

    feat: 181 extend calculations for having berm as part of input profile

    Prevent error at export of shapefile

commit f393ff4
Merge: e60ed60 3ab9c75
Author: Ardt Klapwijk <[email protected]>
Date:   Wed Nov 13 11:36:15 2024 +0100

    Merge branch 'master' into feat/181-extend-calculations-for-having-berm-as-part-of-input-profile

commit e60ed60
Merge: 356764e 5450a2c
Author: Ardt Klapwijk <[email protected]>
Date:   Wed Nov 13 10:56:49 2024 +0100

    Merge branch 'master' into feat/181-extend-calculations-for-having-berm-as-part-of-input-profile

commit 356764e
Merge: fbbe933 d942e77
Author: Carles S. Soriano Pérez <[email protected]>
Date:   Mon Nov 11 11:44:57 2024 +0100

    Merge branch 'master' into feat/181-extend-calculations-for-having-berm-as-part-of-input-profile

commit fbbe933
Merge: 93e31c3 b05ad5e
Author: Carles S. Soriano Pérez <[email protected]>
Date:   Mon Nov 11 09:22:17 2024 +0100

    Merge branch 'master' into feat/181-extend-calculations-for-having-berm-as-part-of-input-profile

commit 93e31c3
Author: Carles S. Soriano Pérez <[email protected]>
Date:   Fri Nov 8 12:48:03 2024 +0100

    fix: 220 last row error in strategy buffering and clustering

commit 2469306
Author: Ardt Klapwijk <[email protected]>
Date:   Wed Nov 6 15:06:22 2024 +0100

    chore: fix cofferdam bug

commit 68991a7
Author: Ardt Klapwijk <[email protected]>
Date:   Wed Nov 6 14:57:28 2024 +0100

    chore: fix vps bug

commit c367b7e
Author: Ardt Klapwijk <[email protected]>
Date:   Wed Nov 6 14:49:02 2024 +0100

    chore: fix bugs

commit 36c3e42
Merge: 56816c8 b672c7b
Author: Ardt Klapwijk <[email protected]>
Date:   Wed Nov 6 12:25:29 2024 +0100

    Merge branch 'master' into feat/181-extend-calculations-for-having-berm-as-part-of-input-profile

commit 56816c8
Author: peterdgr <[email protected]>
Date:   Wed Nov 6 11:11:28 2024 +0100

    feat: 181 extend calculations for having berm as part of input profile

    Update scenario cases and base profiles

commit 16b8dda
Author: peterdgr <[email protected]>
Date:   Fri Nov 1 09:49:47 2024 +0100

    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.

commit accfc5b
Author: peterdgr <[email protected]>
Date:   Wed Oct 30 17:53:24 2024 +0100

    feat: 181 extend calculations for having berm as part of input profile

    Improve input profile calculations to accommodate dikes with existing berms at polderside

* chore: Removed unnecessary file

* chore: Simplified (and improved) how to determine the added geometry

* test: Added new reference data

* chore: Processed review remarks

* feat: 181 fix unittest and improve code (sub) (#241)

---------

Co-authored-by: peterdgr <[email protected]>
Co-authored-by: Carles S. Soriano Pérez <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent cb597fd commit baa433d
Show file tree
Hide file tree
Showing 222 changed files with 2,880 additions and 1,310 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ coverage.xml

# Koswat ignore
tests/test_results/
tests/test_data/issues/
site/
*.log

Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class KoswatSoilSettings(KoswatConfigProtocol):

soil_surtax_factor: SurtaxFactorEnum = SurtaxFactorEnum.NORMAAL
land_purchase_surtax_factor: SurtaxFactorEnum = SurtaxFactorEnum.NORMAAL
min_berm_height: float = 0
max_berm_height_factor: float = 0
factor_increase_berm_height: float = 0
min_berm_height: float = 0.5
max_berm_height_factor: float = 0.4
factor_increase_berm_height: float = 0.05

def is_valid(self) -> bool:
return True
2 changes: 1 addition & 1 deletion koswat/dike/profile/koswat_input_profile_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class KoswatInputProfileBase(KoswatInputProfileProtocol):
waterside_berm_width: float = math.nan
crest_height: float = math.nan
crest_width: float = math.nan
polderside_ground_level: float = math.nan
polderside_slope: float = math.nan
polderside_berm_height: float = math.nan
polderside_berm_width: float = math.nan
polderside_ground_level: float = math.nan
ground_price_builtup: float = math.nan
ground_price_unbuilt: float = math.nan
factor_settlement: float = math.nan
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from dataclasses import asdict

from koswat.configuration.settings import KoswatScenario
from koswat.configuration.settings.koswat_general_settings import ConstructionTypeEnum
from koswat.configuration.settings.reinforcements.koswat_cofferdam_settings import (
Expand All @@ -8,16 +10,22 @@
)
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.input_profile_enum import InputProfileEnum
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.reinforcement_profile.berm_calculator.berm_calculated_factors import (
BermCalculatedFactors,
)
from koswat.dike_reinforcements.reinforcement_profile.berm_calculator.berm_calculator_factory import (
BermCalculatorFactory,
)


class CofferdamInputProfileCalculation(
Expand All @@ -32,64 +40,22 @@ def __init__(self) -> None:
self.base_profile = None
self.scenario = None

def _calculate_new_crest_height(
self, base_data: KoswatInputProfileBase, scenario: KoswatScenario
) -> float:
return base_data.crest_height + scenario.d_h

def _calculate_new_polderside_slope(
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.polderside_slope * (
base_data.crest_height - base_data.polderside_ground_level
)
_operand = base_data.crest_width + _mid_operand - scenario.crest_width
_dividend = (
base_data.crest_height - base_data.polderside_ground_level + scenario.d_h
)
return _operand / _dividend

def _calculate_new_waterside_slope(
self, base_data: KoswatInputProfileBase, scenario: KoswatScenario
) -> float:
"""
Kruin_Hoogte_Oud*Buiten_Talud_Oud
/(Kruin_Hoogte_Oud+dH)
"""
_operand = (
base_data.crest_height - base_data.waterside_ground_level
) * base_data.waterside_slope
_dividend = (
base_data.crest_height - base_data.waterside_ground_level + scenario.d_h
)
return _operand / _dividend

@staticmethod
def _calculate_length_cofferdam(
self,
old_data: KoswatInputProfileProtocol,
cofferdam_settings: KoswatCofferdamSettings,
soil_polderside_berm_width: float,
seepage_length: float,
new_crest_height: float,
) -> float:
"""
Identical to calculation of Stability wall
"""
if soil_polderside_berm_width == 0:
_length_stability = (new_crest_height - 0.5) - (old_data.pleistocene - 1.0)
if seepage_length == 0.0:
# Length of wall is not determined by piping.
_length_piping = 0.0
else:
_length_piping = (
(soil_polderside_berm_width / 6)
+ (new_crest_height - 0.5)
- old_data.aquifer
(seepage_length / 6.0) + (new_crest_height - 0.5) - old_data.aquifer
)
_length_stability = (new_crest_height - 0.5) - (old_data.pleistocene - 1)

return round(
min(
max(
Expand All @@ -102,64 +68,72 @@ def _calculate_length_cofferdam(
1,
)

@staticmethod
def _determine_construction_type(
self,
construction_length: float,
) -> ConstructionTypeEnum | None:
if construction_length == 0:
if construction_length == 0.0:
return None
else:
return ConstructionTypeEnum.KISTDAM

def _calculate_new_input_profile(
self,
base_data: KoswatInputProfileBase,
cofferdam_settings: KoswatCofferdamSettings,
scenario: KoswatScenario,
) -> CofferDamInputProfile:
_new_data = CofferDamInputProfile()
_new_data.dike_section = base_data.dike_section
_new_data.waterside_ground_level = base_data.waterside_ground_level
_new_data.waterside_slope = self._calculate_new_waterside_slope(
base_data, scenario
)
_new_data.waterside_berm_height = base_data.waterside_berm_height
_new_data.waterside_berm_width = base_data.waterside_berm_width
_new_data.crest_height = self._calculate_new_crest_height(base_data, scenario)
_new_data.crest_width = scenario.crest_width
_new_data.polderside_slope = self._calculate_new_polderside_slope(
base_data, scenario
)
_new_data.polderside_berm_width = 0
_new_data.polderside_berm_height = base_data.polderside_ground_level
_new_data.polderside_ground_level = base_data.polderside_ground_level
_soil_polderside_berm_width = self._calculate_soil_polderside_berm_width(
base_data, _new_data, scenario
@staticmethod
def _calculate_new_waterside_slope(
base_data: KoswatInputProfileProtocol, scenario: KoswatScenario
) -> float:
_operand = (
base_data.crest_height - base_data.waterside_ground_level
) * base_data.waterside_slope
_dividend = (
base_data.crest_height - base_data.waterside_ground_level + scenario.d_h
)
_new_data.ground_price_builtup = base_data.ground_price_builtup
_new_data.ground_price_unbuilt = base_data.ground_price_unbuilt
_new_data.factor_settlement = base_data.factor_settlement
_new_data.pleistocene = base_data.pleistocene
_new_data.aquifer = base_data.aquifer
_new_data.construction_length = self._calculate_length_cofferdam(
base_data,
cofferdam_settings,
_soil_polderside_berm_width,
_new_data.crest_height,
return _operand / _dividend

def build(self) -> CofferDamInputProfile:
_reinforced_data = self._get_reinforcement_profile(
CofferDamInputProfile, self.base_profile.input_data, self.scenario
)
_new_data.construction_type = self._determine_construction_type(
_new_data.construction_length
assert isinstance(_reinforced_data, CofferDamInputProfile)

# Berm calculation
_calculated_factors = BermCalculatedFactors.from_calculation_input(
self.base_profile.input_data,
_reinforced_data,
self.reinforcement_settings,
self.scenario,
)
_new_data.soil_surtax_factor = cofferdam_settings.soil_surtax_factor
_new_data.constructive_surtax_factor = (
cofferdam_settings.constructive_surtax_factor
_polderside_berm_calculator = BermCalculatorFactory.get_berm_calculator(
InputProfileEnum.COFFERDAM, _calculated_factors
)
_new_data.land_purchase_surtax_factor = None
return _new_data
(
_reinforced_data.polderside_berm_width,
_reinforced_data.polderside_berm_height,
_reinforced_data.polderside_slope,
) = asdict(
_polderside_berm_calculator.calculate(
self.base_profile.input_data, _reinforced_data
)
).values()

def build(self) -> CofferDamInputProfile:
return self._calculate_new_input_profile(
# Construction calculations
_seepage_length = self.scenario.d_p
_reinforced_data.construction_length = self._calculate_length_cofferdam(
self.base_profile.input_data,
self.reinforcement_settings.cofferdam_settings,
self.scenario,
_seepage_length,
_reinforced_data.crest_height,
)
_reinforced_data.construction_type = self._determine_construction_type(
_reinforced_data.construction_length
)

# Settings
_reinforced_data.soil_surtax_factor = (
self.reinforcement_settings.cofferdam_settings.soil_surtax_factor
)
_reinforced_data.constructive_surtax_factor = (
self.reinforcement_settings.cofferdam_settings.constructive_surtax_factor
)
_reinforced_data.land_purchase_surtax_factor = None

return _reinforced_data
14 changes: 14 additions & 0 deletions koswat/dike_reinforcements/input_profile/input_profile_enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from enum import Enum


class InputProfileEnum(Enum):
"""
Enum class for input profiles.
"""

NONE = 0
SOIL = 1
VPS = 2
PIPING_WALL = 3
STABILITY_WALL = 4
COFFERDAM = 5
Loading

0 comments on commit baa433d

Please sign in to comment.