예제 #1
0
        private static void ReadInputParameters(ProbabilisticPipingInput inputParameters, ProbabilisticPipingCalculationEntity entity,
                                                ReadConversionCollector collector)
        {
            if (entity.SurfaceLineEntity != null)
            {
                inputParameters.SurfaceLine = entity.SurfaceLineEntity.ReadAsPipingSurfaceLine(collector);
            }

            if (entity.HydraulicLocationEntity != null)
            {
                inputParameters.HydraulicBoundaryLocation = entity.HydraulicLocationEntity.Read(collector);
            }

            if (entity.PipingStochasticSoilProfileEntity != null)
            {
                inputParameters.StochasticSoilModel   = entity.PipingStochasticSoilProfileEntity.StochasticSoilModelEntity.ReadAsPipingStochasticSoilModel(collector);
                inputParameters.StochasticSoilProfile = entity.PipingStochasticSoilProfileEntity.Read(collector);
            }

            inputParameters.EntryPointL            = (RoundedDouble)entity.EntryPointL.ToNullAsNaN();
            inputParameters.ExitPointL             = (RoundedDouble)entity.ExitPointL.ToNullAsNaN();
            inputParameters.PhreaticLevelExit.Mean = (RoundedDouble)entity.PhreaticLevelExitMean.ToNullAsNaN();
            inputParameters.PhreaticLevelExit.StandardDeviation = (RoundedDouble)entity.PhreaticLevelExitStandardDeviation.ToNullAsNaN();
            inputParameters.DampingFactorExit.Mean = (RoundedDouble)entity.DampingFactorExitMean.ToNullAsNaN();
            inputParameters.DampingFactorExit.StandardDeviation = (RoundedDouble)entity.DampingFactorExitStandardDeviation.ToNullAsNaN();

            inputParameters.ShouldProfileSpecificIllustrationPointsBeCalculated = Convert.ToBoolean(entity.ShouldProfileSpecificIllustrationPointsBeCalculated);
            inputParameters.ShouldSectionSpecificIllustrationPointsBeCalculated = Convert.ToBoolean(entity.ShouldSectionSpecificIllustrationPointsBeCalculated);
        }
        public void ParameteredConstructor_CalculationNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculationInput = new ProbabilisticPipingInput();
            var surfaceLines     = new[]
            {
                new PipingSurfaceLine(string.Empty)
            };

            PipingStochasticSoilModel[] stochasticSoilModels =
            {
                PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel()
            };
            var failureMechanism = new PipingFailureMechanism();

            // Call
            TestDelegate call = () => new ProbabilisticPipingInputContext(calculationInput, null, surfaceLines, stochasticSoilModels, failureMechanism, assessmentSection);

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

            Assert.AreEqual("calculation", exception.ParamName);
            mocks.VerifyAll();
        }
