// Copyright (C) Stichting Deltares 2026. 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.That(calculator.CalculateTotalMass(), Is.EqualTo(76.358).Within(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.That(calculator.CalculateTotalMass(), Is.EqualTo(230.22).Within(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.That(calculator.CalculateTotalMass(), Is.EqualTo(290.0).Within(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.That(calculator.CalculateTotalMass(), Is.EqualTo(180.0).Within(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.That(calculator.CalculateTotalMass(), Is.EqualTo(216.0).Within(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(); 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.That(calculator.CalculateTotalMass(), Is.EqualTo(216.0).Within(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.That(calculator.CalculateTotalMass(), Is.EqualTo(344.0).Within(cTolerance)); } [Test] public void ThrowsExceptionWhenSoilProfileParameterIsMissing() { var calculator = new SoilVolumicMassCalculator(); Assert.That(() => calculator.CalculateTotalMass(), Throws.InstanceOf()); } [Test] public void ThrowsExceptionWhenSurfaceLevelIsAboveProfile() { var calculator = new SoilVolumicMassCalculator { SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile(), SurfaceLevel = 15.0 }; Assert.That(() => calculator.CalculateTotalMass(), Throws.InstanceOf()); } [Test] public void ThrowsExceptionWhenSurfaceLevelIsBelowProfile() { var calculator = new SoilVolumicMassCalculator { SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile(), SurfaceLevel = -100.0 }; Assert.That(() => calculator.CalculateTotalMass(), Throws.InstanceOf()); } [Test] public void ThrowsExceptionWhenTopLevelToBeValuatedIsBelowProfile() { var calculator = new SoilVolumicMassCalculator { SoilProfile = FactoryForSoilProfiles.CreateSimpleProfile(), TopOfLayerToBeEvaluated = -100.0 }; Assert.That(() => calculator.CalculateTotalMass(), Throws.InstanceOf()); } }