//-----------------------------------------------------------------------
//
// Copyright (c) 2009 Deltares. All rights reserved.
//
// B.S.T.I.M. The
// tom.the@deltares.nl
// 14-07-2009
// Contains class to test creation of PL-Line
//-----------------------------------------------------------------------
using Deltares.Geotechnics;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Geotechnics.TestUtils;
namespace Deltares.Dam.Tests
{
using System;
using System.Linq;
using NUnit.Framework;
using Deltares.Dam.Data;
using System.Diagnostics;
[TestFixture]
public class ExpertCreatePhreaticLineTest
{
[TestFixtureSetUp]
public void FixtureSetup()
{
}
[SetUp]
public void Setup()
{
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
}
[Test]
public void CreatePhreaticLine1ForSimpleSurfaceLine()
{
/*Retrieve all required data to determine the phreatic level*/
using (var surfaceLineTutorial1 = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = surfaceLineTutorial1;
//Create phreatic line
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
//Validate if phreatic points match expected line
Assert.AreEqual(8, phreaticLine.Points.Count, "Incorrect number phreatic points");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[0].X - 0) < 0.1) && (Math.Abs(phreaticLine.Points[0].Z - 4) < 0.1)), "Incorrect phreatic point 2");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[1].X - 29.59) < 0.1) && (Math.Abs(phreaticLine.Points[1].Z - 4) < 0.1)), "Incorrect phreatic point 3");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[2].X - 34.5) < 0.1) && (Math.Abs(phreaticLine.Points[2].Z - 3.5) < 0.1)), "Incorrect phreatic point 4");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[3].X - 40.5) < 0.1) && (Math.Abs(phreaticLine.Points[3].Z - 2.5) < 0.1)), "Incorrect phreatic point 5");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[4].X - 50.5) < 0.1) && (Math.Abs(phreaticLine.Points[4].Z + 0.1) < 0.1)), "Incorrect phreatic point 8");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[5].X - 58.625) < 0.1) && (Math.Abs(phreaticLine.Points[5].Z + 0.25) < 0.1)), "Incorrect phreatic point 9");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[6].X - 61.5) < 0.1) && (Math.Abs(phreaticLine.Points[6].Z + 0.25) < 0.1)), "Incorrect phreatic point 10");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[7].X - 75) < 0.1) && (Math.Abs(phreaticLine.Points[7].Z + 0.25) < 0.1)), "Incorrect phreatic point 10");
}
}
[Test]
public void CreatePhreatic1LineForSimpleSurfaceLineLow()
{
/*Retrieve all required data to determine the phreatic level*/
using (var surfaceLineTutorial1 = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelRiverLow = 1;
linesCreator.IsUseLowWaterLevel = true;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = surfaceLineTutorial1;
//Create phreatic line
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
//Validate if phreatic points match expected line
Assert.AreEqual(8, phreaticLine.Points.Count, "Incorrect number phreatic points");
Assert.AreEqual(0, phreaticLine.Points[0].X, 0.01);
Assert.AreEqual(1, phreaticLine.Points[0].Z, 0.01);
Assert.AreEqual(14.9, phreaticLine.Points[1].X, 0.01);
Assert.AreEqual(1, phreaticLine.Points[1].Z, 0.01);
Assert.AreEqual(34.5, phreaticLine.Points[2].X, 0.01);
Assert.AreEqual(3.5, phreaticLine.Points[2].Z, 0.01);
Assert.AreEqual(40.5, phreaticLine.Points[3].X, 0.01);
Assert.AreEqual(2.5, phreaticLine.Points[3].Z, 0.01);
Assert.AreEqual(50.5, phreaticLine.Points[4].X, 0.01);
Assert.AreEqual(-0.1, phreaticLine.Points[4].Z, 0.01);
Assert.AreEqual(58.625, phreaticLine.Points[5].X, 0.01);
Assert.AreEqual(-0.25, phreaticLine.Points[5].Z, 0.01);
Assert.AreEqual(61.5, phreaticLine.Points[6].X, 0.01);
Assert.AreEqual(-0.25, phreaticLine.Points[6].Z, 0.01);
Assert.AreEqual(75, phreaticLine.Points[7].X, 0.01);
Assert.AreEqual(-0.25, phreaticLine.Points[7].Z, 0.01);
}
}
[Test]
[ExpectedException(typeof(PLLinesCreatorException))]
public void ThrowsExceptionIfNoSurfaceLineExists()
{
/*Retrieve all required data to determine the phreatic level*/
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = null;
linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
}
[Test]
[ExpectedException(typeof(PLLinesCreatorException))]
public void ThrowsExceptionWhenDikeTopAtRiverCharacteristicPointDoesNotExist()
{
/*Retrieve all required data to determine the phreatic level*/
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1MissingCharacteristicPointDikeTopAtRiver())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = line;
linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
}
}
[Test]
[ExpectedException(typeof(PLLinesCreatorException))]
public void ThrowsExceptionWhenDikeTopAtPolderharacteristicPointDoesNotExist()
{
/*Retrieve all required data to determine the phreatic level*/
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1MissingCharacteristicPointDikeTopAtPolder())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = line;
linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
}
}
[Test]
[ExpectedException(typeof(PLLinesCreatorException))]
public void ThrowsExceptionWhenDikeToeAtPolderaracteristicPointDoesNotExist()
{
/*Retrieve all required data to determine the phreatic level*/
using (var surfaceLineTutorial1MissingCharacteristicPointDikeToeAtPolder =
FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1MissingCharacteristicPointDikeToeAtPolder())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = surfaceLineTutorial1MissingCharacteristicPointDikeToeAtPolder;
linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
}
}
[Test]
[ExpectedException(typeof(SurfaceLineException))]
public void ThrowExceptionIfWaterlevelRiverIsAboveDikeTopAtRiver()
{
/*Retrieve all required data to determine the phreatic level*/
using (var surfaceLineTutorial1 = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 6;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = surfaceLineTutorial1;
linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
}
}
[Test]
public void ReturnDikeToeAtRiverIfWaterlevelRiverIsBelowDikeToeAtRiver()
{
/*Retrieve all required data to determine the phreatic level*/
using (var surfaceLineTutorial1 = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = -0.5;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = surfaceLineTutorial1;
PLLine plLine1 = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
Assert.IsTrue(plLine1.Points[1].LocationEquals(linesCreator.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver)));
}
}
[Test]
public void CreatePhreaticLineSurfaceWithWaterLevelAtFirstLineSegmentOfOutsideShoulder()
{
/*Retrieve all required data to determine the phreatic level*/
using (var surfaceLineTutorial1WithOutsideShoulder =
FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1WithOutsideShoulder())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 1.5;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = surfaceLineTutorial1WithOutsideShoulder;
//Create phreatic line
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
//Validate if phreatic points match expected line
Assert.IsTrue(phreaticLine.Points.Count > 0, "Surface does not intersect waterlevel at first line segment");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[1].X - 10) < 0.1) && (Math.Abs(phreaticLine.Points[1].Z - 1.5) < 0.1)), "Surface does not intersect waterlevel at first line segment");
}
}
[Test]
public void CreatePhreaticLineSurfaceWithWaterLevelAtSecondLineSegmentOfOutsideShoulder()
{
/*Retrieve all required data to determine the phreatic level*/
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1WithOutsideShoulder())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 2.2;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = line;
//Create phreatic line
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
Assert.IsTrue(phreaticLine.Points.Count > 0, "Surface does not intersect waterlevel at second line segment");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[1].X - 13.5) < 0.1) && (Math.Abs(phreaticLine.Points[1].Z - 2.2) < 0.1)), "Surface does not intersect waterlevel at second line segment");
}
}
[Test]
public void IsPhreaticLineAboveWaterlevelPolder()
{
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1PhreaticLowerPolderWaterLevel())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = -0.5;
linesCreator.WaterLevelPolder = -0.25;
linesCreator.SurfaceLine = line;
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
Trace.Assert(phreaticLine.Points.Where(x => x.Z < linesCreator.WaterLevelPolder) != null, "Phreatic points below waterlevel polder is not allowed");
}
}
[Test]
public void CreatePhreaticLineWhenWaterLevelPolderBelowDitch()
{
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -3;
linesCreator.SurfaceLine = line;
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
Assert.AreEqual(true, (Math.Abs(phreaticLine.Points[phreaticLine.Points.Count - 1].Z - linesCreator.WaterLevelPolder) < 0.1), "Last phreaticline coordinate should have the same height as waterlevel polder");
}
}
[Test]
public void CreatePhreaticLineWhenWaterLevelPolderAboveDitch()
{
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = 2;
linesCreator.SurfaceLine = line;
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
Assert.AreEqual(true, (Math.Abs(phreaticLine.Points[phreaticLine.Points.Count - 1].Z - linesCreator.WaterLevelPolder) < 0.1), "Last phreaticline coordinate should have the same height as waterlevel polder");
}
}
[Test]
public void IsPhreaticLineCorrectedWhenItIntersectsDikeAtPolderSide()
{
using (var line = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1PhreaticAboveSurface())
{
PLLinesCreator linesCreator = new PLLinesCreator();
linesCreator.WaterLevelRiverHigh = 4;
linesCreator.WaterLevelPolder = -0.250;
linesCreator.SurfaceLine = line;
PLLine phreaticLine = linesCreator.CreatePLLineByExpertKnowledge(PLLineType.PL1, DamType.Regional, 0.02);
//Validate if phreatic points match expected line
Assert.AreEqual(10, phreaticLine.Points.Count, "Incorrect number of phreatic points");
Assert.AreEqual(10, phreaticLine.Points.Count, "Incorrect phreatic point 1");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[0].X - 0) < 0.1) && (Math.Abs(phreaticLine.Points[0].Z - 4) < 0.1)), "Incorrect phreatic point 2");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[1].X - 31) < 0.1) && (Math.Abs(phreaticLine.Points[1].Z - 4) < 0.1)), "Incorrect phreatic point 3");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[2].X - 34.5) < 0.1) && (Math.Abs(phreaticLine.Points[2].Z - 3.5) < 0.1)), "Incorrect phreatic point 4");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[3].X - 40.5) < 0.1) && (Math.Abs(phreaticLine.Points[3].Z - 2.5) < 0.1)), "Incorrect phreatic point 5");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[4].X - 44.642) < 0.1) && (Math.Abs(phreaticLine.Points[4].Z - 1.323) < 0.1)), "Incorrect phreatic point 6");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[5].X - 46.0) < 0.1) && (Math.Abs(phreaticLine.Points[5].Z - 0.150) < 0.1)), "Incorrect phreatic point 7");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[6].X - 50.5) < 0.1) && (Math.Abs(phreaticLine.Points[6].Z + 0.1) < 0.1)), "Incorrect phreatic point 8");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[7].X - 58.625) < 0.1) && (Math.Abs(phreaticLine.Points[7].Z + 0.25) < 0.1)), "Incorrect phreatic point 9");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[8].X - 61.375) < 0.1) && (Math.Abs(phreaticLine.Points[8].Z + 0.25) < 0.1)), "Incorrect phreatic point 10");
Assert.AreEqual(true, ((Math.Abs(phreaticLine.Points[9].X - 75) < 0.1) && (Math.Abs(phreaticLine.Points[9].Z + 0.25) < 0.1)), "Incorrect phreatic point 10");
}
}
}
}