// Copyright (C) Stichting Deltares 2017. 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.Data; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Calculators.KernelWrappers.DamPipingSellmeijer4Forces; using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.Results; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard.Logging; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamPipingSellmeijer4Forces { [TestFixture] public class DamPipingSellmeijer4ForcesTests { [Test] public void TestFullCalculation() { // expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 // reducedFall = HRiver - HExit - (Rc * DTotal) = 1.0 - 0.0 - (0.3 * 2.0) = 0.4 // FoSp = Hc / reducedFall = 4.7596 / 0.4 = 11.899 // For calculation of Hc see TestCanCalculateHCritical // See also "..\..\doc\Evaluation Piping\Nieuwe rekenregel bligh Sellmeijeruli.xls" const double diff = 0.0001; var designScenario = new DesignScenario(); designScenario.Location = new Location(); designScenario.RiverLevel = 1.0; designScenario.ModelFactors.UpliftCriterionPiping = 1.0; var location = new Location(); location.SurfaceLine = CreateSurfaceLineTutorial1(); var subSoilScenario = new SoilGeometryProbability(); subSoilScenario.SoilProfile1D = CreatePipingSellmeijerProfileWithOneSandlayer(); subSoilScenario.SegmentFailureMechanismType = FailureMechanismSystemType.Piping; var damKernelInput = new DamKernelInput { DesignScenario = designScenario, Location = location, SubSoilScenario = subSoilScenario }; var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); // Prepare the wrapper. Result is input for the calculation dll IKernelDataInput damPipingInput; kernelWrapper.Prepare(damKernelInput, out damPipingInput); // Validate the input List messages; kernelWrapper.Validate(damPipingInput, out messages); Assert.AreEqual(0, messages.Count); // Run the dll DamPipingSellmeijer4ForcesOutput output = (DamPipingSellmeijer4ForcesOutput) kernelWrapper.Execute(damPipingInput, out messages); Assert.AreEqual(0, messages.Count); Assert.AreEqual(11.899117458988471, output.FoSp, diff); Assert.AreEqual(4.7596469835953883, output.Hc, diff); // Fill the design results DesignResult result; kernelWrapper.PostProcess(damKernelInput, output, out result); Assert.AreEqual(11.899117458988471, result.PipingDesignResults.Sellmeijer4ForcesFactor, diff); Assert.AreEqual(4.7596469835953883, result.PipingDesignResults.Sellmeijer4ForcesHcritical, diff); } [Test] public void TestPrepare() { const double diff = 0.0001; var designScenario = new DesignScenario(); designScenario.Location = new Location(); designScenario.RiverLevel = 1.0; designScenario.ModelFactors.UpliftCriterionPiping = 1.0; var location = new Location(); location.SurfaceLine = CreateSurfaceLineTutorial1(); var subSoilScenario = new SoilGeometryProbability(); subSoilScenario.SoilProfile1D = CreatePipingSellmeijerProfileWithOneSandlayer(); subSoilScenario.SegmentFailureMechanismType = FailureMechanismSystemType.Piping; var damKernelInput = new DamKernelInput { DesignScenario = designScenario, Location = location, SubSoilScenario = subSoilScenario }; var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); IKernelDataInput kernelDataInput; kernelWrapper.Prepare(damKernelInput, out kernelDataInput); DamPipingSellmeijer4ForcesInput damPipingInput = (DamPipingSellmeijer4ForcesInput) kernelDataInput; Assert.AreEqual(1.0, damPipingInput.HRiver, diff); Assert.AreEqual(0.0, damPipingInput.HExit, diff); Assert.AreEqual(0.3, damPipingInput.Rc, diff); Assert.AreEqual(2.0, damPipingInput.DTotal, diff); Assert.AreEqual(8.0, damPipingInput.AquiferHeight, diff); Assert.AreEqual(40.5, damPipingInput.SeepageLength, diff); Assert.AreEqual(200.0, damPipingInput.D70, diff); Assert.AreEqual(0.25, damPipingInput.WhitesConstant, diff); Assert.AreEqual(37.0, damPipingInput.BeddingAngle, diff); Assert.AreEqual(1.33E-06, damPipingInput.WaterViscosity, diff); Assert.AreEqual(0.0001, damPipingInput.PermeabilityKx, diff); } [Test] public void TestValidate() { var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); // Validate without setting values. Expected error messages. var damPipingInput = new DamPipingSellmeijer4ForcesInput(); List messages; kernelWrapper.Validate(damPipingInput, out messages); Assert.IsTrue(messages.Count > 0); // Validate the input when valid input is provided. Expected no messages. damPipingInput = new DamPipingSellmeijer4ForcesInput { HRiver = 1.0, HExit = 0.0, Rc = 0.3, DTotal = 2.0, AquiferHeight = 8.0, SeepageLength = 40.5, D70 = 200.0, WhitesConstant = 0.25, BeddingAngle = 37.0, WaterViscosity = 1.33E-06, PermeabilityKx = 0.0001 }; messages.Clear(); kernelWrapper.Validate(damPipingInput, out messages); Assert.AreEqual(0, messages.Count); } [Test] public void TestPostProcess() { var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); var input = new DamKernelInput { DesignScenario = new DesignScenario(), Location = new Location(), SubSoilScenario = new SoilGeometryProbability() }; input.DesignScenario.Location = new Location(); DamPipingSellmeijer4ForcesOutput output = new DamPipingSellmeijer4ForcesOutput { FoSp = 1.1, Hc = 2.2 }; DesignResult result; kernelWrapper.PostProcess(input, output, out result); Assert.AreEqual(output.FoSp, result.PipingDesignResults.Sellmeijer4ForcesFactor); Assert.AreEqual(output.Hc, result.PipingDesignResults.Sellmeijer4ForcesHcritical); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Sellmeijer 4 Krachten")] [SetUICulture("nl-NL")] public void TestLanguageNLThrowsExceptionInExecuteWhenInputIsNull() { var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); List messages; kernelWrapper.Execute(null, out messages); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Sellmeijer 4 Forces")] [SetUICulture("en-US")] public void TestLanguageENThrowsExceptionInExecuteWhenInputIsNull() { var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); List messages; kernelWrapper.Execute(null, out messages); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen uitvoer object gedefinieerd voor Sellmeijer 4 Krachten")] [SetUICulture("nl-NL")] public void TestThrowsExceptionInPostProcessWhenOutputIsNull() { var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); DesignResult result; kernelWrapper.PostProcess(new DamKernelInput(), null, out result); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Sellmeijer 4 Krachten")] [SetUICulture("nl-NL")] public void TestThrowsExceptionInPostProcessWhenInputIsNull() { var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); DesignResult result; kernelWrapper.PostProcess(null, new DamPipingSellmeijer4ForcesOutput(), out result); } private static SoilProfile1D CreatePipingSellmeijerProfileWithOneSandlayer() { SoilProfile1D soilProfile1D = new SoilProfile1D(); SoilLayer1D soilLayer1D1 = new SoilLayer1D(); soilLayer1D1.Name = "L0"; soilLayer1D1.TopLevel = 10.0; soilLayer1D1.Soil = new Soil("Topmaterial", 1.0, 1.0); soilLayer1D1.Soil.PermeabKx = 0.0003; soilLayer1D1.Soil.DiameterD70 = 0.0003; soilLayer1D1.Soil.WhitesConstant = 0.5; soilLayer1D1.Soil.BeddingAngle = 57.0; soilLayer1D1.IsAquifer = false; soilProfile1D.Layers.Add(soilLayer1D1); SoilLayer1D soilLayer1D2 = new SoilLayer1D(); soilLayer1D2.Name = "L1"; soilLayer1D2.TopLevel = -2.0; soilLayer1D2.Soil = new Soil("Sand", 22.0, 20.0); soilLayer1D2.Soil.PermeabKx = 0.0001; soilLayer1D2.Soil.DiameterD70 = 0.0002; soilLayer1D2.Soil.WhitesConstant = 0.25; soilLayer1D2.Soil.BeddingAngle = 37.0; soilLayer1D2.IsAquifer = true; soilProfile1D.Layers.Add(soilLayer1D2); soilProfile1D.BottomLevel = -10.0; return soilProfile1D; } private static SurfaceLine2 CreateSurfaceLineTutorial1(bool includingTraffic = false) { SurfaceLine2 surfaceLine2 = new SurfaceLine2(); surfaceLine2.Name = "Tutorial1"; surfaceLine2.Geometry = new GeometryPointString(); surfaceLine2.CharacteristicPoints.GeometryMustContainPoint = true; SurfaceLine2 line = surfaceLine2; line.EnsurePointOfType(0.0, 0.0, CharacteristicPointType.SurfaceLevelOutside); line.EnsurePointOfType(10.0, 0.0, CharacteristicPointType.DikeToeAtRiver); line.EnsurePointOfType(34.5, 5.0, CharacteristicPointType.DikeTopAtRiver); if (includingTraffic) { line.EnsurePointOfType(35.0, 5.0, CharacteristicPointType.TrafficLoadOutside); line.EnsurePointOfType(38.5, 5.0, CharacteristicPointType.TrafficLoadInside); } line.EnsurePointOfType(40.5, 5.0, CharacteristicPointType.DikeTopAtPolder); line.EnsurePointOfType(50.5, 0.0, CharacteristicPointType.DikeToeAtPolder); line.EnsurePointOfType(58.5, 0.0, CharacteristicPointType.DitchDikeSide); line.EnsurePointOfType(59.5, -2.0, CharacteristicPointType.BottomDitchDikeSide); line.EnsurePointOfType(61.5, -2.0, CharacteristicPointType.BottomDitchPolderSide); line.EnsurePointOfType(61.5, 0.0, CharacteristicPointType.DitchPolderSide); line.EnsurePointOfType(75.0, 0.0, CharacteristicPointType.SurfaceLevelInside); line.Geometry.SyncCalcPoints(); return line; } } }