Exemple #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ConstructionProperties"/> class.
            /// </summary>
            public ConstructionProperties()
            {
                LevelCrestStructure = new NormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.05
                };
                FlowWidthAtBottomProtection = new LogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.05
                };
                CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    CoefficientOfVariation = (RoundedDouble)0.15
                };
                WidthFlowApertures = new NormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.2
                };
                StorageStructureArea = new VariationCoefficientLogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    CoefficientOfVariation = (RoundedDouble)0.1
                };
                AllowedLevelIncreaseStorage = new LogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.1
                };

                FailureProbabilityStructureWithErosion = 1.0;
            }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeightStructure"/> class.
 /// </summary>
 /// <param name="constructionProperties">The construction properties.</param>
 /// <exception cref="ArgumentException">Thrown when <see cref="ConstructionProperties.Name"/>
 /// or <see cref="ConstructionProperties.Id"/> is <c>null</c>, empty or consists of whitespace.</exception>
 /// <exception cref="ArgumentNullException">Thrown when <see cref="ConstructionProperties.Location"/> is <c>null</c>.</exception>
 public HeightStructure(ConstructionProperties constructionProperties) : base(constructionProperties)
 {
     LevelCrestStructure = new NormalDistribution(2)
     {
         Mean = constructionProperties.LevelCrestStructure.Mean,
         StandardDeviation = constructionProperties.LevelCrestStructure.StandardDeviation
     };
     FlowWidthAtBottomProtection = new LogNormalDistribution(2)
     {
         Mean = constructionProperties.FlowWidthAtBottomProtection.Mean,
         StandardDeviation = constructionProperties.FlowWidthAtBottomProtection.StandardDeviation
     };
     CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2)
     {
         Mean = constructionProperties.CriticalOvertoppingDischarge.Mean,
         CoefficientOfVariation = constructionProperties.CriticalOvertoppingDischarge.CoefficientOfVariation
     };
     WidthFlowApertures = new NormalDistribution(2)
     {
         Mean = constructionProperties.WidthFlowApertures.Mean,
         StandardDeviation = constructionProperties.WidthFlowApertures.StandardDeviation
     };
     FailureProbabilityStructureWithErosion = constructionProperties.FailureProbabilityStructureWithErosion;
     StorageStructureArea = new VariationCoefficientLogNormalDistribution(2)
     {
         Mean = constructionProperties.StorageStructureArea.Mean,
         CoefficientOfVariation = constructionProperties.StorageStructureArea.CoefficientOfVariation
     };
     AllowedLevelIncreaseStorage = new LogNormalDistribution(2)
     {
         Mean = constructionProperties.AllowedLevelIncreaseStorage.Mean,
         StandardDeviation = constructionProperties.AllowedLevelIncreaseStorage.StandardDeviation
     };
 }