예제 #3
0
        private static void SetInputParametersToEntity(ProbabilisticPipingCalculationEntity entity,
                                                       ProbabilisticPipingInput inputParameters,
                                                       PersistenceRegistry registry)
        {
            if (inputParameters.SurfaceLine != null)
            {
                entity.SurfaceLineEntity = registry.Get(inputParameters.SurfaceLine);
            }

            if (inputParameters.HydraulicBoundaryLocation != null)
            {
                entity.HydraulicLocationEntity = registry.Get(inputParameters.HydraulicBoundaryLocation);
            }

            if (inputParameters.StochasticSoilProfile != null)
            {
                entity.PipingStochasticSoilProfileEntity = registry.Get(inputParameters.StochasticSoilProfile);
            }

            entity.ExitPointL  = inputParameters.ExitPointL.Value.ToNaNAsNull();
            entity.EntryPointL = inputParameters.EntryPointL.Value.ToNaNAsNull();

            entity.PhreaticLevelExitMean = inputParameters.PhreaticLevelExit.Mean.ToNaNAsNull();
            entity.PhreaticLevelExitStandardDeviation = inputParameters.PhreaticLevelExit.StandardDeviation.ToNaNAsNull();

            entity.DampingFactorExitMean = inputParameters.DampingFactorExit.Mean.ToNaNAsNull();
            entity.DampingFactorExitStandardDeviation = inputParameters.DampingFactorExit.StandardDeviation.ToNaNAsNull();

            entity.ShouldProfileSpecificIllustrationPointsBeCalculated = Convert.ToByte(inputParameters.ShouldProfileSpecificIllustrationPointsBeCalculated);
            entity.ShouldSectionSpecificIllustrationPointsBeCalculated = Convert.ToByte(inputParameters.ShouldSectionSpecificIllustrationPointsBeCalculated);
        }
        private static void AssertCalculatorInput(GeneralPipingInput generalInput, ProbabilisticPipingInput input, double sectionLength, PipingCalculationInput actualInput)
        {
            LogNormalDistribution effectiveThicknessCoverageLayer       = DerivedPipingInput.GetEffectiveThicknessCoverageLayer(input, generalInput);
            LogNormalDistribution saturatedVolumicWeightOfCoverageLayer = DerivedPipingInput.GetSaturatedVolumicWeightOfCoverageLayer(input);
            VariationCoefficientLogNormalDistribution seepageLength     = DerivedPipingInput.GetSeepageLength(input);
            LogNormalDistribution thicknessAquiferLayer = DerivedPipingInput.GetThicknessAquiferLayer(input);
            VariationCoefficientLogNormalDistribution darcyPermeability = DerivedPipingInput.GetDarcyPermeability(input);
            VariationCoefficientLogNormalDistribution diameterD70       = DerivedPipingInput.GetDiameterD70(input);

            var expectedInput = new PipingCalculationInput(
                1300001,
                sectionLength,
                input.PhreaticLevelExit.Mean, input.PhreaticLevelExit.StandardDeviation,
                generalInput.WaterVolumetricWeight,
                effectiveThicknessCoverageLayer.Mean, effectiveThicknessCoverageLayer.StandardDeviation,
                saturatedVolumicWeightOfCoverageLayer.Mean, saturatedVolumicWeightOfCoverageLayer.StandardDeviation,
                saturatedVolumicWeightOfCoverageLayer.Shift,
                generalInput.UpliftModelFactor.Mean, generalInput.UpliftModelFactor.StandardDeviation,
                input.DampingFactorExit.Mean, input.DampingFactorExit.StandardDeviation,
                seepageLength.Mean, seepageLength.CoefficientOfVariation,
                thicknessAquiferLayer.Mean, thicknessAquiferLayer.StandardDeviation,
                generalInput.SandParticlesVolumicWeight,
                generalInput.SellmeijerModelFactor.Mean, generalInput.SellmeijerModelFactor.StandardDeviation,
                generalInput.BeddingAngle,
                generalInput.WhitesDragCoefficient,
                generalInput.WaterKinematicViscosity,
                darcyPermeability.Mean, darcyPermeability.CoefficientOfVariation,
                diameterD70.Mean, diameterD70.CoefficientOfVariation,
                generalInput.Gravity,
                generalInput.CriticalHeaveGradient.Mean, generalInput.CriticalHeaveGradient.StandardDeviation);

            HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput);
        }
예제 #5
0
        /// <summary>
        /// This method sets random data values to all properties of <paramref name="input"/>.
        /// </summary>
        /// <param name="input">The input to set the random data values to.</param>
        public static void SetRandomDataToPipingInput(ProbabilisticPipingInput input)
        {
            SetRandomDataToPipingInput((PipingInput)input);

            var random = new Random(21);

            input.ShouldProfileSpecificIllustrationPointsBeCalculated = random.NextBoolean();
            input.ShouldSectionSpecificIllustrationPointsBeCalculated = random.NextBoolean();
        }
