// 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.Globalization; using System.IO; using System.Threading; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geotechnics; 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 PipingBlighTests { private const double tolerance = 0.0005; private const string workingDir = @"TestFiles\"; private string oldWorkingDir; [SetUp] public void TestFixtureSetup() { oldWorkingDir = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(workingDir); } [TearDown] public void TestFixtureTearDown() { Directory.SetCurrentDirectory(oldWorkingDir); } /// Test for different segmentFailureMechanismType /// The soilprobabilities are set tot the specified segmentFailureMechanismType [Test] [TestCase(ConversionHelper.InputSegmentFailureMechanismPiping)] [TestCase(ConversionHelper.InputSegmentFailureMechanismAll)] public void CanPerformBlighDesignNoAdaptionPipingVoorbeeld1(int segmentFailureMechanismType) { // Based on ".\data\DamEngineTestProjects\PipingVoorbeeld1\PipingVoorbeeld1.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "No Adaption" const string fileName = @"PipingVoorbeeld1_BlighInputFile.xml"; string inputString = File.ReadAllText(fileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", segmentFailureMechanismType.ToString()); // Factor piping = 0.521 // Kritische hoogte = 1.667 // Factor opdrijven = 0.5825 // Kwelweglengte piping = 25.0 // Intredepunt x-lokaal = 10.0 // Uittredepunt x-lokaal = 35.0 // Opdrijven = true // Profielnaam = soilprofile_01 // PL3 opdrijven = 0.582 // PL3 stijghoogte aangepast = 1.262 // PL3 locatie opdrijven lokaal = 35.0 // PL4 opdrijven = 0.0 // PL4 stijghoogte aangepast = 0.0 // PL4 locatie opdrijven lokaal = 0.0 // Locatie naam = "profiel 1" // ID locatie scenario = "1" // Heave Factor = 90.0 Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].PipingDesignResults.RedesignedSurfaceLine; Assert.AreEqual(0.521, output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.667, output.Results.CalculationResults[0].PipingDesignResults.BlighHcritical, tolerance); Assert.AreEqual(35.0, output.Results.CalculationResults[0].PipingDesignResults.ExitPointX, tolerance); Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(25.00).Within(tolerance)); Assert.AreEqual(true, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.IsUplift); // The following values are not the same as in the Dam 15.1.2.24738 release (but explainable) // The upliftfactor in Dam 15.1.2.24738 is 0.351, but that is the Wti Upliftfactor Assert.AreEqual(0.5825, output.Results.CalculationResults[0].PipingDesignResults.UpliftFactor, tolerance); // The adjusted PL3/PL4 values in Dam 15.1.2.24738 are not 0.0, but those are the values for stability; for piping no adjustment has to be made Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3MinUplift, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3HeadAdjusted, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3LocationXMinUplift, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4MinUplift, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4HeadAdjusted, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4LocationXMinUplift, tolerance); } [Test] public void CanPerformBlighDesignNoAdaptionRechterDiezedijk() { // Based on ".\data\DamEngineTestProjects\Larenstein_AaenMaas\Rechter Diezedijk.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "No Adaption" // Select all locations const string fileName = @"Rechter Diezedijk_BlighInputFile.xml"; string inputString = File.ReadAllText(fileName); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.AreEqual(112, output.Results.CalculationResults.Length); Assert.AreEqual(0.782, output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(0.809, output.Results.CalculationResults[111].PipingDesignResults.BlighFactor, tolerance); } [Test] public void CanPerformBlighDesignWithAdaptionPipingVoorbeeld1() { // Based on ".\data\DamEngineTestProjects\PipingVoorbeeld1\PipingVoorbeeld1.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "Adapt geometry" const string fileName = @"PipingVoorbeeld1_BlighDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].PipingDesignResults.RedesignedSurfaceLine; Assert.AreEqual(true, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.IsUplift); Assert.AreEqual(1.995, redesignedSurfaceLine.DetermineShoulderHeight(), tolerance); Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(63.486).Within(tolerance)); Assert.AreEqual(32.5, redesignedSurfaceLine.DetermineShoulderLength(), tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3MinUplift, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3HeadAdjusted, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3LocationXMinUplift, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4MinUplift, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4HeadAdjusted, tolerance); Assert.AreEqual(0.0, output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4LocationXMinUplift, tolerance); // The following values are not the same as in the Dam 15.1.2.24738 release // The final Bligh calculation at the redesigned situation is done at X = 29.013552941176471 (the "insteek van de berm"), because there an // upliftfactor of 1.99999 is found, but it should have been done at X = 73.486 (the "teen van de dijk") // The BlighFactor in Dam 15.1.2.24738 is 2.092, but that is not correct, because that is the value at X = 29.013552941176471 Assert.AreEqual(1.323, output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, tolerance); // The BlighHcritical in Dam 15.1.2.24738 is 1.268, but that is not correct, because that is the value at X = 29.013552941176471 Assert.AreEqual(4.232, output.Results.CalculationResults[0].PipingDesignResults.BlighHcritical, tolerance); // The upliftfactor in Dam 15.1.2.24738 is (incorrectly) not shown Assert.AreEqual(0.5825, output.Results.CalculationResults[0].PipingDesignResults.UpliftFactor, tolerance); // The ExitPointX in Dam 15.1.2.24738 is (incorrectly) not shown Assert.AreEqual(73.486, output.Results.CalculationResults[0].PipingDesignResults.ExitPointX, tolerance); } [Test] public void CanPerformBlighDesignWithAdaptionRechterDiezedijk1Location() { // Based on ".\data\DamEngineTestProjects\Larenstein_AaenMaas\Rechter Diezedijk.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "Adapt Geometry" // Select second location (101) const string fileName = @"Rechter Diezedijk_BlighDesignInputFile_1Location.xml"; string inputString = File.ReadAllText(fileName); Output output = GeneralHelper.RunAfterInputValidation(inputString); var locationIndex = 0; Assert.AreEqual(1.313, output.Results.CalculationResults[locationIndex * 2 + 0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.295, output.Results.CalculationResults[locationIndex * 2 + 1].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual((locationIndex + 1) * 2, output.Results.CalculationResults.Length); } [Test] [SetUICulture("en-US")] public void CanPerformBlighFailingDesignWithAdaptionRechterDiezedijk1Location() { // Based on ".\data\DamEngineTestProjects\Larenstein_AaenMaas\Rechter Diezedijk.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "Adapt Geometry" // Select second location (101) // Set for this location in location scenario Required safety factor for piping to 8.0 Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; const string fileName = @"Rechter Diezedijk_BlighFailedDesignInputFile_1Location.xml"; string inputString = File.ReadAllText(fileName); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.AreEqual(2, output.Results.CalculationResults.Length); Assert.AreEqual("The new shoulder length is too large to fit in the current surface line.", output.Results.CalculationResults[1].PipingDesignResults.ResultMessage); Assert.AreEqual(CalculationResult.RunFailed, ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult)); Assert.AreEqual(2, output.Results.CalculationMessages.Length); Assert.AreEqual("Location '101', subsoil scenario 'segment1_1D1', design scenario '1': " + "The calculation failed with error message " + "'The design was not successful. " + "The new shoulder length is too large to fit in the current surface line.'", output.Results.CalculationMessages[0].Message1); } [Test] public void CanPerformBlighDesignWithAdaptionRechterDiezedijk() { // Based on ".\data\DamEngineTestProjects\Larenstein_AaenMaas\Rechter Diezedijk.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "Adapt Geometry" // Select first 5 locations (100, 101, 102, 103 and 104) const string fileName = @"Rechter Diezedijk_BlighDesignInputFile.xml"; string inputString = File.ReadAllText(fileName); Output output = GeneralHelper.RunAfterInputValidation(inputString); var locationIndex = 0; Assert.AreEqual(1.516, output.Results.CalculationResults[locationIndex + 0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.497, output.Results.CalculationResults[locationIndex + 1].PipingDesignResults.BlighFactor, tolerance); locationIndex++; Assert.AreEqual(1.313, output.Results.CalculationResults[locationIndex * 2 + 0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.295, output.Results.CalculationResults[locationIndex * 2 + 1].PipingDesignResults.BlighFactor, tolerance); locationIndex++; Assert.AreEqual(2.166, output.Results.CalculationResults[locationIndex * 2 + 0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.312, output.Results.CalculationResults[locationIndex * 2 + 1].PipingDesignResults.BlighFactor, tolerance); locationIndex++; Assert.AreEqual(1.486, output.Results.CalculationResults[locationIndex * 2 + 0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.356, output.Results.CalculationResults[locationIndex * 2 + 1].PipingDesignResults.BlighFactor, tolerance); locationIndex++; Assert.AreEqual(1.722, output.Results.CalculationResults[locationIndex * 2 + 0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(1.311, output.Results.CalculationResults[locationIndex * 2 + 1].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual((locationIndex + 1) * 2, output.Results.CalculationResults.Length); } [Test] [TestCase(1)] [TestCase(4)] public void TestPipingBlightWithoutUplift(int maxCores) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; const string fileName = @"PipingBlighWithoutUplift.xml"; string inputString = File.ReadAllText(fileName); var engineInterface = new EngineInterface(inputString); string outputName = "Output" + maxCores + ".xml"; Output output = GeneralHelper.RunAfterInputValidation(engineInterface, true, outputName); int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages); Assert.AreEqual(0, errorCount, "There should be no errors during the calculation."); Assert.AreNotEqual(null, output.Results.CalculationResults); Assert.AreEqual(6, output.Results.CalculationResults.Length); Assert.AreEqual(17.208, output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(90.000, output.Results.CalculationResults[1].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(90.000, output.Results.CalculationResults[2].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(90.000, output.Results.CalculationResults[3].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(7.041, output.Results.CalculationResults[4].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(90.000, output.Results.CalculationResults[5].PipingDesignResults.BlighFactor, tolerance); Assert.AreEqual(5, output.Results.CalculationMessages.Length); Assert.IsTrue(output.Results.CalculationMessages[0].Message1.Contains("no uplift")); Assert.IsTrue(output.Results.CalculationMessages[1].Message1.Contains("no uplift")); Assert.IsTrue(output.Results.CalculationMessages[2].Message1.Contains("no uplift")); Assert.IsTrue(output.Results.CalculationMessages[3].Message1.Contains("no uplift")); Assert.IsTrue(output.Results.CalculationMessages[4].Message1.Contains("no uplift")); } }