// Copyright (C) Stichting Deltares 2023. 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.Text.RegularExpressions; 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; 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.0005; private const string mapTestFiles = @"TestFiles\"; private const double tol2Digits = 0.005; [TearDown] public void TearDown() { // Ensure clearing directories at end. RemoveUsedDirectoryAfterTests("TestStabInwardsBishop2DStix"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishop"); RemoveUsedDirectoryAfterTests("TestStabInwardsUpliftVan"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVan_UpliftVanLowest"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVan_BishopLowest"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVan_NoUplift"); RemoveUsedDirectoryAfterTests("TestStabInwardsForbiddenZoneBishop"); RemoveUsedDirectoryAfterTests("TestStabInwardsWithErrorUpliftVan"); RemoveUsedDirectoryAfterTests("TestStabInwardsWithErrorBishopUpliftVan"); RemoveUsedDirectoryAfterTests("TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption"); RemoveUsedDirectoryAfterTests("TestRunFailedExpectCalculationMessageInSlopeAdaptionBeforeShoulderAdaption"); RemoveUsedDirectoryAfterTests("TestGiveFeedBackWhenNoProfilesAreAvailable"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishopWithStixFiles"); RemoveUsedDirectoryAfterTests("TestStabInwardsUpliftVanWithStixFiles"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVanWithUpliftWithStixFiles"); RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVanWithoutUpliftWithStixFiles"); } [Test, Category("Slow")] [Category(Categories.WorkInProgress)] public void TestBishopNoAdaptionWith2DGeometriesBasedOnStixFiles() { const string calcDir = "TestStabInwardsBishop2DStix"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\Test2DGeometryBasedOnStixFiles.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 var engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.IsNotNull(output.Results.CalculationResults, "No results available"); Assert.AreEqual(1.282, output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, tolerance); } /// Test for different segmentFailureMechanismType /// The soil probabilities are set tot the specified segmentFailureMechanismType [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] [TestCase(ConversionHelper.InputSegmentFailureMechanismStability)] [TestCase(ConversionHelper.InputSegmentFailureMechanismAll)] public void TestRunMacroStabilityTutorialDesignBishop(int 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); const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", segmentFailureMechanismType.ToString()); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.IsNotNull(output.Results.CalculationResults, "No results available"); Assert.AreEqual(1.282, output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, tolerance); // NumberOfIterations=0 Assert.AreEqual(0, output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations); // ResultMessage "" Assert.AreEqual("", output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage); // Check that a line is specified Assert.IsNotNull(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine); // Profile name = DWP_1.sti Assert.AreEqual("DWP_1.sti", output.Results.CalculationResults[0].ProfileName); // Uplift UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation; Assert.IsNotNull(upliftSituation); Assert.AreEqual(true, upliftSituation.IsUplift); Assert.AreEqual(1.141, upliftSituation.Pl3MinUplift, tolerance); Assert.AreEqual(4.4, upliftSituation.Pl3HeadAdjusted, tolerance); Assert.AreEqual(60.64, upliftSituation.Pl3LocationXMinUplift, tolerance); Assert.AreEqual(0.0, upliftSituation.Pl4MinUplift, tolerance); Assert.AreEqual(0.0, upliftSituation.Pl4HeadAdjusted, tolerance); Assert.AreEqual(0.0, upliftSituation.Pl4LocationXMinUplift, tolerance); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult)); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] 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 } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan); 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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.AreEqual(1.115, output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, tolerance); // NumberOfIterations=0 Assert.AreEqual(0, output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations); // ResultMessage "" Assert.AreEqual("", output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage); // Check that a line is specified Assert.IsNotNull(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine); // Profile name = DWP_1.sti Assert.AreEqual("DWP_1.sti", output.Results.CalculationResults[0].ProfileName); // Uplift UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation; Assert.IsNotNull(upliftSituation); Assert.AreEqual(true, upliftSituation.IsUplift); Assert.AreEqual(1.141, upliftSituation.Pl3MinUplift, tolerance); Assert.AreEqual(4.4, upliftSituation.Pl3HeadAdjusted, tolerance); Assert.AreEqual(60.64, upliftSituation.Pl3LocationXMinUplift, tolerance); Assert.AreEqual(0.0, upliftSituation.Pl4MinUplift, tolerance); Assert.AreEqual(0.0, upliftSituation.Pl4HeadAdjusted, tolerance); Assert.AreEqual(0.0, upliftSituation.Pl4LocationXMinUplift, tolerance); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult)); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] 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 } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResult result = output.Results.CalculationResults[0]; Assert.AreEqual(1.282, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.IsNotNull(result.StabilityDesignResults.UpliftSituation); Assert.IsTrue(result.StabilityDesignResults.UpliftSituation.IsUplift); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.Bishop, result.StabilityDesignResults.StabilityModelType); Assert.AreEqual("Loc(DWP_1)_Sce(1)_Pro(DWP_1)", result.BaseFileName); // Uplift Van result = output.Results.CalculationResults[1]; Assert.AreEqual(1.115, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.IsNotNull(result.StabilityDesignResults.UpliftSituation); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, result.StabilityDesignResults.StabilityModelType); Assert.AreEqual("Loc(DWP_1)_Sce(1)_Pro(DWP_1)", result.BaseFileName); // Worst of Bishop and Uplift Van result = output.Results.CalculationResults[2]; Assert.AreEqual(1.115, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.IsNotNull(result.StabilityDesignResults.UpliftSituation); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, result.StabilityDesignResults.StabilityModelType); Assert.AreEqual("Loc(DWP_1)_Sce(1)_Pro(DWP_1)", result.BaseFileName); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult)); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult)); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult)); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_BishopLowest() { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // with Dam Classic rev.1059 // Select 5th location (DWP_13) // with Dam Classic rev.833 const string calcDir = "TestStabInwardsBishopUpliftVan_BishopLowest"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile13.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults; Assert.AreEqual(0.452, result.SafetyFactor, tolerance); Assert.IsNotNull(result.UpliftSituation); Assert.IsTrue(result.UpliftSituation.IsUplift); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.Bishop, result.StabilityModelType); // Uplift Van result = output.Results.CalculationResults[1].StabilityDesignResults; Assert.AreEqual(0.574, result.SafetyFactor, tolerance); Assert.IsNotNull(result.UpliftSituation); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, result.StabilityModelType); // Worst of Bishop and Uplift Van result = output.Results.CalculationResults[2].StabilityDesignResults; Assert.AreEqual(0.452, result.SafetyFactor, tolerance); Assert.IsNotNull(result.UpliftSituation); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, result.StabilityModelType); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult)); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult)); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult)); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] 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 } const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile18.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // Bishop DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults; Assert.IsTrue(result.SafetyFactorSpecified); Assert.AreEqual(1.458, result.SafetyFactor, tolerance); Assert.IsNotNull(result.UpliftSituation); Assert.IsFalse(result.UpliftSituation.IsUplift); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.Bishop, result.StabilityModelType); // Uplift Van result = output.Results.CalculationResults[1].StabilityDesignResults; Assert.IsFalse(result.SafetyFactorSpecified); Assert.IsNotNull(result.UpliftSituation); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, result.StabilityModelType); // Worst of Bishop and Uplift Van result = output.Results.CalculationResults[2].StabilityDesignResults; Assert.IsTrue(result.SafetyFactorSpecified); Assert.AreEqual(1.458, result.SafetyFactor, tolerance); Assert.IsNotNull(result.UpliftSituation); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, result.StabilityModelType); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult)); Assert.AreEqual(CalculationResult.NoRun, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult)); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult)); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] public void TestRunMacroStabilityInvoer10ForbiddenZoneBishop() { // Expected results are determined by running dam\dam clients\DamUI\trunk\data\DamEngineTestProjects\Invoer10\ZoneType.damx // with Dam Classic rev.1059 // Select locations DWP_10_2 and DWP_10_6 // Analysis type "No adaption" // Calculation options: Stability Inside - Bishop // This tests two locations with same profile // But first location with Zone Areas and second location with Forbidden Zone // Note: this test might be activated again in the future as Forbidden zone seems to be supported by the new kernel. But then all new reference values are needed. 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 inputString = XmlAdapter.ChangeValueInXml(inputString, "MapForSoilgeometries2D", @"TestFiles\ZoneType.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\ZoneType0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.AreEqual(2, output.Results.CalculationResults.Length); DesignResult result = output.Results.CalculationResults[0]; // SafetyFactor=1.972 (Zone Areas) Assert.AreEqual(1.972, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.AreEqual("DWP_10_2", result.LocationName); Assert.AreEqual("DWP_10.sti", result.ProfileName); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); result = output.Results.CalculationResults[1]; // SafetyFactor=2.034 (Forbidden Zone) Assert.AreEqual(2.034, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.AreEqual("DWP_10_6", result.LocationName); Assert.AreEqual("DWP_10.sti", result.ProfileName); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityWithErrorUpliftVan() { // Expected results are determined by running .\data\DamEngineTestProjects\DeltaDijk_zonering_BI\DeltaDijk normal.damx // with Dam Classic rev.1059 // Select 5th and 6th location (6-4-3-A-1-C and 6-4-3-A-1-D) // This project has 2 locations with each 2 profiles // In one the combinations location-profile (1st location, 2nd profile) DGeoStability stops during the calculation. // Then the kernel tries to read the safety factor, but fails because the dumpfile is not complete. // In Release+Classic this returned a result Unexpected Error but the calculation continued with the next combination. const string calcDir = "TestStabInwardsWithErrorUpliftVan"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\ErrorInDGeoStabilityCalculation.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(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.AreEqual(4, output.Results.CalculationResults.Length); DesignResult result = output.Results.CalculationResults[0]; Assert.AreEqual("6-4-3-A-1-C", result.LocationName); Assert.AreEqual("6-4-3-A-1-C_1_s", result.ProfileName); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor=1.814 Assert.AreEqual(1.814, result.StabilityDesignResults.SafetyFactor, tolerance); result = output.Results.CalculationResults[1]; Assert.AreEqual("6-4-3-A-1-C", result.LocationName); Assert.AreEqual("6-4-3-A-1-C_2_s", result.ProfileName); // Calculation Result Assert.AreEqual(CalculationResult.UnexpectedError, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor not specified Assert.IsFalse(result.StabilityDesignResults.SafetyFactorSpecified); result = output.Results.CalculationResults[2]; Assert.AreEqual("6-4-3-B-1-D", result.LocationName); Assert.AreEqual("6-4-3-B-1-D_1_s", result.ProfileName); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor=2.099 Assert.AreEqual(2.099, result.StabilityDesignResults.SafetyFactor, tolerance); result = output.Results.CalculationResults[3]; Assert.AreEqual("6-4-3-B-1-D", result.LocationName); Assert.AreEqual("6-4-3-B-1-D_2_s", result.ProfileName); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor=2.300 Assert.AreEqual(2.300, result.StabilityDesignResults.SafetyFactor, tolerance); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] public void TestRunMacroStabilityWithErrorBishopUpliftVan() { // Expected results are determined by running .\data\DamEngineTestProjects\DeltaDijk_zonering_BI\DeltaDijk normal.damx // with Dam Classic rev.1059 // Select 5th and 6th location (6-4-3-A-1-C and 6-4-3-A-1-D) // This project has 2 locations with each 2 profiles // In one the combinations location-profile (1st location, 2nd profile) DGeoStability stops during the calculation. // Then the kernel tries to read the safety factor, but fails because the dumpfile is not complete. // In Release+Classic this returned a result Unexpected Error but the calculation continued with the next combination. const string calcDir = "TestStabInwardsWithErrorBishopUpliftVan"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\ErrorInDGeoStabilityCalculation.xml"; string inputString = File.ReadAllText(fileName); inputString = ChangeInputModel(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); var expectedCount = output.Results.CalculationResults.Length; Assert.AreEqual(12, expectedCount, "12 results expected but only " + expectedCount); DesignResult result = output.Results.CalculationResults[3]; Assert.AreEqual("6-4-3-A-1-C", result.LocationName); Assert.AreEqual("6-4-3-A-1-C_2_s", result.ProfileName); // Bishop Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor=2.219 Assert.AreEqual(2.219, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.Bishop, result.StabilityDesignResults.StabilityModelType); result = output.Results.CalculationResults[4]; Assert.AreEqual("6-4-3-A-1-C", result.LocationName); Assert.AreEqual("6-4-3-A-1-C_2_s", result.ProfileName); // Uplift Van Assert.AreEqual(CalculationResult.UnexpectedError, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor not specified Assert.IsFalse(result.StabilityDesignResults.SafetyFactorSpecified); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, result.StabilityDesignResults.StabilityModelType); result = output.Results.CalculationResults[5]; Assert.AreEqual("6-4-3-A-1-C", result.LocationName); Assert.AreEqual("6-4-3-A-1-C_2_s", result.ProfileName); // Bishop/Uplift Van Assert.AreEqual(CalculationResult.UnexpectedError, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // SafetyFactor not specified Assert.IsFalse(result.StabilityDesignResults.SafetyFactorSpecified); Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, result.StabilityDesignResults.StabilityModelType); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] public void TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption() { // Inputfile was created with .\data\DamEngineTestProjects\Invoer2\DAM Tutorial Design\DAM Tutorial Design.damx // Select dwp 13 // Expected: RunFailed const string calcDir = "TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\MacroStabilityRunFailedExpectCalculationMessage.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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString, false); Assert.IsNull(output.Results.CalculationResults); Assert.AreEqual("Location 'DWP_13', subsoil scenario 'DWP_13.sti', design scenario '1': " + "The calculation failed with error message " + "'The design was not successful. " + "The new shoulder height with topslope exceeds the allowed maximum height.'", output.Results.CalculationMessages[0].Message1); } [Test, Category(Categories.Slow)] public void DesignBishopOptimizedSlopeAndShoulderAdaptionWithScenariosForHeadPL3CalculatesCorrect() { 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; var calcDir = engineInterface.DamProjectData.CalculationMap + "_SingleCore"; engineInterface.DamProjectData.CalculationMap = calcDir; Assert.IsNotNull(engineInterface.DamProjectData); calcDir = Directory.GetCurrentDirectory() + "\\" + calcDir; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } string result = engineInterface.Validate(); Assert.IsTrue(result == null, "Validation must succeed but does not, see output xml in debugger"); string outputString = engineInterface.Run(); File.WriteAllText("Results_Single_Core" + ".xml", outputString); Output output = DamXmlSerialization.LoadOutputFromXmlString(outputString); Assert.AreEqual(18, output.Results.CalculationResults.Length); Assert.AreEqual(3020, output.Results.CalculationMessages.Length); int resultsFound = CheckLargeResultsSets.CheckResultsDesignBishopAdaptionWithScenariosForHeadPl3CalculatesCorrect( output.Results.CalculationResults); Assert.AreEqual(18, resultsFound); } [Test, Category(Categories.Slow)] 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); 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 inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\SlopeAdaption0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.AreEqual(1.724, output.Results.CalculationResults.First().StabilityDesignResults.SafetyFactor, tolerance); } [Test, Category(Categories.Slow)] [Category(Categories.WorkInProgress)] // Expected results are determined by running .\DamUI\trunk\data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx // with Dam Classic rev.1059 // Select 1st location (DWP_1) // Set designscenario Safetyfactor Inwards to 1.4 // Design strategy: OptimizedSlopeAndShoulderAdaption // Set NewMinDistanceDikeToeStartDitch = 3.0, UseNewMinDistanceDikeToeStartDitch = 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.444, 39.081, 67.577, 45.387, 2.799, 5, "")] [TestCase("TestStabInwardsBishopDesignOptimized", "Bishop", "OptimizedSlopeAndShoulderAdaption", CalculationResult.Succeeded, 1.412, 50.236, 67.077, 43.760, 3.889, 4, "")] [TestCase("TestStabInwardsUpliftVanDesignSequential", "UpliftVan", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.4847, 39.243, 73.587, 50.285, 3.465, 7, "")] [TestCase("TestStabInwardsUpliftVanDesignOptimized", "UpliftVan", "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.214, 39.514, 66.926, 36.150, 0.0, 4, "The new shoulder height with topslope exceeds the allowed maximum height.")] public void CanPerformStabilityInwardsDesignTutorialDesignOptimizedSlopeAndShoulderAdaption_OneLocation( string calcDir, string stabilityModel, string designStrategy, CalculationResult calculationResult, double expectedSafetyFactor, double expectedZone1EntryPointX, double expectedZone1ExitPointX, 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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityModelType", stabilityModel); inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityDesignMethod", designStrategy); Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); Assert.AreEqual(calculationResult, ConversionHelper.ConvertToCalculationResult( output.Results.CalculationResults[0].CalculationResult)); DesignResultStabilityDesignResults stabilityDesignResults = output.Results.CalculationResults[0].StabilityDesignResults; Assert.AreEqual(expectedSafetyFactor, stabilityDesignResults.SafetyFactor, tolerance); Assert.AreEqual(expectedNumberOfIterations, stabilityDesignResults.NumberOfIterations); Assert.AreEqual(expectedResultMessage, stabilityDesignResults.ResultMessage); SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].StabilityDesignResults.RedesignedSurfaceLine; if (redesignedSurfaceLine != null) { Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(expectedDikeLength).Within(tolerance)); GeometryPoint pointShoulderBaseInside = redesignedSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderTopInside); if (pointShoulderBaseInside != null) { Assert.AreEqual(expectedShoulderHeight, pointShoulderBaseInside.Z, 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.IsNull(output.Results.CalculationResults); Assert.AreEqual(2, output.Results.CalculationMessages.Length); Assert.AreEqual(MessageMessageType.Warning, output.Results.CalculationMessages[0].MessageType); Assert.AreEqual("Geen ondergrond profielen beschikbaar voor locatie '12-2_027'", output.Results.CalculationMessages[0].Message1); } [Test] [Category(Categories.WorkInProgress)] public void TestDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate() { var analysisType = "AdaptGeometry"; // Test just to see if calculation works in this case as it should do. Output output = GetOutputStringForProject(analysisType); // Note Bka: it already failed, with message "The preparation for this calculation failed". // Now for a different reason. Probably because DTH is not yet taken into account with testing/adjusting the data. Assert.IsTrue(output.Results.CalculationMessages[0].Message1.Contains("Location 'DWP_1', subsoil scenario 'DWP_1.sti', design scenario '1': " + "The calculation failed with error message 'Value cannot be null.")); Assert.IsTrue(output.Results.CalculationMessages[0].Message1.Contains("Location 'DWP_1', subsoil scenario 'DWP_1.sti', design scenario '1': " + "The preparation for this calculation failed.")); } [Test] [Category(Categories.WorkInProgress)] public void TestNoDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate() { var 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); Assert.AreEqual(2, output.Results.CalculationMessages.Length); } [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 = ChangeInputModel(inputString, InputStabilityModelType.Bishop); 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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DeltaDijk normal0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles Assert.AreEqual(3, output.Results.CalculationResults.Length); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[0].LocationName); Assert.AreEqual("6-4-1-A-1-F_1_s", output.Results.CalculationResults[0].ProfileName); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[1].LocationName); Assert.AreEqual("6-4-1-A-1-F_2_s", output.Results.CalculationResults[1].ProfileName); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[2].LocationName); Assert.AreEqual("6-4-1-A-1-F_3_s", output.Results.CalculationResults[2].ProfileName); DesignResult result = output.Results.CalculationResults[0]; // SafetyFactor=1.682 Assert.AreEqual(1.682, result.StabilityDesignResults.SafetyFactor, tolerance); // skip testing some of the results like uplift etc. // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // test safety factor for other profiles result = output.Results.CalculationResults[1]; // SafetyFactor=1.644 Assert.AreEqual(1.644, result.StabilityDesignResults.SafetyFactor, tolerance); result = output.Results.CalculationResults[2]; // SafetyFactor=1.682 Assert.AreEqual(1.682, result.StabilityDesignResults.SafetyFactor, tolerance); // Stix file var fileList = new List { #if DEBUG "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", #endif "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.IsTrue(File.Exists(file), file + " does not exist"); } } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityDeltaDijkUpliftVanWith1DProducesStixFiles() { // 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 = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan); 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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DeltaDijk normal0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // 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.AreEqual(2, output.Results.CalculationResults.Length); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[0].LocationName); Assert.AreEqual("6-4-1-A-1-F_1_s", output.Results.CalculationResults[0].ProfileName); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[1].LocationName); Assert.AreEqual("6-4-1-A-1-F_2_s", output.Results.CalculationResults[1].ProfileName); DesignResult result = output.Results.CalculationResults[0]; // SafetyFactor=1.638 DSTAB 1.518 (1.079) Assert.AreEqual(1.638, result.StabilityDesignResults.SafetyFactor, tolerance); // skip testing some of the results like uplift etc. // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // test safety factor for other profiles result = output.Results.CalculationResults[1]; // SafetyFactor=1.551 DSTAB 1.414. 1.097 Assert.AreEqual(1.551, result.StabilityDesignResults.SafetyFactor, tolerance); Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); var fileList = new List { #if DEBUG "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", #endif "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 fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.IsTrue(File.Exists(file), file + " does not exist"); } } [Test, Category(Categories.Slow)] public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithUpliftProducesStixFiles() { // 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 = ChangeInputModel(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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DeltaDijk normal0.soilmaterials.mdb"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles Assert.AreEqual(3, output.Results.CalculationResults.Length); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[0].LocationName); Assert.AreEqual("6-4-1-A-1-F_1_s", output.Results.CalculationResults[0].ProfileName); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[1].LocationName); Assert.AreEqual("6-4-1-A-1-F_2_s", output.Results.CalculationResults[1].ProfileName); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[2].LocationName); Assert.AreEqual("6-4-1-A-1-F_3_s", output.Results.CalculationResults[2].ProfileName); DesignResult result = output.Results.CalculationResults[0]; // SafetyFactor=1.638 Assert.AreEqual(1.638, result.StabilityDesignResults.SafetyFactor, tolerance); // skip testing some of the results like uplift etc. // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // test safety factor for other profiles result = output.Results.CalculationResults[1]; // SafetyFactor=1.551 Assert.AreEqual(1.551, result.StabilityDesignResults.SafetyFactor, tolerance); // Stix file var fileList = new List { #if DEBUG "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\\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", #endif "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\\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 fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file))) { Assert.IsTrue(File.Exists(file), 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 = ChangeInputModel(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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DeltaDijk normal0.soilmaterials.mdb"); inputString = XmlAdapter.ChangeValueInXml(inputString, "UpliftCriterionStability", @"1.0"); Output output = GeneralHelper.RunAfterInputValidation(inputString); // one location is calculated with 3 1D profiles Assert.AreEqual(3, output.Results.CalculationResults.Length); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[0].LocationName); Assert.AreEqual("6-4-1-A-1-F_1_s", output.Results.CalculationResults[0].ProfileName); Assert.AreEqual("6-4-1-A-1-F", output.Results.CalculationResults[1].LocationName); Assert.AreEqual("6-4-1-A-1-F_2_s", output.Results.CalculationResults[1].ProfileName); DesignResult result = output.Results.CalculationResults[0]; // SafetyFactor=1.682 Assert.AreEqual(1.682, result.StabilityDesignResults.SafetyFactor, tolerance); // skip testing some of the results like uplift etc. // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(result.CalculationResult)); // test safety factor for other profiles result = output.Results.CalculationResults[1]; // SafetyFactor=1.644 Assert.AreEqual(1.644, result.StabilityDesignResults.SafetyFactor, tolerance); // Stix file var existingFilesList = new List { #if DEBUG "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", #endif "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.IsTrue(File.Exists(file), file + " does not exist"); } var noneExistingFilesList = new List { #if DEBUG "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", #endif "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.IsFalse(File.Exists(file), file + " does exist"); } } private void RemoveUsedDirectoryAfterTests(string directory) { if (Directory.Exists(directory)) { Directory.Delete(directory, true); } } private static Output GetOutputStringForProject(string analysisType) { const string calcDir = "TestStabInwardsBishop"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } Directory.CreateDirectory(calcDir); const string fileName = @"TestFiles\DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", ConversionHelper.InputSegmentFailureMechanismStability.ToString()); inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", analysisType); return GeneralHelper.RunAfterInputValidation(inputString, false); } private string ChangeInputModel(string input, InputStabilityModelType modelType) { var pattern = "StabilityModelType=\"[a-zA-Z]+\""; string replacement = pattern; switch (modelType) { case InputStabilityModelType.Bishop: replacement = "StabilityModelType=\"Bishop\""; break; case InputStabilityModelType.UpliftVan: replacement = "StabilityModelType=\"UpliftVan\""; break; case InputStabilityModelType.BishopUpliftVan: replacement = "StabilityModelType=\"BishopUpliftVan\""; break; } string result = Regex.Replace(input, pattern, replacement); return result; } }