//-----------------------------------------------------------------------
//
// Copyright (c) 2009 Deltares. All rights reserved.
//
// R. Blankenburgh
// remko.blankenburgh@deltares.nl
// 07-07-2009
// n.a.
//-----------------------------------------------------------------------
using Deltares.Geometry;
using Deltares.Geotechnics;
using Deltares.Geotechnics.GeotechnicalGeometry;
using Deltares.Piping.Data;
using System.IO;
using Deltares.Dam.Data;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Geotechnics.TestUtils;
using Deltares.Uplift;
using NUnit.Framework;
namespace Deltares.Dam.Tests
{
[TestFixture]
public class PipingCalculatorSellmeijerTest
{
[Test]
[ExpectedException(typeof(ParameterMissingException))]
public void ThrowsExceptionWhenSurfaceLineParameterIsMissing()
{
var soilProfile = FactoryForSoilProfileTests.CreateClaySandClaySandProfile();
var calculator = new PipingCalculatorSellmeijer(new ModelParametersForPLLines(), 0, null, null, null, 1.0);
using (var location = new Location())
{
calculator.CalculatePipingFactor(location, null, soilProfile, 0.0);
}
}
[Test]
[ExpectedException(typeof(DamFailureMechanismeCalculatorException))]
public void ThrowsExceptionWhenSoilProfileParameterIsMissing()
{
var calculator = new PipingCalculatorSellmeijer(new ModelParametersForPLLines(), 0, null, null, null, 1.0);
using(var surfaceLine = new SurfaceLine2
{
Geometry = new LocalizedGeometryPointString(),
CharacteristicPoints = { GeometryMustContainPoint = true }
})
using (var location = new Location())
{
calculator.CalculatePipingFactor(location, surfaceLine, null, 0.0);
}
}
[Test]
[ExpectedException(typeof(ParameterMissingException))]
public void ThrowsExceptionWhenCharacteristicPointDikeToeAtRiverDoesNotExist()
{
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
{
int index = -1;
for (int i = 0; i < surfaceLine.CharacteristicPoints.Count; i++)
{
if (surfaceLine.CharacteristicPoints[i].CharacteristicPointType == CharacteristicPointType.DikeToeAtRiver)
{
index = i;
break;
}
}
surfaceLine.CharacteristicPoints.Annotate(index, CharacteristicPointType.None);
Assert.IsNull(surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver),
"Test prerequisite failed.");
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreateClaySandClaySandProfile();
dike.SoilProfiles.Add(soilProfile);
var calculator = new PipingCalculatorSellmeijer(new ModelParametersForPLLines(),
1.0, dike.GaugePLLines, dike.Gauges, null, 1.0);
calculator.CalculatePipingFactor(location, surfaceLine, soilProfile, 0.0);
}
}
}
[Test]
public void CanCalculateThePipingFactorUsingSellmeijerNoUplift()
{
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreateClaySandClaySandProfile();
var calculator = new PipingCalculatorSellmeijer(new ModelParametersForPLLines(),
1.0, dike.GaugePLLines, dike.Gauges, null, 1.0);
var actual = calculator.CalculatePipingFactor(location, surfaceLine, soilProfile, 0.0);
// Phreatic level in profile
// Mass of soil volume above
// dry 6 m x 12 kN/m3 = 72
// wet 9 m x 16 kN/m3 = 144
// Total: 72 + 144 = 216
// Phreatic pressure
// 20 m x 10 kN/m3 = 200
// UpliftFactor = 216/200 = 1.08
// UpliftFactor > 1.0, so no piping, so returns cDefaultMaxReturnValue
var expected = PipingCalculatorSellmeijer.cDefaultMaxReturnValue;
Assert.AreEqual(expected, actual);
}
}
[Test]
[ExpectedException(typeof(SoilVolumicMassCalculatorException))]
public void ThrowsExceptionWhenNoToplayer()
{
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreatePipingSellmeijerProfileWithTwoSandlayers();
soilProfile.Layers.RemoveAt(0);
var modelParametersForPLLines = new ModelParametersForPLLines();
modelParametersForPLLines.DampingFactorPL4 = 0.0;
var calculator = new PipingCalculatorSellmeijer(modelParametersForPLLines,
1.0, dike.GaugePLLines, dike.Gauges, null, 1.0);
var actual = calculator.CalculatePipingFactor(location, surfaceLine, soilProfile, 1.0);
}
}
[Test]
public void CalculateTheSellmeijerPipingFactorForProfileWithTwoSandlayers()
{
const double cTolerance = 0.01;
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreatePipingSellmeijerProfileWithTwoSandlayers();
var modelParametersForPLLines = new ModelParametersForPLLines();
modelParametersForPLLines.DampingFactorPL4 = 0.0;
var calculator = new PipingCalculatorSellmeijer(modelParametersForPLLines,
1.0, dike.GaugePLLines, dike.Gauges, null, 1.0);
var actual = calculator.CalculatePipingFactor(location, surfaceLine, soilProfile, 1.0);
// Phreatic level in profile
// Mass of soil volume above
// material above bottom sandlayer: 0 to -5 m
// dry/wet 5 m x 1 kN/m3 = 5
// Phreatic pressure (Head PLLine 4 is ca. 1.0
// 6.0 m x 10 kN/m3 = 60,0
// UpliftFactor = 5/60.0 = 0.0833
// UpliftFactor < 1.0, so piping will occur in toe of dike
//
// See dgs-as2.geodelft.nl/DGWebPiping for calculation
// ===========
// gamma_w = 9.81
// mu = 1.33E-06
// gamma_p = 26.5
// eta = 0.25
// theta = 37
// F = 1.2
// i = 0.3
// ===========
// D1 = dikte bovenste zandlaag = 2.0
// D2 = dikte onderste zandlaag = 6.0
// k1 = 0.0001
// k2 = 0.0002
// k3 = 0.0001
// Do = 2.0
// D70 = 200
// Calculate dH
// L = ToeOfDike.x - entrypoint.x = 50.5 - 10.0 = 40.5
// ===========
// Hc = Calculated dH = 3.65
// Ha = waterlevel - polderlevel = 1.0 - 0.0 = 1.0
// Piping factor = Hc / Ha = 3.46
const double expected = 3.65;
Assert.AreEqual(expected, actual.Value, cTolerance);
}
}
[Test]
public void CalculateTheSellmeijerPipingFactorForProfileWithOneSandlayer()
{
const double cTolerance = 0.01;
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreatePipingSellmeijerProfileWithOneSandlayer();
var modelParametersForPLLines = new ModelParametersForPLLines();
modelParametersForPLLines.DampingFactorPL4 = 0.0;
var calculator = new PipingCalculatorSellmeijer(modelParametersForPLLines,
1.0, dike.GaugePLLines, dike.Gauges, null, 1.0);
calculator.FilenameCalculation = Path.GetFullPath(".\\CalculateTheSellmeijerPipingFactorForProfileWithOneSandlayer");
var actual = calculator.CalculatePipingFactor(location, surfaceLine, soilProfile, 1.0);
// Phreatic level in profile
// Mass of soil volume above
// material above bottom sandlayer: 0 to -5 m
// dry/wet 5 m x 1 kN/m3 = 5
// Phreatic pressure (Head PLLine 4 is ca. 1.0
// 6.0 m x 10 kN/m3 = 60,0
// UpliftFactor = 5/60.0 = 0.0833
// UpliftFactor < 1.0, so piping will occur in toe of dike
//
// See dgs-as2.geodelft.nl/DGWebPiping for calculation
// ===========
// gamma_w = 9.81
// mu = 1.33E-06
// gamma_p = 26.5
// eta = 0.25
// theta = 37
// F = 1.2
// i = 0.3
// ===========
// D1 = dikte bovenste zandlaag = 4.0
// D2 = dikte onderste zandlaag = 4.0
// k1 = 0.0001
// k2 = 0.0001
// k3 = 0.0001
// Do = 2.0
// D70 = 200
// Calculate dH
// L = ToeOfDike.x - entrypoint.x = 50.5 - 10.0 = 40.5
// ===========
// Hc = Calculated dH = 4.13581
// Ha = waterlevel - polderlevel = 1.0 - 0.0 = 1.0
// Piping factor = Hc / Ha = 4.13581
const double expected = 4.13581;
Assert.AreEqual(expected, actual.Value, cTolerance);
}
}
[Test]
public void CanCalculatePipingDesignUsingSellmeijer()
{
const double cTolerance = 0.01;
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreatePipingDesignSellmeijerDesign();
var modelParametersForPLLines = new ModelParametersForPLLines();
modelParametersForPLLines.DampingFactorPL4 = 0.0;
var calculator = new PipingCalculatorSellmeijer(modelParametersForPLLines,
1.1, dike.GaugePLLines, dike.Gauges, null, 1.0);
calculator.IsHydraulicShortcut = true;
var point = new GeometryPoint(55, 0, 0);
var actualPipingDesign = calculator.CalculateDesignAtPoint(location, surfaceLine, soilProfile, 4.0, point);
// Phreatic level in profile
// Mass of soil volume above
// material above bottom sandlayer: 0 to -2 m
// dry/wet 2 m x 5 kN/m3 = 10
// Phreatic pressure (Head PLLine 4) is 4.0 - -2 = 6
// 6.0 m x 9.81 kN/m3 = 58.86
// UpliftFactor = 10.0/58.86 = 0.1699 (in inbetween aquiferlayer; for bottomlayer its 0.25 so inbetween layer is prevelant)
// UpliftFactor < 1.0, so piping will occur in toe of dike
//
// See dgs-as2.geodelft.nl/DGWebPiping for calculation
// ===========
// gamma_w = 9.81
// mu = 1.33E-06
// gamma_p = 26.5
// eta = 0.25
// theta = 37
// F = 1.2
// i = 0.3
// ===========
// D1 = dikte bovenste zandlaag = 2.0
// D2 = dikte onderste zandlaag = 6.0
// k1 = 0.0001
// k2 = 0.0002
// k3 = 0.0001
// Do = 2.0
// D70 = 200
// Calculate dH
// L = Point.x - entrypoint.x = 55 - 10.0 = 45
// ===========
// Ha = waterlevel - polderlevel = 4.0 - 0.0 = 4.0
// Hcrit = 3.96
// Pipingfactor = 0.9911 (smaller then required so shoulder is needed)
// Shoulder length = point.x - diketoe.x = 55 -50.5 = 4.5
// Shoulderheight calculation
// Phreatic pressure (Head PLLine 4) is 4.0
// 6.0 m x 9.81 kN/m3 = 58.86
// Materialweight = UpliftFactor * Wateruplift = 1.0 * 58.86
// material height above bottom sandlayer should be
// Height = Materialweight / (dry or wet) = 58.86 / 5.0 = 11.772 3.924;
// Height shoulder = Height - (Height to Surfacelevel) = 11.772 - 2.0 = 9.772 m
//
var expectedPipingDesign = new PipingDesign(4.50, 9.772);
Assert.AreEqual(expectedPipingDesign.PipingLengthFromToe, actualPipingDesign.PipingLengthFromToe, cTolerance);
Assert.AreEqual(expectedPipingDesign.ShoulderHeightFromToe, actualPipingDesign.ShoulderHeightFromToe, cTolerance);
}
}
///
/// This test should be testing PipingCalculatorSellmeijer.CalculateReliabilityIndex()
/// The test is not yet complete
///
[Test]
[Ignore("In development")]
public void CalculateTheSellmeijerReliabilityIndexForProfileWithOneSandlayer()
{
using (var surfaceLine = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1())
using (var dike = new Dike())
using (var location = new Location())
{
var soilProfile = FactoryForSoilProfileTests.CreatePipingSellmeijerProfileWithOneSandlayer();
var modelParametersForPLLines = new ModelParametersForPLLines();
modelParametersForPLLines.DampingFactorPL4 = 0.0;
var calculator = new PipingCalculatorSellmeijer(modelParametersForPLLines,
1.0, dike.GaugePLLines, dike.Gauges, null, 1.0);
calculator.FilenameCalculation = Path.GetFullPath(".\\CalculateTheSellmeijerPipingFactorForProfileWithOneSandlayer");
var actual = calculator.CalculateReliabilityIndex(location, surfaceLine, soilProfile, new ProbabilisticStruct { Distribution = 1, IsUsed = true, Mean = 1.0, StandardDeviation = 0.5 });
}
}
}
}