Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/CalamityTests.cs =================================================================== diff -u -r6300 -r6304 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/CalamityTests.cs (.../CalamityTests.cs) (revision 6300) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/CalamityTests.cs (.../CalamityTests.cs) (revision 6304) @@ -19,23 +19,31 @@ // 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 Deltares.DamEngine.Io; +using Deltares.DamEngine.Io.XmlInput; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; +using Deltares.MacroStability.Io; +using Deltares.MacroStability.Io.XmlInput; using NUnit.Framework; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; [TestFixture] public class CalamityTests { - private const double tolerance = 0.00051; + private const double tolerance4Decimals = 0.000051; + private const string inputFileName = @"TestFiles\Calamity\PulauTekongCalamity.xml"; + private const string calcDir = "TestCalamity"; [Test] [Category(Categories.Slow)] public void GivenCalamityInputFile_WhenRun_ThenOutputIsCorrect() { - const string calcDir = "TestCalamity"; if (Directory.Exists(calcDir)) { Directory.Delete(calcDir, true); @@ -44,7 +52,6 @@ Directory.CreateDirectory(calcDir); // Based on "DamUI\trunk\src\Dam\Deltares.Dam.IntegrationTests\TestData\Calamity\PulauTekongCalamity.damx" - const string inputFileName = @"TestFiles\Calamity\PulauTekongCalamity.xml"; string inputString = File.ReadAllText(inputFileName); inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used @@ -56,24 +63,52 @@ { Assert.That(output.Results.OperationalOutputTimeSeries[0].LocationId, Is.EqualTo("CD CS1 X1")); Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput, Has.Length.EqualTo(3)); - Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput[0].Value, Is.EqualTo(1.4078).Within(tolerance)); - Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput[1].Value, Is.EqualTo(1.4083).Within(tolerance)); - Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput[2].Value, Is.EqualTo(1.4053).Within(tolerance)); + Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput[0].Value, Is.EqualTo(1.4078).Within(tolerance4Decimals)); + Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput[1].Value, Is.EqualTo(1.4084).Within(tolerance4Decimals)); + Assert.That(output.Results.OperationalOutputTimeSeries[0].Entries.TimeSerieEntryOutput[2].Value, Is.EqualTo(1.4053).Within(tolerance4Decimals)); Assert.That(output.Results.OperationalOutputTimeSeries[1].LocationId, Is.EqualTo("CD CS2 X3")); Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput, Has.Length.EqualTo(3)); - Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput[0].Value, Is.EqualTo(0.9985).Within(tolerance)); - Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput[1].Value, Is.EqualTo(0.9950).Within(tolerance)); - Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput[2].Value, Is.EqualTo(0.9891).Within(tolerance)); + Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput[0].Value, Is.EqualTo(0.9985).Within(tolerance4Decimals)); + Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput[1].Value, Is.EqualTo(0.9950).Within(tolerance4Decimals)); + Assert.That(output.Results.OperationalOutputTimeSeries[1].Entries.TimeSerieEntryOutput[2].Value, Is.EqualTo(0.9891).Within(tolerance4Decimals)); // The following locations were not present in the Water level time series input so no result available for (int i = 2; i < 5; i++) { Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput, Has.Length.EqualTo(3)); - Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput[0].Value, Is.EqualTo(double.NaN).Within(tolerance)); - Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput[1].Value, Is.EqualTo(double.NaN).Within(tolerance)); - Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput[2].Value, Is.EqualTo(double.NaN).Within(tolerance)); + Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput[0].Value, Is.EqualTo(double.NaN).Within(tolerance4Decimals)); + Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput[1].Value, Is.EqualTo(double.NaN).Within(tolerance4Decimals)); + Assert.That(output.Results.OperationalOutputTimeSeries[i].Entries.TimeSerieEntryOutput[2].Value, Is.EqualTo(double.NaN).Within(tolerance4Decimals)); } }); + CheckWaterLevelInCreatedPhreaticLine(); } + + private static void CheckWaterLevelInCreatedPhreaticLine() + { + // Read the kernel input data from the input file and check that the phreatic line starts with the water level given in the Time series + Input input = DamXmlSerialization.LoadInputFromXmlFile(inputFileName); + foreach (TimeSerie timeSeries in input.OperationalInputTimeSeries) + { + for (int i = 0; i < timeSeries.Entries.TimeSerieEntry.Length; i++) + { + TimeSerieEntriesTimeSerieEntry entry = timeSeries.Entries.TimeSerieEntry[i]; + string segmentName = input.Locations.First(location => location.Name == timeSeries.LocationId).SegmentName; + string soilProfileId = input.Segments.First(segment => segment.Name == segmentName).SoilGeometryProbability[0].SoilProfileName; + soilProfileId = soilProfileId.Replace(".", "_"); + var date = entry.DateTime.ToString("s", DateTimeFormatInfo.InvariantInfo); + date = date.Replace(":", "_"); + string kernelInputFilename = @".\\" + calcDir + "\\Stability\\Bishop\\Dik(dike)_Loc(" + timeSeries.LocationId + ")_Stp(" + i + ")_Mdl(Bishop)_" + date + "_Pro(" + soilProfileId + ").skx"; + FullInputModelType expectedMacrostabilityInput = MacroStabilityXmlSerialization.LoadInputFromXmlFile(kernelInputFilename); + Deltares.MacroStability.Io.XmlInput.WaternetType waternet = expectedMacrostabilityInput.StabilityModel.ConstructionStages[0].Waternet; + List phreaticLine = waternet.PhreaticLine.WaternetLine.Points.ToList(); + Assert.Multiple(() => + { + Assert.That(phreaticLine[0].Z, Is.EqualTo(entry.Value).Within(tolerance4Decimals)); + Assert.That(phreaticLine[1].Z, Is.EqualTo(entry.Value).Within(tolerance4Decimals)); + }); + } + } + } } \ No newline at end of file