Index: Demo/Ringtoets/src/Demo.Ringtoets/Resources/DR6.soil =================================================================== diff -u -ra7b3472fa86591b26a0bd03b4ad1b1461d1bfa88 -r6a19166f5818e07d3430442efc50b8dfabb92e1b Binary files differ Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r6a19166f5818e07d3430442efc50b8dfabb92e1b --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 6a19166f5818e07d3430442efc50b8dfabb92e1b) @@ -420,7 +420,7 @@ GetAccuracy(inputParameters.PhreaticLevelExit)); Assert.AreEqual(0.011453, PipingSemiProbabilisticDesignValueFactory.GetDiameter70(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.Diameter70)); - Assert.AreEqual(2.345281, PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(inputParameters).GetDesignValue(), + Assert.AreEqual(1.186644, PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.DarcyPermeability)); Assert.AreEqual(17.5, PipingSemiProbabilisticDesignValueFactory.GetSaturatedVolumicWeightOfCoverageLayer(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.SaturatedVolumicWeightOfCoverageLayer)); @@ -448,8 +448,8 @@ Assert.AreEqual(-0.139, calculation.Output.HeaveZValue, 1e-3); Assert.AreEqual(1.784, calculation.Output.UpliftFactorOfSafety, 1e-3); Assert.AreEqual(2.019, calculation.Output.UpliftZValue, 1e-3); - Assert.AreEqual(0.955, calculation.Output.SellmeijerFactorOfSafety, 1e-3); - Assert.AreEqual(-0.054, calculation.Output.SellmeijerZValue, 1e-3); + Assert.AreEqual(1.198, calculation.Output.SellmeijerFactorOfSafety, 1e-3); + Assert.AreEqual(0.234, calculation.Output.SellmeijerZValue, 1e-3); } private static void AssertCalculationInFailureMechanismSectionResult(PipingCalculationScenario calculation, PipingFailureMechanismSectionResult[] sectionResults, IEnumerable calculations) Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r6a19166f5818e07d3430442efc50b8dfabb92e1b --- Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision 6a19166f5818e07d3430442efc50b8dfabb92e1b) @@ -237,28 +237,28 @@ private void UpdateDarcyPermeabilityParameters(LogNormalDistribution darcyPermeabilityDistribution) { - PipingSoilLayer topMostAquiferLayer = GetConsecutiveAquiferLayers().FirstOrDefault(); - if (topMostAquiferLayer != null) + PipingSoilLayer[] aquiferLayers = GetConsecutiveAquiferLayers(); + + if (HasCorrectDarcyPermeabilityWeightDistributionParameterDefinition( + aquiferLayers, + GetNumberOfDecimals(darcyPermeabilityDistribution))) { - var darcyPermeabilityMean = new RoundedDouble(darcyPermeabilityDistribution.Mean.NumberOfDecimalPlaces, topMostAquiferLayer.PermeabilityMean); + var weightedMean = new RoundedDouble(2, GetWeightedMeanForDarcyPermeabilityOfAquiferLayer(aquiferLayers, + input.StochasticSoilProfile.SoilProfile, + input.SurfaceLine.GetZAtL(input.ExitPointL))); - if (darcyPermeabilityMean > 0) - { - darcyPermeabilityDistribution.Mean = darcyPermeabilityMean; - } - darcyPermeabilityDistribution.StandardDeviation = (RoundedDouble) topMostAquiferLayer.PermeabilityDeviation; + darcyPermeabilityDistribution.Mean = weightedMean; + darcyPermeabilityDistribution.StandardDeviation = (RoundedDouble) (weightedMean/2); } } private void UpdateSaturatedVolumicWeightOfCoverageLayerParameters(LogNormalDistribution volumicWeightDistribution) { PipingSoilLayer[] coverageLayers = GetConsecutiveCoverageLayers(); - var numberOfDecimals = GetNumberOfDecimals(volumicWeightDistribution); - if (HasCorrectSaturatedWeightDistributionParameterDefinition( coverageLayers, - numberOfDecimals)) + GetNumberOfDecimals(volumicWeightDistribution))) { PipingSoilLayer topMostAquitardLayer = coverageLayers.First(); volumicWeightDistribution.Shift = (RoundedDouble) topMostAquitardLayer.BelowPhreaticLevelShift; @@ -277,9 +277,9 @@ } } - private int GetNumberOfDecimals(LogNormalDistribution volumicWeightDistribution) + private static int GetNumberOfDecimals(LogNormalDistribution distribution) { - return volumicWeightDistribution.Mean.NumberOfDecimalPlaces; + return distribution.Mean.NumberOfDecimalPlaces; } private static bool HasCorrectSaturatedWeightDistributionParameterDefinition(IList consecutiveAquitardLayers, int numberOfDecimals) @@ -306,6 +306,24 @@ distributions[0])); } + private static bool HasCorrectDarcyPermeabilityWeightDistributionParameterDefinition(IList consecutiveAquitardLayers, int numberOfDecimals) + { + if (!consecutiveAquitardLayers.Any()) + { + return false; + } + + var distributions = GetLayerPermeabilityDistributionDefinitions(consecutiveAquitardLayers, numberOfDecimals); + + if (distributions == null) + { + return false; + } + + return distributions.All(currentLayerDistribution + => Math.Abs(currentLayerDistribution.StandardDeviation - (currentLayerDistribution.Mean/2)) < 1e-6); + } + private static LogNormalDistribution[] GetLayerDistributionDefinitions(IList consecutiveAquitardLayers, int numberOfDecimals) { try @@ -323,6 +341,22 @@ } } + private static LogNormalDistribution[] GetLayerPermeabilityDistributionDefinitions(IList consecutiveAquitardLayers, int numberOfDecimals) + { + try + { + return consecutiveAquitardLayers.Select(layer => new LogNormalDistribution(numberOfDecimals) + { + Mean = (RoundedDouble) layer.PermeabilityMean, + StandardDeviation = (RoundedDouble) layer.PermeabilityDeviation + }).ToArray(); + } + catch (ArgumentOutOfRangeException) + { + return null; + } + } + private static bool AreShiftAndDeviationEqual(LogNormalDistribution currentLayerDistribution, LogNormalDistribution baseLayerDistribution) { return currentLayerDistribution.StandardDeviation == baseLayerDistribution.StandardDeviation && @@ -347,6 +381,24 @@ return weighedTotal/totalThickness; } + private static double GetWeightedMeanForDarcyPermeabilityOfAquiferLayer(PipingSoilLayer[] aquitardLayers, PipingSoilProfile profile, double surfaceLevel) + { + double totalThickness = 0.0; + double weighedTotal = 0.0; + + foreach (var layer in aquitardLayers) + { + double layerThickness = profile.GetLayerThickness(layer); + double bottom = layer.Top - layerThickness; + double thicknessUnderSurface = Math.Min(layer.Top, surfaceLevel) - bottom; + + totalThickness += thicknessUnderSurface; + weighedTotal += layer.PermeabilityMean*thicknessUnderSurface; + } + + return weighedTotal/totalThickness; + } + private PipingSoilLayer[] GetConsecutiveAquiferLayers() { RingtoetsPipingSurfaceLine surfaceLine = input.SurfaceLine; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs =================================================================== diff -u -r8142644ec1337be8032e9214b1f103c85d9037f7 -r6a19166f5818e07d3430442efc50b8dfabb92e1b --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs (.../DerivedPipingInputTest.cs) (revision 8142644ec1337be8032e9214b1f103c85d9037f7) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs (.../DerivedPipingInputTest.cs) (revision 6a19166f5818e07d3430442efc50b8dfabb92e1b) @@ -931,12 +931,76 @@ } [Test] - public void DarcyPermeability_SingleAquiferLayers_ReturnsWithParametersFromLayer() + public void DarcyPermeability_SingleAquiferLayer_ReturnsWithWeightedMean() { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); var derivedInput = new DerivedPipingInput(input); var random = new Random(21); + double mean = random.NextDouble(); + double deviation = mean/2; + input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", 0.0, new[] + { + new PipingSoilLayer(0.5) + { + IsAquifer = true, + PermeabilityDeviation = deviation, + PermeabilityMean = mean + } + }, SoilProfileType.SoilProfile1D, 0); + + // Call + var result = derivedInput.DarcyPermeability; + + // Assert + var weightedMean = 0.35 / 0.5; + Assert.AreEqual(weightedMean, result.Mean, result.Mean.GetAccuracy()); + Assert.AreEqual(weightedMean/2, result.StandardDeviation, result.StandardDeviation.GetAccuracy()); + } + + [Test] + public void DarcyPermeability_MultipleAquiferLayers_ReturnsWithWeightedMean() + { + // Setup + PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); + var derivedInput = new DerivedPipingInput(input); + var random = new Random(21); + double mean = random.NextDouble(); + double deviation = mean / 2; + double mean2 = random.NextDouble(); + double deviation2 = mean2/2; + input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", 0.0, new[] + { + new PipingSoilLayer(0.5) + { + IsAquifer = true, + PermeabilityDeviation = deviation, + PermeabilityMean = mean + }, + new PipingSoilLayer(1.5) + { + IsAquifer = true, + PermeabilityDeviation = deviation2, + PermeabilityMean = mean2 + } + }, SoilProfileType.SoilProfile1D, 0); + + // Call + var result = derivedInput.DarcyPermeability; + + // Assert + var weightedMean = new RoundedDouble(2, 1.33 / 1.5); + Assert.AreEqual(weightedMean, result.Mean, result.Mean.GetAccuracy()); + Assert.AreEqual(weightedMean / 2, result.StandardDeviation, result.StandardDeviation.GetAccuracy()); + } + + [Test] + public void DarcyPermeability_SingleAquiferLayerWithRandomMeanAndDeviation_ReturnsNaNForParameters() + { + // Setup + PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); + var derivedInput = new DerivedPipingInput(input); + var random = new Random(21); var permeabilityMean = random.NextDouble(); var permeabilityDeviation = random.NextDouble(); input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] @@ -953,12 +1017,12 @@ var result = derivedInput.DarcyPermeability; // Assert - Assert.AreEqual(permeabilityMean, result.Mean, result.Mean.GetAccuracy()); - Assert.AreEqual(permeabilityDeviation, result.StandardDeviation, result.StandardDeviation.GetAccuracy()); + Assert.IsNaN(result.Mean); + Assert.IsNaN(result.StandardDeviation); } [Test] - public void DarcyPermeability_MultipleAquiferLayers_ReturnsWithParametersFromTopmostLayer() + public void DarcyPermeability_MultipleAquiferLayersWithRandomMeanAndDeviation_ReturnsNaNForParameters() { // Setup PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer(); @@ -985,8 +1049,8 @@ var result = derivedInput.DarcyPermeability; // Assert - Assert.AreEqual(permeabilityMean, result.Mean, result.Mean.GetAccuracy()); - Assert.AreEqual(permeabilityDeviation, result.StandardDeviation, result.StandardDeviation.GetAccuracy()); + Assert.IsNaN(result.Mean); + Assert.IsNaN(result.StandardDeviation); } [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationScenarioFactory.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r6a19166f5818e07d3430442efc50b8dfabb92e1b --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationScenarioFactory.cs (.../PipingCalculationScenarioFactory.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationScenarioFactory.cs (.../PipingCalculationScenarioFactory.cs) (revision 6a19166f5818e07d3430442efc50b8dfabb92e1b) @@ -156,7 +156,7 @@ IsAquifer = true, DiameterD70Deviation = 0, DiameterD70Mean = 4.0e-4, - PermeabilityDeviation = 0, + PermeabilityDeviation = 0.5, PermeabilityMean = 1.0 } }, SoilProfileType.SoilProfile1D, 0) Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs =================================================================== diff -u -r603e8bd9a029ad240267e5aec4d89aab7709bb06 -r6a19166f5818e07d3430442efc50b8dfabb92e1b --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 603e8bd9a029ad240267e5aec4d89aab7709bb06) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 6a19166f5818e07d3430442efc50b8dfabb92e1b) @@ -298,7 +298,7 @@ DiameterD70Deviation = 0, DiameterD70Mean = 1e-4, PermeabilityDeviation = 0.5, - PermeabilityMean = 0.1 + PermeabilityMean = 1 } }, SoilProfileType.SoilProfile1D, -1); @@ -367,7 +367,6 @@ // Setup const string name = ""; - var random = new Random(21); var profile = new PipingSoilProfile(string.Empty, 0.0, new[] { @@ -376,8 +375,8 @@ IsAquifer = true, DiameterD70Deviation = 0, DiameterD70Mean = 1e-4, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble() + PermeabilityDeviation = 0.5, + PermeabilityMean = 1 } }, SoilProfileType.SoilProfile1D, -1); @@ -410,7 +409,6 @@ // Setup const string name = ""; - var random = new Random(21); var profile = new PipingSoilProfile(string.Empty, 0.0, new[] { @@ -423,8 +421,8 @@ IsAquifer = true, DiameterD70Deviation = 0, DiameterD70Mean = 1e-4, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble() + PermeabilityDeviation = 0.5, + PermeabilityMean = 1 } }, SoilProfileType.SoilProfile1D, -1); @@ -464,8 +462,8 @@ var incompletePipingSoilLayer = new PipingSoilLayer(5.0) { IsAquifer = true, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble() + PermeabilityDeviation = 0.5, + PermeabilityMean = 1 }; if (meanSet) { @@ -606,8 +604,8 @@ new PipingSoilLayer(5.0) { IsAquifer = true, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble(), + PermeabilityDeviation = 0.5, + PermeabilityMean = 1, DiameterD70Deviation = 0, DiameterD70Mean = 1e-4 } @@ -642,8 +640,8 @@ const string name = ""; var random = new Random(21); - var belowPhreaticLevelDeviation = random.NextDouble(); - var belowPhreaticLevelShift = random.NextDouble(); + var belowPhreaticLevelDeviation = 0.5; + var belowPhreaticLevelShift = 1; var belowPhreaticLevelMeanBase = 15.0; var profile = new PipingSoilProfile(string.Empty, 0.0, new[] @@ -665,8 +663,8 @@ new PipingSoilLayer(5.0) { IsAquifer = true, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble(), + PermeabilityDeviation = 0.5, + PermeabilityMean = 1, DiameterD70Deviation = 0, DiameterD70Mean = 1e-4 } @@ -706,8 +704,8 @@ var soilLayer = new PipingSoilLayer(5.0) { IsAquifer = true, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble(), + PermeabilityDeviation = 0.5, + PermeabilityMean = 1, DiameterD70Mean = diameter70Value, DiameterD70Deviation = 0 }; @@ -754,8 +752,6 @@ // Setup const string name = ""; - var random = new Random(21); - var profile = new PipingSoilProfile(string.Empty, 0.0, new[] { @@ -769,8 +765,8 @@ new PipingSoilLayer(5.0) { IsAquifer = true, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble(), + PermeabilityDeviation = 0.5, + PermeabilityMean = 1, DiameterD70Mean = 0.0002, DiameterD70Deviation = 0 } @@ -807,8 +803,6 @@ // Setup const string name = ""; - var random = new Random(21); - var profile = new PipingSoilProfile(string.Empty, 0.0, new[] { @@ -829,8 +823,8 @@ new PipingSoilLayer(5.0) { IsAquifer = true, - PermeabilityDeviation = random.NextDouble(), - PermeabilityMean = 0.1 + random.NextDouble(), + PermeabilityDeviation = 0.3, + PermeabilityMean = 0.6, DiameterD70Mean = 0.0002, DiameterD70Deviation = 0 }