Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/DesignVariable.cs =================================================================== diff -u -r8805f03189f521994b42a519bbca7561bf12eb68 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/DesignVariable.cs (.../DesignVariable.cs) (revision 8805f03189f521994b42a519bbca7561bf12eb68) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/DesignVariable.cs (.../DesignVariable.cs) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -21,32 +21,21 @@ using System; using Core.Common.Base.Data; -using MathNet.Numerics.Distributions; using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.Probabilistics { - /// - /// This class is a representation of a variable derived from a probabilistic distribution, - /// based on a percentile. - /// - /// The type of the underlying distribution from which a value is - /// derived. - public abstract class DesignVariable where TDistributionType : IDistribution - { - private double percentile; + public abstract class DesignVariable where TDistributionType : IDistribution { private TDistributionType distribution; /// - /// Initializes a new instance of the class with - /// equal to 0.5. + /// Initializes a new instance of the class. /// /// Thrown when is /// null. protected DesignVariable(TDistributionType distribution) { Distribution = distribution; - percentile = 0.5; } /// @@ -71,45 +60,9 @@ } /// - /// Gets or sets the percentile used to derive a deterministic value based on . + /// Gets a projected (design) value based on the . /// - /// Thrown when - /// is not in range [0,1]. - public double Percentile - { - get - { - return percentile; - } - set - { - if (value < 0.0 || value > 1.0) - { - throw new ArgumentOutOfRangeException("value", Resources.DesignVariable_Percentile_must_be_in_range); - } - percentile = value; - } - } - - /// - /// Gets the design value based on the and . - /// /// A design value. public abstract RoundedDouble GetDesignValue(); - - /// - /// Determines the design value based on a 'normal space' expected value and standard deviation. - /// - /// The expected value. - /// The standard deviation. - /// The design value - protected double DetermineDesignValue(double expectedValue, double standardDeviation) - { - // Design factor is determined using the 'probit function', which is the inverse - // CDF function of the standard normal distribution. For more information see: - // "Quantile function" https://en.wikipedia.org/wiki/Normal_distribution - double designFactor = Normal.InvCDF(0.0, 1.0, Percentile); - return expectedValue + designFactor*standardDeviation; - } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/DeterministicDesignVariable.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/DeterministicDesignVariable.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/DeterministicDesignVariable.cs (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -0,0 +1,47 @@ +// Copyright (C) Stichting Deltares 2016. 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 Core.Common.Base.Data; + +namespace Ringtoets.Common.Data.Probabilistics +{ + /// + /// This class defines a design variable for a log-normal distribution. + /// + public class DeterministicDesignVariable : DesignVariable where T : IDistribution + { + /// + /// Initializes a new instance of the class. + /// + /// A log-normal distribution. + public DeterministicDesignVariable(T distribution) : base(distribution) { } + + /// + /// Gets or sets the value that was set to be returned for the distribution. + /// + public double DeterministicValue { get; set; } + + public override RoundedDouble GetDesignValue() + { + return new RoundedDouble(Distribution.Mean.NumberOfDecimalPlaces, DeterministicValue); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/LogNormalDistributionDesignVariable.cs =================================================================== diff -u -r4bab160dd44cb5e104ad8fbf2bb49add8227c116 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/LogNormalDistributionDesignVariable.cs (.../LogNormalDistributionDesignVariable.cs) (revision 4bab160dd44cb5e104ad8fbf2bb49add8227c116) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/LogNormalDistributionDesignVariable.cs (.../LogNormalDistributionDesignVariable.cs) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -27,7 +27,7 @@ /// /// This class defines a design variable for a log-normal distribution. /// - public class LogNormalDistributionDesignVariable : DesignVariable + public class LogNormalDistributionDesignVariable : PercentileBasedDesignVariable { /// /// Initializes a new instance of the class. @@ -42,7 +42,7 @@ } /// - /// Projects into 'normal + /// Projects into 'normal /// distribution' space and calculates the design value for that value space. /// /// The design value in 'normal distribution' space. Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/NormalDistributionDesignVariable.cs =================================================================== diff -u -rd9ca53f8fa89c230d499c7ac28b3b0b8e9290fe5 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/NormalDistributionDesignVariable.cs (.../NormalDistributionDesignVariable.cs) (revision d9ca53f8fa89c230d499c7ac28b3b0b8e9290fe5) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/NormalDistributionDesignVariable.cs (.../NormalDistributionDesignVariable.cs) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -26,7 +26,7 @@ /// /// This class defines a design variable for a normal distribution. /// - public class NormalDistributionDesignVariable : DesignVariable + public class NormalDistributionDesignVariable : PercentileBasedDesignVariable { /// /// Initializes a new instance of the class. Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/PercentileBasedDesignVariable.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/PercentileBasedDesignVariable.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/PercentileBasedDesignVariable.cs (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -0,0 +1,85 @@ +// Copyright (C) Stichting Deltares 2016. 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 MathNet.Numerics.Distributions; +using Ringtoets.Common.Data.Properties; + +namespace Ringtoets.Common.Data.Probabilistics +{ + /// + /// This class is a representation of a variable derived from a probabilistic distribution, + /// based on a percentile. + /// + /// The type of the underlying distribution from which a value is + /// derived. + public abstract class PercentileBasedDesignVariable : DesignVariable where TDistributionType : IDistribution + { + private double percentile; + + /// + /// Initializes a new instance of the class with + /// equal to 0.5. + /// + /// Thrown when is + /// null. + protected PercentileBasedDesignVariable(TDistributionType distribution) : base(distribution) + { + percentile = 0.5; + } + + /// + /// Gets or sets the percentile used to derive a deterministic value based on . + /// + /// Thrown when + /// is not in range [0,1]. + public double Percentile + { + get + { + return percentile; + } + set + { + if (value < 0.0 || value > 1.0) + { + throw new ArgumentOutOfRangeException("value", Resources.DesignVariable_Percentile_must_be_in_range); + } + percentile = value; + } + } + + /// + /// Determines the design value based on a 'normal space' expected value and standard deviation. + /// + /// The expected value. + /// The standard deviation. + /// The design value + protected double DetermineDesignValue(double expectedValue, double standardDeviation) + { + // Design factor is determined using the 'probit function', which is the inverse + // CDF function of the standard normal distribution. For more information see: + // "Quantile function" https://en.wikipedia.org/wiki/Normal_distribution + double designFactor = Normal.InvCDF(0.0, 1.0, Percentile); + return expectedValue + designFactor*standardDeviation; + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -55,7 +55,9 @@ + + Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/DesignVariableTest.cs =================================================================== diff -u -r11b25a9a8ba5c1fcadad1e32fa072e159aafff26 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/DesignVariableTest.cs (.../DesignVariableTest.cs) (revision 11b25a9a8ba5c1fcadad1e32fa072e159aafff26) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/DesignVariableTest.cs (.../DesignVariableTest.cs) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -43,7 +43,6 @@ // Assert Assert.AreSame(distributionMock, designVariable.Distribution); - Assert.AreEqual(0.5, designVariable.Percentile); mocks.VerifyAll(); // Expect no calls on mocks } @@ -63,54 +62,6 @@ } [Test] - [TestCase(-1234.5678)] - [TestCase(0 - 1e-6)] - [TestCase(1 + 1e-6)] - [TestCase(12345.789)] - public void Percentile_SettingInvalidValue_ThrowArgumentOutOfRangeException(double invalidPercentile) - { - // Setup - var mocks = new MockRepository(); - var distributionMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var designVariable = new SimpleDesignVariable(distributionMock); - - // Call - TestDelegate call = () => designVariable.Percentile = invalidPercentile; - - // Assert - var exception = Assert.Throws(call); - string customMessagePart = exception.Message.Split(new[] - { - Environment.NewLine - }, StringSplitOptions.RemoveEmptyEntries)[0]; - Assert.AreEqual("Percentiel moet in het bereik [0, 1] liggen.", customMessagePart); - mocks.VerifyAll(); // Expect no calls on mocks - } - - [Test] - [TestCase(0.0)] - [TestCase(0.54638291)] - [TestCase(1.0)] - public void Percentile_SettingValidValue_PropertySet(double validPercentile) - { - // Setup - var mocks = new MockRepository(); - var distributionMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var designVariable = new SimpleDesignVariable(distributionMock); - - // Call - designVariable.Percentile = validPercentile; - - // Assert - Assert.AreEqual(validPercentile, designVariable.Percentile); - mocks.VerifyAll(); // Expect no calls on mocks - } - - [Test] public void Distribution_SetToNull_ThrowArgumentNullException() { // Setup @@ -135,7 +86,7 @@ private class SimpleDesignVariable : DesignVariable { - public SimpleDesignVariable(IDistribution distribution) : base(distribution) {} + public SimpleDesignVariable(IDistribution distribution) : base(distribution) { } public override RoundedDouble GetDesignValue() { Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/PercentileBasedDesignVariableTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/PercentileBasedDesignVariableTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probabilistics/PercentileBasedDesignVariableTest.cs (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -0,0 +1,109 @@ +// Copyright (C) Stichting Deltares 2016. 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.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Probabilistics; + +namespace Ringtoets.Common.Data.Test.Probabilistics +{ + [TestFixture] + public class PercentileBasedDesignVariableTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var distributionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + // Call + var designVariable = new SimpleDesignVariable(distributionMock); + + // Assert + Assert.IsInstanceOf>(designVariable); + Assert.AreSame(distributionMock, designVariable.Distribution); + Assert.AreEqual(0.5, designVariable.Percentile); + mocks.VerifyAll(); // Expect no calls on mocks + } + + [Test] + [TestCase(-1234.5678)] + [TestCase(0 - 1e-6)] + [TestCase(1 + 1e-6)] + [TestCase(12345.789)] + public void Percentile_SettingInvalidValue_ThrowArgumentOutOfRangeException(double invalidPercentile) + { + // Setup + var mocks = new MockRepository(); + var distributionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var designVariable = new SimpleDesignVariable(distributionMock); + + // Call + TestDelegate call = () => designVariable.Percentile = invalidPercentile; + + // Assert + var exception = Assert.Throws(call); + string customMessagePart = exception.Message.Split(new[] + { + Environment.NewLine + }, StringSplitOptions.RemoveEmptyEntries)[0]; + Assert.AreEqual("Percentiel moet in het bereik [0, 1] liggen.", customMessagePart); + mocks.VerifyAll(); // Expect no calls on mocks + } + + [Test] + [TestCase(0.0)] + [TestCase(0.54638291)] + [TestCase(1.0)] + public void Percentile_SettingValidValue_PropertySet(double validPercentile) + { + // Setup + var mocks = new MockRepository(); + var distributionMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var designVariable = new SimpleDesignVariable(distributionMock); + + // Call + designVariable.Percentile = validPercentile; + + // Assert + Assert.AreEqual(validPercentile, designVariable.Percentile); + mocks.VerifyAll(); // Expect no calls on mocks + } + + private class SimpleDesignVariable : PercentileBasedDesignVariable + { + public SimpleDesignVariable(IDistribution distribution) : base(distribution) {} + + public override RoundedDouble GetDesignValue() + { + throw new NotImplementedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -64,6 +64,7 @@ + @@ -75,7 +76,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSemiProbabilisticDesignValueFactory.cs =================================================================== diff -u -r4bab160dd44cb5e104ad8fbf2bb49add8227c116 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSemiProbabilisticDesignValueFactory.cs (.../PipingSemiProbabilisticDesignValueFactory.cs) (revision 4bab160dd44cb5e104ad8fbf2bb49add8227c116) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSemiProbabilisticDesignValueFactory.cs (.../PipingSemiProbabilisticDesignValueFactory.cs) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -44,13 +44,25 @@ }; } + private static DesignVariable CreateDeterministicDesignVariable(LogNormalDistribution distribution, double deterministicValue) + { + return new DeterministicDesignVariable(distribution) + { + DeterministicValue = deterministicValue + }; + } + #region General parameters /// /// Creates the design variable for . /// public static DesignVariable GetSaturatedVolumicWeightOfCoverageLayer(PipingInput parameters) { + if (double.IsNaN(parameters.SaturatedVolumicWeightOfCoverageLayer.Mean)) + { + return CreateDeterministicDesignVariable(parameters.SaturatedVolumicWeightOfCoverageLayer, 0); + } return CreateDesignVariable(parameters.SaturatedVolumicWeightOfCoverageLayer, 0.05); } @@ -59,6 +71,10 @@ /// public static DesignVariable GetThicknessCoverageLayer(PipingInput parameters) { + if (double.IsNaN(parameters.ThicknessCoverageLayer.Mean)) + { + return CreateDeterministicDesignVariable(parameters.ThicknessCoverageLayer, 0); + } return CreateDesignVariable(parameters.ThicknessCoverageLayer, 0.05); } Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/PipingSemiProbabilisticDesignValueFactoryTest.cs =================================================================== diff -u -r375ff37edf7bfb578e804373044eab32700f0e07 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/PipingSemiProbabilisticDesignValueFactoryTest.cs (.../PipingSemiProbabilisticDesignValueFactoryTest.cs) (revision 375ff37edf7bfb578e804373044eab32700f0e07) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/PipingSemiProbabilisticDesignValueFactoryTest.cs (.../PipingSemiProbabilisticDesignValueFactoryTest.cs) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -19,9 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; +using Core.Common.Base.Data; using NUnit.Framework; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.TestUtil; namespace Ringtoets.Piping.KernelWrapper.Test { @@ -31,9 +34,25 @@ #region General parameters [Test] - public void GetThicknessCoverageLayer_ValidPipingCalculation_CreateDesignVariableForThicknessCoverageLayer() + public void GetThicknessCoverageLayer_PipingInputWithCoverLayer_CreateDesignVariableForThicknessCoverageLayer() { // Setup + var inputParameters = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); + + // Call + DesignVariable thicknessCoverageLayer = PipingSemiProbabilisticDesignValueFactory.GetThicknessCoverageLayer(inputParameters); + + // Assert + Assert.IsInstanceOf>(thicknessCoverageLayer); + Assert.AreEqual(inputParameters.ThicknessCoverageLayer.Mean, thicknessCoverageLayer.Distribution.Mean); + Assert.AreEqual(inputParameters.ThicknessCoverageLayer.StandardDeviation, thicknessCoverageLayer.Distribution.StandardDeviation); + AssertPercentile(0.05, thicknessCoverageLayer); + } + + [Test] + public void GetThicknessCoverageLayer_PipingInputWithoutCoverLayer_CreateDesignVariableForThicknessCoverageLayer() + { + // Setup var inputParameters = new PipingInput(new GeneralPipingInput()); // Call @@ -42,7 +61,7 @@ // Assert Assert.AreEqual(inputParameters.ThicknessCoverageLayer.Mean, thicknessCoverageLayer.Distribution.Mean); Assert.AreEqual(inputParameters.ThicknessCoverageLayer.StandardDeviation, thicknessCoverageLayer.Distribution.StandardDeviation); - Assert.AreEqual(0.05, thicknessCoverageLayer.Percentile); + Assert.AreEqual(new RoundedDouble(2), thicknessCoverageLayer.GetDesignValue()); } [Test] @@ -56,7 +75,7 @@ // Assert Assert.AreSame(inputParameters.PhreaticLevelExit, freaticLevelExit.Distribution); - Assert.AreEqual(0.05, freaticLevelExit.Percentile); + AssertPercentile(0.05, freaticLevelExit); } [Test] @@ -70,7 +89,7 @@ // Assert Assert.AreSame(inputParameters.DampingFactorExit, dampingFactorExit.Distribution); - Assert.AreEqual(0.95, dampingFactorExit.Percentile); + AssertPercentile(0.95, dampingFactorExit); } #endregion @@ -89,7 +108,7 @@ // Assert Assert.AreEqual(inputParameters.SeepageLength.Mean, seepageLength.Distribution.Mean); Assert.AreEqual(inputParameters.SeepageLength.StandardDeviation, seepageLength.Distribution.StandardDeviation); - Assert.AreEqual(0.05, seepageLength.Percentile); + AssertPercentile(0.05, seepageLength); } [Test] @@ -104,7 +123,7 @@ // Assert Assert.AreEqual(inputParameters.Diameter70.Mean, d70.Distribution.Mean); Assert.AreEqual(inputParameters.Diameter70.StandardDeviation, d70.Distribution.StandardDeviation); - Assert.AreEqual(0.05, d70.Percentile); + AssertPercentile(0.05, d70); } [Test] @@ -119,13 +138,33 @@ // Assert Assert.AreEqual(inputParameters.DarcyPermeability.Mean, darcyPermeability.Distribution.Mean); Assert.AreEqual(inputParameters.DarcyPermeability.StandardDeviation, darcyPermeability.Distribution.StandardDeviation); - Assert.AreEqual(0.95, darcyPermeability.Percentile); + AssertPercentile(0.95, darcyPermeability); } [Test] - public void GetSaturatedVolumicWeightOfCoverageLayer_ValidPipingCalculation_CreateDesignVariableForSaturatedVolumicWeightOfCoverageLayer() + public void GetSaturatedVolumicWeightOfCoverageLayer_PipingInputWithCoverLayerWithSaturatedDefinition_CreateDesignVariableForSaturatedVolumicWeightOfCoverageLayer() { // Setup + var inputParameters = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); + inputParameters.StochasticSoilProfile.SoilProfile.Layers.ElementAt(0).BelowPhreaticLevelMean = 3.2; + + // Call + DesignVariable saturatedVolumicWeightOfCoverageLayer = PipingSemiProbabilisticDesignValueFactory.GetSaturatedVolumicWeightOfCoverageLayer(inputParameters); + + // Assert + Assert.AreEqual(inputParameters.SaturatedVolumicWeightOfCoverageLayer.Mean, + saturatedVolumicWeightOfCoverageLayer.Distribution.Mean); + Assert.AreEqual(inputParameters.SaturatedVolumicWeightOfCoverageLayer.StandardDeviation, + saturatedVolumicWeightOfCoverageLayer.Distribution.StandardDeviation); + Assert.AreEqual(inputParameters.SaturatedVolumicWeightOfCoverageLayer.Shift, + saturatedVolumicWeightOfCoverageLayer.Distribution.Shift); + AssertPercentile(0.05, saturatedVolumicWeightOfCoverageLayer); + } + + [Test] + public void GetSaturatedVolumicWeightOfCoverageLayer_PipingInputWithoutCoverLayer_CreateDesignVariableForSaturatedVolumicWeightOfCoverageLayer() + { + // Setup var inputParameters = new PipingInput(new GeneralPipingInput()); // Call @@ -138,7 +177,7 @@ saturatedVolumicWeightOfCoverageLayer.Distribution.StandardDeviation); Assert.AreEqual(inputParameters.SaturatedVolumicWeightOfCoverageLayer.Shift, saturatedVolumicWeightOfCoverageLayer.Distribution.Shift); - Assert.AreEqual(0.05, saturatedVolumicWeightOfCoverageLayer.Percentile); + Assert.AreEqual(new RoundedDouble(2), saturatedVolumicWeightOfCoverageLayer.GetDesignValue()); } [Test] @@ -153,9 +192,16 @@ // Assert Assert.AreEqual(inputParameters.ThicknessAquiferLayer.Mean, thicknessAquiferLayer.Distribution.Mean); Assert.AreEqual(inputParameters.ThicknessAquiferLayer.StandardDeviation, thicknessAquiferLayer.Distribution.StandardDeviation); - Assert.AreEqual(0.95, thicknessAquiferLayer.Percentile); + AssertPercentile(0.95, thicknessAquiferLayer); } #endregion + + private void AssertPercentile(double percentile, DesignVariable designVariable) where T : IDistribution + { + Assert.IsInstanceOf>(designVariable); + var percentileBasedDesignVariable = (PercentileBasedDesignVariable) designVariable; + Assert.AreEqual(percentile, percentileBasedDesignVariable.Percentile); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Ringtoets.Piping.KernelWrapper.Test.csproj =================================================================== diff -u -r76095f14a847cd54fd958c5b326f7eb903dfd456 -r977a58268db81a93ad74f6079b41cf40d43fb1aa --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Ringtoets.Piping.KernelWrapper.Test.csproj (.../Ringtoets.Piping.KernelWrapper.Test.csproj) (revision 76095f14a847cd54fd958c5b326f7eb903dfd456) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.Test/Ringtoets.Piping.KernelWrapper.Test.csproj (.../Ringtoets.Piping.KernelWrapper.Test.csproj) (revision 977a58268db81a93ad74f6079b41cf40d43fb1aa) @@ -97,6 +97,10 @@ {14C6F716-64E2-4BC4-A1EF-05865FCEFA4C} Ringtoets.Piping.Primitives + + {955E574D-67CE-4347-AA6B-7DF8A04ED754} + Ringtoets.Piping.Data.TestUtil + {27e0a5c9-3abf-426a-a3da-7d0b83a218c8} Ringtoets.Piping.KernelWrapper.TestUtil