// 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.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.Geometry;
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;
using UpliftSituation = Deltares.DamEngine.Io.XmlOutput.UpliftSituation;
namespace Deltares.DamEngine.IntegrationTests.IntegrationTests;
[TestFixture]
public class MacroStabilityInwardsTests
{
private const double tolerance = 0.0005;
private const string mapTestFiles = @"TestFiles\";
private const double tol2Digits = 0.005;
[TearDown]
public void TearDown()
{
// Ensure clearing directories at end.
RemoveUsedDirectoryAfterTests("2DGeometryNoFittingSurfaceLine");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishop2DStix");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishop");
RemoveUsedDirectoryAfterTests("TestStabInwardsUpliftVan");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVan_UpliftVanLowest");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVan_BishopLowest");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVan_NoUplift");
RemoveUsedDirectoryAfterTests("TestStabInwardsForbiddenZoneBishop");
RemoveUsedDirectoryAfterTests("TestStabInwardsWithErrorUpliftVan");
RemoveUsedDirectoryAfterTests("TestStabInwardsWithErrorBishopUpliftVan");
RemoveUsedDirectoryAfterTests("TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption");
RemoveUsedDirectoryAfterTests("TestRunFailedExpectCalculationMessageInSlopeAdaptionBeforeShoulderAdaption");
RemoveUsedDirectoryAfterTests("TestGiveFeedBackWhenNoProfilesAreAvailable");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishopWithStixFiles");
RemoveUsedDirectoryAfterTests("TestStabInwardsUpliftVanWithStixFiles");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVanWithUpliftWithStixFiles");
RemoveUsedDirectoryAfterTests("TestStabInwardsBishopUpliftVanWithoutUpliftWithStixFiles");
}
[Test, Category("Slow"), Ignore("This test is not yet implemented, waits on stix implementation")]
//ToDo bka: The profiles that are mentioned in the xml are not available
[Category(Categories.WorkInProgress)]
public void TestBishopNoAdaptionWith2DGeometriesBasedOnStixFiles()
{
const string calcDir = "TestStabInwardsBishop2DStix";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\Test2DGeometryBasedOnStixFiles.xml";
string inputString = File.ReadAllText(fileName);
inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
var engineInterface = new EngineInterface(inputString);
Assert.That(engineInterface.DamProjectData, Is.Not.Null);
Output output = GeneralHelper.RunAfterInputValidation(inputString);
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.282).Within(tolerance));
}
/// Test for different segmentFailureMechanismType
/// The soil probabilities are set tot the specified segmentFailureMechanismType
[Test, Category(Categories.Slow)]
[Category(Categories.WorkInProgress)]
[TestCase(ConversionHelper.InputSegmentFailureMechanismStability)]
//[TestCase(ConversionHelper.InputSegmentFailureMechanismAll)] //ToDo bka: Does not work. Should this be implemented? Or remove it?
public void TestRunMacroStabilityTutorialDesignBishop(int segmentFailureMechanismType)
{
// Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx"
// with Dam Classic rev.1059
// Set Analysis type to "No adaption"
// Select 1st location (DWP_1)
// Set Calculation Options: Stability Inside - Bishop
// Expected results are determined by running dam\dam clients\DamUI\trunk\data\DamEngineTestProjects\DAM Tutorial Design
// with Dam Classic rev.833
const string calcDir = "TestStabInwardsBishop";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml";
string inputString = File.ReadAllText(fileName);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", segmentFailureMechanismType.ToString());
Output output = GeneralHelper.RunAfterInputValidation(inputString);
Assert.Multiple(() =>
{
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.309).Within(tolerance));
// NumberOfIterations=0
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations, Is.EqualTo(0));
// ResultMessage ""
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage, Is.EqualTo(""));
// Check that a line is specified
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine, Is.Not.Null);
// Profile name = DWP_1.sti
Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("DWP_1.stix"));
});
// Uplift
UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation;
Assert.That(upliftSituation, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(upliftSituation.IsUplift, Is.EqualTo(true));
Assert.That(upliftSituation.Pl3MinUplift, Is.EqualTo(1.135).Within(tolerance));
Assert.That(upliftSituation.Pl3HeadAdjusted, Is.EqualTo(4.400).Within(tolerance));
Assert.That(upliftSituation.Pl3LocationXMinUplift, Is.EqualTo(60.640).Within(tolerance));
Assert.That(upliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance));
Assert.That(upliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance));
Assert.That(upliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance));
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
}
[Test, Category(Categories.Slow)]
public void TestRunMacroStabilityTutorialDesignUpliftVan()
{
// Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx"
// with Dam Classic rev.1059
// Select 1st location (DWP_1)
// with Dam Classic rev.833
const string calcDir = "TestStabInwardsUpliftVan";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
Assert.Multiple(() =>
{
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, Is.EqualTo(1.218).Within(tolerance));
// NumberOfIterations=0
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.NumberOfIterations, Is.EqualTo(0));
// ResultMessage ""
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.ResultMessage, Is.EqualTo(""));
// Check that a line is specified
Assert.That(output.Results.CalculationResults[0].StabilityDesignResults.RedesignedSurfaceLine, Is.Not.Null);
// Profile name = DWP_1.sti
Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("DWP_1.stix"));
});
// Uplift
UpliftSituation upliftSituation = output.Results.CalculationResults[0].StabilityDesignResults.UpliftSituation;
Assert.That(upliftSituation, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(upliftSituation.IsUplift, Is.EqualTo(true));
Assert.That(upliftSituation.Pl3MinUplift, Is.EqualTo(1.135).Within(tolerance));
Assert.That(upliftSituation.Pl3HeadAdjusted, Is.EqualTo(4.400).Within(tolerance));
Assert.That(upliftSituation.Pl3LocationXMinUplift, Is.EqualTo(60.640).Within(tolerance));
Assert.That(upliftSituation.Pl4MinUplift, Is.EqualTo(0.0).Within(tolerance));
Assert.That(upliftSituation.Pl4HeadAdjusted, Is.EqualTo(0.0).Within(tolerance));
Assert.That(upliftSituation.Pl4LocationXMinUplift, Is.EqualTo(0.0).Within(tolerance));
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
}
[Test, Category(Categories.Slow)]
public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_UpliftVanLowest()
{
// Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx"
// with Dam Classic rev.1059
// Select 1st location (DWP_1)
// with Dam Classic rev.833
const string calcDir = "TestStabInwardsBishopUpliftVan_UpliftVanLowest";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
// Bishop
DesignResult result = output.Results.CalculationResults[0];
Assert.Multiple(() =>
{
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.309).Within(tolerance));
Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null);
});
Assert.Multiple(() =>
{
Assert.That(result.StabilityDesignResults.UpliftSituation.IsUplift, Is.True);
Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop));
Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)"));
});
// Uplift Van
result = output.Results.CalculationResults[1];
Assert.Multiple(() =>
{
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.218).Within(tolerance));
Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null);
Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan));
Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)"));
});
// Worst of Bishop and Uplift Van
result = output.Results.CalculationResults[2];
Assert.Multiple(() =>
{
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.218).Within(tolerance));
Assert.That(result.StabilityDesignResults.UpliftSituation, Is.Not.Null);
Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan));
Assert.That(result.BaseFileName, Is.EqualTo("Loc(DWP_1)_Sce(1)_Pro(DWP_1_stix)"));
});
Assert.Multiple(() =>
{
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
}
[Test, Category(Categories.Slow), Ignore("Create test where Bishop is lowest. Not anymore for DWP_13")]
[Category(Categories.WorkInProgress)]
public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_BishopLowest()
{
// Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx"
// with Dam Classic rev.1059
// Select 5th location (DWP_13)
// with Dam Classic rev.833
const string calcDir = "TestStabInwardsBishopUpliftVan_BishopLowest";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile13.xml";
string inputString = File.ReadAllText(fileName);
//inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan);
inputString = ChangeInputModel(inputString, InputStabilityModelType.Bishop);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
// Bishop
DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults;
Assert.Multiple(() =>
{
Assert.That(result.SafetyFactor, Is.EqualTo(0.452).Within(tolerance));
Assert.That(result.UpliftSituation, Is.Not.Null);
});
Assert.Multiple(() =>
{
Assert.That(result.UpliftSituation.IsUplift, Is.True);
Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop));
});
// Uplift Van
result = output.Results.CalculationResults[1].StabilityDesignResults;
Assert.Multiple(() =>
{
Assert.That(result.SafetyFactor, Is.EqualTo(0.574).Within(tolerance));
Assert.That(result.UpliftSituation, Is.Not.Null);
Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan));
});
// Worst of Bishop and Uplift Van
result = output.Results.CalculationResults[2].StabilityDesignResults;
Assert.Multiple(() =>
{
Assert.That(result.SafetyFactor, Is.EqualTo(0.452).Within(tolerance));
Assert.That(result.UpliftSituation, Is.Not.Null);
Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan));
});
Assert.Multiple(() =>
{
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
}
[Test, Category(Categories.Slow)]
public void TestRunMacroStabilityTutorialDesignBishopUpliftVan_NoUplift()
{
// Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx"
// with Dam Classic rev.1059
// Select 10th location (DWP_18)
// with Dam Classic rev.833
const string calcDir = "TestStabInwardsBishopUpliftVan_NoUplift";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile18.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
// Bishop
DesignResultStabilityDesignResults result = output.Results.CalculationResults[0].StabilityDesignResults;
Assert.Multiple(() =>
{
Assert.That(result.SafetyFactorSpecified, Is.True);
Assert.That(result.SafetyFactor, Is.EqualTo(1.450).Within(tolerance));
Assert.That(result.UpliftSituation, Is.Not.Null);
});
Assert.Multiple(() =>
{
Assert.That(result.UpliftSituation.IsUplift, Is.False);
Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop));
});
// Uplift Van
result = output.Results.CalculationResults[1].StabilityDesignResults;
Assert.Multiple(() =>
{
Assert.That(result.SafetyFactorSpecified, Is.False);
Assert.That(result.UpliftSituation, Is.Not.Null);
Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan));
});
// Worst of Bishop and Uplift Van
result = output.Results.CalculationResults[2].StabilityDesignResults;
Assert.Multiple(() =>
{
Assert.That(result.SafetyFactorSpecified, Is.True);
Assert.That(result.SafetyFactor, Is.EqualTo(1.450).Within(tolerance));
Assert.That(result.UpliftSituation, Is.Not.Null);
Assert.That(result.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan));
});
Assert.Multiple(() =>
{
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[1].CalculationResult), Is.EqualTo(CalculationResult.NoRun));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.Results.CalculationResults[2].CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
}
[Test, Category(Categories.Slow), Ignore("This test is not yet implemented, waits on stix implementation.")]
[Category(Categories.WorkInProgress)]
public void TestRunMacroStabilityInvoer10ForbiddenZoneBishop()
{
// Expected results are determined by running dam\dam clients\DamUI\trunk\data\DamEngineTestProjects\Invoer10\ZoneType.damx
// with Dam Classic rev.1059
// Select locations DWP_10_2 and DWP_10_6
// Analysis type "No adaption"
// Calculation options: Stability Inside - Bishop
// This tests two locations with same profile
// But first location with Zone Areas and second location with Forbidden Zone
// Note: this test might be activated again in the future as Forbidden zone seems to be supported by the new kernel. But then all new reference values are needed.
const string calcDir = "TestStabInwardsForbiddenZoneBishop";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\Invoer10.xml";
string inputString = File.ReadAllText(fileName);
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, "MapForSoilgeometries2D", @"TestFiles\ZoneType.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(2));
DesignResult result = output.Results.CalculationResults[0];
// SafetyFactor=1.972 (Zone Areas)
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.972).Within(tolerance));
Assert.That(result.LocationName, Is.EqualTo("DWP_10_2"));
Assert.That(result.ProfileName, Is.EqualTo("DWP_10.sti"));
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
result = output.Results.CalculationResults[1];
// SafetyFactor=2.034 (Forbidden Zone)
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(2.034).Within(tolerance));
Assert.That(result.LocationName, Is.EqualTo("DWP_10_6"));
Assert.That(result.ProfileName, Is.EqualTo("DWP_10.sti"));
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
}
[Test, Category(Categories.Slow)]
public void TestRunMacroStabilityWithErrorUpliftVan()
{
// Expected results are determined by running .\data\DamEngineTestProjects\DeltaDijk_zonering_BI\DeltaDijk normal.damx
// with Dam Classic rev.1059
// Select 5th and 6th location (6-4-3-A-1-C and 6-4-3-A-1-D)
// This project has 2 locations with each 2 profiles
// In one the combinations location-profile (1st location, 2nd profile) DGeoStability stops during the calculation.
// Then the kernel tries to read the safety factor, but fails because the dumpfile is not complete.
// In Release+Classic this returned a result Unexpected Error but the calculation continued with the next combination.
const string calcDir = "TestStabInwardsWithErrorUpliftVan";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\ErrorInDGeoStabilityCalculation.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan);
inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
Output output = GeneralHelper.RunAfterInputValidation(inputString);
Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(4));
DesignResult result = output.Results.CalculationResults[0];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-A-1-C"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-A-1-C_1_s"));
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
// SafetyFactor=1.814
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.816).Within(tolerance));
result = output.Results.CalculationResults[1];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-A-1-C"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-A-1-C_2_s"));
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.RunFailed));
// SafetyFactor not specified
Assert.That(result.StabilityDesignResults.SafetyFactorSpecified, Is.False);
result = output.Results.CalculationResults[2];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-B-1-D"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-B-1-D_1_s"));
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
// SafetyFactor=2.099
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(2.087).Within(tolerance));
result = output.Results.CalculationResults[3];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-B-1-D"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-B-1-D_2_s"));
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
// SafetyFactor=2.300
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(2.300).Within(tolerance));
}
[Test, Category(Categories.Slow), Ignore("This test is not yet implemented, waits on stix implementation.")]
[Category(Categories.WorkInProgress)]
public void TestRunMacroStabilityWithErrorBishopUpliftVan()
{
// Expected results are determined by running .\data\DamEngineTestProjects\DeltaDijk_zonering_BI\DeltaDijk normal.damx
// with Dam Classic rev.1059
// Select 5th and 6th location (6-4-3-A-1-C and 6-4-3-A-1-D)
// This project has 2 locations with each 2 profiles
// In one the combinations location-profile (1st location, 2nd profile) DGeoStability stops during the calculation.
// Then the kernel tries to read the safety factor, but fails because the dumpfile is not complete.
// In Release+Classic this returned a result Unexpected Error but the calculation continued with the next combination.
const string calcDir = "TestStabInwardsWithErrorBishopUpliftVan";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\ErrorInDGeoStabilityCalculation.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan);
inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
Output output = GeneralHelper.RunAfterInputValidation(inputString);
int expectedCount = output.Results.CalculationResults.Length;
Assert.That(expectedCount, Is.EqualTo(12), "12 results expected but only " + expectedCount);
DesignResult result = output.Results.CalculationResults[3];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-A-1-C"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-A-1-C_2_s"));
// Bishop
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
// SafetyFactor=2.219
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(2.219).Within(tolerance));
Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.Bishop));
result = output.Results.CalculationResults[4];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-A-1-C"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-A-1-C_2_s"));
// Uplift Van
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.UnexpectedError));
// SafetyFactor not specified
Assert.That(result.StabilityDesignResults.SafetyFactorSpecified, Is.False);
Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.UpliftVan));
result = output.Results.CalculationResults[5];
Assert.That(result.LocationName, Is.EqualTo("6-4-3-A-1-C"));
Assert.That(result.ProfileName, Is.EqualTo("6-4-3-A-1-C_2_s"));
// Bishop/Uplift Van
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.UnexpectedError));
// SafetyFactor not specified
Assert.That(result.StabilityDesignResults.SafetyFactorSpecified, Is.False);
Assert.That(result.StabilityDesignResults.StabilityModelType, Is.EqualTo(DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan));
}
[Test, Category(Categories.Slow), Ignore("This test is not yet implemented, waits on stix implementation.")]
[Category(Categories.WorkInProgress)]
public void TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption()
{
// Inputfile was created with .\data\DamEngineTestProjects\Invoer2\DAM Tutorial Design\DAM Tutorial Design.damx
// Select dwp 13
// Expected: RunFailed
const string calcDir = "TestRunFailedExpectCalculationMessageInOptimizedSlopeAndShoulderAdaption";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\MacroStabilityRunFailedExpectCalculationMessage.xml";
string inputString = File.ReadAllText(fileName);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString, false);
Assert.That(output.Results.CalculationMessages[0].Message1,
Is.EqualTo("Location 'DWP_13', subsoil scenario 'DWP_13.sti', design scenario '1': " +
"The calculation failed with error message " +
"'The design was not successful. " +
"The new shoulder height with topslope exceeds the allowed maximum height.'"));
}
[Test, Category(Categories.Slow), Ignore("Work in progress")]
public void DesignBishopOptimizedSlopeAndShoulderAdaptionWithScenariosForHeadPL3CalculatesCorrect()
{
const string inputFilename = "InputFileMultiCoreTestForScenarioAdaption.xml";
string fullInputFilename = Path.Combine(mapTestFiles, inputFilename);
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
string inputString = File.ReadAllText(fullInputFilename);
var engineInterface = new EngineInterface(inputString);
engineInterface.DamProjectData.MaxCalculationCores = 1;
string calcDir = engineInterface.DamProjectData.CalculationMap + "_SingleCore";
engineInterface.DamProjectData.CalculationMap = calcDir;
Assert.That(engineInterface.DamProjectData, Is.Not.Null);
calcDir = Directory.GetCurrentDirectory() + "\\" + calcDir;
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Output output = GeneralHelper.RunAfterInputValidation(engineInterface, true, "Results_Single_Core" + ".xml");
Assert.Multiple(() =>
{
Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(18));
Assert.That(output.Results.CalculationMessages, Has.Length.EqualTo(1336));
int resultsFound = CheckLargeResultsSets.CheckResultsDesignBishopAdaptionWithScenariosForHeadPl3CalculatesCorrect(
output.Results.CalculationResults);
Assert.That(resultsFound, Is.EqualTo(11));
});
}
[Test, Category(Categories.Slow), Ignore("Work in progress")]
public void TestRunSlopeAdaptionBeforeShoulderAdaptionSucceeds()
{
// Input file was created with .\data\Dam\Benchmarks\Validatie SlopeAdaption\SlopeAdaption.damx
// Expected: a valid calculation.
const string calcDir = "TestRunFailedExpectCalculationMessageInSlopeAdaptionBeforeShoulderAdaption";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\ValidatieSlopeAdaption.xml";
string inputString = File.ReadAllText(fileName);
inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
Output output = GeneralHelper.RunAfterInputValidation(inputString);
Assert.That(output.Results.CalculationResults.First().StabilityDesignResults.SafetyFactor, Is.EqualTo(1.366).Within(tolerance));
}
[Test, Category(Categories.Slow), Ignore("This test is not yet implemented, waits on stix implementation.")]
[Category(Categories.WorkInProgress)]
// Expected results are determined by running .\DamUI\trunk\data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx
// with Dam Classic rev.1059
// Select 1st location (DWP_1)
// Set designscenario Safetyfactor Inwards to 1.4
// Design strategy: OptimizedSlopeAndShoulderAdaption
// Set NewMinDistanceDikeToeStartDitch = 3.0, UseNewMinDistanceDikeToeStartDitch = true (to force value to be written to XML)
//
// Parameters: CalcDir - StabilityModel - DesignStrategy - CalculationResult - FoS - EntryPointX - ExitPointX - DikeLength - ShoulderHeight - Iterations - ResultMessage
[TestCase("TestStabInwardsBishopDesignSequential", "Bishop", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.444, 39.081, 67.577, 45.387, 2.799, 5, "")]
[TestCase("TestStabInwardsBishopDesignOptimized", "Bishop", "OptimizedSlopeAndShoulderAdaption", CalculationResult.Succeeded, 1.412, 50.236, 67.077, 43.760, 3.889, 4, "")]
[TestCase("TestStabInwardsUpliftVanDesignSequential", "UpliftVan", "SlopeAdaptionBeforeShoulderAdaption", CalculationResult.Succeeded, 1.4847, 39.243, 73.587, 50.285, 3.465, 7, "")]
[TestCase("TestStabInwardsUpliftVanDesignOptimized", "UpliftVan", "OptimizedSlopeAndShoulderAdaption", CalculationResult.RunFailed, 1.214, 39.514, 66.926, 36.150, 0.0, 4, "The new shoulder height with topslope exceeds the allowed maximum height.")]
public void CanPerformStabilityInwardsDesignTutorialDesignOptimizedSlopeAndShoulderAdaption_OneLocation(
string calcDir, string stabilityModel, string designStrategy,
CalculationResult calculationResult, double expectedSafetyFactor,
double expectedZone1EntryPointX, double expectedZone1ExitPointX,
double expectedDikeLength, double expectedShoulderHeight,
int expectedNumberOfIterations, string expectedResultMessage)
{
const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFile1LocationWithAdaption.xml";
string inputString = File.ReadAllText(fileName);
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, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\");
inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityModelType", stabilityModel);
inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityDesignMethod", designStrategy);
Output output = GeneralHelper.RunAfterInputValidation(inputString);
DamProjectData actualDamProjectData = FillDamFromXmlOutput.CreateDamProjectData(null, output);
Assert.That(ConversionHelper.ConvertToCalculationResult(
output.Results.CalculationResults[0].CalculationResult), Is.EqualTo(calculationResult));
DesignResultStabilityDesignResults stabilityDesignResults = output.Results.CalculationResults[0].StabilityDesignResults;
Assert.That(stabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor).Within(tolerance));
Assert.That(stabilityDesignResults.NumberOfIterations, Is.EqualTo(expectedNumberOfIterations));
Assert.That(stabilityDesignResults.ResultMessage, Is.EqualTo(expectedResultMessage));
SurfaceLine2 redesignedSurfaceLine = actualDamProjectData.DesignCalculations[0].StabilityDesignResults.RedesignedSurfaceLine;
if (redesignedSurfaceLine != null)
{
Assert.That(redesignedSurfaceLine.GetDikeLength(), Is.EqualTo(expectedDikeLength).Within(tolerance));
GeometryPoint pointShoulderBaseInside = redesignedSurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.ShoulderTopInside);
if (pointShoulderBaseInside != null)
{
Assert.That(pointShoulderBaseInside.Z, Is.EqualTo(expectedShoulderHeight).Within(tolerance));
}
}
}
[Test]
[SetUICulture("nl-NL")]
public void TestGiveFeedBackWhenNoProfilesAreAvailable()
{
// Based on "dam/IssueRelatedData/MWDAM-1341/HHNK Leggerstudie\DAM Leggerstudie.defx"
// Import as Design -Primary dike: "DAM Leggerstudie.defx"
// Select first location and start calculation
// xml file is created with rev.2039
const string calcDir = "TestGiveFeedBackWhenNoProfilesAreAvailable";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\MacroStabilityNoProfilesInputFile.xml";
string inputString = File.ReadAllText(fileName);
inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
Output output = GeneralHelper.RunAfterInputValidation(inputString, false);
Assert.That(output.Results.CalculationMessages.Length, Is.EqualTo(2));
Assert.That(output.Results.CalculationMessages[0].MessageType, Is.EqualTo(MessageMessageType.Warning));
Assert.That(output.Results.CalculationMessages[0].Message1, Is.EqualTo("Geen ondergrond profielen beschikbaar voor locatie '12-2_027'"));
}
[Test, Ignore("Not clear what the expected result is. In 19.3.2 the name of the test was TestDesignWithRiverLevelAboveDikeTopButBelowDthCanCalculate.")]
[Category(Categories.WorkInProgress)]
public void TestDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate()
{
var analysisType = "AdaptGeometry";
// Test just to see if calculation works in this case as it should do.
Output output = GetOutputStringForProject(analysisType);
//ToDo Bka: Note Bka: it already failed, Probably because DTH is not yet taken into account with testing/adjusting the data.
const string message = "The error calculation message is not has expected.";
Assert.That(output.Results.CalculationMessages[0].Message1.Contains("Location 'DWP_1', subsoil scenario 'DWP_1.stix', design scenario '1': " +
"The calculation failed with error message 'Value cannot be null."), Is.True, message);
}
[Test]
public void TestNoDesignWithRiverLevelAboveDikeTopButBelowDthCanNotCalculate()
{
var analysisType = "NoAdaption";
// Test to see if calculation does NOT work in this case as it must fail with water level above dike top.
Output output = GetOutputStringForProject(analysisType);
Assert.That(output.Results.CalculationMessages.Length, Is.EqualTo(2));
}
[Test, Category(Categories.Slow)]
public void TestRunMacroStabilityDeltaDijkBishopWith1DProducesStixFiles()
{
// Expected results are taken as is from the first run with the new kernel
// This tests use of 1D profiles
// Selected location (6-4-1-A-1-F)
// Analysis type "No adaption"
// Calculation options: Stability Inside - Bishop
const string calcDir = "TestStabInwardsBishopWithStixFiles";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.Bishop);
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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
// one location is calculated with 3 1D profiles
Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(3));
Assert.That(output.Results.CalculationResults[0].LocationName, Is.EqualTo("6-4-1-A-1-F"));
Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("6-4-1-A-1-F_1_s"));
Assert.That(output.Results.CalculationResults[1].LocationName, Is.EqualTo("6-4-1-A-1-F"));
Assert.That(output.Results.CalculationResults[1].ProfileName, Is.EqualTo("6-4-1-A-1-F_2_s"));
Assert.That(output.Results.CalculationResults[2].LocationName, Is.EqualTo("6-4-1-A-1-F"));
Assert.That(output.Results.CalculationResults[2].ProfileName, Is.EqualTo("6-4-1-A-1-F_3_s"));
DesignResult result = output.Results.CalculationResults[0];
// SafetyFactor=1.682
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.682).Within(tolerance));
// skip testing some of the results like uplift etc.
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
// test safety factor for other profiles
result = output.Results.CalculationResults[1];
// SafetyFactor=1.644
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.624).Within(tolerance));
result = output.Results.CalculationResults[2];
// SafetyFactor=1.682
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.682).Within(tolerance));
// Stix file
var fileList = new List
{
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix"
};
foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file)))
{
Assert.That(File.Exists(file), Is.True, file + " does not exist");
}
}
[Test, Category(Categories.Slow)]
[TestCase(MStabSearchMethod.BeeSwarm, 4, 1.613, 1.535)]
[TestCase(MStabSearchMethod.Grid, 2, 1.611, 1.536)]
public void TestRunMacroStabilityDeltaDijkUpliftVanWith1DProducesStixFiles(MStabSearchMethod searchMethod, int expectedStixFileCount, double expectedSafetyFactor1, double expectedSafetyFactor2)
{
// Expected results are taken as is from the first run with the new kernel
// Selected location (6-4-1-A-1-F)
// Analysis type "No adaption"
// Calculation options: Stability Inside - UpliftVan
// This tests use of 1D profiles
const string calcDir = "TestStabInwardsUpliftVanWithStixFiles";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
// Read as Bishop, then change to UpliftVan
const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.UpliftVan);
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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\");
var engineInterface = new EngineInterface(inputString);
engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod;
Output output = GeneralHelper.RunAfterInputValidation(engineInterface);
// one location is calculated with 3 1D profiles
// However, profile 6-4-1-A-1-F_3_s has no UpliftVan occuring and thus has no result
Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(2));
Assert.Multiple(() =>
{
Assert.That(output.Results.CalculationResults[0].LocationName, Is.EqualTo("6-4-1-A-1-F"));
Assert.That(output.Results.CalculationResults[0].ProfileName, Is.EqualTo("6-4-1-A-1-F_1_s"));
Assert.That(output.Results.CalculationResults[1].LocationName, Is.EqualTo("6-4-1-A-1-F"));
Assert.That(output.Results.CalculationResults[1].ProfileName, Is.EqualTo("6-4-1-A-1-F_2_s"));
});
DesignResult result = output.Results.CalculationResults[0];
Assert.Multiple(() =>
{
// SafetyFactor=1.638 DSTAB 1.518 (1.079)
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor1).Within(tolerance));
// skip testing some of the results like uplift etc.
// Calculation Result
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
// test safety factor for other profiles
result = output.Results.CalculationResults[1];
Assert.Multiple(() =>
{
Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(expectedSafetyFactor2).Within(tolerance));
Assert.That(ConversionHelper.ConvertToCalculationResult(result.CalculationResult), Is.EqualTo(CalculationResult.Succeeded));
});
var fileList = new List
{
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix",
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix"
};
if (searchMethod == MStabSearchMethod.BeeSwarm)
{
fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix");
fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix");
}
int stixFileCount = Directory.GetFiles(Path.GetFullPath(calcDir), "*.stix", SearchOption.AllDirectories).Length;
Assert.That(stixFileCount, Is.EqualTo(expectedStixFileCount), "The number of created STIX files is not as expected");
foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file)))
{
Assert.That(File.Exists(file), Is.True, file + " does not exist");
}
}
[Test, Category(Categories.Slow)]
[TestCase(MStabSearchMethod.BeeSwarm, 10, 1.613, 1.535)]
[TestCase(MStabSearchMethod.Grid, 8, 1.611, 1.536)]
public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithUpliftProducesStixFiles(MStabSearchMethod searchMethod, int expectedStixFileCount, double expectedSafetyFactor1, double expectedSafetyFactor2)
{
// Expected results are taken as is from the first run with the new kernel
// This tests use of 1D profiles
// Selected location (6-4-1-A-1-F)
// Analysis type "No adaption"
// Calculation options: Stability Inside - Bishop
const string calcDir = "TestStabInwardsBishopUpliftVanWithUpliftWithStixFiles";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan);
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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\");
var engineInterface = new EngineInterface(inputString);
engineInterface.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod;
Output output = GeneralHelper.RunAfterInputValidation(engineInterface);
// one location is calculated with 3 1D profiles, and results are for the 3 models
Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(9));
Assert.Multiple(() =>
{
CheckCalculationResults(
output.Results.CalculationResults[0], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s",
DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, true, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[1], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s",
DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, expectedSafetyFactor1, true, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[2], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s",
DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, expectedSafetyFactor1, true, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[3], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s",
DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.624, true, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[4], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s",
DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, expectedSafetyFactor2, true, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[5], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s",
DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, expectedSafetyFactor2, true, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[6], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s",
DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, false, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[7], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s",
DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun);
CheckCalculationResults(
output.Results.CalculationResults[8], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s",
DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.682, false, CalculationResult.Succeeded);
});
// Stix file
var fileList = new List
{
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix",
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix",
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix"
};
if (searchMethod == MStabSearchMethod.BeeSwarm)
{
fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix");
fileList.Add("Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix");
}
int stixFileCount = Directory.GetFiles(Path.GetFullPath(calcDir), "*.stix", SearchOption.AllDirectories).Length;
Assert.That(stixFileCount, Is.EqualTo(expectedStixFileCount), "The number of created STIX files is not as expected");
foreach (string file in fileList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file)))
{
Assert.That(File.Exists(file), Is.True, file + " does not exist");
}
}
[Test, Category(Categories.Slow)]
public void TestRunMacroStabilityDeltaDijkBishopUpliftVanWith1DWithoutUpliftProducesStixFiles()
{
// Expected results are taken as is from the first run with the new kernel
// This tests use of 1D profiles
// Selected location (6-4-1-A-1-F)
// Analysis type "No adaption"
// Calculation options: Stability Inside - Bishop
const string calcDir = "TestStabInwardsBishopUpliftVanWithoutUpliftWithStixFiles";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\DeltaDijkBishopInwards.xml";
string inputString = File.ReadAllText(fileName);
inputString = ChangeInputModel(inputString, InputStabilityModelType.BishopUpliftVan);
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, "MapForSoilgeometries2D", @"TestFiles\DeltaDijk normal.geometries2D.0\");
inputString = XmlAdapter.ChangeValueInXml(inputString, "UpliftCriterionStability", @"1.0");
Output output = GeneralHelper.RunAfterInputValidation(inputString);
// one location is calculated with 3 1D profiles and results are for the 3 models (Bishop, Uplift-Van and Bishop/UpliftVan)
Assert.That(output.Results.CalculationResults, Has.Length.EqualTo(9));
Assert.Multiple(() =>
{
CheckCalculationResults(
output.Results.CalculationResults[0], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s",
DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, false, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[1], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s",
DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun);
CheckCalculationResults(
output.Results.CalculationResults[2], "6-4-1-A-1-F", "6-4-1-A-1-F_1_s",
DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.682, false, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[3], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s",
DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.624, false, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[4], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s",
DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun);
CheckCalculationResults(
output.Results.CalculationResults[5], "6-4-1-A-1-F", "6-4-1-A-1-F_2_s",
DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.624, false, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[6], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s",
DesignResultStabilityDesignResultsStabilityModelType.Bishop, 1.682, false, CalculationResult.Succeeded);
CheckCalculationResults(
output.Results.CalculationResults[7], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s",
DesignResultStabilityDesignResultsStabilityModelType.UpliftVan, 0, false, CalculationResult.NoRun);
CheckCalculationResults(
output.Results.CalculationResults[8], "6-4-1-A-1-F", "6-4-1-A-1-F_3_s",
DesignResultStabilityDesignResultsStabilityModelType.BishopUpliftVan, 1.682, false, CalculationResult.Succeeded);
});
// Stix file
var existingFilesList = new List
{
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_input.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix",
"Stability\\Bishop\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_3_s)_result.stix"
};
foreach (string file in existingFilesList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file)))
{
Assert.That(File.Exists(file), Is.True, file + " does not exist");
}
var noneExistingFilesList = new List
{
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_input.stix",
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_input.stix",
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_1_s)_result.stix",
"Stability\\UpliftVan\\Loc(6-4-1-A-1-F)_Sce(1)_Pro(6-4-1-A-1-F_2_s)_result.stix"
};
foreach (string file in noneExistingFilesList.Select(file => Path.Combine(Path.GetFullPath(calcDir), file)))
{
Assert.That(File.Exists(file), Is.False, file + " does exist");
}
}
private void RemoveUsedDirectoryAfterTests(string directory)
{
if (Directory.Exists(directory))
{
//Directory.Delete(directory, true);
}
}
private static Output GetOutputStringForProject(string analysisType)
{
const string calcDir = "TestStabInwardsBishop";
if (Directory.Exists(calcDir))
{
Directory.Delete(calcDir, true); // delete previous results
}
Directory.CreateDirectory(calcDir);
const string fileName = @"TestFiles\DesignInputFileWithRiverLevelAboveDikeTopButBelowDTH.xml";
string inputString = File.ReadAllText(fileName);
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, "MapForSoilgeometries2D",
@"TestFiles\DAM Tutorial Design.geometries2D.0\");
inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType",
ConversionHelper.InputSegmentFailureMechanismStability.ToString());
inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", analysisType);
return GeneralHelper.RunAfterInputValidation(inputString, false);
}
private string ChangeInputModel(string input, InputStabilityModelType modelType)
{
var pattern = "StabilityModelType=\"[a-zA-Z]+\"";
string replacement = pattern;
switch (modelType)
{
case InputStabilityModelType.Bishop:
replacement = "StabilityModelType=\"Bishop\"";
break;
case InputStabilityModelType.UpliftVan:
replacement = "StabilityModelType=\"UpliftVan\"";
break;
case InputStabilityModelType.BishopUpliftVan:
replacement = "StabilityModelType=\"BishopUpliftVan\"";
break;
}
string result = Regex.Replace(input, pattern, replacement);
return result;
}
private static void CheckCalculationResults(DesignResult output, string locationName, string profileName, DesignResultStabilityDesignResultsStabilityModelType model, double safetyFactor, bool isUplift, CalculationResult result)
{
Assert.Multiple(() =>
{
Assert.That(output.LocationName, Is.EqualTo(locationName));
Assert.That(output.ProfileName, Is.EqualTo(profileName));
Assert.That(output.StabilityDesignResults.StabilityModelType, Is.EqualTo(model));
Assert.That(output.StabilityDesignResults.SafetyFactor, Is.EqualTo(safetyFactor).Within(tolerance));
Assert.That(output.StabilityDesignResults.UpliftSituation.IsUplift, Is.EqualTo(isUplift));
Assert.That(ConversionHelper.ConvertToCalculationResult(output.CalculationResult), Is.EqualTo(result));
});
}
}