Пример #1
0
        public void Constructor_WithTop_ReturnsNewInstanceWithTopSet()
        {
            // Setup
            double top = new Random(22).NextDouble();

            // Call
            var layer = new PipingSoilLayer(top);

            // Assert
            Assert.NotNull(layer);
            Assert.AreEqual(top, layer.Top);
            Assert.IsFalse(layer.IsAquifer);
            Assert.IsEmpty(layer.MaterialName);
            Assert.AreEqual(Color.Empty, layer.Color);

            DistributionAssert.AreEqual(new LogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN,
                Shift             = RoundedDouble.NaN
            }, layer.BelowPhreaticLevel);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(6)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, layer.DiameterD70);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(6)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, layer.Permeability);
        }
Пример #2
0
        public void Read_WithValues_ReturnsPipingSoilLayerWithDoubleParameterValues()
        {
            // Setup
            var          random       = new Random(21);
            double       top          = random.NextDouble();
            Color        color        = Color.FromKnownColor(random.NextEnumValue <KnownColor>());
            const string materialName = "sand";

            bool   isAquifer = random.NextBoolean();
            double belowPhreaticLevelMean             = random.NextDouble(1, double.MaxValue);
            double belowPhreaticLevelDeviation        = random.NextDouble();
            double belowPhreaticLevelShift            = random.NextDouble();
            double diameterD70Mean                    = random.NextDouble(1, double.MaxValue);
            double diameterD70CoefficientOfVariation  = random.NextDouble();
            double permeabilityMean                   = random.NextDouble(1, double.MaxValue);
            double permeabilityCoefficientOfVariation = random.NextDouble();

            var entity = new PipingSoilLayerEntity
            {
                Top                                = top,
                IsAquifer                          = Convert.ToByte(isAquifer),
                Color                              = color.ToInt64(),
                MaterialName                       = materialName,
                BelowPhreaticLevelMean             = belowPhreaticLevelMean,
                BelowPhreaticLevelDeviation        = belowPhreaticLevelDeviation,
                BelowPhreaticLevelShift            = belowPhreaticLevelShift,
                DiameterD70Mean                    = diameterD70Mean,
                DiameterD70CoefficientOfVariation  = diameterD70CoefficientOfVariation,
                PermeabilityMean                   = permeabilityMean,
                PermeabilityCoefficientOfVariation = permeabilityCoefficientOfVariation
            };

            // Call
            PipingSoilLayer layer = entity.Read();

            // Assert
            Assert.IsNotNull(layer);
            Assert.AreEqual(top, layer.Top, 1e-6);
            Assert.AreEqual(isAquifer, layer.IsAquifer);
            Assert.IsNotNull(color);
            Assert.AreEqual(color.ToArgb(), layer.Color.ToArgb());
            Assert.AreEqual(materialName, layer.MaterialName);

            Assert.AreEqual(belowPhreaticLevelMean, layer.BelowPhreaticLevel.Mean,
                            layer.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelDeviation, layer.BelowPhreaticLevel.StandardDeviation,
                            layer.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelShift, layer.BelowPhreaticLevel.Shift,
                            layer.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(diameterD70Mean, layer.DiameterD70.Mean,
                            layer.DiameterD70.GetAccuracy());
            Assert.AreEqual(diameterD70CoefficientOfVariation, layer.DiameterD70.CoefficientOfVariation,
                            layer.DiameterD70.GetAccuracy());

            Assert.AreEqual(permeabilityMean, layer.Permeability.Mean,
                            layer.Permeability.GetAccuracy());
            Assert.AreEqual(permeabilityCoefficientOfVariation, layer.Permeability.CoefficientOfVariation,
                            layer.Permeability.GetAccuracy());
        }
Пример #3
0
        public void SetData_WithEmptyNameAndColor_ExpectedValuesInTable()
        {
            // Setup
            using (var table = new PipingSoilLayerTable())
            {
                PipingSoilLayer soilLayer = CreatePipingSoilLayer();
                soilLayer.MaterialName = string.Empty;
                soilLayer.Color        = Color.Empty;

                PipingSoilLayer[] layers =
                {
                    soilLayer
                };

                // Call
                table.SetData(layers);

                // Assert
                PipingSoilLayer            pipingSoilLayer = layers[0];
                DataGridViewCellCollection rowCells        = table.Rows[0].Cells;
                AssertColumnValueEqual("Onbekend", rowCells[nameColumnIndex].Value);
                AssertColumnValueEqual(Color.White, rowCells[colorColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.Top, rowCells[topColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.IsAquifer, rowCells[isAquiferColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.Permeability.Mean, rowCells[permeabilityMeanColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.Permeability.CoefficientOfVariation, rowCells[permeabilityCoefficientOfVariationColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.DiameterD70.Mean, rowCells[d70MeanColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.DiameterD70.CoefficientOfVariation, rowCells[d70CoefficientOfVariationColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Mean, rowCells[belowPhreaticLevelWeightMeanColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.StandardDeviation, rowCells[belowPhreaticLevelWeightDeviationColumnIndex].Value);
                AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Shift, rowCells[belowPhreaticLevelWeightShiftColumnIndex].Value);
            }
        }
        public void GetValidationWarnings_WithoutAquitardLayer_ReturnsMessage()
        {
            // Setup
            var aquiferLayer = new PipingSoilLayer(10.56)
            {
                IsAquifer   = true,
                DiameterD70 = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)1e-4,
                    CoefficientOfVariation = (RoundedDouble)0
                },
                Permeability = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)1,
                    CoefficientOfVariation = (RoundedDouble)0.5
                }
            };
            var profile = new PipingSoilProfile(string.Empty, 0.0,
                                                new[]
            {
                aquiferLayer
            },
                                                SoilProfileType.SoilProfile1D);

            calculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile);

            // Call
            IEnumerable <string> messages = PipingCalculationValidationHelper.GetValidationWarnings(calculation.InputParameters);

            // Assert
            Assert.AreEqual(1, messages.Count());
            Assert.AreEqual("Geen deklaag gevonden voor de ondergrondschematisatie onder de profielschematisatie bij het uittredepunt. Er wordt een deklaagdikte gebruikt gelijk aan 0.", messages.ElementAt(0));
        }
Пример #5
0
        public void Permeability_Always_ExpectedValues()
        {
            // Setup
            var random = new Random(21);
            var layer  = new PipingSoilLayer(random.NextDouble());

            var distributionToSet = new VariationCoefficientLogNormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                CoefficientOfVariation = random.NextRoundedDouble(),
                Shift = random.NextRoundedDouble()
            };

            // Call
            layer.Permeability = distributionToSet;

            // Assert
            var expectedDistribution = new VariationCoefficientLogNormalDistribution(6)
            {
                Mean = distributionToSet.Mean,
                CoefficientOfVariation = distributionToSet.CoefficientOfVariation,
                Shift = layer.DiameterD70.Shift
            };

            DistributionTestHelper.AssertDistributionCorrectlySet(layer.Permeability, distributionToSet, expectedDistribution);
        }
Пример #6
0
        public void Read_WithNullValues_ReturnsPipingSoilProfileWithNaNValues()
        {
            // Setup
            var entity = new PipingSoilProfileEntity
            {
                Name = nameof(PipingSoilProfileEntity),
                PipingSoilLayerEntities =
                {
                    new PipingSoilLayerEntity
                    {
                        MaterialName = nameof(PipingSoilLayerEntity)
                    }
                }
            };
            var collector = new ReadConversionCollector();

            // Call
            PipingSoilProfile profile = entity.Read(collector);

            // Assert
            Assert.IsNotNull(profile);
            Assert.AreEqual(entity.Name, profile.Name);
            Assert.IsNaN(profile.Bottom);
            Assert.AreEqual(entity.PipingSoilLayerEntities.Count, profile.Layers.Count());

            PipingSoilLayer layer = profile.Layers.ElementAt(0);

            Assert.AreEqual(entity.PipingSoilLayerEntities.First().MaterialName, layer.MaterialName);
        }
        public void CreateSoilLayerAreas_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 3.0),
                new Point3D(1, 0, 2.0),
                new Point3D(2, 0, 2.0)
            });
            const double bottom      = 1.5;
            const double top         = 2.5;
            var          soilLayer   = new PipingSoilLayer(top);
            var          soilProfile = new PipingSoilProfile("name", bottom, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(1, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0.5, top),
                new Point2D(1, 2.0),
                new Point2D(2, 2.0),
                new Point2D(2, bottom),
                new Point2D(0, bottom),
                new Point2D(0, top)
            }, areas.ElementAt(0));
        }
        public void CreateSoilLayerAreas_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4),
                new Point3D(0, 0, 3.2),
                new Point3D(2, 0, 4)
            });
            var soilLayer   = new PipingSoilLayer(3.2);
            var soilProfile = new PipingSoilProfile("name", 2.0, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(1, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0, 3.2),
                new Point2D(2, 3.2),
                new Point2D(2, 2),
                new Point2D(0, 2)
            }, areas.ElementAt(0));
        }
