// Copyright (C) Stichting Deltares 2021. 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 Deltares.Dam.Data.DamEngineIo;
using Deltares.DamEngine.Interface;
using Deltares.DamEngine.Io;
using System.Collections.Generic;
using Deltares.Dam.Data;
using Deltares.Standard.TestUtils;
using NUnit.Framework;
using Deltares.Dam.TestHelper;
namespace Deltares.Dam.Tests
{
[TestFixture]
public class DamCalculationBenchmarkTest
{
const double cTolerance = 0.001;
#region SupportingMethods
#endregion SupportingMethods
#region Uplift
///
/// Compute project
///
///
///
///
///
private static List ComputeStabilityInsideProject(string projectFilename,
MStabModelType modelType, int expectedLocations)
{
using (DamProjectData damProjectData =
ProjectLoader.LoadProjectData(projectFilename))
{
Assert.AreEqual(1, damProjectData.WaterBoard.Dikes.Count);
Dike dike = damProjectData.WaterBoard.Dikes[0];
Assert.AreEqual(expectedLocations, dike.Locations.Count);
// Specify calculation
damProjectData.DamProjectCalculationSpecification.CurrentSpecification.StabilityModelType =
modelType;
damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismeParamatersMStab
.MStabParameters.GridPosition = MStabGridPosition.Right;
damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismeParamatersMStab
.MStabParameters.SearchMethod = MStabSearchMethod.Grid;
damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType =
FailureMechanismSystemType.StabilityInside;
damProjectData.LocationJobs[0].Run = true;
DamProjectCalculationSpecification.SelectedAnalysisType = AnalysisType.NoAdaption;
DamEngine.Io.XmlInput.Input input = FillXmlInputFromDamUi.CreateInput(damProjectData);
string inputXml = DamXmlSerialization.SaveInputAsXmlString(input);
var damEngineInterface = new EngineInterface(inputXml);
string validationMessages = damEngineInterface.Validate();
if (string.IsNullOrEmpty(validationMessages))
{
// only if validation is ok, then
string outputXml = damEngineInterface.Run();
var output = DamXmlSerialization.LoadOutputFromXmlString(outputXml);
FillDamUiFromXmlOutput.AddOutputToDamProjectData(damProjectData, output);
}
List allCalculationResults = damProjectData.DesignCalculations;
return allCalculationResults;
}
}
///
/// Performs test BM04Opdijven01 situation without uplift 1D
///
[Test, Ignore]
[Category("Slow")]
[Category(Categories.WorkInProgress)] // DamMacroStability kernel is being replaced by Macrostability kernel in DamEngine
public void BM04Opdrijven01SituatieZonderOpdrijven1D()
{
string cFolderName =
@"..\..\..\data\Dam\\Benchmarks\4 Validatie opdrijfberekeningen\01 Situatie zonder opdrijven (1D)\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.Bishop, 1);
Assert.IsTrue(allCalculationResults[0].IsUplift.Value);
Assert.AreEqual(1.024077029, allCalculationResults[0].Pl3MinUplift.Value, cTolerance);
Assert.AreEqual(49.1, allCalculationResults[0].Pl3LocalLocationXMinUplift.Value,
cTolerance);
}
///
/// Performs test BM04Opdrijven02 situation where uplift occurs 1D
///
[Test, Ignore]
[Category("Slow")]
[Category(Categories.WorkInProgress)] // DamMacroStability kernel is being replaced by Macrostability kernel in DamEngine
public void BM04Opdrijven02SituatieMetOpdrijven1D()
{
string cFolderName =
@"..\..\..\data\Dam\\Benchmarks\4 Validatie opdrijfberekeningen\02 Situatie met opdrijven (1D)\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.Bishop, 1);
Assert.IsTrue(allCalculationResults[0].IsUplift.Value);
Assert.AreEqual(0.905914295, allCalculationResults[0].Pl3MinUplift.Value, cTolerance);
Assert.AreEqual(-1.289245668, allCalculationResults[0].Pl3HeadAdjusted.Value, cTolerance);
Assert.AreEqual(49.1, allCalculationResults[0].Pl3LocalLocationXMinUplift.Value, cTolerance);
}
///
/// Performs test BM04Opdrijven03 situation with a labile equilibirum 1D
///
[Test, Ignore]
[Category("Slow")]
[Category(Categories.WorkInProgress)] // DamMacroStability kernel is being replaced by Macrostability kernel in DamEngine
public void BM04Opdrijven03SituatieMetEenLabielEvenwicht1D()
{
string cFolderName =
@"..\..\..\data\Dam\\Benchmarks\4 Validatie opdrijfberekeningen\03 Situatie met een labiel evenwicht (1D)\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.Bishop, 1);
Assert.IsTrue(allCalculationResults[0].IsUplift.Value);
Assert.AreEqual(1.0, allCalculationResults[0].Pl3MinUplift.Value, cTolerance);
Assert.AreEqual(-1.289245668, allCalculationResults[0].Pl3HeadAdjusted.Value, cTolerance);
Assert.AreEqual(49.1, allCalculationResults[0].Pl3LocalLocationXMinUplift.Value, cTolerance);
}
///
/// performs test BM04Opdrijven04 situation with an inclined ditch bottom where uplift occurs 1D
///
[Test, Ignore]
[Category("Slow")]
[Category(Categories.WorkInProgress)] // DamMacroStability kernel is being replaced by Macrostability kernel in DamEngine
public void BM04Opdrijven04SituatieMetEenSchuineSlootbodemEnOpdrijvenOp1Locatie1D()
{
string cFolderName =
@"..\..\..\data\Dam\Benchmarks\4 Validatie opdrijfberekeningen\04 Situatie met een schuine slootbodem en opdrijven op 1 locatie (1D)\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.Bishop, 1);
Assert.IsTrue(allCalculationResults[0].IsUplift.Value);
Assert.AreEqual(0.969283045, allCalculationResults[0].Pl3MinUplift.Value, cTolerance);
Assert.AreEqual(-1.6382263, allCalculationResults[0].Pl3HeadAdjusted.Value, cTolerance);
Assert.AreEqual(49.1, allCalculationResults[0].Pl3LocalLocationXMinUplift.Value, cTolerance);
}
///
/// Performs test BM04Opdrijven05 situation with soil layers aboven and below the phreatic line 1D
///
[Test, Ignore]
[Category("Slow")]
public void BM04Opdrijven05SituatieMetGrondlagenBovenEnOnderHetFreatischVlak1D()
{
string cFolderName =
@"..\..\..\data\Dam\\Benchmarks\4 Validatie opdrijfberekeningen\05 Situatie met grondlagen boven en onder het freatisch vlak (1D)\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.Bishop, 1);
var isUplift = allCalculationResults[0].IsUplift;
Assert.IsFalse(isUplift != null && isUplift.Value);
Assert.AreEqual(null, allCalculationResults[0].Pl3MinUplift);
Assert.AreEqual(null, allCalculationResults[0].Pl3LocalLocationXMinUplift);
}
///
/// Performs test BM04Opdrijven06 situation with uplift on different locations along the 1D profile
///
[Test, Ignore]
[Category("Slow")]
[Category(Categories.WorkInProgress)] // DamMacroStability kernel is being replaced by Macrostability kernel in DamEngine
public void BM04Opdrijven06SituatieMetOpdrijvenOpVerschillendeLocatiesLangsHetProfiel1D()
{
string cFolderName =
@"..\..\..\data\Dam\Benchmarks\4 Validatie opdrijfberekeningen\06 Situatie met verschillende opdrijflocaties (1D)\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.Bishop, 1);
Assert.IsTrue(allCalculationResults[0].IsUplift.Value);
// Values at bottom ditch dikeside
Assert.AreEqual(0.820097604, allCalculationResults[0].Pl3MinUplift.Value, cTolerance);
Assert.AreEqual(-1.289245668, allCalculationResults[0].Pl3HeadAdjusted.Value, cTolerance);
Assert.AreEqual(49.1, allCalculationResults[0].Pl3LocalLocationXMinUplift.Value, cTolerance);
}
///
/// Performs test on Dijkring13, 3 different scenarios are tested, with different uplift potentials
///
[Test]
[Category("Slow")]
public void Dijkring13NormalStabilityCalculation()
{
const string cDikeFolder = @"..\..\..\data\Dam\Benchmarks\4 Validatie opdrijfberekeningen\Dijkring13-Sec1\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cDikeFolder, MStabModelType.Bishop, 1);
// Following values are just taken from the Geo Stability calculation and not manually calculated
Assert.AreEqual(0.785, allCalculationResults[0].StabilitySafetyFactor.Value, cTolerance);
Assert.AreEqual(0.998, allCalculationResults[1].StabilitySafetyFactor.Value, cTolerance);
Assert.AreEqual(0.792, allCalculationResults[2].StabilitySafetyFactor.Value, cTolerance);
}
///
/// Performs test BMStabilityInwardsNoAdaptation
///
[Test]
[Category("Slow")]
public void BMStabilityInwardsNoAdaptation()
{
string cFolderName =
@"..\..\..\data\Dam\\Benchmarks\Validatie UpliftVan\StabilityInwards-NoAdaptation\Databronbestand.damx";
List allCalculationResults = ComputeStabilityInsideProject(cFolderName, MStabModelType.UpliftVan, 1);
Assert.IsTrue(allCalculationResults[0].IsUplift.Value);
Assert.AreEqual(0.767, allCalculationResults[0].StabilitySafetyFactor.Value, cTolerance);
}
#endregion Uplift
}
}