// Copyright (C) Stichting Deltares 2021. 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 Deltares.DamEngine.Calculators.Uplift;
using Deltares.DamEngine.TestHelpers.Factories;
using NUnit.Framework;
namespace Deltares.DamEngine.Calculators.Tests.Uplift
{
[TestFixture]
public class UpliftCalculatorTest
{
[Test]
public void CalculateExtraHeightForSimpleProfileWithPhreaticLineInProfile()
{
const double cTolerance = 0.0001;
var calculator = new UpliftCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = -1.0;
calculator.TopOfLayerToBeEvaluated = -10;
calculator.VolumicWeightOfWater = 10.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
// UpliftFactor = 1.2
// Phreatic pressure
// 20 m x 10 kN/m3 = 200
// Mass of Watervolume = 200
// mass of soil = uplift factor * Mass of watervolume = 1.2 * 200 = 240
// Extra mass soil = 240 - 216 = 24
// Extra Height = Extra mass soil / (unit weight soil for raising) = 24 / 12 = 2.0
calculator.UnitWeightSoilEmbankment = null;
Assert.AreEqual(2.0, calculator.CalculateExtraHeight(10.0, 1.2), cTolerance);
// Extra Height = Extra mass soil / (unit weight soil for raising) = 24 / 8 = 3.0
calculator.UnitWeightSoilEmbankment = 8.0;
Assert.AreEqual(3.0, calculator.CalculateExtraHeight(10.0, 1.2), cTolerance);
}
[Test]
public void CalculateHeadOfPlLineForSimpleProfileWithPhreaticLineInProfile()
{
const double cTolerance = 0.0001;
var calculator = new UpliftCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = -1.0;
calculator.TopOfLayerToBeEvaluated = -10;
calculator.VolumicWeightOfWater = 10.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
// UpliftFactor = 1.0
// Mass of Watervolume = mass of soil / uplift factor = 216 / 1.0 = 216
// Head = mass of watervolume / volumic weight water - top of layer = 216 / 10 - (-10) = 21.6 - (-10.0) = 11.6 m
Assert.AreEqual(11.6, calculator.CalculateHeadOfPlLine(1.0), cTolerance);
double upliftFactor = calculator.CalculateUpliftFactor(11.6);
Assert.AreEqual(1.0, upliftFactor, cTolerance);
calculator.IsUseOvenDryUnitWeight = true;
double head = calculator.CalculateHeadOfPlLine(1.0);
double upliftFactorOvenDry = calculator.CalculateUpliftFactor(head);
Assert.AreEqual(1.0, upliftFactorOvenDry, cTolerance);
}
[Test]
public void CalculateUpliftFactorForSimpleProfileWithPhreaticLineInProfile()
{
const double cTolerance = 0.0001;
var calculator = new UpliftCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = -1.0;
calculator.TopOfLayerToBeEvaluated = -10;
calculator.VolumicWeightOfWater = 10.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
Assert.AreEqual(1.08, calculator.CalculateUpliftFactor(10.0), cTolerance);
}
///
/// Same as above test, but now the oven dry unit weight has to be used
///
[Test]
public void CalculateUpliftFactorForSimpleProfileWithPhreaticLineInProfileAndDryOption()
{
const double cTolerance = 0.0001;
var calculator = new UpliftCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
foreach (var layer in calculator.SoilProfile.Layers)
{
layer.Soil.DryUnitWeight = layer.Soil.AbovePhreaticLevel;
layer.Soil.AbovePhreaticLevel = layer.Soil.AbovePhreaticLevel + 1.0;
}
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = -1.0;
calculator.TopOfLayerToBeEvaluated = -10;
calculator.VolumicWeightOfWater = 10.0;
calculator.IsUseOvenDryUnitWeight = true;
// 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
Assert.AreEqual(1.08, calculator.CalculateUpliftFactor(10.0), cTolerance);
}
[Test]
[ExpectedException(typeof(UpliftCalculatorException))]
public void ThrowsExceptionWhenSoilProfileParameterIsMissingInCalculateHeadOfPlLine()
{
var calculator = new UpliftCalculator();
calculator.CalculateHeadOfPlLine(0.0);
}
[Test]
[ExpectedException(typeof(UpliftCalculatorException))]
public void ThrowsExceptionWhenSoilProfileParameterIsMissingInCalculateUpliftFactor()
{
var calculator = new UpliftCalculator();
calculator.CalculateUpliftFactor(0.0);
}
[TestFixtureSetUp]
public void FixtureSetup() {}
[TestFixtureTearDown]
public void FixtureTearDown() {}
}
}