Пример #9
0
        public void SetData_WithData_ExpectedValuesInTable()
        {
            // Setup
            using (var table = new PipingSoilLayerTable())
            {
                PipingSoilLayer[] layers =
                {
                    CreatePipingSoilLayer(),
                    CreatePipingSoilLayer(),
                    CreatePipingSoilLayer()
                };

                // Call
                table.SetData(layers);

                // Assert
                Assert.AreEqual(layers.Length, table.Rows.Count);
                for (var i = 0; i < table.Rows.Count; i++)
                {
                    PipingSoilLayer            pipingSoilLayer = layers[i];
                    DataGridViewCellCollection rowCells        = table.Rows[i].Cells;
                    AssertColumnValueEqual(pipingSoilLayer.MaterialName, rowCells[nameColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.Color, rowCells[colorColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.Top, rowCells[topColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.IsAquifer, rowCells[isAquiferColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.Permeability.Mean, rowCells[permeabilityMeanColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.Permeability.CoefficientOfVariation, rowCells[permeabilityCoefficientOfVariationColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.DiameterD70.Mean, rowCells[d70MeanColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.DiameterD70.CoefficientOfVariation, rowCells[d70CoefficientOfVariationColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Mean, rowCells[belowPhreaticLevelWeightMeanColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.StandardDeviation, rowCells[belowPhreaticLevelWeightDeviationColumnIndex].Value);
                    AssertColumnValueEqual(pipingSoilLayer.BelowPhreaticLevel.Shift, rowCells[belowPhreaticLevelWeightShiftColumnIndex].Value);
                }
            }
        }
Пример #10
0
        public void BelowPhreaticLevel_Always_ExpectedValues()
        {
            // Setup
            var random = new Random(21);
            var layer  = new PipingSoilLayer(random.NextDouble());

            var distributionToSet = new LogNormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                StandardDeviation = random.NextRoundedDouble(),
                Shift             = random.NextRoundedDouble()
            };

            // Call
            layer.BelowPhreaticLevel = distributionToSet;

            // Assert
            var expectedDistribution = new LogNormalDistribution(2)
            {
                Mean = distributionToSet.Mean,
                StandardDeviation = distributionToSet.StandardDeviation,
                Shift             = distributionToSet.Shift
            };

            DistributionTestHelper.AssertDistributionCorrectlySet(layer.BelowPhreaticLevel, distributionToSet, expectedDistribution);
        }
Пример #11
0
        /// <summary>
        /// Transforms the generic <paramref name="soilLayer"/> into one or more <see cref="PipingSoilLayer"/>.
        /// </summary>
        /// <param name="soilLayer">The soil layer to use in the transformation.</param>
        /// <param name="atX">The 1D intersection of the profile.</param>
        /// <param name="soilLayers">The collection of transformed piping soil layers to add the
        /// transformation to.</param>
        /// <param name="bottom">The bottom of the soil layer.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/> is <c>null</c>.</exception>
        /// <exception cref="ImportedDataTransformException">Thrown when transformation would not result
        /// in a valid transformed instance.</exception>
        private static void Transform(SoilLayer2D soilLayer, double atX, ICollection <PipingSoilLayer> soilLayers, ref double bottom)
        {
            if (soilLayer == null)
            {
                throw new ArgumentNullException(nameof(soilLayer));
            }

            ValidateStochasticParameters(soilLayer);

            if (soilLayer.OuterLoop == null)
            {
                return;
            }

            string soilLayerName = soilLayer.MaterialName;

            double[] outerLoopIntersectionHeights = GetLoopIntersectionHeights(soilLayer.OuterLoop.Segments, atX, soilLayerName).ToArray();

            if (!outerLoopIntersectionHeights.Any())
            {
                return;
            }

            IEnumerable <IEnumerable <double> > innerLoopsIntersectionHeights = soilLayer.NestedLayers.Select(l => GetLoopIntersectionHeights(l.OuterLoop.Segments,
                                                                                                                                              atX,
                                                                                                                                              soilLayerName));
            IEnumerable <Tuple <double, double> > innerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(innerLoopsIntersectionHeights).ToList();
            IEnumerable <Tuple <double, double> > outerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(outerLoopIntersectionHeights).ToList();

            double currentBottom = outerLoopIntersectionHeightPairs.First().Item1;
            var    heights       = new List <double>();

            heights.AddRange(innerLoopIntersectionHeightPairs.Where(p => p.Item1 >= currentBottom).Select(p => p.Item1));
            heights.AddRange(outerLoopIntersectionHeightPairs.Select(p => p.Item2));

            foreach (double height in heights.Where(height => !innerLoopIntersectionHeightPairs.Any(tuple => HeightInInnerLoop(tuple, height))))
            {
                var pipingSoilLayer = new PipingSoilLayer(height)
                {
                    IsAquifer    = TransformIsAquifer(soilLayer.IsAquifer, soilLayerName),
                    MaterialName = soilLayer.MaterialName,
                    Color        = SoilLayerColorConverter.Convert(soilLayer.Color)
                };

                SetStochasticParameters(pipingSoilLayer, soilLayer);

                soilLayers.Add(pipingSoilLayer);
            }

            bottom = currentBottom < bottom ? currentBottom : bottom;

            foreach (SoilLayer2D nestedLayer in soilLayer.NestedLayers)
            {
                Transform(nestedLayer, atX, soilLayers, ref bottom);
            }
        }
Пример #12
0
 private static void AssertPipingSoilLayer(PipingSoilLayer expected, PipingSoilLayer actual)
 {
     Assert.AreEqual(expected.Top, actual.Top);
     Assert.AreEqual(expected.IsAquifer, actual.IsAquifer);
     DistributionAssert.AreEqual(expected.BelowPhreaticLevel, actual.BelowPhreaticLevel);
     DistributionAssert.AreEqual(expected.DiameterD70, actual.DiameterD70);
     DistributionAssert.AreEqual(expected.Permeability, actual.Permeability);
     Assert.AreEqual(expected.MaterialName, actual.MaterialName);
     Assert.AreEqual(expected.Color, actual.Color);
 }
        public void GetValidationErrors_SaturatedCoverageLayerLessThanWaterLayerAndMissingSaturatedParameter_ReturnsMessage()
        {
            // Setup
            var topCoverageLayer = new PipingSoilLayer(testSurfaceLineTopLevel)
            {
                IsAquifer          = false,
                BelowPhreaticLevel = new LogNormalDistribution
                {
                    Mean = (RoundedDouble)5,
                    StandardDeviation = (RoundedDouble)2,
                    Shift             = (RoundedDouble)0
                }
            };
            var middleCoverageLayerMissingParameter = new PipingSoilLayer(8.5)
            {
                IsAquifer          = false,
                BelowPhreaticLevel = new LogNormalDistribution
                {
                    Mean = (RoundedDouble)5,
                    StandardDeviation = (RoundedDouble)2,
                    Shift             = RoundedDouble.NaN
                }
            };
            var bottomAquiferLayer = new PipingSoilLayer(5.0)
            {
                IsAquifer    = true,
                Permeability = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)0.3,
                    CoefficientOfVariation = (RoundedDouble)0.6
                },
                DiameterD70 = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)0.0002,
                    CoefficientOfVariation = (RoundedDouble)0
                }
            };
            var profile = new PipingSoilProfile(string.Empty, 0.0,
                                                new[]
            {
                topCoverageLayer,
                middleCoverageLayerMissingParameter,
                bottomAquiferLayer
            },
                                                SoilProfileType.SoilProfile1D);

            calculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile);

            // Call
            IEnumerable <string> messages = PipingCalculationValidationHelper.GetValidationErrors(calculation.InputParameters);

            // Assert
            Assert.AreEqual(1, messages.Count());
            Assert.AreEqual("Kan de definitie voor het verzadigd gewicht van de deklaag niet (volledig) afleiden.", messages.ElementAt(0));
        }
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var random    = new Random(21);
            int order     = random.Next();
            var soilLayer = new PipingSoilLayer(random.NextDouble())
            {
                IsAquifer          = random.NextBoolean(),
                Color              = Color.FromKnownColor(random.NextEnumValue <KnownColor>()),
                MaterialName       = "MaterialName",
                BelowPhreaticLevel = new LogNormalDistribution
                {
                    Mean = random.NextRoundedDouble(1, double.MaxValue),
                    StandardDeviation = random.NextRoundedDouble(),
                    Shift             = random.NextRoundedDouble()
                },
                DiameterD70 = new VariationCoefficientLogNormalDistribution
                {
                    Mean = random.NextRoundedDouble(1, double.MaxValue),
                    CoefficientOfVariation = random.NextRoundedDouble()
                },
                Permeability = new VariationCoefficientLogNormalDistribution
                {
                    Mean = random.NextRoundedDouble(1, double.MaxValue),
                    CoefficientOfVariation = random.NextRoundedDouble()
                }
            };

            // Call
            PipingSoilLayerEntity entity = soilLayer.Create(order);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(soilLayer.Top, entity.Top);
            Assert.AreEqual(Convert.ToByte(soilLayer.IsAquifer), entity.IsAquifer);
            Assert.AreEqual(soilLayer.Color.ToInt64(), Convert.ToInt64(entity.Color));

            Assert.AreEqual(soilLayer.BelowPhreaticLevel.Mean, entity.BelowPhreaticLevelMean,
                            soilLayer.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(soilLayer.BelowPhreaticLevel.StandardDeviation, entity.BelowPhreaticLevelDeviation,
                            soilLayer.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(soilLayer.BelowPhreaticLevel.Shift, entity.BelowPhreaticLevelShift,
                            soilLayer.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(soilLayer.DiameterD70.Mean, entity.DiameterD70Mean,
                            soilLayer.DiameterD70.GetAccuracy());
            Assert.AreEqual(soilLayer.DiameterD70.CoefficientOfVariation, entity.DiameterD70CoefficientOfVariation,
                            soilLayer.DiameterD70.GetAccuracy());

            Assert.AreEqual(soilLayer.Permeability.Mean, entity.PermeabilityMean,
                            soilLayer.Permeability.GetAccuracy());
            Assert.AreEqual(soilLayer.Permeability.CoefficientOfVariation, entity.PermeabilityCoefficientOfVariation,
                            soilLayer.Permeability.GetAccuracy());
            Assert.AreEqual(order, entity.Order);
        }
        public void GetValidationErrors_IncompleteSaturatedVolumicWeightDefinition_ReturnsMessage(bool meanSet, bool deviationSet, bool shiftSet)
        {
            // Setup
            var random = new Random(21);
            var incompletePipingSoilLayer = new PipingSoilLayer(testSurfaceLineTopLevel)
            {
                IsAquifer = false
            };

            incompletePipingSoilLayer.BelowPhreaticLevel = new LogNormalDistribution
            {
                Mean = meanSet
                           ? random.NextRoundedDouble(1, double.MaxValue)
                           : RoundedDouble.NaN,
                StandardDeviation = deviationSet
                                        ? random.NextRoundedDouble()
                                        : RoundedDouble.NaN,
                Shift = shiftSet
                            ? random.NextRoundedDouble()
                            : RoundedDouble.NaN
            };

            var completeLayer = new PipingSoilLayer(5.0)
            {
                IsAquifer    = true,
                Permeability = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)1,
                    CoefficientOfVariation = (RoundedDouble)0.5
                },
                DiameterD70 = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)1e-4,
                    CoefficientOfVariation = (RoundedDouble)0
                }
            };

            var profile = new PipingSoilProfile(string.Empty, 0.0,
                                                new[]
            {
                incompletePipingSoilLayer,
                completeLayer
            },
                                                SoilProfileType.SoilProfile1D);

            calculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile);

            // Call
            IEnumerable <string> messages = PipingCalculationValidationHelper.GetValidationErrors(calculation.InputParameters);

            // Assert
            Assert.AreEqual(1, messages.Count());
            Assert.AreEqual("Kan de definitie voor het verzadigd gewicht van de deklaag niet (volledig) afleiden.", messages.ElementAt(0));
        }
