Index: DamClients/DamPythonInterface/trunk/src/tests/test_input.py
===================================================================
diff -u -r3486 -r3487
--- DamClients/DamPythonInterface/trunk/src/tests/test_input.py (.../test_input.py) (revision 3486)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_input.py (.../test_input.py) (revision 3487)
@@ -63,11 +63,13 @@
Name="soil 1",
AbovePhreaticLevel=17,
BelowPhreaticLevel=17,
+ IsAquifer=True,
)
soil_2 = Soil(
Name="soil 2",
AbovePhreaticLevel=20,
BelowPhreaticLevel=20,
+ IsAquifer=False,
)
soils = [soil_1, soil_2]
# Create stability parameters
Index: DamClients/DamPythonInterface/trunk/src/tests/test_output/test_full_output.xml
===================================================================
diff -u -r3486 -r3487
--- DamClients/DamPythonInterface/trunk/src/tests/test_output/test_full_output.xml (.../test_full_output.xml) (revision 3486)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_output/test_full_output.xml (.../test_full_output.xml) (revision 3487)
@@ -26,4 +26,8 @@
+
+
+
+
Index: DamClients/DamPythonInterface/trunk/src/tests/test_soil.py
===================================================================
diff -u -r3484 -r3487
--- DamClients/DamPythonInterface/trunk/src/tests/test_soil.py (.../test_soil.py) (revision 3484)
+++ DamClients/DamPythonInterface/trunk/src/tests/test_soil.py (.../test_soil.py) (revision 3487)
@@ -32,14 +32,19 @@
@pytest.mark.unittest
def test_soil_can_be_initialized(self):
# initialize the soil model class
- test_soil = Soil(Name="new soil", AbovePhreaticLevel=18, BelowPhreaticLevel=20)
+ test_soil = Soil(
+ Name="new soil",
+ AbovePhreaticLevel=18,
+ BelowPhreaticLevel=20,
+ IsAquifer=True,
+ )
# check expectations
assert test_soil.Name == "new soil"
assert test_soil.AbovePhreaticLevel == 18
assert test_soil.BelowPhreaticLevel == 20
@pytest.mark.unittest
- def test_serialize(self):
+ def test_serialize_soil(self):
# initialize the soil model class
test_soil = Soil(
Name="Dijkmateriaal",
@@ -58,9 +63,10 @@
RRatio=1,
StrengthIncreaseExponent=0.7,
RatioCuPc=0.22,
+ IsAquifer=True,
)
# run test
- root = test_soil.serialize()
+ root = test_soil.serialize_soil()
# test output
xml_output = Path(
TestUtils.get_output_test_data_dir(""), "test_serialize_soil.xml"
@@ -75,3 +81,27 @@
# 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()
+
+ @pytest.mark.unittest
+ def test_serialize_aquifer_soil(self):
+ # initialize the soil model class
+ test_soil = Soil(
+ Name="Aquifer soil",
+ IsAquifer=True,
+ )
+ # run test
+ root = test_soil.serialize_aquifer_soil()
+ # test output
+ xml_output = Path(
+ TestUtils.get_output_test_data_dir(""), "test_serialize_aquifer_soil.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_serialize_aquifer_soil.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/src/dampythoninterface/input.py
===================================================================
diff -u -r3486 -r3487
--- DamClients/DamPythonInterface/trunk/src/dampythoninterface/input.py (.../input.py) (revision 3486)
+++ DamClients/DamPythonInterface/trunk/src/dampythoninterface/input.py (.../input.py) (revision 3487)
@@ -55,11 +55,15 @@
input_root.append(SurfaceLines_root)
# create soils element
soils_root = et.Element("Soils")
+ soils_aquifer = et.Element("AquiferSoils")
for soil in self.Soils:
- soils_root.append(soil.serialize())
+ soils_root.append(soil.serialize_soil())
+ soils_aquifer.append(soil.serialize_aquifer_soil())
input_root.append(soils_root)
# add stability parameters to input root
input_root.append(self.StabilityParameters.serialize())
+ # append soil aquifers
+ input_root.append(soils_aquifer)
# Construct the whole input tree
tree = et.ElementTree(input_root)
tree.write(str(xml_file), pretty_print=True)
Index: DamClients/DamPythonInterface/trunk/src/dampythoninterface/soil.py
===================================================================
diff -u -r3485 -r3487
--- DamClients/DamPythonInterface/trunk/src/dampythoninterface/soil.py (.../soil.py) (revision 3485)
+++ DamClients/DamPythonInterface/trunk/src/dampythoninterface/soil.py (.../soil.py) (revision 3487)
@@ -71,6 +71,7 @@
:param RRatio:
:param StrengthIncreaseExponent:
:param RatioCuPc:
+ :param IsAquifer: Is the soil defined as an aquifer
"""
Name: str
@@ -92,20 +93,34 @@
RRatio: Optional[float] = None
StrengthIncreaseExponent: Optional[float] = None
RatioCuPc: Optional[float] = None
+ IsAquifer: bool = False
- def serialize(self):
+ def serialize_soil(self):
"""
Function that serializes the Soil class.
"""
soil_root = et.Element("Soil")
dictionary_of_values = self.dict()
for field, value in dictionary_of_values.items():
- if value is None:
- soil_root.set(field, str(1))
- elif isinstance(value, Enum):
- soil_root.set(field, value.value)
- elif isinstance(value, bool):
- soil_root.set(field, str(value).lower())
- else:
- soil_root.set(field, str(value))
+ if not (field == "IsAquifer"):
+ if value is None:
+ soil_root.set(field, str(1))
+ elif isinstance(value, Enum):
+ soil_root.set(field, value.value)
+ elif isinstance(value, bool):
+ soil_root.set(field, str(value).lower())
+ else:
+ soil_root.set(field, str(value))
return soil_root
+
+ def serialize_aquifer_soil(self):
+ """
+ Function that serializes the AquiferSoil part of the class.
+ """
+ aquifer_soil_root = et.Element("AquiferSoil")
+ dictionary_of_values = self.dict()
+ aquifer_soil_root.set("Soilname", dictionary_of_values.get("Name"))
+ aquifer_soil_root.set(
+ "IsAquifer", str(dictionary_of_values.get("IsAquifer")).lower()
+ )
+ return aquifer_soil_root