예제 #6
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var inputParameters = new ProbabilisticPipingInput();

            // Assert
            Assert.IsInstanceOf <PipingInput>(inputParameters);
            Assert.IsFalse(inputParameters.ShouldProfileSpecificIllustrationPointsBeCalculated);
            Assert.IsFalse(inputParameters.ShouldSectionSpecificIllustrationPointsBeCalculated);
        }
        private static void ToProbabilisticConfiguration(PipingCalculationConfiguration calculationConfiguration,
                                                         ProbabilisticPipingInput input)
        {
            if (input.HydraulicBoundaryLocation != null)
            {
                calculationConfiguration.HydraulicBoundaryLocationName = input.HydraulicBoundaryLocation.Name;
            }

            calculationConfiguration.ShouldProfileSpecificIllustrationPointsBeCalculated = input.ShouldProfileSpecificIllustrationPointsBeCalculated;
            calculationConfiguration.ShouldSectionSpecificIllustrationPointsBeCalculated = input.ShouldSectionSpecificIllustrationPointsBeCalculated;
        }
            protected override void AssertPipingCalculationScenario(ProbabilisticPipingCalculationScenario expectedCalculation,
                                                                    ProbabilisticPipingCalculationScenario actualCalculation)
            {
                AssertPipingCalculationScenarioGenericProperties(expectedCalculation, actualCalculation);

                ProbabilisticPipingInput expectedInput = expectedCalculation.InputParameters;
                ProbabilisticPipingInput actualInput   = actualCalculation.InputParameters;

                Assert.AreSame(expectedInput.HydraulicBoundaryLocation, actualInput.HydraulicBoundaryLocation);
                Assert.AreEqual(expectedInput.ShouldProfileSpecificIllustrationPointsBeCalculated, actualInput.ShouldProfileSpecificIllustrationPointsBeCalculated);
                Assert.AreEqual(expectedInput.ShouldSectionSpecificIllustrationPointsBeCalculated, actualInput.ShouldSectionSpecificIllustrationPointsBeCalculated);
            }
예제 #9
0
        public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new ProbabilisticPipingInput();

            PipingTestDataGenerator.SetRandomDataToPipingInput(original);

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones);
        }
예제 #10
0
        public void Clone_NotAllPropertiesSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new ProbabilisticPipingInput();

            PipingTestDataGenerator.SetRandomDataToPipingInput(original);

            original.SurfaceLine               = null;
            original.StochasticSoilModel       = null;
            original.StochasticSoilProfile     = null;
            original.HydraulicBoundaryLocation = null;

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones);
        }
        private static IEnumerable <string> ValidateInput(ProbabilisticPipingInput input, GeneralPipingInput generalInput)
        {
            var validationResults = new List <string>();

            if (input.HydraulicBoundaryLocation == null)
            {
                validationResults.Add(RiskeerCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected);
            }

            validationResults.AddRange(PipingCalculationValidationHelper.GetValidationErrors(input));

            if (!validationResults.Any())
            {
                validationResults.AddRange(ValidateCoverageLayers(input, generalInput));
            }

            return(validationResults);
        }
예제 #12
0
        public void GetViewData_WithContext_ReturnsWrappedCalculation()
        {
            // Setup
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var pipingInput = new ProbabilisticPipingInput();

            var calculation             = new ProbabilisticPipingCalculationScenario();
            var calculationInputContext = new ProbabilisticPipingInputContext(pipingInput, calculation, Enumerable.Empty <PipingSurfaceLine>(),
                                                                              Enumerable.Empty <PipingStochasticSoilModel>(),
                                                                              new PipingFailureMechanism(),
                                                                              assessmentSection);

            // Call
            object viewData = info.GetViewData(calculationInputContext);

            // Assert
            Assert.AreSame(calculation, viewData);
            mocks.VerifyAll();
        }
