Index: DamClients/DamPythonInterface/trunk/src/tests/test_stability_parameters.py
===================================================================
diff -u
--- DamClients/DamPythonInterface/trunk/src/tests/test_stability_parameters.py (revision 0)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_stability_parameters.py (revision 3486)
@@ -0,0 +1,92 @@
+# Copyright (C) Stichting Deltares 2021. All rights reserved.
+#
+# This file is part of the Dam Python Interface.
+#
+# The Dam Python Interface is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+# All names, logos, and references to "Deltares" are registered trademarks of
+# Stichting Deltares and remain full property of Stichting Deltares at all times.
+# All rights reserved.
+
+
+from dampythoninterface.stability_parameters import (
+ StabilityParameters,
+ SearchMethodType,
+ GridDeterminationType,
+ BishopTangentLinesDefinitionType,
+ UpliftVanTangentLinesDefinitionType,
+)
+from .utils import TestUtils
+
+import pytest
+from pathlib import Path
+from lxml import etree
+
+
+class TestStabiltyParameters:
+ @pytest.mark.unittest
+ def test_soil_can_be_initialized(self):
+ # initialize the stabilty parameters class
+ test_stabilty_parameters = StabilityParameters(
+ SearchMethod=SearchMethodType.GeneticAlgorithm,
+ GridDetermination=GridDeterminationType.Specified,
+ )
+ # check expectations
+ assert (
+ test_stabilty_parameters.SearchMethod == SearchMethodType.GeneticAlgorithm
+ )
+ assert (
+ test_stabilty_parameters.GridDetermination
+ == GridDeterminationType.Specified
+ )
+
+ @pytest.mark.unittest
+ def test_serialize(self):
+ # initialize the stabilty parameters class
+ test_stabilty_parameters = StabilityParameters(
+ SearchMethod=SearchMethodType.Calculationgrid,
+ GridDetermination=GridDeterminationType.Automatic,
+ BishopTangentLinesDefinition=BishopTangentLinesDefinitionType.OnBoundaryLines,
+ BishopTangentLinesDistance=0.25,
+ BishopGridVerticalPointsCount=10,
+ BishopGridVerticalPointsDistance=2.5,
+ BishopGridHorizontalPointsCount=10,
+ BishopGridHorizontalPointsDistance=2.5,
+ UpliftVanGridLeftVerticalPointsCount=36,
+ UpliftVanGridLeftVerticalPointsDistance=2,
+ UpliftVanGridLeftHorizontalPointsCount=14,
+ UpliftVanGridLeftHorizontalPointsDistance=2,
+ UpliftVanGridRightVerticalPointsCount=3,
+ UpliftVanGridRightVerticalPointsDistance=2,
+ UpliftVanGridRightHorizontalPointsCount=6,
+ UpliftVanGridRightHorizontalPointsDistance=2,
+ UpliftVanTangentLinesDefinition=UpliftVanTangentLinesDefinitionType.OnBoundaryLines,
+ UpliftVanTangentLinesDistance=0.25,
+ )
+ # run test
+ root = test_stabilty_parameters.serialize()
+ # test output
+ xml_output = Path(
+ TestUtils.get_output_test_data_dir(""), "test_stabilty_parameters.xml"
+ )
+ tree = etree.ElementTree(root)
+ tree.write(str(xml_output), pretty_print=True)
+ # get template file
+ xml_test_data = Path(
+ TestUtils.get_test_data_dir("", "test_data"),
+ "test_stabilty_parameters.xml",
+ )
+ # Line by line comparison
+ for output_file, test_file in zip(open(xml_output), open(xml_test_data)):
+ assert output_file.strip() == test_file.strip()
Index: DamClients/DamPythonInterface/trunk/doc/source/dev/input.rst
===================================================================
diff -u -r3484 -r3486
--- DamClients/DamPythonInterface/trunk/doc/source/dev/input.rst (.../input.rst) (revision 3484)
+++ DamClients/DamPythonInterface/trunk/doc/source/dev/input.rst (.../input.rst) (revision 3486)
@@ -26,4 +26,13 @@
.. automodule:: dampythoninterface.soil
:members:
+ :undoc-members:
+
+
+Stability Parameters
+-------------------
+
+
+.. automodule:: dampythoninterface.stability_parameters
+ :members:
:undoc-members:
\ No newline at end of file
Index: DamClients/DamPythonInterface/trunk/src/tests/test_input.py
===================================================================
diff -u -r3484 -r3486
--- DamClients/DamPythonInterface/trunk/src/tests/test_input.py (.../test_input.py) (revision 3484)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_input.py (.../test_input.py) (revision 3486)
@@ -27,6 +27,12 @@
from dampythoninterface.input import DamInput
from dampythoninterface.surface_line import SurfaceLine, PointTypeEnum, Point
from dampythoninterface.soil import Soil
+from dampythoninterface.stability_parameters import (
+ SearchMethodType,
+ StabilityParameters,
+ BishopTangentLinesDefinitionType,
+ GridDeterminationType,
+)
from .utils import TestUtils
@@ -64,9 +70,23 @@
BelowPhreaticLevel=20,
)
soils = [soil_1, soil_2]
-
+ # Create stability parameters
+ test_stabilty_parameters = StabilityParameters(
+ SearchMethod=SearchMethodType.Calculationgrid,
+ GridDetermination=GridDeterminationType.Automatic,
+ BishopTangentLinesDefinition=BishopTangentLinesDefinitionType.OnBoundaryLines,
+ BishopTangentLinesDistance=0.25,
+ BishopGridVerticalPointsCount=10,
+ BishopGridVerticalPointsDistance=2.5,
+ BishopGridHorizontalPointsCount=10,
+ BishopGridHorizontalPointsDistance=2.5,
+ )
# Make input class
- model = DamInput(SurfaceLines=list_of_surface_lines, Soils=soils)
+ model = DamInput(
+ SurfaceLines=list_of_surface_lines,
+ Soils=soils,
+ StabilityParameters=test_stabilty_parameters,
+ )
assert model
# run test
xml_output = Path(
Index: DamClients/DamPythonInterface/trunk/src/dampythoninterface/input.py
===================================================================
diff -u -r3484 -r3486
--- DamClients/DamPythonInterface/trunk/src/dampythoninterface/input.py (.../input.py) (revision 3484)
+++ DamClients/DamPythonInterface/trunk/src/dampythoninterface/input.py (.../input.py) (revision 3486)
@@ -27,6 +27,7 @@
from .surface_line import SurfaceLine
from .soil import Soil
from .base_class import BaseDataClass
+from .stability_parameters import StabilityParameters
class DamInput(BaseDataClass):
@@ -39,6 +40,7 @@
SurfaceLines: List[SurfaceLine] = []
Soils: List[Soil] = []
+ StabilityParameters: StabilityParameters
def ExportToXml(self, xml_file: Path) -> None:
"""
@@ -56,6 +58,8 @@
for soil in self.Soils:
soils_root.append(soil.serialize())
input_root.append(soils_root)
+ # add stability parameters to input root
+ input_root.append(self.StabilityParameters.serialize())
# Construct the whole input tree
tree = et.ElementTree(input_root)
tree.write(str(xml_file), pretty_print=True)
Index: DamClients/DamPythonInterface/trunk/src/tests/test_output/test_full_output.xml
===================================================================
diff -u -r3484 -r3486
--- DamClients/DamPythonInterface/trunk/src/tests/test_output/test_full_output.xml (.../test_full_output.xml) (revision 3484)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_output/test_full_output.xml (.../test_full_output.xml) (revision 3486)
@@ -25,4 +25,5 @@
+
Index: DamClients/DamPythonInterface/trunk/src/tests/test_data/test_stabilty_parameters.xml
===================================================================
diff -u
--- DamClients/DamPythonInterface/trunk/src/tests/test_data/test_stabilty_parameters.xml (revision 0)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_data/test_stabilty_parameters.xml (revision 3486)
@@ -0,0 +1 @@
+
Index: DamClients/DamPythonInterface/trunk/src/dampythoninterface/stability_parameters.py
===================================================================
diff -u
--- DamClients/DamPythonInterface/trunk/src/dampythoninterface/stability_parameters.py (revision 0)
+++ DamClients/DamPythonInterface/trunk/src/dampythoninterface/stability_parameters.py (revision 3486)
@@ -0,0 +1,110 @@
+# Copyright (C) Stichting Deltares 2021. All rights reserved.
+#
+# This file is part of the Dam Python Interface.
+#
+# The Dam Python Interface is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+# All names, logos, and references to "Deltares" are registered trademarks of
+# Stichting Deltares and remain full property of Stichting Deltares at all times.
+# All rights reserved.
+
+from .base_class import BaseDataClass
+
+from typing import Optional
+from enum import IntEnum
+import lxml.etree as et
+
+
+class SearchMethodType(IntEnum):
+ Calculationgrid = 0
+ GeneticAlgorithm = 1
+
+
+class GridDeterminationType(IntEnum):
+ Automatic = 0
+ Specified = 1
+
+
+class BishopTangentLinesDefinitionType(IntEnum):
+ OnBoundaryLines = 0
+ Specified = 1
+
+
+class UpliftVanTangentLinesDefinitionType(IntEnum):
+ OnBoundaryLines = 0
+ Specified = 1
+
+
+class StabilityParameters(BaseDataClass):
+ """
+ Dataclass that contains stability parameters.
+
+ :param SearchMethod: Type of search method for stability
+ :param GridDetermination: Type of grid determination method
+ :param BishopTangentLinesDefinition: Types of tangent lines for the Bishop model
+ :param BishopTangentLinesDistance: Distance between tangent lines
+ :param BishopGridVerticalPointsCount: Number of points contained on the Bishop grid on the vertical direction
+ :param BishopGridVerticalPointsDistance: Distance of points contained on the Bishop grid on the vertical direction
+ :param BishopGridHorizontalPointsCount: Number of points contained on the Bishop grid on the horizontal direction
+ :param BishopGridHorizontalPointsDistance: Distance of points contained on the Bishop grid on the horizontal direction
+ :param UpliftVanGridLeftVerticalPointsCount: Number of point for the left side of the Uplift van Grid model on the vertical direction
+ :param UpliftVanGridLeftVerticalPointsDistance: Distance of points for the left side of the Uplift van Grid model on the vertical direction
+ :param UpliftVanGridLeftHorizontalPointsCount: Number of point for the left side of the Uplift van Grid model on the horizontal direction
+ :param UpliftVanGridLeftHorizontalPointsDistance: Distance of points for the left side of the Uplift van Grid model on the horizontal direction
+ :param UpliftVanGridRightVerticalPointsCount: Number of point for the right side of the Uplift van Grid model on the vertical direction
+ :param UpliftVanGridRightVerticalPointsDistance :Distance of points for the right side of the Uplift van Grid model on the vertical direction
+ :param UpliftVanGridRightHorizontalPointsCount: Number of point for the right side of the Uplift van Grid model on the horizontal direction
+ :param UpliftVanGridRightHorizontalPointsDistance: Number of point for the right side of the Uplift van Grid model on the vertical direction
+ :param UpliftVanTangentLinesDefinition: Types of tangent lines for the Uplift van Grid model
+ :param UpliftVanTangentLinesDistance: Distance between tangent lines for the Uplift van Grid model
+
+ """
+
+ SearchMethod: SearchMethodType = SearchMethodType.Calculationgrid
+ GridDetermination: GridDeterminationType = GridDeterminationType.Automatic
+ BishopTangentLinesDefinition: Optional[
+ BishopTangentLinesDefinitionType
+ ] = BishopTangentLinesDefinitionType.OnBoundaryLines
+ BishopTangentLinesDistance: Optional[float] = None
+ BishopGridVerticalPointsCount: Optional[int] = None
+ BishopGridVerticalPointsDistance: Optional[float] = None
+ BishopGridHorizontalPointsCount: Optional[int] = None
+ BishopGridHorizontalPointsDistance: Optional[float] = None
+ UpliftVanGridLeftVerticalPointsCount: Optional[int] = None
+ UpliftVanGridLeftVerticalPointsDistance: Optional[float] = None
+ UpliftVanGridLeftHorizontalPointsCount: Optional[int] = None
+ UpliftVanGridLeftHorizontalPointsDistance: Optional[float] = None
+ UpliftVanGridRightVerticalPointsCount: Optional[int] = None
+ UpliftVanGridRightVerticalPointsDistance: Optional[float] = None
+ UpliftVanGridRightHorizontalPointsCount: Optional[int] = None
+ UpliftVanGridRightHorizontalPointsDistance: Optional[float] = None
+ UpliftVanTangentLinesDefinition: Optional[
+ UpliftVanTangentLinesDefinitionType
+ ] = UpliftVanTangentLinesDefinitionType.OnBoundaryLines
+ UpliftVanTangentLinesDistance: Optional[float] = None
+
+ def serialize(self):
+ """
+ Function that serializes the StabilityParameters class.
+ """
+ stability_parameters_root = et.Element("StabilityParameters")
+ dictionary_of_values = self.dict()
+ for field, value in dictionary_of_values.items():
+ if value is None:
+ stability_parameters_root.set(field, str(1))
+ elif isinstance(value, IntEnum):
+ stability_parameters_root.set(field, str(value.value))
+ else:
+ stability_parameters_root.set(field, str(value))
+ return stability_parameters_root