// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine 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. using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Threading; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io.XmlInput; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; using ConversionHelper = Deltares.DamEngine.Interface.ConversionHelper; using UpliftSituation = Deltares.DamEngine.Io.XmlOutput.UpliftSituation; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class MacroStabilityInwardsTests { private const double tolerance = 0.00051; private const string mapTestFiles = @"TestFiles\"; private const string tutorialStability2D = @"TestFiles\InputTutorialStability2D.xml"; [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignUpliftVan() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 1st location (DWP_1) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsUpliftVan"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.UpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.165).Within(tolerance)); // NumberOfIterations=0 Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations, Is.EqualTo(0)); // ResultMessage "" Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage, Is.EqualTo("")); // Check that a line is specified Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine, Is.Not.Null); // Profile name = DWP_1.stix Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("DWP_1.stix")); }); // Uplift UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation; Assert.That(upliftSituation, Is.Not.Null); Assert.Multiple(() => { Assert.That(upliftSituation.IsUplift, Is.EqualTo(true)); Assert.That(upliftSituation.Pl3MinUplift, Is.EqualTo(1.141).Within(tolerance)); Assert.That(upliftSituation.Pl3HeadAdjusted, Is.EqualTo(4.400).Within(tolerance)); Assert.That(upliftSituation.Pl3LocationXMinUplift, Is.EqualTo(60.640).Within(tolerance)); Assert.That(upliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance)); // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_UpliftVanLowest() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 1st location (DWP_1) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishopUpliftVan_UpliftVanLowest"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.248).Within(tolerance)); Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null); }); Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.UpliftSituation.IsUplift, Is.True); Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop)); Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)")); }); // Uplift Van result = output.Results.CalculationResults[1]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.165).Within(tolerance)); Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan)); Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)")); }); // Lowest of Bishop and Uplift Van result = output.Results.CalculationResults[2]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.165).Within(tolerance)); Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan)); Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)")); }); Assert.Multiple(() => { // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_BishopLowest() { // Based on DAM UI tutorial for stability, for location DWP_22 const string calcDir = "TestStabInwardsBishopUpliftVan_BishopLowest"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_22"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "SearchMethod", "BeeSwarm"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactor, Is.EqualTo(1.153).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); }); Assert.Multiple(() => { Assert.That(result.UpliftSituation.IsUplift, Is.True); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop)); }); // Uplift Van result = output.Results.CalculationResults[1].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactor, Is.EqualTo(1.421).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan)); }); // Lowest of Bishop and Uplift Van result = output.Results.CalculationResults[2].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactor, Is.EqualTo(1.1534).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan)); }); Assert.Multiple(() => { // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_NoUplift() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 10th location (DWP_18) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishopUpliftVan_NoUplift"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_18"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactorSpecified, Is.True); Assert.That(result.SafetyFactor, Is.EqualTo(1.357).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); }); Assert.Multiple(() => { Assert.That(result.UpliftSituation.IsUplift, Is.False); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop)); }); // Uplift Van result = output.Results.CalculationResults[1].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactorSpecified, Is.False); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan)); }); // Lowest of Bishop and Uplift Van result = output.Results.CalculationResults[2].StabilityDesignResults; Assert.Multiple(() => { Assert.That(result.SafetyFactorSpecified, Is.True); Assert.That(result.SafetyFactor, Is.EqualTo(1.357).Within(tolerance)); Assert.That(result.UpliftSituation, Is.Not.Null); Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan)); }); Assert.Multiple(() => { // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.NoRun)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test] [Category(Categories.Slow)] public void TestRunMacroStabilityInvoer10ForbiddenZoneBishop() { // xml file is created with Invoer10\ZoneType.defx // Select locations DWP_10_1 and DWP_10_4 // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop // This tests the first location with No Zones and the second with Forbidden Zone const string calcDir = "TestStabInwardsForbiddenZoneBishop"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\Invoer10.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(2)); DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { // No Zone Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.318).Within(tolerance)); Assert.That(result.LocationName, Is.EqualTo("DWP_10_1")); Assert.That(result.ProfileName, Is.EqualTo("DWP_10.stix")); Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); result = output.Results.CalculationResults[1]; Assert.Multiple(() => { // Forbidden Zone, factor = 0.2 Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.835).Within(tolerance)); Assert.That(result.LocationName, Is.EqualTo("DWP_10_4")); Assert.That(result.ProfileName, Is.EqualTo("DWP_10.stix")); Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow), Ignore("Work in progress")] public void DesignBishopOptimizedSlopeAndShoulderAdaptionWithScenariosForHeadPL3CalculatesCorrect() { // ToDo: When fixed, check if tutorialStability2D can be used instead of next xml file const string inputFilename = "InputFileMultiCoreTestForScenarioAdaption.xml"; string fullInputFilename = Path.Combine(mapTestFiles, inputFilename); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; string inputString = File.ReadAllText(fullInputFilename); var engineInterface = new EngineInterface(inputString); engineInterface.DamProjectData.MaxCalculationCores = 1; string calcDir = engineInterface.DamProjectData.CalculationMap + "_SingleCore"; engineInterface.DamProjectData.CalculationMap = calcDir; Assert.That(engineInterface.DamProjectData, Is.Not.Null); calcDir = Directory.GetCurrentDirectory() + "\\" + calcDir; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Output output = GeneralHelper.RunAfterInputValidation(engineInterface, true, "Results_Single_Core" + ".xml"); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(18)); Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(1336)); int resultsFound = CheckLargeResultsSets.CheckResultsDesignBishopAdaptionWithScenariosForHeadPl3CalculatesCorrect( output.Results.CalculationResults); Assert.That(resultsFound, Is.EqualTo(11)); }); } [Test, Category(Categories.Slow), Ignore("Work in progress")] public void TestRunSlopeAdaptionBeforeShoulderAdaptionSucceeds() { // Input file was created with .\data\Dam\Benchmarks\Validatie SlopeAdaption\SlopeAdaption.damx // Expected: a valid calculation. const string calcDir = "TestRunFailedExpectCalculationMessageInSlopeAdaptionBeforeShoulderAdaption"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); // ToDo: When fixed, check if tutorialStability2D can be used instead of next xml file const string fileName = @"TestFiles\ValidatieSlopeAdaption.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.That(output.Results.CalculationResults.First().StabilityDesignResults.SafetyFactor, Is.EqualTo(1.366).Within(tolerance)); } [Test] [Category(Categories.Slow)] // Xml is created with DAM Tutorial Design.damx // Select 1st location (DWP_1) // Set location scenario, Required safety factor stability inner slope to 1.4 // Design strategy: OptimizedSlopeAndShoulderAdaption // Set NewMinDistanceDikeToeStartDitch(New allowed distance toe-ditch) = 3.0 // Set UseNewMinDistanceDikeToeStartDitch(Use new allowed distance toe-ditch) = true (to force value to be written to XML) // // Parameters: CalcDir - StabilityModel - DesignStrategy - CalculationResult - FoS - EntryPointX - ExitPointX - DikeLength - ShoulderHeight - Iterations - ResultMessage [TestCase("TestStabInwardsBishopDesignSequential", "Bishop", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.467, 45.387, 2.799, 5, "")] [TestCase("TestStabInwardsBishopDesignOptimized", "Bishop", "OptimizedSlopeAndShoulderAdaption", CalculationResult.Succeeded, 1.483, 43.760, 3.889, 4, "")] [TestCase("TestStabInwardsUpliftVanDesignSequential", "UpliftVan", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.428, 47.737, 3.132, 6, "")] [TestCase("TestStabInwardsUpliftVanDesignOptimized", "UpliftVan", "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.342, 80.402, 4.545, 20, "After height adaption ditch does not fit inside surfaceline anymore.")] public void CanPerformStabilityInwardsDesignTutorialDesignWithAdaption_OneLocation( string calcDir, string stabilityModel, string designStrategy, CalculationResult calculationResult, double expectedSafetyFactor, double expectedDikeLength, double expectedShoulderHeight, int expectedNumberOfIterations, string expectedResultMessage) { const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile1LocationWithAdaption.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityModelType", stabilityModel); inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityDesignMethod", designStrategy); if (stabilityModel == "UpliftVan") { inputString = XmlAdapter.ChangeValueInXml(inputString, "SearchMethod", "BeeSwarm"); } Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); Assert.That(ConversionHelper.ConvertToCalculationResult( output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(calculationResult)); DesignResultStabilityDesignResults stabilityDesignResults = output.Results.CalculationResults[0].StabilityDesignResults; Assert.Multiple(() => { Assert.That(stabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor).Within(tolerance)); Assert.That(stabilityDesignResults.NumberOfIterations, Is.EqualTo(expectedNumberOfIterations)); Assert.That(stabilityDesignResults.ResultMessage, Is.EqualTo(expectedResultMessage)); }); SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].StabilityDesignResults.RedesignedSurfaceLine; if (redesignedSurfaceLine != null) { double? actualDikeLength = redesignedSurfaceLine.GetDikeLength(); Point2D pointShoulderBaseInside = redesignedSurfaceLine.CharacteristicPoints.GetPoint2D(CharacteristicPointType.ShoulderTopInside); Assert.Multiple(() => { Assert.That(actualDikeLength, Is.EqualTo(expectedDikeLength).Within(tolerance)); if (pointShoulderBaseInside != null) { Assert.That(pointShoulderBaseInside.Z, Is.EqualTo(expectedShoulderHeight).Within(tolerance)); } }); } } [Test] [SetUICulture("nl-NL")] public void TestGiveFeedBackWhenNoProfilesAreAvailable() { // Based on "dam/IssueRelatedData/MWDAM-1341/HHNK Leggerstudie\DAM Leggerstudie.defx" // Import as Design -Primary dike: "DAM Leggerstudie.defx" // Select first location and start calculation // xml file is created with rev.2039 const string calcDir = "TestGiveFeedBackWhenNoProfilesAreAvailable"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\MacroStabilityNoProfilesInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString, false); Assert.That(output.Results.CalculationMessages.Length, Is.EqualTo(2)); Assert.That(output.Results.CalculationMessages[0].MessageType, Is.EqualTo(MessageMessageType.Warning)); Assert.That(output.Results.CalculationMessages[0].Message1, Is.EqualTo("Geen ondergrond profielen beschikbaar voor locatie '12-2_027'")); } [Test] public void TestAdaptWithRiverLevelAboveDikeTopButBelowDikeTableHeightCanCalculate() { const string analysisType = "AdaptGeometry"; // Test just to see if calculation works in this case as it should do. Output output = GetOutputStringForProject(analysisType, true); Assert.That(output.Results.CalculationResults, Is.Not.Null, "No results available"); Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.259).Within(0.0005)); } [Test] public void TestNoAdaptionWithRiverLevelAboveDikeTopButBelowDikeTableHeightCanNotCalculate() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; const string analysisType = "NoAdaption"; // Test to see if calculation does NOT work in this case as it must fail with water level above dike top. Output output = GetOutputStringForProject(analysisType, false); Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(2)); Assert.Multiple(() => { Assert.That(output.Results.CalculationMessages[0].Message1, Does.Contain("Location 'DWP_1', subsoil scenario 'DWP_1.stix', design scenario '1': The preparation for this calculation failed.")); Assert.That(output.Results.CalculationMessages[1].Message1, Does.Contain("Level (5.50 m) should NOT be higher than dike top at river side (5.24)")); }); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityDeltaDijkBishopWith1DProducesStixFiles() { // Expected results are taken as is from the first run with the new kernel // This tests use of 1D profiles // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop const string calcDir = "TestStabInwardsBishopWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.Bishop); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(3)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("6-4-1-A-1-F_1_s")); Assert.That(output.Results.CalculationResults[1].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[1].ProfileName, Is.EqualTo("6-4-1-A-1-F_2_s")); Assert.That(output.Results.CalculationResults[2].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[2].ProfileName, Is.EqualTo("6-4-1-A-1-F_3_s")); }); DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.678).Within(tolerance)); // skip testing some of the results like uplift etc. // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); // test safety factor for other profiles result = output.Results.CalculationResults[1]; Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.619).Within(tolerance)); result = output.Results.CalculationResults[2]; Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.678).Within(tolerance)); // Stix file var fileList = new List { "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix" }; foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } } [Test, Category(Categories.Slow)] [TestCase(StabilitySearchMethod.BeeSwarm, 4, 1.612, 1.536)] [TestCase(StabilitySearchMethod.Grid, 2, 1.610, 1.535)] public void TestRunMacroStabilityDeltaDijkUpliftVanWith1DProducesStixFiles(StabilitySearchMethod searchMethod, int expectedStixFileCount, double expectedSafetyFactor1, double expectedSafetyFactor2) { // Expected results are taken as is from the first run with the new kernel // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - UpliftVan // This tests use of 1D profiles const string calcDir = "TestStabInwardsUpliftVanWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); // Read as Bishop, then change to UpliftVan const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.UpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used var engineInterface = new EngineInterface(inputString); engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod; Output output = GeneralHelper.RunAfterInputValidation(engineInterface); // one location is calculated with 3 1D profiles // However, profile 6-4-1-A-1-F_3_s has no UpliftVan occuring and thus has no result Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(2)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("6-4-1-A-1-F_1_s")); Assert.That(output.Results.CalculationResults[1].LocationName, Is.EqualTo("6-4-1-A-1-F")); Assert.That(output.Results.CalculationResults[1].ProfileName, Is.EqualTo("6-4-1-A-1-F_2_s")); }); DesignResult result = output.Results.CalculationResults[0]; Assert.Multiple(() => { // SafetyFactor=1.638 DSTAB 1.518 (1.079) Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor1).Within(tolerance)); // skip testing some of the results like uplift etc. // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); // test safety factor for other profiles result = output.Results.CalculationResults[1]; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor2).Within(tolerance)); Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); var fileList = new List { "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix" }; if (searchMethod == StabilitySearchMethod.BeeSwarm) { fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix"); fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix"); } int stixFileCount = Directory.GetFiles(Path.GetFullPath(calcDir), "*.stix", SearchOption.AllDirectories).Length; Assert.That(stixFileCount, Is.EqualTo(expectedStixFileCount), "The number of created STIX files is not as expected"); foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } } [Test, Category(Categories.Slow)] [TestCase(StabilitySearchMethod.BeeSwarm, 10, 1.612, 1.536)] [TestCase(StabilitySearchMethod.Grid, 8, 1.610, 1.535)] public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithUpliftProducesStixFiles(StabilitySearchMethod searchMethod, int expectedStixFileCount, double expectedSafetyFactor1, double expectedSafetyFactor2) { // Expected results are taken as is from the first run with the new kernel // This tests use of 1D profiles // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop const string calcDir = "TestStabInwardsBishopUpliftVanWithUpliftWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used var engineInterface = new EngineInterface(inputString); engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod; Output output = GeneralHelper.RunAfterInputValidation(engineInterface); // one location is calculated with 3 1D profiles, and results are for the 3 models Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(9)); Assert.Multiple(() => { CheckCalculationResults( output.Results.CalculationResults[0], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.678, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[1], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, expectedSafetyFactor1, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[2], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, expectedSafetyFactor1, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[3], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.619, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[4], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, expectedSafetyFactor2, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[5], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, expectedSafetyFactor2, true, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[6], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.678, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[7], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[8], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.678, false, CalculationResult.Succeeded); }); // Stix file var fileList = new List { "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix" }; if (searchMethod == StabilitySearchMethod.BeeSwarm) { fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix"); fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix"); } int stixFileCount = Directory.GetFiles(Path.GetFullPath(calcDir), "*.stix", SearchOption.AllDirectories).Length; Assert.That(stixFileCount, Is.EqualTo(expectedStixFileCount), "The number of created STIX files is not as expected"); foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithoutUpliftProducesStixFiles() { // Expected results are taken as is from the first run with the new kernel // This tests use of 1D profiles // Selected location (6-4-1-A-1-F) // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop const string calcDir = "TestStabInwardsBishopUpliftVanWithoutUpliftWithStixFiles"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, InputStabilityModelType.BishopUpliftVan); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "UpliftCriterionStability", @"1.0"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles and results are for the 3 models (Bishop, Uplift-Van and Bishop/UpliftVan) Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(9)); Assert.Multiple(() => { CheckCalculationResults( output.Results.CalculationResults[0], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.678, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[1], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[2], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.678, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[3], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.619, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[4], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[5], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.619, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[6], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.678, false, CalculationResult.Succeeded); CheckCalculationResults( output.Results.CalculationResults[7], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun); CheckCalculationResults( output.Results.CalculationResults[8], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s", DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.678, false, CalculationResult.Succeeded); }); // Stix file var existingFilesList = new List { "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix", "Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix" }; foreach (string file in existingFilesList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.True, file + " does not exist"); } var noneExistingFilesList = new List { "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix", "Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix" }; foreach (string file in noneExistingFilesList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.That(File.Exists(file), Is.False, file + " does exist"); } } /// /// This test uses the location DWP 1 of the Design Tutorial Stability. /// Different values for the degree of consolidation (DoC) of the layers due to the traffic load are tested. /// Expected is that a larger DoC leads to a larger safety factor because the soil effective stresses /// below the traffic load are larger and therefore also the resisting moment. /// Note that the test case where the DoC is unchanged (i.e. 100% for sand layers and 0% for cohesive layers) /// and the test case where DoC=0% return the same safety factor because the Bishop slip circle cuts only the cohesive layers. /// /// /// [Test] [TestCase(double.NaN, 1.248)] // DoC is unchanged [TestCase(0, 1.248)] [TestCase(50, 1.276)] [TestCase(100, 1.305)] public void GivenStabilityDesignTutorial_WhenCalculatingWithDifferentDegreeOfConsolidation_ThenReturnsADifferentSafetyFactor(double trafficLoadDegreeOfConsolidation, double expectedSafetyFactor) { const string calcDir = "TestEffectOfTrafficLoadDegreeOfConsolidation"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); } string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); var engineInterface = new EngineInterface(inputString); if (!double.IsNaN(trafficLoadDegreeOfConsolidation)) { foreach (TrafficLoadDegreeOfConsolidation degreeOfConsolidation in engineInterface.DamProjectData.Dike.TrafficLoadDegreeOfConsolidations) { degreeOfConsolidation.DegreeOfConsolidation = trafficLoadDegreeOfConsolidation; } } Output output = GeneralHelper.RunAfterInputValidation(engineInterface); Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(1)); Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor).Within(tolerance)); } /// Test for different segmentFailureMechanismType /// The soil probabilities are set tot the specified segmentFailureMechanismType [Test] [TestCase(SegmentSoilGeometryProbabilitySegmentFailureMechanismType.Stability)] [TestCase(SegmentSoilGeometryProbabilitySegmentFailureMechanismType.All)] public void TestRunMacroStabilityTutorialDesignBishop(SegmentSoilGeometryProbabilitySegmentFailureMechanismType segmentFailureMechanismType) { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Set Analysis type to "No adaption" // Select 1st location (DWP_1) // Set Calculation Options: Stability Inside - Bishop // Expected results are determined by running dam\dam clients\DamUI\trunk\data\DamEngineTestProjects\DAM Tutorial Design // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishop"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", segmentFailureMechanismType.ToString()); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.248).Within(tolerance)); // NumberOfIterations=0 Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations, Is.EqualTo(0)); // ResultMessage "" Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage, Is.EqualTo("")); // Check that a line is specified Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine, Is.Not.Null); // Profile name = DWP_1.stix Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("DWP_1.stix")); }); // Uplift UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation; Assert.That(upliftSituation, Is.Not.Null); Assert.Multiple(() => { Assert.That(upliftSituation.IsUplift, Is.EqualTo(true)); Assert.That(upliftSituation.Pl3MinUplift, Is.EqualTo(1.141).Within(tolerance)); Assert.That(upliftSituation.Pl3HeadAdjusted, Is.EqualTo(4.400).Within(tolerance)); Assert.That(upliftSituation.Pl3LocationXMinUplift, Is.EqualTo(60.640).Within(tolerance)); Assert.That(upliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(upliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance)); // Calculation Result Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); }); } [Test, Category(Categories.Slow)] [TestCase("DWP_1", InputStabilityModelType.Bishop, "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.4, 1.493, 5)] [TestCase("DWP_1", InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", CalculationResult.Succeeded, 1.4, 1.545, 4)] [TestCase("DWP_2", InputStabilityModelType.Bishop, "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.5, 1.546, 9)] [TestCase("DWP_2", InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.5, 1.176, 17, "Location 'DWP_2', subsoil scenario 'DWP_2.stix', design scenario '1': The calculation failed with error message 'The design was not successful. After height adaption ditch does not fit inside surfaceline anymore.'")] [TestCase("DWP_13", InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.5, 0.936, 23, "The characteristic points of the surfaceline are not ascending in X-direction.")] [TestCase("DWP_10", InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.5, 1.308, 16, "Location 'DWP_10', subsoil scenario 'DWP_10.stix', design scenario '3': The calculation failed with error message 'The design was not successful. After height adaption ditch does not fit inside surfaceline anymore.'")] [TestCase("DWP_1", InputStabilityModelType.BishopUpliftVan, "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.4, 1.406, 6)] public void GivenTutorialDesign_WhenSpecifiedLocationRunWithGeometryAdaption_ThenGivesExpectedResults(string locationId, InputStabilityModelType stabilityModelType, string designMethod, CalculationResult calculationResult, double requiredSafetyFactor, double actualSafetyFactor, int iterationCount, string errorMessage = "", string firstStabilityMessage = "") { // Use XML of general Tutorial Design project var calcDir = $"TestStabInwards{stabilityModelType.ToString()}_AdaptGeometry_{locationId}_{designMethod}_{requiredSafetyFactor.ToString(CultureInfo.InvariantCulture)}"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string inputString = File.ReadAllText(tutorialStability2D); string[] locations = [locationId]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeStabilityInputModel(inputString, stabilityModelType); inputString = XmlAdapter.ChangeValueInXml(inputString, "FailureMechanismSystemType", ConversionHelper.ConvertToInputFailureMechanismSystemType( FailureMechanismSystemType.StabilityInside).ToString()); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", SegmentSoilGeometryProbabilitySegmentFailureMechanismType.Stability.ToString()); inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", "AdaptGeometry"); inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityDesignMethod", designMethod); inputString = XmlAdapter.ChangeValueInXml(inputString, "RequiredSafetyFactorStabilityInnerSlope", requiredSafetyFactor.ToString(CultureInfo.InvariantCulture)); File.WriteAllText(calcDir + "_InputFile.xml", inputString); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.Multiple(() => { Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults.Last().CalculationResult), Is.EqualTo(calculationResult)); if (calculationResult == CalculationResult.Succeeded) { Assert.That(output.Results.CalculationResults.Last().StabilityDesignResults.SafetyFactor, Is.GreaterThanOrEqualTo(requiredSafetyFactor)); } else { if (!errorMessage.Equals("")) { Assert.That(output.Results.CalculationMessages.Last().Message1, Does.Contain(errorMessage)); } if (!firstStabilityMessage.Equals("")) { Assert.That(output.Results.CalculationResults.Last().StabilityDesignResults.ResultMessage, Does.Contain(firstStabilityMessage)); } } Assert.That(output.Results.CalculationResults.Last().StabilityDesignResults.SafetyFactor, Is.EqualTo(actualSafetyFactor).Within(tolerance)); Assert.That(output.Results.CalculationResults.Last().StabilityDesignResults.NumberOfIterations, Is.EqualTo(iterationCount)); }); } private static Output GetOutputStringForProject(string analysisType, bool isSuccessful) { // Create xml with Tutorial project // Select location DWP_1 // Calculation options: Stability Inside - Bishop string calcDir = "TestStabInwardsBishop_" + analysisType; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); string inputString = File.ReadAllText(tutorialStability2D); string[] locations = ["DWP_1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", SegmentSoilGeometryProbabilitySegmentFailureMechanismType.Stability.ToString()); inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", analysisType); inputString = XmlAdapter.ChangeValueInXml(inputString, "DikeTableHeight", "5.9"); inputString = XmlAdapter.ChangeValueInXml(inputString, "RiverLevel", "5.5"); inputString = XmlAdapter.ChangeValueInXml(inputString, "RequiredSafetyFactorStabilityInnerSlope", "1.2"); return GeneralHelper.RunAfterInputValidation(inputString, isSuccessful); } private static void CheckCalculationResults(DesignResult output, string locationName, string profileName, DesignResultStabilityDesignResultsStabilityModelType model, double safetyFactor, bool isUplift, CalculationResult result) { Assert.Multiple(() => { Assert.That(output.LocationName, Is.EqualTo(locationName)); Assert.That(output.ProfileName, Is.EqualTo(profileName)); Assert.That(output.StabilityDesignResults.StabilityModelType, Is.EqualTo(model)); Assert.That(output.StabilityDesignResults.SafetyFactor, Is.EqualTo(safetyFactor).Within(tolerance)); Assert.That(output.StabilityDesignResults.UpliftSituation.IsUplift, Is.EqualTo(isUplift)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.CalculationResult), Is.EqualTo(result)); }); } }