Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/DerivedMacroStabilityInwardsOutputFactory.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/DerivedMacroStabilityInwardsOutputFactory.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/DerivedMacroStabilityInwardsOutputFactory.cs (revision e751a698f14762ba8279c2e0f88e9312ffe574fb) @@ -0,0 +1,103 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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; +using Core.Common.Util; + +namespace Ringtoets.MacroStabilityInwards.Data +{ + /// + /// Factory class to create . + /// + public static class DerivedMacroStabilityInwardsOutputFactory + { + /// + /// Calculates the semi-probabilistic results given a with . + /// + /// The output of a calculation. + /// General input that influences the probability estimate for a + /// macro stability inwards assessment. + /// The norm to assess for. + /// The contribution of macro stability inwards as a percentage (0-100) to the total of the failure probability + /// of the assessment section. + /// Thrown when or + /// is null. + public static DerivedMacroStabilityInwardsOutput Create(MacroStabilityInwardsOutput output, + MacroStabilityInwardsProbabilityAssessmentInput probabilityAssessmentInput, + double norm, double contribution) + { + if (output == null) + { + throw new ArgumentNullException(nameof(output)); + } + + if (probabilityAssessmentInput == null) + { + throw new ArgumentNullException(nameof(probabilityAssessmentInput)); + } + + double factorOfStability = output.FactorOfStability; + double requiredProbability = CalculateRequiredProbability(probabilityAssessmentInput.A, + probabilityAssessmentInput.B, + probabilityAssessmentInput.SectionLength, + norm, + contribution / 100); + double requiredReliability = StatisticsConverter.ProbabilityToReliability(requiredProbability); + + double macroStabilityInwardsReliability = CalculateEstimatedReliability(factorOfStability); + double macroStabilityInwardsProbability = StatisticsConverter.ReliabilityToProbability(macroStabilityInwardsReliability); + + double macroStabilityInwardsFactorOfSafety = macroStabilityInwardsReliability / requiredReliability; + + return new DerivedMacroStabilityInwardsOutput(factorOfStability, + requiredProbability, + requiredReliability, + macroStabilityInwardsProbability, + macroStabilityInwardsReliability, + macroStabilityInwardsFactorOfSafety); + } + + /// + /// Calculates the required probability of the piping failure mechanism for the complete assessment section. + /// + /// The constant a. + /// The constant b. + /// The length of the assessment section. + /// The norm. + /// The contribution of piping to the total failure. + /// A value representing the required probability. + private static double CalculateRequiredProbability(double constantA, double constantB, double sectionLength, double norm, double contribution) + { + return (norm * contribution) / (1 + (constantA * sectionLength) / constantB); + } + + /// + /// Calculates the estimated reliability of the macro stability inwards failure mechanism + /// based on the stability factor. + /// + /// The factory of stability to calculate the reliability for. + /// The estimated reliability based on the stability factor. + private static double CalculateEstimatedReliability(double factorOfStability) + { + return (6.21 * factorOfStability) - 2.88; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj =================================================================== diff -u -r490ca61d1c7791776cc522141816391f075a9752 -re751a698f14762ba8279c2e0f88e9312ffe574fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 490ca61d1c7791776cc522141816391f075a9752) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision e751a698f14762ba8279c2e0f88e9312ffe574fb) @@ -13,6 +13,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/DerivedMacroStabilityInwardsOutputFactoryTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/DerivedMacroStabilityInwardsOutputFactoryTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/DerivedMacroStabilityInwardsOutputFactoryTest.cs (revision e751a698f14762ba8279c2e0f88e9312ffe574fb) @@ -0,0 +1,84 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; + +namespace Ringtoets.MacroStabilityInwards.Data.Test +{ + [TestFixture] + public class DerivedMacroStabilityInwardsOutputFactoryTest + { + [Test] + public void Create_OutputNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DerivedMacroStabilityInwardsOutputFactory.Create(null, + new MacroStabilityInwardsProbabilityAssessmentInput(), + double.NaN, + double.NaN); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("output", exception.ParamName); + } + + [Test] + public void Create_ProbabilityAssessmentInputNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => DerivedMacroStabilityInwardsOutputFactory.Create(MacroStabilityInwardsOutputTestFactory.CreateOutput(), + null, + double.NaN, + double.NaN); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("probabilityAssessmentInput", exception.ParamName); + } + + [Test] + public void Create_ValidData_ReturnsExpectedValue() + { + // Setup + var probabilityAssessmentInput = new MacroStabilityInwardsProbabilityAssessmentInput + { + SectionLength = 6000 + }; + + MacroStabilityInwardsOutput output = MacroStabilityInwardsOutputTestFactory.CreateRandomOutput(); + const double norm = 1.0 / 30000; + + // Call + DerivedMacroStabilityInwardsOutput derivedOutput = DerivedMacroStabilityInwardsOutputFactory.Create(output, probabilityAssessmentInput, norm, 1000); + + // Assert + Assert.AreEqual(0.697, derivedOutput.FactorOfStability, derivedOutput.FactorOfStability.GetAccuracy()); + Assert.AreEqual(0.38, derivedOutput.MacroStabilityInwardsFactorOfSafety, derivedOutput.MacroStabilityInwardsFactorOfSafety.GetAccuracy()); + Assert.AreEqual(0.073605149538226278, derivedOutput.MacroStabilityInwardsProbability, 1e-6); + Assert.AreEqual(1.44946, derivedOutput.MacroStabilityInwardsReliability, derivedOutput.MacroStabilityInwardsReliability.GetAccuracy()); + Assert.AreEqual(6.7204301075268831E-05, derivedOutput.RequiredProbability, 1e-6); + Assert.AreEqual(3.81824, derivedOutput.RequiredReliability, derivedOutput.RequiredReliability.GetAccuracy()); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -r490ca61d1c7791776cc522141816391f075a9752 -re751a698f14762ba8279c2e0f88e9312ffe574fb --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 490ca61d1c7791776cc522141816391f075a9752) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision e751a698f14762ba8279c2e0f88e9312ffe574fb) @@ -21,6 +21,7 @@ +