Exemple #3
0
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var random = new Random(31);

            var stress = new MacroStabilityInwardsPreconsolidationStress(new Point2D(random.NextDouble(), random.NextDouble()),
                                                                         new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)0.005,
                CoefficientOfVariation = random.NextRoundedDouble()
            });
            int order = random.Next();

            // Call
            MacroStabilityInwardsPreconsolidationStressEntity entity = stress.Create(order);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(stress.Location.X, entity.CoordinateX);
            Assert.AreEqual(stress.Location.Y, entity.CoordinateZ);

            VariationCoefficientLogNormalDistribution preconsolidationStressDistribution = stress.Stress;

            Assert.AreEqual(preconsolidationStressDistribution.Mean, entity.PreconsolidationStressMean,
                            preconsolidationStressDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationStressDistribution.CoefficientOfVariation, entity.PreconsolidationStressCoefficientOfVariation,
                            preconsolidationStressDistribution.GetAccuracy());
            Assert.AreEqual(order, entity.Order);
        }
        /// <summary>
        /// Creates a new instance of <see cref="StabilityPointStructuresInput"/>.
        /// </summary>
        public StabilityPointStructuresInput()
        {
            volumicWeightWater = new RoundedDouble(2, 9.81);
            factorStormDurationOpenStructure = new RoundedDouble(2, 1.0);
            failureProbabilityRepairClosure  = 0;

            evaluationLevel  = new RoundedDouble(2);
            verticalDistance = new RoundedDouble(verticalDistanceNumberOfDecimals);

            drainCoefficient = new LogNormalDistribution(2)
            {
                Mean = (RoundedDouble)1.0,
                StandardDeviation = (RoundedDouble)0.20
            };

            insideWaterLevelFailureConstruction = new NormalDistribution(2);
            insideWaterLevel = new NormalDistribution(2);
            flowVelocityStructureClosable = new VariationCoefficientNormalDistribution(2);

            levelCrestStructure                    = new NormalDistribution(2);
            thresholdHeightOpenWeir                = new NormalDistribution(2);
            areaFlowApertures                      = new LogNormalDistribution(2);
            constructiveStrengthLinearLoadModel    = new VariationCoefficientLogNormalDistribution(2);
            constructiveStrengthQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2);
            stabilityLinearLoadModel               = new VariationCoefficientLogNormalDistribution(2);
            stabilityQuadraticLoadModel            = new VariationCoefficientLogNormalDistribution(2);
            failureCollisionEnergy                 = new VariationCoefficientLogNormalDistribution(2);
            shipMass     = new VariationCoefficientNormalDistribution(2);
            shipVelocity = new VariationCoefficientNormalDistribution(2);
            bankWidth    = new NormalDistribution(2);

            SetDefaultSchematizationProperties();
        }
Exemple #5
0
        private void SetDefaultCommonStructureSchematizationProperties()
        {
            StructureNormalOrientation = RoundedDouble.NaN;

            AllowedLevelIncreaseStorage = new LogNormalDistribution
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            StorageStructureArea = new VariationCoefficientLogNormalDistribution
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            FlowWidthAtBottomProtection = new LogNormalDistribution
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            WidthFlowApertures = new NormalDistribution
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };
        }
        public void Pop_Always_ExpectedValues()
        {
            // Setup
            var random = new Random(21);
            var data   = new MacroStabilityInwardsSoilLayerData();

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

            // Call
            data.Pop = distributionToSet;

            // Assert
            var expectedDistribution = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = distributionToSet.Mean,
                CoefficientOfVariation = distributionToSet.CoefficientOfVariation,
                Shift = data.Pop.Shift
            };

            DistributionTestHelper.AssertDistributionCorrectlySet(data.Pop, distributionToSet, expectedDistribution);
        }
        public void GetDarcyPermeability_MultipleAquiferLayersWithDifferentMeanAndDeviation_ReturnsDistributionWithParametersNaN()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            input.StochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0, new PipingSoilProfile("", -2.0, new[]
            {
                new PipingSoilLayer(1.0)
                {
                    IsAquifer    = true,
                    Permeability = new VariationCoefficientLogNormalDistribution
                    {
                        Mean = (RoundedDouble)0.5,
                        CoefficientOfVariation = (RoundedDouble)0.2
                    }
                },
                new PipingSoilLayer(0.0)
                {
                    IsAquifer    = true,
                    Permeability = new VariationCoefficientLogNormalDistribution
                    {
                        Mean = (RoundedDouble)12.5,
                        CoefficientOfVariation = (RoundedDouble)2.3
                    }
                }
            }, SoilProfileType.SoilProfile1D));

            // Call
            VariationCoefficientLogNormalDistribution result = DerivedPipingInput.GetDarcyPermeability(input);

            // Assert
            AssertDarcyPermeability(result);
        }
        private static void AssertSeepageLength(VariationCoefficientLogNormalDistribution seepageLength, double mean = double.NaN)
        {
            var expected = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = (RoundedDouble)mean,
                CoefficientOfVariation = (RoundedDouble)0.1
            };

            DistributionAssert.AreEqual(expected, seepageLength);
        }
        public void GetSeepageLength_ValidData_ReturnsDistributionWithExpectedMean()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            // Call
            VariationCoefficientLogNormalDistribution seepageLength = DerivedPipingInput.GetSeepageLength(input);

            // Assert
            AssertSeepageLength(seepageLength, 0.5);
        }
        public void Mean_SetNewValue_ReturnNewlySetValue(double actualSetValue, double expectedRoundedValue)
        {
            // Setup
            var distribution = new VariationCoefficientLogNormalDistribution(2);

            // Call
            distribution.Mean = (RoundedDouble)actualSetValue;

            // Assert
            Assert.AreEqual(expectedRoundedValue, distribution.Mean.Value);
        }