Пример #16
0
        public void MaterialName_NotNullValue_ValueSet(string materialName)
        {
            // Setup
            double top   = new Random(22).NextDouble();
            var    layer = new PipingSoilLayer(top);

            // Call
            layer.MaterialName = materialName;

            // Assert
            Assert.AreEqual(materialName, layer.MaterialName);
        }
        public void CreateSoilLayerAreas_SoilProfileNull_ReturnsEmptyAreasCollection()
        {
            // Setup
            var soilLayer = new PipingSoilLayer(3.2);
            PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, null, surfaceLine);

            // Assert
            CollectionAssert.IsEmpty(areas);
        }
        public void Constructor_ValidPipingSoilLayer_ExpectedValues()
        {
            // Setup
            var soilLayer = new PipingSoilLayer(2.0);

            // Call
            var properties = new PipingSoilLayerProperties(soilLayer);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <PipingSoilLayer> >(properties);
            Assert.AreSame(soilLayer, properties.Data);
        }
        public void GetValidationErrors_IncompletePermeabilityDefinition_ReturnsMessage(bool meanSet, bool coefficientOfVariationSet)
        {
            // Setup
            var random = new Random(21);
            var incompletePipingSoilLayer = new PipingSoilLayer(5.0)
            {
                IsAquifer   = true,
                DiameterD70 = new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)1e-4,
                    CoefficientOfVariation = (RoundedDouble)0
                },
                Permeability = new VariationCoefficientLogNormalDistribution
                {
                    Mean = meanSet
                               ? random.NextRoundedDouble(1, double.MaxValue)
                               : RoundedDouble.NaN,
                    CoefficientOfVariation = coefficientOfVariationSet
                                                 ? random.NextRoundedDouble()
                                                 : RoundedDouble.NaN
                }
            };

            var completeLayer = new PipingSoilLayer(testSurfaceLineTopLevel)
            {
                IsAquifer          = false,
                BelowPhreaticLevel = new LogNormalDistribution
                {
                    Mean = random.NextRoundedDouble(15.0, 999.999),
                    StandardDeviation = random.NextRoundedDouble(1e-6, 999.999),
                    Shift             = random.NextRoundedDouble(1e-6, 10)
                }
            };

            var profile = new PipingSoilProfile(string.Empty, 0.0,
                                                new[]
            {
                completeLayer,
                incompletePipingSoilLayer
            },
                                                SoilProfileType.SoilProfile1D);

            calculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, profile);

            // Call
            IEnumerable <string> messages = PipingCalculationValidationHelper.GetValidationErrors(calculation.InputParameters);

            // Assert
            Assert.AreEqual(1, messages.Count());
            Assert.AreEqual("Kan de definitie voor de doorlatendheid van de watervoerende laag niet (volledig) afleiden.", messages.ElementAt(0));
        }
