Index: DamClients/DamPythonInterface/trunk/doc/source/tutorial.rst =================================================================== diff -u -r3531 -r3539 --- DamClients/DamPythonInterface/trunk/doc/source/tutorial.rst (.../tutorial.rst) (revision 3531) +++ DamClients/DamPythonInterface/trunk/doc/source/tutorial.rst (.../tutorial.rst) (revision 3539) @@ -1,22 +1,36 @@ Tutorial: Setting up a DAM project from pre-existing csv files ============================================================== +Introduction +------------ +This tutorial is an example of how a user would go about creating and running a DAM project from the python API. +In this case the user uses a collection of csv files that would be normally be used as an input of the DAM UI. +These csv files are: +* characteristicpoints.csv: download from :download:`here <../_downloads/characteristicpoints.csv>`. +* locations.csv: download from :download:`here <../_downloads/locations.csv>`. +* scenarios.csv: download from :download:`here <../_downloads/scenarios.csv>`. +* segments.csv: download from :download:`here <../_downloads/segments.csv>`. +* soilmaterials.csv: download from :download:`here <../_downloads/soilmaterials.csv>`. +* soilprofiles.csv: download from :download:`here <../_downloads/soilprofiles.csv>`. +* surfacelines.csv: download from :download:`here <../_downloads/surfacelines.csv>` . + + .. include:: tutorial_sections/segment_csv_tutorial.rst The full code snippet for reading the segment.csv can be found in :doc:`this document. ` .. include:: tutorial_sections/surface_lines_csv_tutorial.rst -The full code snippet for reading the csvs can be found in :doc:`this document. ` +The full code snippet for reading the csv files can be found in :doc:`this document. ` .. include:: tutorial_sections/soil_profile_1d_csv_tutorial.rst -The full code snippet for reading the csvs can be found in :doc:`this document. ` +The full code snippet for reading the csv files can be found in :doc:`this document. ` .. include:: tutorial_sections/locations_csv_tutorial.rst -The full code snippet for reading the csvs can be found in :doc:`this document. ` +The full code snippet for reading the csv files can be found in :doc:`this document. ` .. include:: tutorial_sections/soil_materials_tutorial.rst Index: DamClients/DamPythonInterface/trunk/src/tests/test_dampythonframework.py =================================================================== diff -u -r3536 -r3539 --- DamClients/DamPythonInterface/trunk/src/tests/test_dampythonframework.py (.../test_dampythonframework.py) (revision 3536) +++ DamClients/DamPythonInterface/trunk/src/tests/test_dampythonframework.py (.../test_dampythonframework.py) (revision 3539) @@ -26,6 +26,7 @@ import pandas as pd from pathlib import Path import pytest +import xml.etree.cElementTree as et class TestDamPythonInterface: @@ -200,7 +201,7 @@ profile_list.append( dpi.SoilProfile1D( Name=str(profile_id), - BottomLevel=-30, + BottomLevel=-10, Layers1D=list_of_1D_layers, ) ) @@ -269,8 +270,8 @@ NewWidthDitchBottom=row["NewWidthDitchBottom"], NewDepthDitch=row["NewDepthDitch"], NewSlopeAngleDitch=row["NewSlopeAngleDitch"], - RedesignDikeHeight=0, - RedesignDikeShoulder=0, + RedesignDikeHeight=True, + RedesignDikeShoulder=True, SlopeAdaptionStartCotangent=1, SlopeAdaptionEndCotangent=1, SlopeAdaptionStepCotangent=1, @@ -288,7 +289,7 @@ DampingFactorPl4=row["dempingsfactor_pl4"], PhreaticLineCreationMethod=row["PLLineCreationMethod"], PenetrationLength=0, - SlopeDampingFactor=1, + SlopeDampingFactor=0, IntrusionVerticalWaterPressure=dpi.IntrusionVerticalWaterPressureType.Standard, DikeSoilScenario=dpi.DikeSoilScenarioType.ClayDikeOnClay, ) @@ -325,6 +326,8 @@ ShearStrengthModel=dpi.ShearStrengthModelType.CPhi, StrengthIncreaseExponent=row["Strengthincreaseexp(m)"], RatioCuPc=row["RatioSu/Pc"], + DryUnitWeight=0.01, + DilatancyType=dpi.DilatancyTypeModel.Phi, ) soils_list.append(soil) return soils_list @@ -371,6 +374,16 @@ SearchMethod=dpi.SearchMethodType.Calculationgrid, GridDetermination=dpi.GridDeterminationType.Automatic, BishopTangentLinesDefinition=dpi.BishopTangentLinesDefinitionType.OnBoundaryLines, + UpliftVanGridLeftVerticalPointsCount=36, + UpliftVanGridLeftVerticalPointsDistance=2, + UpliftVanGridLeftHorizontalPointsCount=14, + UpliftVanGridLeftHorizontalPointsDistance=2, + UpliftVanGridRightVerticalPointsCount=3, + UpliftVanGridRightVerticalPointsDistance=2, + UpliftVanGridRightHorizontalPointsCount=6, + UpliftVanGridRightHorizontalPointsDistance=2, + UpliftVanTangentLinesDefinition=0, + UpliftVanTangentLinesDistance=0.25, ) # create dam input dam_input = dpi.DamInput( @@ -395,3 +408,14 @@ result_code = dam_input.execute( xml_input_file=xml_dam_input, xml_output_file=xml_dam_output ) + # read output xml + tree = et.parse(str(xml_dam_output)) + root = tree.getroot() + stability_results = ( + root.find("Results") + .find("CalculationResults") + .find("DesignResults") + .find("StabilityDesignResults") + ) + safety_factor = stability_results.get("SafetyFactor") + print("DAM produced a safety factor of ", safety_factor) Index: DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/setting_up_dam_input_and_executing.rst =================================================================== diff -u -r3529 -r3539 --- DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/setting_up_dam_input_and_executing.rst (.../setting_up_dam_input_and_executing.rst) (revision 3529) +++ DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/setting_up_dam_input_and_executing.rst (.../setting_up_dam_input_and_executing.rst) (revision 3539) @@ -4,6 +4,8 @@ Finally the user cab set up the more general settings of the :py:class:`dampythoninterface.stability_parameters.StabilityParameters` class. An example is shown in the following code snippet. +Note that despite the grid determination being Automatic the user DamPythonInterface tool cannot determine +the Uplift Van grid values. Thus, they should be manually inputted. .. code-block:: python @@ -12,6 +14,16 @@ SearchMethod=dpi.SearchMethodType.Calculationgrid, GridDetermination=dpi.GridDeterminationType.Automatic, BishopTangentLinesDefinition=dpi.BishopTangentLinesDefinitionType.OnBoundaryLines, + UpliftVanGridLeftVerticalPointsCount=36, + UpliftVanGridLeftVerticalPointsDistance=2, + UpliftVanGridLeftHorizontalPointsCount=14, + UpliftVanGridLeftHorizontalPointsDistance=2, + UpliftVanGridRightVerticalPointsCount=3, + UpliftVanGridRightVerticalPointsDistance=2, + UpliftVanGridRightHorizontalPointsCount=6, + UpliftVanGridRightHorizontalPointsDistance=2, + UpliftVanTangentLinesDefinition=0, + UpliftVanTangentLinesDistance=0.25, ) The :py:class:`dampythoninterface.input.DamInput` class can then be defined as follows. @@ -35,18 +47,34 @@ .. code-block:: python - xml_dam_input = Path( - TestUtils.get_output_test_data_dir(""), "InputTutorialFile.xml" - ) + xml_dam_input = Path( "InputTutorialFile.xml") dam_input.ExportToXml(xml_file=xml_dam_input) -Finally, the user can define an output file location and name and execute a DAM calculation +The user can define an output file location and name and execute a DAM calculation .. code-block:: python - xml_dam_output = Path( - TestUtils.get_output_test_data_dir(""), "OutputTutorialxml.xml" - ) + xml_dam_output = Path( "OutputTutorialxml.xml") result_code = dam_input.execute( xml_input_file=xml_dam_input, xml_output_file=xml_dam_output - ) \ No newline at end of file + ) + +After the calculation is run the user can access the output by parsing the xml in Python. +The user can also use the output. +For example, in this case the user outputs the safety factor. + +.. code-block:: python + + import xml.etree.cElementTree as et + + # read output xml + tree = et.parse(str(xml_dam_output)) + root = tree.getroot() + stability_results = ( + root.find("Results") + .find("CalculationResults") + .find("DesignResults") + .find("StabilityDesignResults") + ) + safety_factor = stability_results.get("SafetyFactor") + print("DAM produced a safety factor of ", safety_factor) Index: DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilprofiles.csv =================================================================== diff -u -r3529 -r3539 --- DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilprofiles.csv (.../soilprofiles.csv) (revision 3529) +++ DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilprofiles.csv (.../soilprofiles.csv) (revision 3539) @@ -2,4 +2,3 @@ soilprofile_01;10;Dijkmateriaal soilprofile_01;0;Deklaag_klei soilprofile_01;-2;wl_zand1 -soilprofile_01;-10;wl_zand4 Index: DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilmaterials.csv =================================================================== diff -u -r3529 -r3539 --- DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilmaterials.csv (.../soilmaterials.csv) (revision 3529) +++ DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilmaterials.csv (.../soilmaterials.csv) (revision 3539) @@ -1,10 +1,10 @@ Name;Soiltype;Saturatedunitweight;Unsaturatedunitweight;Cohesion;Frictionangle;DiameterD70;PermeabilityX;Shearstrengthmodel;Strengthincreaseexp(m);RatioSu/Pc;UsePOP;POP -Dijkmateriaal;Clay;17;17;0.5;22;200;0;C phi;0.7;0.22;CheckUnchecked;10 -Deklaag_klei;Clay;16;16;0.5;22;200;0.001;C phi;0.7;0.22;CheckUnchecked;10 -wl_zand1;Sand;19;18;0;32;210;0.001;C phi;0.7;0.22;CheckUnchecked;10 -Ophoogmateriaal_dijk;Clay;17;17;0.5;22;200;0;C phi;0.7;0.22;CheckUnchecked;10 -Ophoogmateriaal_berm;Sand;19;18;0.5;22;200;0;C phi;0.7;0.22;CheckUnchecked;10 -wl_zand2;Sand;19;18;0;32;215;0.001;C phi;0.7;0.22;CheckUnchecked;10 -wl_zand3;Sand;19;18;0;32;220;0.001;C phi;0.7;0.22;CheckUnchecked;10 -wl_zand4;Sand;19;18;0;32;225;0.001;C phi;0.7;0.22;CheckUnchecked;10 -wl_zand5;Sand;19;18;0;32;230;0.001;C phi;0.7;0.22;CheckUnchecked;10 +Dijkmateriaal;Clay;17;17;0.5;22;0.0002;0.0004;C phi;0.7;0.22;CheckUnchecked;10 +Deklaag_klei;Clay;16;16;0.5;22;0.0002;0.001;C phi;0.7;0.22;CheckUnchecked;10 +wl_zand1;Sand;19;18;0;32;0.00021;0.009;C phi;0.7;0.22;CheckUnchecked;10 +Ophoogmateriaal_dijk;Clay;17;17;0.5;22;0.0002;0.0004;C phi;0.7;0.22;CheckUnchecked;10 +Ophoogmateriaal_berm;Sand;19;18;0.5;22;0.0002;0.0004;C phi;0.7;0.22;CheckUnchecked;10 +wl_zand2;Sand;19;18;0;32;0.000215;0.0008;C phi;0.7;0.22;CheckUnchecked;10 +wl_zand3;Sand;19;18;0;32;0.00022;0.0007;C phi;0.7;0.22;CheckUnchecked;10 +wl_zand4;Sand;19;18;0;32;0.000225;0.0006;C phi;0.7;0.22;CheckUnchecked;10 +wl_zand5;Sand;19;18;0;32;0.00023;0.0005;C phi;0.7;0.22;CheckUnchecked;10 Index: DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/surface_lines_csv_tutorial.rst =================================================================== diff -u -r3529 -r3539 --- DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/surface_lines_csv_tutorial.rst (.../surface_lines_csv_tutorial.rst) (revision 3529) +++ DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/surface_lines_csv_tutorial.rst (.../surface_lines_csv_tutorial.rst) (revision 3539) @@ -61,7 +61,7 @@ After defining the surface line read function the read_characteristic_points function is defined. The first step is to establish a relationship between the columns of the characteristicpoints.csv and the :py:class:`dampythoninterface.surface_line.PointTypeEnum` class. To do that a simple function is created -were a helper dictionary is used to retrieve the enum value from the :py:class:`dampythoninterface.surface_line.PointTypeEnum` class. +where a helper dictionary is used to retrieve the enum value from the :py:class:`dampythoninterface.surface_line.PointTypeEnum` class. The code is appended below .. code-block:: python Index: DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/full_tutorial_snippet.rst =================================================================== diff -u -r3536 -r3539 --- DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/full_tutorial_snippet.rst (.../full_tutorial_snippet.rst) (revision 3536) +++ DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/full_tutorial_snippet.rst (.../full_tutorial_snippet.rst) (revision 3539) @@ -8,8 +8,9 @@ import pandas as pd from pathlib import Path + import xml.etree.cElementTree as et - def get_failure_mechanism(soil_profile: str): + def get_failure_mechanism(self, soil_profile: str): import dampythoninterface as dpi output_dictionary = { @@ -20,8 +21,7 @@ } return output_dictionary[soil_profile] - - def read_segment_csv_file(file_name: str): + def read_segment_csv_file(self, file_name: str): # read csv file using pandas segment_csv = pd.read_csv(file_name, delimiter=";") # initialize segment list that will be used for the dam input @@ -37,7 +37,7 @@ "SoilProfileName": segment_csv["soilprofile_id"][csv_row], "SoilProfileType": dpi.SoilProfileTypeClass.ProfileType1D, "Probability": segment_csv["probability"][csv_row], - "SegmentFailureMechanismType": get_failure_mechanism( + "SegmentFailureMechanismType": self.get_failure_mechanism( segment_csv["calculation_type"][csv_row] ), } @@ -52,8 +52,7 @@ ) return segments_list - - def read_surface_lines_csv(file_name: str): + def read_surface_lines_csv(self, file_name: str): # read csv file using pandas surface_lines_csv = pd.read_csv(file_name, delimiter=";", index_col=False) surface_lines = {} @@ -70,12 +69,13 @@ # check if point is defined or if it is nan if not (str(point[0]) == "nan") or not (str(point[-1]) == "nan"): surface_lines[location_id].append( - dpi.Point(X=point[0], Z=point[-1], PointType=dpi.PointTypeEnum.NONE) + dpi.Point( + X=point[0], Z=point[-1], PointType=dpi.PointTypeEnum.NONE + ) ) return surface_lines - - def get_characteristic_point_type(point_type: str): + def get_characteristic_point_type(self, point_type: str): output_dictionary = { "Maaiveld buitenwaarts": dpi.PointTypeEnum.SurfaceLevelOutside, "Teen dijk buitenwaarts": dpi.PointTypeEnum.DikeToeAtRiver, @@ -97,8 +97,7 @@ } return output_dictionary.get(point_type, dpi.PointTypeEnum.NONE) - - def read_characteristic_points(file_name: str): + def read_characteristic_points(self, file_name: str): # read csv file using pandas characteristic_points_csv = pd.read_csv(file_name, delimiter=";") column_groups = [ @@ -124,30 +123,30 @@ char_point = row_csv[relevant_columns] if not (char_point.isin([-1]).sum().sum() == 3): characteristic_points_results[characteristic_points].append( - Point( + dpi.Point( X=list(char_point["X_" + characteristic_point_type])[0], Z=list(char_point["Z_" + characteristic_point_type])[0], - PointType=get_characteristic_point_type( + PointType=self.get_characteristic_point_type( characteristic_point_type ), ) ) return characteristic_points_results - - def get_X(d): + def get_X(self, d): return d.X - - def read_profile(file_name: str): + def read_profile(self, file_name: str): # read csv file using pandas profile_csv = pd.read_csv(file_name, delimiter=";") # initialize profile list that will be used for the dam input profile_list = [] # Loop through all unique profile names of the csv for profile_id in profile_csv["soilprofile_id"].unique(): list_of_1D_layers = [] - for csv_row in profile_csv[profile_csv["soilprofile_id"] == profile_id].index: + for csv_row in profile_csv[ + profile_csv["soilprofile_id"] == profile_id + ].index: if "zand" in profile_csv["soil_name"][csv_row]: is_aquifer = True else: @@ -167,23 +166,21 @@ profile_list.append( dpi.SoilProfile1D( Name=str(profile_id), - BottomLevel=-30, + BottomLevel=-10, Layers1D=list_of_1D_layers, ) ) return profile_list - - def get_zone_type(csv_zone_type: str): + def get_zone_type(self, csv_zone_type: str): dictionary = { "NoZones": dpi.ZoneTypeClass.NoZones, "ZoneAreas": dpi.ZoneTypeClass.ZoneAreas, "ForbiddenZones": dpi.ZoneTypeClass.ForbiddenZones, } return dictionary[csv_zone_type] - - def read_locations_csv(location_csv_name: str, scenario_csv_name: str): + def read_locations_csv(self, location_csv_name: str, scenario_csv_name: str): # read csv file using pandas location_csv = pd.read_csv(location_csv_name, delimiter=";") scenario_csv = pd.read_csv(scenario_csv_name, delimiter=";") @@ -199,11 +196,15 @@ HeadPl2=row["head_pl2"], HeadPl3=row["head_pl3"], PlLineOffsetBelowDikeTopAtRiver=row["PLLineOffsetBelowDikeTopAtRiver"], - PlLineOffsetBelowDikeTopAtPolder=row["PLLineOffsetBelowDikeTopAtPolder"], + PlLineOffsetBelowDikeTopAtPolder=row[ + "PLLineOffsetBelowDikeTopAtPolder" + ], PlLineOffsetBelowShoulderBaseInside=row[ "PLLineOffsetBelowShoulderBaseInside" ], - PlLineOffsetBelowDikeToeAtPolder=row["PLLIneOffsetBelowDikeToeAtPolder"], + PlLineOffsetBelowDikeToeAtPolder=row[ + "PLLIneOffsetBelowDikeToeAtPolder" + ], RiverLevel=row["water_height"], RiverLevelLow=row["water_height_low"], DikeTableHeight=row["dike_table_height"], @@ -234,8 +235,8 @@ NewWidthDitchBottom=row["NewWidthDitchBottom"], NewDepthDitch=row["NewDepthDitch"], NewSlopeAngleDitch=row["NewSlopeAngleDitch"], - RedesignDikeHeight=0, - RedesignDikeShoulder=0, + RedesignDikeHeight=True, + RedesignDikeShoulder=True, SlopeAdaptionStartCotangent=1, SlopeAdaptionEndCotangent=1, SlopeAdaptionStepCotangent=1, @@ -245,15 +246,15 @@ stability_options = dpi.StabilityOptions( MinimumCircleDepth=row["minimal_circle_depth"], TrafficLoad=row["trafficload"], - ZoneType=get_zone_type(row["ZoneType"]), + ZoneType=self.get_zone_type(row["ZoneType"]), ) # initialize waternet options waternet_options = dpi.WaternetOptions( DampingFactorPl3=row["dempingsfactor_pl3"], DampingFactorPl4=row["dempingsfactor_pl4"], PhreaticLineCreationMethod=row["PLLineCreationMethod"], PenetrationLength=0, - SlopeDampingFactor=1, + SlopeDampingFactor=0, IntrusionVerticalWaterPressure=dpi.IntrusionVerticalWaterPressureType.Standard, DikeSoilScenario=dpi.DikeSoilScenarioType.ClayDikeOnClay, ) @@ -272,8 +273,7 @@ locations_list.append(location) return locations_list - - def read_soilmaterials_csv(soilmaterials_csv_name: str): + def read_soilmaterials_csv(self, soilmaterials_csv_name: str): # read csv file using pandas soils_csv = pd.read_csv(soilmaterials_csv_name, delimiter=";") # initialize soil list that will be used for the dam input @@ -291,48 +291,63 @@ ShearStrengthModel=dpi.ShearStrengthModelType.CPhi, StrengthIncreaseExponent=row["Strengthincreaseexp(m)"], RatioCuPc=row["RatioSu/Pc"], + DryUnitWeight=0.01, + DilatancyType=dpi.DilatancyTypeModel.Phi, ) soils_list.append(soil) return soils_list - - @pytest.mark.acceptance - def test_tutorial_read_csv_files(): - segments_list = read_segment_csv_file( - "trunk\\src\\tests\\test_data\\csvfiles\\segments.csv" + if __name__ == "__main__": + current_path = Path(__file__).parent.resolve() + segments_list = self.read_segment_csv_file( + str(Path(current_path, "segments.csv")) ) - surface_lines = read_surface_lines_csv( - "trunk\\src\\tests\\test_data\\csvfiles\\surfacelines.csv" + surface_lines = self.read_surface_lines_csv( + str(Path(current_path, "surfacelines.csv")) ) - characteristic_points = read_characteristic_points( - "trunk\\src\\tests\\test_data\\csvfiles\\characteristicpoints.csv" + characteristic_points = self.read_characteristic_points( + str(Path(current_path, "characteristicpoints.csv")) ) # merge the two dictionaries to create surface line for key, value in surface_lines.items(): surface_lines[key] += characteristic_points.get(key, []) # sort points based on X coordinate - surface_lines[key].sort(key=get_X) + surface_lines[key].sort(key=self.get_X) # all the points of the surface lines are merged so the surface lines list can be created surface_lines_dam_input = [] for location, points in surface_lines.items(): - surface_lines_dam_input.append(dpi.SurfaceLine(Name=location, Points=points)) + surface_lines_dam_input.append( + dpi.SurfaceLine(Name=location, Points=points) + ) # the soil profile should also be created # In this case only 1D segments will be inputted - profiles = read_profile("trunk\\src\\tests\\test_data\\csvfiles\\soilprofiles.csv") + profiles = self.read_profile( + str(Path(current_path, "soilprofiles.csv")) + ) # read location csv - locations = read_locations_csv( - "trunk\\src\\tests\\test_data\\csvfiles\\locations.csv", - "trunk\\src\\tests\\test_data\\csvfiles\\scenarios.csv", + locations = self.read_locations_csv( + str(Path(current_path, "locations.csv")), + str(Path(current_path, "scenarios.csv")), ) # read soil materials csv - soils = read_soilmaterials_csv( - "trunk\\src\\tests\\test_data\\csvfiles\\soilmaterials.csv" + soils = self.read_soilmaterials_csv( + str(Path(current_path, "soilmaterials.csv")) ) # create stability parameters stability_parameter = dpi.StabilityParameters( SearchMethod=dpi.SearchMethodType.Calculationgrid, GridDetermination=dpi.GridDeterminationType.Automatic, BishopTangentLinesDefinition=dpi.BishopTangentLinesDefinitionType.OnBoundaryLines, + UpliftVanGridLeftVerticalPointsCount=36, + UpliftVanGridLeftVerticalPointsDistance=2, + UpliftVanGridLeftHorizontalPointsCount=14, + UpliftVanGridLeftHorizontalPointsDistance=2, + UpliftVanGridRightVerticalPointsCount=3, + UpliftVanGridRightVerticalPointsDistance=2, + UpliftVanGridRightHorizontalPointsCount=6, + UpliftVanGridRightHorizontalPointsDistance=2, + UpliftVanTangentLinesDefinition=0, + UpliftVanTangentLinesDistance=0.25, ) # create dam input dam_input = dpi.DamInput( @@ -347,13 +362,20 @@ StabilityParameters=stability_parameter, ) - xml_dam_input = Path( - TestUtils.get_output_test_data_dir(""), "InputTutorialFile.xml" - ) + xml_dam_input = Path("InputTutorialFile.xml") dam_input.ExportToXml(xml_file=xml_dam_input) - xml_dam_output = Path( - TestUtils.get_output_test_data_dir(""), "OutputTutorialxml.xml" - ) + xml_dam_output = Path("OutputTutorialxml.xml") result_code = dam_input.execute( xml_input_file=xml_dam_input, xml_output_file=xml_dam_output - ) \ No newline at end of file + ) + # read output xml + tree = et.parse(str(xml_dam_output)) + root = tree.getroot() + stability_results = ( + root.find("Results") + .find("CalculationResults") + .find("DesignResults") + .find("StabilityDesignResults") + ) + safety_factor = stability_results.get("SafetyFactor") + print("DAM produced a safety factor of ", safety_factor) Index: DamClients/DamPythonInterface/trunk/doc/source/index.rst =================================================================== diff -u -r3529 -r3539 --- DamClients/DamPythonInterface/trunk/doc/source/index.rst (.../index.rst) (revision 3529) +++ DamClients/DamPythonInterface/trunk/doc/source/index.rst (.../index.rst) (revision 3539) @@ -9,6 +9,45 @@ DamPythonInterface is a Python package to generate input for the DAM engine basically bypassing the DAM UI. Release v\ |version|. +Introduction +============ +DamPythonInterface is a tool that basically contains three different functionalities: + +* A skeleton of the inputs required to run the DAMEngine. +* The ability of writing an input xml file for the DAMEngine. +* The ability of running the DAMEngine. + +Therefore, the user can use this tool to create xml input files with inputs that can be specified from Python. + + +This part of the documentation covers the installation of DamPythonInterface. +The first step to using any software package is getting it properly installed. + +DamPythonInterface installation +------------------------------- +DamPythonInterface releases defined as .whl files. You can download these and install such files with:: + + $ pip install geolib-0.1.0-py3-none-any.whl + + +Packages used +------------- + +This package, tries to limit the number of +*heavy* depedencies. The main packages used are: + +- Poetry_ for package management (replacing setuptools) see also `PEP 518 `_. +- Pydantic_ for validation of types and some parameters (min/max/defaults). + +.. _Poetry: https://python-poetry.org/docs/ +.. _Pydantic: https://pydantic-docs.helpmanual.io/ + +You don't need to install anything manually, as the pip installation should take care of it. + +Initialization of classes +------------------------- + + Tutorial -------- The tutorial can be found in :doc:`this document. ` @@ -23,6 +62,9 @@ dev/input +Tips for Python development +=========================== +For more tips refer :doc:`this document. ` Indices and tables ================== Index: DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilmaterials.mdb =================================================================== diff -u -r3529 -r3539 Binary files differ Fisheye: Tag 3539 refers to a dead (removed) revision in file `DamClients/DamPythonInterface/trunk/src/tests/test_data/csvfiles/soilmaterials.mds'. Fisheye: No comparison available. Pass `N' to diff? Index: DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/soil_materials_tutorial.rst =================================================================== diff -u -r3529 -r3539 --- DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/soil_materials_tutorial.rst (.../soil_materials_tutorial.rst) (revision 3529) +++ DamClients/DamPythonInterface/trunk/doc/source/tutorial_sections/soil_materials_tutorial.rst (.../soil_materials_tutorial.rst) (revision 3539) @@ -3,5 +3,5 @@ To create a list of :py:class:`dampythoninterface.soil.Soil` class list that can later be inputted in the dam input a read_soilmaterials_csv function is created. This function takes as input the location od the soilmaterials csv file which is exported from the DamUI. -The csv id read using pandas. And values of each row are used as inputs if the soil class. +The csv id read using pandas. And values of each row are used as inputs of the soil class. The reader is referred directly to the code snippet referred below.