// Copyright (C) Stichting Deltares 2018. 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 SoilVolumeMassCalculatorTest
{
[Test]
public void CalculateForComplexProfileWithPhreaticLineInProfile1()
{
const double cTolerance = 0.001;
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateComplexProfile();
calculator.SurfaceLevel = 0.21;
calculator.PhreaticLevel = -0.98;
calculator.TopOfLayerToBeEvaluated = -5.0;
// See spreadsheet "DAM Volumic weight test"
Assert.AreEqual(76.358, calculator.CalculateTotalMass(), cTolerance);
}
[Test]
public void CalculateForComplexProfileWithPhreaticLineInProfile2()
{
const double cTolerance = 0.001;
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateComplexProfile();
calculator.SurfaceLevel = 10.0;
calculator.PhreaticLevel = -1.8;
calculator.TopOfLayerToBeEvaluated = -5.0;
// See spreadsheet "DAM Volumic weight test"
Assert.AreEqual(230.22, calculator.CalculateTotalMass(), cTolerance);
}
[Test]
public void CalculateForSimpleProfileWithPhreaticLineAboveProfile()
{
const double cTolerance = 0.0001;
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = 10.0;
calculator.TopOfLayerToBeEvaluated = -10;
calculator.VolumicWeightOfWater = 10.0;
// All wet soil
// wet 15 m x 16 kN/m3 = 240
// water above surface 5 m x 10.0 kN/m3 = 50
// Total: 240 + 50 = 290
Assert.AreEqual(290.0, calculator.CalculateTotalMass(), cTolerance);
}
[Test]
public void CalculateForSimpleProfileWithPhreaticLineBelowProfile()
{
const double cTolerance = 0.0001;
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = -20.0;
calculator.TopOfLayerToBeEvaluated = -10;
// All dry soil
// dry 15 m x 12 kN/m3 = 180
Assert.AreEqual(180.0, calculator.CalculateTotalMass(), cTolerance);
}
[Test]
public void CalculateForSimpleProfileWithPhreaticLineInProfile()
{
const double cTolerance = 0.0001;
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 5.0;
calculator.PhreaticLevel = -1.0;
calculator.TopOfLayerToBeEvaluated = -10;
// Phreatic level in profile
// dry 6 m x 12 kN/m3 = 72
// wet 9 m x 16 kN/m3 = 144
// Total: 72 + 144 = 216
Assert.AreEqual(216.0, calculator.CalculateTotalMass(), cTolerance);
}
///
/// Same as above test, but now the oven dry unit weight has to be used
///
[Test]
public void CalculateForSimpleProfileWithPhreaticLineInProfileAndDryOption()
{
const double cTolerance = 0.0001;
var calculator = new SoilVolumicMassCalculator();
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.IsUseOvenDryUnitWeight = true;
// Phreatic level in profile
// dry 6 m x 12 kN/m3 = 72
// wet 9 m x 16 kN/m3 = 144
// Total: 72 + 144 = 216
Assert.AreEqual(216.0, calculator.CalculateTotalMass(), cTolerance);
}
[Test]
public void CalculateForTwoLayerProfileWithPhreaticLineOnBoundary()
{
const double cTolerance = 0.0001;
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateTwoLayerProfile();
calculator.SurfaceLevel = 10.0;
calculator.PhreaticLevel = 2.0;
calculator.TopOfLayerToBeEvaluated = -10;
calculator.VolumicWeightOfWater = 10.0;
// All wet soil
// dry 8 m x 10 kN/m3 = 80
// wet 12 m x 22 kN/m3 = 264
// Total: 80 + 264 = 344
Assert.AreEqual(344.0, calculator.CalculateTotalMass(), cTolerance);
}
[Test]
[ExpectedException(typeof(SoilVolumicMassCalculatorException))]
public void ThrowsExceptionWhenSoilProfileParameterIsMissing()
{
var calculator = new SoilVolumicMassCalculator();
calculator.CalculateTotalMass();
}
[Test]
[ExpectedException(typeof(SoilVolumicMassCalculatorException))]
public void ThrowsExceptionWhenSurfaceLevelIsAboveProfile()
{
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = 15.0;
calculator.CalculateTotalMass();
}
[Test]
[ExpectedException(typeof(SoilVolumicMassCalculatorException))]
public void ThrowsExceptionWhenSurfaceLevelIsBelowProfile()
{
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.SurfaceLevel = -100.0;
calculator.CalculateTotalMass();
}
[Test]
[ExpectedException(typeof(SoilVolumicMassCalculatorException))]
public void ThrowsExceptionWhenTopLevelToBeValuatedIsBelowProfile()
{
var calculator = new SoilVolumicMassCalculator();
calculator.SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile();
calculator.TopOfLayerToBeEvaluated = -100.0;
calculator.CalculateTotalMass();
}
}
}