Пример #20
0
 public FormattedPipingSoilLayerRow(PipingSoilLayer layer)
 {
     MaterialName     = SoilLayerDataHelper.GetValidName(layer.MaterialName);
     Color            = SoilLayerDataHelper.GetValidColor(layer.Color);
     Top              = new RoundedDouble(2, layer.Top);
     IsAquifer        = layer.IsAquifer;
     PermeabilityMean = layer.Permeability.Mean;
     PermeabilityCoefficientOfVariation = layer.Permeability.CoefficientOfVariation;
     DiameterD70Mean = layer.DiameterD70.Mean;
     DiameterD70CoefficientOfVariation = layer.DiameterD70.CoefficientOfVariation;
     BelowPhreaticLevelMean            = layer.BelowPhreaticLevel.Mean;
     BelowPhreaticLevelDeviation       = layer.BelowPhreaticLevel.StandardDeviation;
     BelowPhreaticLevelShift           = layer.BelowPhreaticLevel.Shift;
 }
        public void GetProperties_WithDataEmptyName_ReturnExpectedValues()
        {
            // Setup
            var layer = new PipingSoilLayer(-2.91)
            {
                MaterialName = string.Empty
            };

            // Call
            var properties = new PipingSoilLayerProperties(layer);

            // Assert
            Assert.AreEqual("Onbekend", properties.Name);
        }
