// Copyright (C) Stichting Deltares 2024. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU 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 General Public License for more details. // // You should have received a copy of the GNU 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 System.Collections.Generic; using System.IO; using Deltares.Dam.Data; using Deltares.Dam.TestHelper; using Deltares.Standard; using NUnit.Framework; namespace Deltares.Dam.IntegrationTests { [TestFixture] public class ShearStrengthModelsTests { private const double tolerance6Decimals = 0.00000051; /// /// This test compares the safety factor calculated with the 3 shear strength models: Mohr-Coulomb, Sigma-Tau and Shansep. /// - Mohr-Coulomb (c=5, phi=psi=45) leading to a shear stress of Tau = 5 + NormalEffectiveStress /// - SigmaTau table with one segment line (0, 5)-(400, 405) equivalent to Mohr-Coulomb /// - Shansep (m=S=1, POP=5) leading to a shear stress of Tau = 5 + VerticalEffectiveStress /// Expected is that both shear strength models Mohr-Coulomb and SigmaTau return the same result. /// However, due to the "cut-off" method (reduction of the bottom angle of the slices when too high) which applies to /// Mohr-Coulomb but not SigmaTau table, a small difference in the safety factor is expected. /// But Shansep should return a higher safety factor because the VerticalEffectiveStress is higher than the NormalEffectiveStress. /// [Test] public void GivenSoilProfilesWithDifferentShearStrengthModelWhenRunningThenExpectedResultsAreReturned() { var projectFilename = Path.Combine(Directory.GetCurrentDirectory(), @"TestData\ShearStrengthModelsTests\ShearStrengthModelsComparison.damx"); List allCalculationResults = ComputeHelper.ComputeStabilityProject(projectFilename, MStabModelType.Bishop, true, 1); Assert.That(allCalculationResults, Has.Count.EqualTo(3)); for (int i = 0; i < 3; i++) { Assert.Multiple(() => { Assert.That(allCalculationResults[i].LocationName, Is.EqualTo("Comparison Mohr-Coulomb SigmaTau and SHANSEP")); Assert.That(allCalculationResults[i].CalculationResult, Is.EqualTo(CalculationResult.Succeeded)); Assert.That(allCalculationResults[i].ResultMessage, Is.EqualTo("")); Assert.That(allCalculationResults[i].Notes, Is.EqualTo("")); }); } Assert.Multiple(() => { Assert.That(allCalculationResults[0].ProfileName, Is.EqualTo("MohrCoulombMaterial")); Assert.That(allCalculationResults[0].SafetyFactor, Is.EqualTo(2.099733).Within(tolerance6Decimals)); Assert.That(allCalculationResults[1].ProfileName, Is.EqualTo("SigmaTauMaterial")); Assert.That(allCalculationResults[1].SafetyFactor, Is.EqualTo(2.114490).Within(tolerance6Decimals)); Assert.That(allCalculationResults[2].ProfileName, Is.EqualTo("ShansepMaterial")); Assert.That(allCalculationResults[2].SafetyFactor, Is.EqualTo(2.672868).Within(tolerance6Decimals)); }); } /// /// This test uses the same data as test GivenSoilProfilesWithDifferentShearStrengthModelWhenRunningThenExpectedResultsAreReturned, /// except for the sigma-tau curve which starts at 2 instead of 0. /// Expected is that the soil profile SigmaTauMaterial returns no result and that a clear calculation error message is displayed. /// [Test] [Category("Work_In_Progress")] //[Ignore("unexpected error message occurs, will be solved in MWDAM-2123")] public void GivenInvalidSigmaTauCurveNotStartingAt0WhenCalculatingReturnsCalculationErrorMessage() { var projectFilename = Path.Combine(Directory.GetCurrentDirectory(), @"TestData\ShearStrengthModelsTests\InvalidSigmaTauCurveNotStartingAt0.damx"); List allCalculationResults = ComputeHelper.ComputeStabilityProject(projectFilename, MStabModelType.Bishop, true, 1); Assert.That(allCalculationResults, Has.Count.EqualTo(2)); Assert.Multiple(() => { Assert.That(allCalculationResults[1].CalculationResult, Is.EqualTo(CalculationResult.RunFailed)); Assert.That(allCalculationResults[1].ResultMessage, Does.Contain("The first sigma value must be 0 for sigma/tau table")); }); } } }