예제 #13
0
        public void Create_ProbabilisticPipingCalculationScenarioWithPropertiesSet_ReturnProbabilisticPipingCalculationEntity(
            bool isRelevant, double contribution, string name, string comments,
            double exitPoint, double entryPoint, int order, int randomSeed,
            bool calculateProfileIllustrationPoints, bool calculateSectionIllustrationPoints)
        {
            // Setup
            var random = new Random(randomSeed);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                IsRelevant   = isRelevant,
                Contribution = (RoundedDouble)contribution,
                Name         = name,
                Comments     =
                {
                    Body = comments
                },
                InputParameters =
                {
                    ExitPointL        = (RoundedDouble)exitPoint,
                    EntryPointL       = (RoundedDouble)entryPoint,
                    PhreaticLevelExit =
                    {
                        Mean                                            = random.NextRoundedDouble(-9999.9999, 9999.9999),
                        StandardDeviation                               = random.NextRoundedDouble(1e-6,                                   9999.9999)
                    },
                    DampingFactorExit                                   =
                    {
                        Mean                                            = random.NextRoundedDouble(1e-6,       9999.9999),
                        StandardDeviation                               = random.NextRoundedDouble(1e-6, 9999.9999)
                    },
                    ShouldProfileSpecificIllustrationPointsBeCalculated = calculateProfileIllustrationPoints,
                    ShouldSectionSpecificIllustrationPointsBeCalculated = calculateSectionIllustrationPoints
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            ProbabilisticPipingCalculationEntity entity = calculation.Create(registry, order);

            // Assert
            Assert.AreEqual(Convert.ToByte(isRelevant), entity.RelevantForScenario);
            Assert.AreEqual(calculation.Contribution, entity.ScenarioContribution);
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(comments, entity.Comments);

            Assert.AreEqual(exitPoint.ToNaNAsNull(), entity.ExitPointL);
            Assert.AreEqual(entryPoint.ToNaNAsNull(), entity.EntryPointL);

            ProbabilisticPipingInput input = calculation.InputParameters;

            Assert.AreEqual(input.PhreaticLevelExit.Mean.Value, entity.PhreaticLevelExitMean);
            Assert.AreEqual(input.PhreaticLevelExit.StandardDeviation.Value, entity.PhreaticLevelExitStandardDeviation);
            Assert.AreEqual(input.DampingFactorExit.Mean.Value, entity.DampingFactorExitMean);
            Assert.AreEqual(input.DampingFactorExit.StandardDeviation.Value, entity.DampingFactorExitStandardDeviation);

            Assert.AreEqual(Convert.ToByte(calculateProfileIllustrationPoints), entity.ShouldProfileSpecificIllustrationPointsBeCalculated);
            Assert.AreEqual(Convert.ToByte(calculateSectionIllustrationPoints), entity.ShouldSectionSpecificIllustrationPointsBeCalculated);

            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(0, entity.ProbabilisticPipingCalculationEntityId);
            Assert.IsNull(entity.CalculationGroupEntity);

            Assert.IsNull(entity.SurfaceLineEntity);
            Assert.IsNull(entity.PipingStochasticSoilProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);
            CollectionAssert.IsEmpty(entity.ProbabilisticPipingCalculationOutputEntities);
        }
예제 #14
0
 /// <summary>
 /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/>
 /// are clones.
 /// </summary>
 /// <param name="original">The original object.</param>
 /// <param name="clone">The cloned object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and
 /// <paramref name="clone"/> are not clones.</exception>
 public static void AreClones(ProbabilisticPipingInput original, ProbabilisticPipingInput clone)
 {
     AreClones((PipingInput)original, clone);
     Assert.AreEqual(original.ShouldProfileSpecificIllustrationPointsBeCalculated, clone.ShouldProfileSpecificIllustrationPointsBeCalculated);
     Assert.AreEqual(original.ShouldSectionSpecificIllustrationPointsBeCalculated, clone.ShouldSectionSpecificIllustrationPointsBeCalculated);
 }
        private static PipingCalculationInput CreateInput(ProbabilisticPipingCalculation calculation, GeneralPipingInput generalInput,
                                                          double sectionLength, string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor)
        {
            ProbabilisticPipingInput pipingInput                        = calculation.InputParameters;
            LogNormalDistribution    thicknessCoverageLayer             = DerivedPipingInput.GetThicknessCoverageLayer(pipingInput);
            VariationCoefficientLogNormalDistribution seepageLength     = DerivedPipingInput.GetSeepageLength(pipingInput);
            LogNormalDistribution thicknessAquiferLayer                 = DerivedPipingInput.GetThicknessAquiferLayer(pipingInput);
            VariationCoefficientLogNormalDistribution darcyPermeability = DerivedPipingInput.GetDarcyPermeability(pipingInput);
            VariationCoefficientLogNormalDistribution diameterD70       = DerivedPipingInput.GetDiameterD70(pipingInput);

            PipingCalculationInput input;

            if (double.IsNaN(thicknessCoverageLayer.Mean))
            {
                input = new PipingCalculationInput(
                    pipingInput.HydraulicBoundaryLocation.Id,
                    sectionLength,
                    pipingInput.PhreaticLevelExit.Mean, pipingInput.PhreaticLevelExit.StandardDeviation,
                    generalInput.WaterVolumetricWeight,
                    generalInput.UpliftModelFactor.Mean, generalInput.UpliftModelFactor.StandardDeviation,
                    pipingInput.DampingFactorExit.Mean, pipingInput.DampingFactorExit.StandardDeviation,
                    seepageLength.Mean, seepageLength.CoefficientOfVariation,
                    thicknessAquiferLayer.Mean, thicknessAquiferLayer.StandardDeviation,
                    generalInput.SandParticlesVolumicWeight,
                    generalInput.SellmeijerModelFactor.Mean, generalInput.SellmeijerModelFactor.StandardDeviation,
                    generalInput.BeddingAngle,
                    generalInput.WhitesDragCoefficient,
                    generalInput.WaterKinematicViscosity,
                    darcyPermeability.Mean, darcyPermeability.CoefficientOfVariation,
                    diameterD70.Mean, diameterD70.CoefficientOfVariation,
                    generalInput.Gravity,
                    generalInput.CriticalHeaveGradient.Mean, generalInput.CriticalHeaveGradient.StandardDeviation);
            }
            else
            {
                LogNormalDistribution effectiveThicknessCoverageLayer       = DerivedPipingInput.GetEffectiveThicknessCoverageLayer(pipingInput, generalInput);
                LogNormalDistribution saturatedVolumicWeightOfCoverageLayer = DerivedPipingInput.GetSaturatedVolumicWeightOfCoverageLayer(pipingInput);

                input = new PipingCalculationInput(
                    pipingInput.HydraulicBoundaryLocation.Id,
                    sectionLength,
                    pipingInput.PhreaticLevelExit.Mean, pipingInput.PhreaticLevelExit.StandardDeviation,
                    generalInput.WaterVolumetricWeight,
                    effectiveThicknessCoverageLayer.Mean, effectiveThicknessCoverageLayer.StandardDeviation,
                    saturatedVolumicWeightOfCoverageLayer.Mean, saturatedVolumicWeightOfCoverageLayer.StandardDeviation,
                    saturatedVolumicWeightOfCoverageLayer.Shift,
                    generalInput.UpliftModelFactor.Mean, generalInput.UpliftModelFactor.StandardDeviation,
                    pipingInput.DampingFactorExit.Mean, pipingInput.DampingFactorExit.StandardDeviation,
                    seepageLength.Mean, seepageLength.CoefficientOfVariation,
                    thicknessAquiferLayer.Mean, thicknessAquiferLayer.StandardDeviation,
                    generalInput.SandParticlesVolumicWeight,
                    generalInput.SellmeijerModelFactor.Mean, generalInput.SellmeijerModelFactor.StandardDeviation,
                    generalInput.BeddingAngle,
                    generalInput.WhitesDragCoefficient,
                    generalInput.WaterKinematicViscosity,
                    darcyPermeability.Mean, darcyPermeability.CoefficientOfVariation,
                    diameterD70.Mean, diameterD70.CoefficientOfVariation,
                    generalInput.Gravity,
                    generalInput.CriticalHeaveGradient.Mean, generalInput.CriticalHeaveGradient.StandardDeviation);
            }

            HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath, usePreprocessor);

            return(input);
        }