// Copyright (C) Stichting Deltares 2019. 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.IO; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; using ConversionHelper = Deltares.DamEngine.Interface.ConversionHelper; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests { [TestFixture] public class MacroStabilityOutwardsTests { private const double tolerance = 0.0005; /// Test for different segmentFailureMechanismType /// The soilprobabilities are set tot the specified segmentFailureMechanismType [Test] [TestCase(ConversionHelper.InputSegmentFailureMechanismStability)] [TestCase(ConversionHelper.InputSegmentFailureMechanismAll)] public void TestRunMacroStabilityTutorialDesignBishop(int segmentFailureMechanismType) { // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" // Set Analysis type to "No adaption" // Select first location (DWP_1) // Set Calculation Options: Stability Inside - Bishop // DO NOT SET: Set Calculation Options: Stability Outside - Bishop, this is done in the test itself // Expected results are taken from test TestStabilityClassicOutsideWith2DstiFiles in FailureMechanismTests of DamUI. const string calcDir = "TestOutStabBishop"; 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()); File.WriteAllText(fileName + ".txt", inputString); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.StabilityModelType = MStabModelType.Bishop; engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.GridPosition = MStabGridPosition.Left; engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType = FailureMechanismSystemType.StabilityOutside; string outputString = engineInterface.Run(); Assert.IsNotNull(outputString); var output = DamXmlSerialization.LoadOutputFromXmlString(outputString); Assert.IsNotNull(output.Results.CalculationResults, "No results available"); Assert.AreEqual(0.698, output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, tolerance); // Zone1SafetyFactor=1.282 Assert.AreEqual(0.698, output.Results.CalculationResults[0].StabilityDesignResults.Zone1SafetyFactor, tolerance); // Zone1EntryPointX Local =38.818 Global=47.238 Assert.AreEqual(30.684, output.Results.CalculationResults[0].StabilityDesignResults.Zone1EntryPointX, tolerance); // Zone1ExitPointX Local=64.262 Global=72.682 Assert.AreEqual(13.532, output.Results.CalculationResults[0].StabilityDesignResults.Zone1ExitPointX, tolerance); // Zone2SafetyFactor null, is set to default reading from output.xml Assert.AreEqual(0, output.Results.CalculationResults[0].StabilityDesignResults.Zone2SafetyFactor, tolerance); // Zone2EntryPointX null, is set to default reading from output.xml Assert.AreEqual(0, output.Results.CalculationResults[0].StabilityDesignResults.Zone2EntryPointX, tolerance); // Zone2ExitPointX null, is set to default reading from output.xml Assert.AreEqual(0, output.Results.CalculationResults[0].StabilityDesignResults.Zone2ExitPointX, 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 var 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); // Model Type Assert.AreEqual(DesignResultStabilityDesignResultsStabilityModelType.Bishop, output.Results.CalculationResults[0].StabilityDesignResults.StabilityModelType); // Calculation Result Assert.AreEqual(CalculationResult.Succeeded, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult)); } } }