Exemple #11
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ConstructionProperties"/> class.
            /// </summary>
            public ConstructionProperties()
            {
                StorageStructureArea = new VariationCoefficientLogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    CoefficientOfVariation = (RoundedDouble)0.1
                };
                AllowedLevelIncreaseStorage = new LogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.1
                };
                WidthFlowApertures = new NormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.2
                };
                LevelCrestStructureNotClosing = new NormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.05
                };
                InsideWaterLevel = new NormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.1
                };
                ThresholdHeightOpenWeir = new NormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.1
                };
                AreaFlowApertures = new LogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.01
                };
                CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    CoefficientOfVariation = (RoundedDouble)0.15
                };
                FlowWidthAtBottomProtection = new LogNormalDistribution(2)
                {
                    Mean = RoundedDouble.NaN,
                    StandardDeviation = (RoundedDouble)0.05
                };

                ProbabilityOpenStructureBeforeFlooding = 1;
                FailureProbabilityOpenStructure        = 1;
                IdenticalApertures           = 1;
                FailureProbabilityReparation = 1;
                InflowModelType = ClosingStructureInflowModelType.VerticalWall;
            }
        private static void AssertDiameterD70(VariationCoefficientLogNormalDistribution diameterD70,
                                              double mean = double.NaN,
                                              double coefficientOfVariation = double.NaN)
        {
            var expected = new VariationCoefficientLogNormalDistribution(6)
            {
                Mean = (RoundedDouble)mean,
                CoefficientOfVariation = (RoundedDouble)coefficientOfVariation
            };

            DistributionAssert.AreEqual(expected, diameterD70);
        }
        private static void AssertDarcyPermeability(VariationCoefficientLogNormalDistribution darcyPermeability,
                                                    double mean = double.NaN,
                                                    double standardDeviation = double.NaN)
        {
            var expected = new VariationCoefficientLogNormalDistribution(6)
            {
                Mean = (RoundedDouble)mean,
                CoefficientOfVariation = (RoundedDouble)standardDeviation
            };

            DistributionAssert.AreEqual(expected, darcyPermeability);
        }
