// 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.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.XmlInput; 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 const string fileNamePipingAll = @"InputPipingAll.xml"; // NOTE: The PipingVoorbeeld1 tests are now read from the file "InputPipingAll.xml" // The file is created with DAM UI project .\data\Tutorials\DAMDesign\Piping\PipingAll\PipingAll.damx // SVN rev.6179 // The first location "Profiel 1" is used for the PipingVoorbeeld1 tests private const string pipingModelBligh = "Bligh"; 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(SegmentSoilGeometryProbabilitySegmentFailureMechanismType.Piping)] [TestCase(SegmentSoilGeometryProbabilitySegmentFailureMechanismType.All)] public void CanPerformBlighDesignNoAdaptionPipingVoorbeeld1(SegmentSoilGeometryProbabilitySegmentFailureMechanismType segmentFailureMechanismType) { // Based on ".\data\DamEngineTestProjects\PipingVoorbeeld1\PipingVoorbeeld1.damx" // Select Failure mechanism Piping and model Bligh // Set Analysis type to "No Adaption" string inputString = File.ReadAllText(fileNamePipingAll); string[] locations = ["Profiel 1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeValueInXml(inputString, "PipingModelType", pipingModelBligh); inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", "NoAdaption"); 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.That(output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, Is.EqualTo(0.521).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.BlighHcritical, Is.EqualTo(1.667).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.ExitPointX, Is.EqualTo(35.0).Within(tolerance)); Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(25.00).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.IsUplift, Is.EqualTo(true)); // 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.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftFactor, Is.EqualTo(0.5825).Within(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.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(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.That(output.Results.CalculationResults, Has.Length.EqualTo(112)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, Is.EqualTo(0.782).Within(tolerance)); Assert.That(output.Results.CalculationResults[103].PipingDesignResults.BlighFactor, Is.EqualTo(0.934).Within(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" string inputString = File.ReadAllText(fileNamePipingAll); string[] locations = ["Profiel 1"]; inputString = XmlAdapter.SelectLocations(inputString, locations); inputString = XmlAdapter.ChangeValueInXml(inputString, "PipingModelType", pipingModelBligh); inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", "AdaptGeometry"); Output output = GeneralHelper.RunAfterInputValidation(inputString); DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output); SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].PipingDesignResults.RedesignedSurfaceLine; Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.IsUplift, Is.EqualTo(true)); Assert.That(redesignedSurfaceLine.DetermineShoulderHeight(), Is.EqualTo(1.995).Within(tolerance)); Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(63.486).Within(tolerance)); Assert.That(redesignedSurfaceLine.DetermineShoulderLength(), Is.EqualTo(32.5).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl3LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(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.That(output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, Is.EqualTo(1.323).Within(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.That(output.Results.CalculationResults[0].PipingDesignResults.BlighHcritical, Is.EqualTo(4.232).Within(tolerance)); // The upliftfactor in Dam 15.1.2.24738 is (incorrectly) not shown Assert.That(output.Results.CalculationResults[0].PipingDesignResults.UpliftFactor, Is.EqualTo(0.5825).Within(tolerance)); // The ExitPointX in Dam 15.1.2.24738 is (incorrectly) not shown Assert.That(output.Results.CalculationResults[0].PipingDesignResults.ExitPointX, Is.EqualTo(73.486).Within(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) // Change the required safety factor to 1.1 to ensure that both profiles succeed const string fileName = @"Rechter Diezedijk_BlighDesignInputFile_1Location.xml"; string inputString = File.ReadAllText(fileName); Output output = GeneralHelper.RunAfterInputValidation(inputString); Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(2)); Assert.Multiple(() => { Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(0)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, Is.EqualTo(1.299).Within(tolerance)); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded)); Assert.That(output.Results.CalculationResults[1].PipingDesignResults.BlighFactor, Is.EqualTo(1.103).Within(tolerance)); }); } [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.That(output.Results.CalculationResults, Has.Length.EqualTo(2)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[1].PipingDesignResults.ResultMessage, Is.EqualTo("The design was not successful. Factor achieved = 1.103, Factor required = 8.000.")); Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.RunFailed)); Assert.That(output.Results.CalculationResults[1].PipingDesignResults.BlighFactor, Is.EqualTo(-1.000).Within(tolerance)); Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(2)); }); Assert.That(output.Results.CalculationMessages[0].Message1, Is.EqualTo("Location '101', subsoil scenario 'segment1_1D1', design scenario '1': " + "The calculation failed with error message 'The design was not successful. " + "The design was not successful. Factor achieved = 1.299, Factor required = 8.000.'")); } [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); Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(10)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, Is.EqualTo(1.516).Within(tolerance)); Assert.That(output.Results.CalculationResults[1].PipingDesignResults.BlighFactor, Is.EqualTo(1.497).Within(tolerance)); Assert.That(output.Results.CalculationResults[2].PipingDesignResults.BlighFactor, Is.EqualTo(1.299).Within(tolerance)); Assert.That(output.Results.CalculationResults[3].PipingDesignResults.BlighFactor, Is.EqualTo(-1.000).Within(tolerance)); Assert.That(output.Results.CalculationResults[4].PipingDesignResults.BlighFactor, Is.EqualTo(2.166).Within(tolerance)); Assert.That(output.Results.CalculationResults[5].PipingDesignResults.BlighFactor, Is.EqualTo(1.312).Within(tolerance)); Assert.That(output.Results.CalculationResults[6].PipingDesignResults.BlighFactor, Is.EqualTo(1.486).Within(tolerance)); Assert.That(output.Results.CalculationResults[7].PipingDesignResults.BlighFactor, Is.EqualTo(1.356).Within(tolerance)); Assert.That(output.Results.CalculationResults[8].PipingDesignResults.BlighFactor, Is.EqualTo(1.722).Within(tolerance)); Assert.That(output.Results.CalculationResults[9].PipingDesignResults.BlighFactor, Is.EqualTo(1.311).Within(tolerance)); }); } [Test] [TestCase(1)] [TestCase(4)] public void CanPerformPipingBlightWithoutUplift(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.Multiple(() => { Assert.That(errorCount, Is.EqualTo(0), "There should be no errors during the calculation."); Assert.That(output.Results.CalculationResults, Is.Not.EqualTo(null)); }); Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(6)); Assert.Multiple(() => { Assert.That(output.Results.CalculationResults[0].PipingDesignResults.BlighFactor, Is.EqualTo(1.207).Within(tolerance)); Assert.That(output.Results.CalculationResults[1].PipingDesignResults.BlighFactor, Is.EqualTo(90.000).Within(tolerance)); Assert.That(output.Results.CalculationResults[2].PipingDesignResults.BlighFactor, Is.EqualTo(90.000).Within(tolerance)); Assert.That(output.Results.CalculationResults[3].PipingDesignResults.BlighFactor, Is.EqualTo(90.000).Within(tolerance)); Assert.That(output.Results.CalculationResults[4].PipingDesignResults.BlighFactor, Is.EqualTo(7.041).Within(tolerance)); Assert.That(output.Results.CalculationResults[5].PipingDesignResults.BlighFactor, Is.EqualTo(90.000).Within(tolerance)); Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(5)); }); Assert.Multiple(() => { Assert.That(output.Results.CalculationMessages[0].Message1, Does.Contain("no uplift")); Assert.That(output.Results.CalculationMessages[1].Message1, Does.Contain("no uplift")); Assert.That(output.Results.CalculationMessages[2].Message1, Does.Contain("no uplift")); Assert.That(output.Results.CalculationMessages[3].Message1, Does.Contain("no uplift")); Assert.That(output.Results.CalculationMessages[4].Message1, Does.Contain("no uplift")); }); } [Test] public void CanHandleRunPipingBlighWithGeometry2DIsNotPossible() { // Based on DAM Tutorial Design.damx // Except for the following changes: // - Calculation type is Piping in segments.csv (instead of Stability) // - Select model Piping Bligh // - Select 1st location (DWP_1) const string calcDir = "TestRunPipingBlighWithGeometry2DIsNotPossible"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); // delete previous results } const string tutorialStability2D = @"InputTutorialStability2D.xml"; 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, "FailureMechanismSystemType", "Piping"); inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", "Piping"); inputString = XmlAdapter.ChangeStabilityToPiping(inputString); inputString = XmlAdapter.ChangePipingInputModel(inputString, InputPipingModelType.Bligh); var engineInterface = new EngineInterface(inputString); string validationMessages = engineInterface.Validate(); Assert.Multiple(() => { Assert.That(validationMessages, Does.Contain("A piping calculation with a 2D soil profile is not supported.")); Assert.That(engineInterface.DamProjectData.CalculationMessages, Has.Count.EqualTo(1)); }); Assert.That(engineInterface.DamProjectData.CalculationMessages[0].Message, Does.Contain("A piping calculation with a 2D soil profile is not supported.")); } }