// 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; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.Common; [TestFixture] public class PlLinesHelperTests { [Test] public void TestCreatePlLinesNoHydraulicShortcut() { // expected values retrieved from debugging Dam Classic (rev.663) // test CanCalculateThePipingFactorUsingSellmeijer4Forces SoilProfile1D soilProfile1D = FactoryForSoilProfiles.CreatePipingSellmeijerProfileWithOneSandLayer(out SoilList soilList); var location = new Location { CurrentScenario = new DesignScenario(), // Ditch bottom level (-1.9 m) must be above the bottom aquifer (-2 m) to avoid reduction of PL 3 SurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(false, -1.9), DikeEmbankmentMaterial = soilList.Soils[0].Name, SoilList = soilList }; var riverLevel = 1.0; var timeStepDateTime = new DateTime(); PlLines plLines = PlLinesHelper.CreatePlLinesForPiping(timeStepDateTime, location, soilProfile1D, riverLevel); Assert.Multiple(() => { Assert.That(plLines.PlLineCount, Is.EqualTo(4)); Assert.That(plLines.Lines[PlLineType.Pl1].Points, Has.Count.EqualTo(8)); Assert.That(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[0]), Is.True); Assert.That(new PlLinePoint(14.900, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[1]), Is.True); Assert.That(new PlLinePoint(34.500, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[2]), Is.True); Assert.That(new PlLinePoint(40.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[3]), Is.True); Assert.That(new PlLinePoint(50.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[4]), Is.True); Assert.That(new PlLinePoint(58.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[5]), Is.True); Assert.That(new PlLinePoint(61.510, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[6]), Is.True); Assert.That(new PlLinePoint(75.000, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[7]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl2].Points, Is.Empty); Assert.That(plLines.Lines[PlLineType.Pl3].Points, Has.Count.EqualTo(2)); Assert.That(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[0]), Is.True); Assert.That(new PlLinePoint(75.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[1]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl4].Points, Is.Empty); }); } [Test] public void TestCreatePlLinesHydraulicShortcut() { // expected values retrieved from debugging Dam Classic (rev.663) // test CanCalculateThePipingFactorUsingSellmeijer4Forces // Same as TestCreatePlLinesNoHydraulicShortcut because HeadInPlLine3 is not given. SoilProfile1D soilProfile1D = FactoryForSoilProfiles.CreatePipingSellmeijerProfileWithOneSandLayer(out SoilList soilList); var location = new Location { CurrentScenario = new DesignScenario(), // Ditch bottom level (-1.9 m) must be above the bottom aquifer (-2 m) to avoid reduction of PL 3 SurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(false, -1.9), DikeEmbankmentMaterial = soilList.Soils[0].Name, SoilList = soilList }; var riverLevel = 1.0; var timeStepDateTime = new DateTime(); PlLines plLines = PlLinesHelper.CreatePlLinesForPiping(timeStepDateTime, location, soilProfile1D, riverLevel); Assert.Multiple(() => { Assert.That(plLines.PlLineCount, Is.EqualTo(4)); Assert.That(plLines.Lines[PlLineType.Pl1].Points, Has.Count.EqualTo(8)); Assert.That(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[0]), Is.True); Assert.That(new PlLinePoint(14.900, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[1]), Is.True); Assert.That(new PlLinePoint(34.500, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[2]), Is.True); Assert.That(new PlLinePoint(40.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[3]), Is.True); Assert.That(new PlLinePoint(50.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[4]), Is.True); Assert.That(new PlLinePoint(58.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[5]), Is.True); Assert.That(new PlLinePoint(61.510, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[6]), Is.True); Assert.That(new PlLinePoint(75.000, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[7]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl2].Points, Is.Empty); Assert.That(plLines.Lines[PlLineType.Pl3].Points, Has.Count.EqualTo(2)); Assert.That(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[0]), Is.True); Assert.That(new PlLinePoint(75.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[1]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl4].Points, Is.Empty); }); } [Test] public void TestCreatePlLinesHydraulicShortcutWithHeadPl3AndInBetweenAquifer() { // expected values retrieved from debugging Dam Classic (rev.663) // test CanCalculateThePipingFactorUsingSellmeijer4Forces // PL1 is same as TestCreatePlLinesHydraulicShortcutWithHeadPl3 (same river level = 0.5) // PL3 is same as TestCreatePlLinesNoHydraulicShortcut because HeadInPlLine3 is given with value 1 and there is an // in between aquifer so Head (1.0) is used instead of river level. // PL2 and PL4 now generated at river level. SoilProfile1D soilProfile1D = FactoryForSoilProfiles.CreatePipingSellmeijerProfileWithOneSandLayer(out SoilList soilList); AddLayerToSoilProfile(soilProfile1D, -4, false); AddLayerToSoilProfile(soilProfile1D, -5, true); var scenario = new DesignScenario { HeadPl3 = 1.0 }; var location = new Location { CurrentScenario = scenario, // Ditch bottom level (-1.9 m) must be above the bottom aquifer (-2 m) to avoid reduction of PL 3 SurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(false, -1.9), DikeEmbankmentMaterial = soilList.Soils[0].Name, SoilList = soilList }; var riverLevel = 0.5; var timeStepDateTime = new DateTime(); PlLines plLines = PlLinesHelper.CreatePlLinesForPiping(timeStepDateTime, location, soilProfile1D, riverLevel); Assert.Multiple(() => { Assert.That(plLines.PlLineCount, Is.EqualTo(4)); Assert.That(plLines.Lines[PlLineType.Pl1].Points, Has.Count.EqualTo(8)); Assert.That(new PlLinePoint(0.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[0]), Is.True); Assert.That(new PlLinePoint(12.450, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[1]), Is.True); Assert.That(new PlLinePoint(34.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[2]), Is.True); Assert.That(new PlLinePoint(40.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[3]), Is.True); Assert.That(new PlLinePoint(50.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[4]), Is.True); Assert.That(new PlLinePoint(58.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[5]), Is.True); Assert.That(new PlLinePoint(61.510, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[6]), Is.True); Assert.That(new PlLinePoint(75.000, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[7]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl2].Points, Has.Count.EqualTo(2)); Assert.That(new PlLinePoint(0.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl2].Points[0]), Is.True); Assert.That(new PlLinePoint(75.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl2].Points[1]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl3].Points, Has.Count.EqualTo(2)); Assert.That(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[0]), Is.True); Assert.That(new PlLinePoint(75.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[1]), Is.True); Assert.That(plLines.Lines[PlLineType.Pl4].Points, Has.Count.EqualTo(2)); Assert.That(new PlLinePoint(0.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl4].Points[0]), Is.True); Assert.That(new PlLinePoint(75.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl4].Points[1]), Is.True); }); } private void AddLayerToSoilProfile(SoilProfile1D soilProfile, double topLevel, bool isAquifer) { var layer = new SoilLayer1D { Name = GetNewUniqueLayerId(soilProfile), TopLevel = topLevel, Soil = new Soil("Sand", 22.0, 20.0) { PermeabKx = 0.0001, DiameterD70 = Physics.FactorMicroMeterToMeter * 200.0 }, IsAquifer = isAquifer }; soilProfile.Layers.Add(layer); } private static string GetNewUniqueLayerId(SoilProfile1D soilProfile1D) { var num = 0; string id; do { id = "L" + num++; } while (soilProfile1D.GetLayerWithName(id) != null); return id; } }