Exemple #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClosingStructure"/> class.
 /// </summary>
 /// <param name="constructionProperties">The construction properties.</param>
 /// <exception cref="ArgumentException">Thrown when <see cref="ConstructionProperties.Name"/>
 /// or <see cref="ConstructionProperties.Id"/> is <c>null</c>, empty or consists of whitespace.</exception>
 /// <exception cref="ArgumentNullException">Thrown when <see cref="ConstructionProperties.Location"/> is <c>null</c>.</exception>
 public ClosingStructure(ConstructionProperties constructionProperties) : base(constructionProperties)
 {
     StorageStructureArea = new VariationCoefficientLogNormalDistribution(2)
     {
         Mean = constructionProperties.StorageStructureArea.Mean,
         CoefficientOfVariation = constructionProperties.StorageStructureArea.CoefficientOfVariation
     };
     AllowedLevelIncreaseStorage = new LogNormalDistribution(2)
     {
         Mean = constructionProperties.AllowedLevelIncreaseStorage.Mean,
         StandardDeviation = constructionProperties.AllowedLevelIncreaseStorage.StandardDeviation
     };
     WidthFlowApertures = new NormalDistribution(2)
     {
         Mean = constructionProperties.WidthFlowApertures.Mean,
         StandardDeviation = constructionProperties.WidthFlowApertures.StandardDeviation
     };
     LevelCrestStructureNotClosing = new NormalDistribution(2)
     {
         Mean = constructionProperties.LevelCrestStructureNotClosing.Mean,
         StandardDeviation = constructionProperties.LevelCrestStructureNotClosing.StandardDeviation
     };
     InsideWaterLevel = new NormalDistribution(2)
     {
         Mean = constructionProperties.InsideWaterLevel.Mean,
         StandardDeviation = constructionProperties.InsideWaterLevel.StandardDeviation
     };
     ThresholdHeightOpenWeir = new NormalDistribution(2)
     {
         Mean = constructionProperties.ThresholdHeightOpenWeir.Mean,
         StandardDeviation = constructionProperties.ThresholdHeightOpenWeir.StandardDeviation
     };
     AreaFlowApertures = new LogNormalDistribution(2)
     {
         Mean = constructionProperties.AreaFlowApertures.Mean,
         StandardDeviation = constructionProperties.AreaFlowApertures.StandardDeviation
     };
     CriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2)
     {
         Mean = constructionProperties.CriticalOvertoppingDischarge.Mean,
         CoefficientOfVariation = constructionProperties.CriticalOvertoppingDischarge.CoefficientOfVariation
     };
     FlowWidthAtBottomProtection = new LogNormalDistribution(2)
     {
         Mean = constructionProperties.FlowWidthAtBottomProtection.Mean,
         StandardDeviation = constructionProperties.FlowWidthAtBottomProtection.StandardDeviation
     };
     ProbabilityOpenStructureBeforeFlooding = constructionProperties.ProbabilityOpenStructureBeforeFlooding;
     FailureProbabilityOpenStructure        = constructionProperties.FailureProbabilityOpenStructure;
     IdenticalApertures           = constructionProperties.IdenticalApertures;
     FailureProbabilityReparation = constructionProperties.FailureProbabilityReparation;
     InflowModelType = constructionProperties.InflowModelType;
 }
        private static MacroStabilityInwardsPreconsolidationStress CreateRandomPreconsolidationStress(int seed)
        {
            var random       = new Random(seed);
            var location     = new Point2D(random.NextDouble(), random.NextDouble());
            var distribution = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)0.005,
                CoefficientOfVariation = random.NextRoundedDouble()
            };

            return(new MacroStabilityInwardsPreconsolidationStress(location, distribution));
        }
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution   = new VariationCoefficientLogNormalDistribution();
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionReadOnlyProperties.None,
                                                                                                   designVariable,
                                                                                                   handler);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(4, dynamicProperties.Count);

            PropertyDescriptor distributionTypeProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(distributionTypeProperty,
                                                                            "Misc",
                                                                            "Type verdeling",
                                                                            "Het soort kansverdeling waarin deze parameter gedefinieerd wordt.",
                                                                            true);

            PropertyDescriptor meanProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(meanProperty,
                                                                            "Misc",
                                                                            "Verwachtingswaarde",
                                                                            "De gemiddelde waarde van de lognormale verdeling.");

            PropertyDescriptor standardDeviationProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(standardDeviationProperty,
                                                                            "Misc",
                                                                            "Variatiecoëfficiënt",
                                                                            "De variatiecoëfficiënt van de lognormale verdeling.");

            PropertyDescriptor designValueProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(designValueProperty,
                                                                            "Misc",
                                                                            "Rekenwaarde",
                                                                            "De representatieve waarde die gebruikt wordt door de berekening.",
                                                                            true);
            mockRepository.VerifyAll();
        }
        public void GetDarcyPermeability_ExitPointLNaN_ReturnsDistributionWithParametersNaN()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            input.ExitPointL = RoundedDouble.NaN;

            // Call
            VariationCoefficientLogNormalDistribution result = DerivedPipingInput.GetDarcyPermeability(input);

            // Assert
            AssertDarcyPermeability(result);
        }
        public void GetDarcyPermeability_SurfaceLineNull_ReturnsDistributionWithParametersNaN()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            input.SurfaceLine = null;

            // Call
            VariationCoefficientLogNormalDistribution result = DerivedPipingInput.GetDarcyPermeability(input);

            // Assert
            AssertDarcyPermeability(result);
        }
        public void GetSeepageLength_ExitPointNaN_ReturnsDistributionWithMeanNaN()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            input.ExitPointL = RoundedDouble.NaN;

            // Call
            VariationCoefficientLogNormalDistribution seepageLength = DerivedPipingInput.GetSeepageLength(input);

            // Assert
            AssertSeepageLength(seepageLength);
        }
        public void GetDiameterD70_SoilProfileNull_ReturnsDistributionWithParametersNaN()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            input.StochasticSoilProfile = null;

            // Call
            VariationCoefficientLogNormalDistribution result = DerivedPipingInput.GetDiameterD70(input);

            // Assert
            AssertDiameterD70(result);
        }
