// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU 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 General Public License for more details. // // You should have received a copy of the GNU 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 Deltares.Dam.Data; using Deltares.Dam.Data.DamEngineIo; using NUnit.Framework; using Deltares.Dam.TestHelper; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io; namespace Deltares.Dam.Tests { [TestFixture] public class DamPipingBenchmarkTest { const double cTolerance = 0.0005; /// /// Compute project /// /// /// private static List ComputeProject(string projectFilename, PipingModelType pipingModel) { // Read dikering using (var damProjectData = ProjectLoader.LoadProjectData(projectFilename)) { var analysisType = DamProjectCalculationSpecification.SelectedAnalysisType; try { Assert.AreEqual(1, damProjectData.WaterBoard.Dikes.Count); var dike = damProjectData.WaterBoard.Dikes[0]; Assert.AreEqual(1, dike.Locations.Count); damProjectData.DamProjectCalculationSpecification.CurrentSpecification.PipingModelType = pipingModel; DamProjectCalculationSpecification.SelectedAnalysisType = AnalysisType.NoAdaption; DamEngine.Io.XmlInput.Input input = FillXmlInputFromDamUi.CreateInput(damProjectData); #if DEBUG const string inputFilename = "PipingBlighTestInputFile.xml"; DamXmlSerialization.SaveInputAsXmlFile(inputFilename, input); #endif string inputXml = DamXmlSerialization.SaveInputAsXmlString(input); var damEnginInterface = new EngineInterface(inputXml); string validationMessages = damEnginInterface.Validate(); if (string.IsNullOrEmpty(validationMessages)) { // only if validation is ok, then string outputXml = damEnginInterface.Run(); var output = DamXmlSerialization.LoadOutputFromXmlString(outputXml); #if DEBUG const string outputFilename = "PipingBMTestOutputFile.xml"; DamXmlSerialization.SaveOutputAsXmlFile(outputFilename, output); #endif FillDamUiFromXmlOutput.AddOutputToDamProjectData(damProjectData, output); } } finally { DamProjectCalculationSpecification.SelectedAnalysisType = analysisType; } var allCalculationresults = damProjectData.DesignCalculations; return allCalculationresults; } } /// /// Benchmark test 1 /// [Test] public void Bm01OneAquiferOneLayer() { string projectFilename = @"..\..\..\data\Dam\Benchmarks\Piping\Test 1\Integratietest piping 1.damx"; var allCalculationresults = ComputeProject(projectFilename, PipingModelType.Sellmeijer4Forces); double expectedPipingFactor = 0.506; // This is calculated according to spreadsheet double expectedHCritical = 1.618839023; // This is calculated according to spreadsheet double expectedLocalPipingExitPointX = 35; // This is just taken from the calculation result itself double expectedPl3HeadAdjusted = 0.0; // For Piping, this must always be 0 double expectedPl4HeadAdjusted = 0.0; // For Piping, this must always be 0 Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Sellmeijer4ForcesPipingFactor.Value, cTolerance); Assert.AreEqual(expectedHCritical, allCalculationresults[0].Sellmeijer4ForcesHCritical.Value, cTolerance); Assert.AreEqual(true, allCalculationresults[0].IsUplift.Value); Assert.AreEqual(expectedLocalPipingExitPointX, allCalculationresults[0].LocalPipingExitPointX.Value, cTolerance); Assert.AreEqual(expectedPl3HeadAdjusted, allCalculationresults[0].Pl3HeadAdjusted.Value, cTolerance); Assert.AreEqual(expectedPl4HeadAdjusted, allCalculationresults[0].Pl4HeadAdjusted.Value, cTolerance); allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Bligh); expectedPipingFactor = 0.5208; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].BlighPipingFactor.Value, cTolerance); // Wti2017 allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Wti2017); expectedPipingFactor = 0.43219776821374467; // This is just taken from the calculation result itself expectedHCritical = 1.9830328582839827; // This is just taken from the calculation result itself expectedLocalPipingExitPointX = 35; // This is just taken from the calculation result itself expectedPl3HeadAdjusted = 0.0; // This is just taken from the calculation result itself expectedPl4HeadAdjusted = 0.0; // This is just taken from the calculation result itself var expectedCCreep = 18.076215507286715; var expectedEffectiveStress = 12.38; var expectedBackwardErosionDeltaPhiReduced = 3.20; var expectedBackwardErosionDeltaPhiC = 1.3830328582839828; var expectedUpliftSafetyFactor = 0.33209936155373138; var expectedUpliftHcritical = 1.2619775739041792; var expectedUpliftDeltaPhiC = 1.2619775739041792; var expectedHeaveSafetyFactor = 0.15789473684210525; var expectedHeaveHcritical = 0.6; var expectedGradient = 1.9; var expectedSafetyFactorOverall = expectedPipingFactor; var expectedHcriticalOverall = expectedHCritical; Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Wti2017BackwardErosionSafetyFactor.Value, cTolerance); Assert.AreEqual(expectedHCritical, allCalculationresults[0].Wti2017BackwardErosionHcritical.Value, cTolerance); Assert.AreEqual(true, allCalculationresults[0].IsUplift.Value); Assert.AreEqual(expectedLocalPipingExitPointX, allCalculationresults[0].LocalPipingExitPointX.Value, cTolerance); Assert.AreEqual(expectedPl3HeadAdjusted, allCalculationresults[0].Pl3HeadAdjusted.Value, cTolerance); Assert.AreEqual(expectedPl4HeadAdjusted, allCalculationresults[0].Pl4HeadAdjusted.Value, cTolerance); Assert.AreEqual(expectedCCreep, allCalculationresults[0].Wti2017CCreep, cTolerance); Assert.AreEqual(expectedEffectiveStress, allCalculationresults[0].Wti2017EffectiveStress, cTolerance); Assert.AreEqual(expectedBackwardErosionDeltaPhiReduced, allCalculationresults[0].Wti2017BackwardErosionDeltaPhiReduced, cTolerance); Assert.AreEqual(expectedBackwardErosionDeltaPhiC, allCalculationresults[0].Wti2017BackwardErosionDeltaPhiC, cTolerance); Assert.AreEqual(expectedUpliftSafetyFactor, allCalculationresults[0].Wti2017UpliftSafetyFactor, cTolerance); Assert.AreEqual(expectedUpliftHcritical, allCalculationresults[0].Wti2017UpliftHcritical, cTolerance); Assert.AreEqual(expectedUpliftDeltaPhiC, allCalculationresults[0].Wti2017UpliftDeltaPhiC, cTolerance); Assert.AreEqual(expectedHeaveSafetyFactor, allCalculationresults[0].Wti2017HeaveSafetyFactor, cTolerance); Assert.AreEqual(expectedHeaveHcritical, allCalculationresults[0].Wti2017HeaveHcritical, cTolerance); Assert.AreEqual(expectedGradient, allCalculationresults[0].Wti2017Gradient, cTolerance); Assert.AreEqual(expectedSafetyFactorOverall, allCalculationresults[0].Wti2017SafetyFactorOverall, cTolerance); Assert.AreEqual(expectedHcriticalOverall, allCalculationresults[0].Wti2017HcriticalOverall, cTolerance); } /// /// Benchmark test 2 /// [Test] public void Bm02OneAquiferTwoLayers() { string projectFilename = @"..\..\..\data\Dam\Benchmarks\Piping\Test 2\Integratietest piping 2.damx"; var allCalculationresults = ComputeProject(projectFilename, PipingModelType.Sellmeijer4Forces); double expectedPipingFactor = 0.489; // This is calculated according to spreadsheet Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Sellmeijer4ForcesPipingFactor.Value, cTolerance); allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Bligh); expectedPipingFactor = 0.5208; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].BlighPipingFactor.Value, cTolerance); // Wti2017 allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Wti2017); expectedPipingFactor = 0.42241892923665264; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Wti2017BackwardErosionSafetyFactor.Value, cTolerance); } /// /// Benchmark test 3 /// [Test] public void Bm03OneAquiferThreeLayers() { string projectFilename = @"..\..\..\data\Dam\Benchmarks\Piping\Test 3\Integratietest piping 3.damx"; var allCalculationresults = ComputeProject(projectFilename, PipingModelType.Sellmeijer4Forces); double expectedPipingFactor = 0.494; // This is calculated according to spreadsheet Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Sellmeijer4ForcesPipingFactor.Value, cTolerance); allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Bligh); expectedPipingFactor = 0.5208; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].BlighPipingFactor.Value, cTolerance); // Wti2017 allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Wti2017); expectedPipingFactor = 0.4275708873438484; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Wti2017BackwardErosionSafetyFactor.Value, cTolerance); } /// /// Benchmark test 4 /// [Test] public void Bm04TwoAquifersOneLayer() { string projectFilename = @"..\..\..\data\Dam\Benchmarks\Piping\Test 4\Integratietest piping 4.damx"; var allCalculationresults = ComputeProject(projectFilename, PipingModelType.Sellmeijer4Forces); double expectedPipingFactor = 0.608; // This is calculated according to spreadsheet Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Sellmeijer4ForcesPipingFactor.Value, cTolerance); allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Bligh); expectedPipingFactor = 0.5208; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].BlighPipingFactor.Value, cTolerance); // Wti2017 is not supported for now allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Wti2017); expectedPipingFactor = 0.50501856442086579; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Wti2017BackwardErosionSafetyFactor.Value, cTolerance); } /// /// Benchmark test 5 /// [Test] public void Bm05TwoAquifersTwoLayers() { string projectFilename = @"..\..\..\data\Dam\Benchmarks\Piping\Test 5\Integratietest piping 5.damx"; var allCalculationresults = ComputeProject(projectFilename, PipingModelType.Sellmeijer4Forces); double expectedPipingFactor = 0.618; // This is calculated according to spreadsheet Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Sellmeijer4ForcesPipingFactor.Value, cTolerance); allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Bligh); expectedPipingFactor = 0.5208; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].BlighPipingFactor.Value, cTolerance); // Wti2017 is not supported for now allCalculationresults.Clear(); allCalculationresults = ComputeProject(projectFilename, PipingModelType.Wti2017); expectedPipingFactor = 0.51473283261943303; // This is just taken from the calculation result itself Assert.AreEqual(expectedPipingFactor, allCalculationresults[0].Wti2017BackwardErosionSafetyFactor.Value, cTolerance); } } }