Пример #22
0
        public void MaterialName_Null_ThrowsArgumentNullException()
        {
            // Setup
            double top   = new Random(22).NextDouble();
            var    layer = new PipingSoilLayer(top);

            // Call
            void Call() => layer.MaterialName = null;

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("value", exception.ParamName);
        }
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string materialName = "MaterialName";
            var          soilLayer    = new PipingSoilLayer(0)
            {
                MaterialName = materialName
            };

            // Call
            PipingSoilLayerEntity entity = soilLayer.Create(0);

            // Assert
            TestHelper.AssertAreEqualButNotSame(materialName, entity.MaterialName);
        }
Пример #24
0
        /// <summary>
        /// Create <see cref="ChartMultipleAreaData"/> for a <see cref="PipingSoilLayer"/> based
        /// on its name and fill color.
        /// </summary>
        /// <param name="layer">The layer to create the <see cref="ChartMultipleAreaData"/> for.</param>
        /// <returns>The created <see cref="ChartMultipleAreaData"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="layer"/> is <c>null</c>.</exception>
        public static ChartMultipleAreaData CreateSoilLayerChartData(PipingSoilLayer layer)
        {
            if (layer == null)
            {
                throw new ArgumentNullException(nameof(layer));
            }

            return(new ChartMultipleAreaData(SoilLayerDataHelper.GetValidName(layer.MaterialName),
                                             new ChartAreaStyle
            {
                FillColor = SoilLayerDataHelper.GetValidColor(layer.Color),
                StrokeColor = Color.Black,
                StrokeThickness = 1
            }));
        }
        public void CreateSoilLayerAreas_SurfaceLineNull_ReturnsEmptyAreasCollection()
        {
            // Setup
            var soilLayer   = new PipingSoilLayer(3.2);
            var soilProfile = new PipingSoilProfile("name", 2.0, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, null);

            // Assert
            CollectionAssert.IsEmpty(areas);
        }
        /// <summary>
        /// Retrieves the collection of aquitard layers below a certain <paramref name="level"/>.
        /// </summary>
        /// <param name="soilProfile">The soil profile containing <see cref="PipingSoilLayer"/> to consider.</param>
        /// <param name="level">The level under which the aquitard layers are sought.</param>
        /// <returns>The collection of consecutive aquitard layer(s) (partly) under the <paramref name="level"/>.</returns>
        public static IEnumerable <PipingSoilLayer> GetConsecutiveCoverageLayersBelowLevel(this PipingSoilProfile soilProfile, double level)
        {
            PipingSoilLayer topAquiferLayer = soilProfile.GetConsecutiveAquiferLayersBelowLevel(level).FirstOrDefault();

            if (topAquiferLayer != null)
            {
                PipingSoilLayer[] aquitardLayers = GetConsecutiveLayers(soilProfile, level, false).ToArray();
                if (aquitardLayers.Any() && topAquiferLayer.Top < aquitardLayers.First().Top)
                {
                    return(aquitardLayers);
                }
            }

            return(Enumerable.Empty <PipingSoilLayer>());
        }
        public void ToString_EmptyName_ReturnsDefaultName()
        {
            // Setup
            var layer = new PipingSoilLayer(-2.9)
            {
                MaterialName = string.Empty
            };

            var properties = new PipingSoilLayerProperties(layer);

            // Call
            string name = properties.ToString();

            // Assert
            Assert.AreEqual("Onbekend", name);
        }
        public void ToString_ValidName_ReturnsMaterialName()
        {
            // Setup
            var layer = new PipingSoilLayer(-2.9)
            {
                MaterialName = "Layer A"
            };

            var properties = new PipingSoilLayerProperties(layer);

            // Call
            string name = properties.ToString();

            // Assert
            Assert.AreEqual(layer.MaterialName, name);
        }