Exemple #21
0
        private static void AssertPreconsolidationStress(MacroStabilityInwardsPreconsolidationStress preconsolidationStress,
                                                         MacroStabilityInwardsPreconsolidationStressEntity entity)
        {
            Assert.AreEqual(preconsolidationStress.Location.X, entity.CoordinateX);
            Assert.AreEqual(preconsolidationStress.Location.Y, entity.CoordinateZ);

            VariationCoefficientLogNormalDistribution preconsolidationDistribution = preconsolidationStress.Stress;

            Assert.AreEqual(preconsolidationDistribution.Mean, entity.PreconsolidationStressMean,
                            preconsolidationDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationDistribution.CoefficientOfVariation, entity.PreconsolidationStressCoefficientOfVariation,
                            preconsolidationDistribution.GetAccuracy());
        }
        public void CoefficientOfVariation_NegativeValue_ThrowArgumentOutOfRangeException(double invalidCoefficient)
        {
            // Setup
            var distribution = new VariationCoefficientLogNormalDistribution(2);

            // Call
            void Call() => distribution.CoefficientOfVariation = (RoundedDouble)invalidCoefficient;

            // Assert
            const string expectedMessage = "Variatiecoëfficiënt (CV) moet groter zijn dan of gelijk zijn aan 0.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(Call, expectedMessage);
        }
        public void Mean_NegativeOrZeroValue_ThrowArgumentOutOfRangeException(double invalidCoefficient)
        {
            // Setup
            var distribution = new VariationCoefficientLogNormalDistribution(2);

            // Call
            void Call() => distribution.Mean = (RoundedDouble)invalidCoefficient;

            // Assert
            const string expectedMessage = "Gemiddelde moet groter zijn dan 0.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(Call, expectedMessage);
        }
        public void ParameteredConstructor_ValidLogNormalDistribution_ExpectedValues()
        {
            // Setup
            var logNormalDistribution = new VariationCoefficientLogNormalDistribution(2);

            // Call
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(logNormalDistribution);

            // Assert
            Assert.IsInstanceOf <VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> >(designVariable);
            Assert.AreSame(logNormalDistribution, designVariable.Distribution);
            Assert.AreEqual(0.5, designVariable.Percentile);
        }