Пример #29
0
        /// <summary>
        /// Gets the sieve size through which 70% of the grains of the top part of the aquifer pass.
        /// [m]
        /// </summary>
        /// <param name="input">The input to calculate the derived piping input for.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="input"/> is <c>null</c>.</exception>
        /// <returns>Returns the corresponding derived input value.</returns>
        public static VariationCoefficientLogNormalDistribution GetDiameterD70(PipingInput input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            PipingSoilLayer topMostAquiferLayer = GetConsecutiveAquiferLayers(input).FirstOrDefault();

            return(topMostAquiferLayer != null
                       ? topMostAquiferLayer.DiameterD70
                       : new VariationCoefficientLogNormalDistribution(6)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            });
        }
Пример #30
0
        /// <summary>
        /// Sets the values of the stochastic parameters for the given <see cref="PipingSoilLayer"/>.
        /// </summary>
        /// <param name="pipingSoilLayer">The <see cref="PipingSoilLayer"/> to set the property values for.</param>
        /// <param name="soilLayer">The <see cref="SoilLayerBase"/> to get the properties from.</param>
        /// <remarks>This method does not perform validation. Use <see cref="ValidateStochasticParameters"/> to
        /// verify whether the distributions for the stochastic parameters are correctly defined.</remarks>
        /// <exception cref="ImportedDataTransformException">Thrown when the stochastic values of <paramref name="pipingSoilLayer"/>
        /// are invalid.</exception>
        private static void SetStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer)
        {
            pipingSoilLayer.BelowPhreaticLevel = TransformLogNormalDistribution(soilLayer.BelowPhreaticLevelMean,
                                                                                soilLayer.BelowPhreaticLevelDeviation,
                                                                                soilLayer.BelowPhreaticLevelShift,
                                                                                soilLayer.MaterialName,
                                                                                Resources.SoilLayer_BelowPhreaticLevelDistribution_DisplayName);

            pipingSoilLayer.DiameterD70 = TransformVariationCoefficientLogNormalDistribution(soilLayer.DiameterD70Mean,
                                                                                             soilLayer.DiameterD70CoefficientOfVariation,
                                                                                             soilLayer.MaterialName,
                                                                                             Resources.SoilLayer_DiameterD70Distribution_DisplayName);

            pipingSoilLayer.Permeability = TransformVariationCoefficientLogNormalDistribution(soilLayer.PermeabilityMean,
                                                                                              soilLayer.PermeabilityCoefficientOfVariation,
                                                                                              soilLayer.MaterialName,
                                                                                              Resources.SoilLayer_PermeabilityDistribution_DisplayName);
        }