Exemple #25
0
        private static void AssertPreconsolidationStress(PreconsolidationStress preconsolidationStress,
                                                         MacroStabilityInwardsPreconsolidationStress transformedPreconsolidationStress)
        {
            Assert.AreEqual(preconsolidationStress.XCoordinate,
                            transformedPreconsolidationStress.Location.X);
            Assert.AreEqual(preconsolidationStress.ZCoordinate,
                            transformedPreconsolidationStress.Location.Y);

            VariationCoefficientLogNormalDistribution stressDistribution = transformedPreconsolidationStress.Stress;

            Assert.AreEqual(preconsolidationStress.StressMean, stressDistribution.Mean, stressDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationStress.StressCoefficientOfVariation, stressDistribution.CoefficientOfVariation, stressDistribution.GetAccuracy());
        }
        public void TrySetVariationCoefficientStochast_ValidStochastConfiguration_ReturnsTrueParametersSet(bool setMean, bool setVariationCoefficient)
        {
            // Setup
            var mocks = new MockRepository();
            var log   = mocks.StrictMock <ILog>();

            mocks.ReplayAll();

            var configuration = new StochastConfiguration();

            var    random = new Random(21);
            double mean   = random.NextDouble();
            double variationCoefficient = random.NextDouble();

            if (setMean)
            {
                configuration.Mean = mean;
            }

            if (setVariationCoefficient)
            {
                configuration.VariationCoefficient = variationCoefficient;
            }

            var input = new TestInputWithStochasts();

            // Call
            bool valid = ConfigurationImportHelper.TrySetVariationCoefficientStochast(
                "some stochast name",
                "some calculation name",
                input, configuration,
                i => i.VariationCoefficientDistribution,
                (i, s) => i.VariationCoefficientDistribution = s,
                log);

            // Assert
            Assert.IsTrue(valid);
            var defaultLogNormal = new VariationCoefficientLogNormalDistribution();

            Assert.AreEqual(
                setMean ? mean : defaultLogNormal.Mean,
                input.VariationCoefficientDistribution.Mean,
                input.VariationCoefficientDistribution.Mean.GetAccuracy());
            Assert.AreEqual(
                setVariationCoefficient ? variationCoefficient : defaultLogNormal.CoefficientOfVariation,
                input.VariationCoefficientDistribution.CoefficientOfVariation,
                input.VariationCoefficientDistribution.CoefficientOfVariation.GetAccuracy());

            mocks.VerifyAll();
        }
Exemple #27
0
        public void Constructor_WithData_ReadOnlyProperties()
        {
            // Setup
            var distribution = new VariationCoefficientLogNormalDistribution();

            // Call
            var properties = new VariationCoefficientLogNormalDistributionProperties(distribution);

            // Assert
            Assert.IsInstanceOf <VariationCoefficientDistributionPropertiesBase <VariationCoefficientLogNormalDistribution> >(properties);
            Assert.AreSame(distribution, properties.Data);

            AssertPropertiesInState(properties, true, true);
        }
        private static MacroStabilityInwardsPreconsolidationStress CopyAndModifyPreconsolidationsStress(
            MacroStabilityInwardsPreconsolidationStress preconsolidationStress)
        {
            var random           = new Random(29);
            var modifiedLocation = new Point2D(preconsolidationStress.Location.X + random.NextDouble(),
                                               preconsolidationStress.Location.Y);
            var distribution = new VariationCoefficientLogNormalDistribution
            {
                Mean = preconsolidationStress.Stress.Mean,
                CoefficientOfVariation = preconsolidationStress.Stress.CoefficientOfVariation
            };

            return(new MacroStabilityInwardsPreconsolidationStress(modifiedLocation, distribution));
        }
        public void Constructor_WithParameter_ExpectedValues(int numberOfDecimals)
        {
            // Call
            var distribution = new VariationCoefficientLogNormalDistribution(numberOfDecimals);

            // Assert
            Assert.IsInstanceOf <IVariationCoefficientDistribution>(distribution);

            Assert.AreEqual(numberOfDecimals, distribution.Mean.NumberOfDecimalPlaces);
            Assert.AreEqual(1.0, distribution.Mean.Value);
            Assert.AreEqual(numberOfDecimals, distribution.CoefficientOfVariation.NumberOfDecimalPlaces);
            Assert.AreEqual(1.0, distribution.CoefficientOfVariation.Value);
            Assert.AreEqual(numberOfDecimals, distribution.Shift.NumberOfDecimalPlaces);
            Assert.AreEqual(0, distribution.Shift.Value);
        }
        public void Shift_SetNewValue_GetValueRoundedToGivenNumberOfDecimalPlaces(int numberOfDecimalPlaces, double expectedShift)
        {
            // Setup
            var distribution = new VariationCoefficientLogNormalDistribution(numberOfDecimalPlaces)
            {
                Mean = new RoundedDouble(2, 10.0)
            };

            // Call
            distribution.Shift = new RoundedDouble(4, 5.6473);

            // Assert
            Assert.AreEqual(numberOfDecimalPlaces, distribution.Shift.NumberOfDecimalPlaces);
            Assert.AreEqual(expectedShift, distribution.Shift.Value);
        }