public void RemoveStochasticSoilProfileFromInput_CalculationWithOutputWithProfile_ReturnInputWithoutProfileAndCalculation()
        {
            // Setup
            PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations();
            IEnumerable <IPipingCalculationScenario <PipingInput> > calculations = failureMechanism.Calculations
                                                                                   .Cast <IPipingCalculationScenario <PipingInput> >();

            var expectedAffectedObjects = new List <IObservable>();

            PipingStochasticSoilProfile profileToDelete = null;

            foreach (IPipingCalculationScenario <PipingInput> calculation in calculations)
            {
                PipingInput input = calculation.InputParameters;
                PipingStochasticSoilProfile currentProfile = input.StochasticSoilProfile;
                if (profileToDelete == null)
                {
                    profileToDelete = currentProfile;
                }

                if (profileToDelete != null && ReferenceEquals(profileToDelete, currentProfile))
                {
                    if (calculation.HasOutput)
                    {
                        expectedAffectedObjects.Add(calculation);
                    }

                    expectedAffectedObjects.Add(input);
                }
            }

            // Call
            IEnumerable <IObservable> affected = PipingDataSynchronizationService.RemoveStochasticSoilProfileFromInput(failureMechanism, profileToDelete);

            // Assert
            CollectionAssert.AreEquivalent(expectedAffectedObjects, affected);
            CollectionAssert.IsEmpty(affected.OfType <PipingInput>().Where(a => a.StochasticSoilProfile != null));
            CollectionAssert.IsEmpty(affected.OfType <IPipingCalculationScenario <PipingInput> >().Where(a => a.HasOutput));
        }
        public void GetDiameterD70_MultipleAquiferLayers_ReturnsWithParametersFromTopmostLayer()
        {
            // Setup
            PipingInput input = PipingInputFactory.CreateInputWithAquiferAndCoverageLayer <TestPipingInput>();

            const double diameterD70Mean = 0.5;
            const double diameterD70CoefficientOfVariation = 0.2;

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

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

            // Assert
            AssertDiameterD70(result, diameterD70Mean, diameterD70CoefficientOfVariation);
        }
        public static void CalculateEffectiveThicknessCoverageLayer_InvalidPipingCalculationWithOutput_ReturnsNaN()
        {
            // Setup
            var invalidPipingCalculation =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <TestSemiProbabilisticPipingCalculation>(
                    new TestHydraulicBoundaryLocation());

            // Make invalid by having surface line partially above soil profile:
            double highestLevelSurfaceLine = invalidPipingCalculation.InputParameters.SurfaceLine.Points.Max(p => p.Z);
            double soilProfileTop          = highestLevelSurfaceLine - 0.5;
            double soilProfileBottom       = soilProfileTop - 0.5;

            invalidPipingCalculation.InputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0,
                new PipingSoilProfile("A", soilProfileBottom, new[]
            {
                new PipingSoilLayer(soilProfileTop)
                {
                    IsAquifer = true
                }
            }, SoilProfileType.SoilProfile1D));

            var generalInput = new GeneralPipingInput();

            // Call
            PipingInput input  = invalidPipingCalculation.InputParameters;
            double      result = InputParameterCalculationService.CalculateEffectiveThicknessCoverageLayer(
                generalInput.WaterVolumetricWeight,
                PipingDesignVariableFactory.GetPhreaticLevelExit(input).GetDesignValue(),
                input.ExitPointL,
                input.SurfaceLine,
                input.StochasticSoilProfile.SoilProfile);

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

            input.StochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0, new PipingSoilProfile("", -2.0, new[]
            {
                new PipingSoilLayer(2.0)
                {
                    IsAquifer = false
                },
                new PipingSoilLayer(1.0)
                {
                    IsAquifer = true
                }
            }, SoilProfileType.SoilProfile1D));

            // Call
            LogNormalDistribution result = DerivedPipingInput.GetSaturatedVolumicWeightOfCoverageLayer(input);

            // Assert
            AssertSaturatedVolumicWeightOfCoverageLayer(result);
        }
        private static IEnumerable <string> ValidateAquiferLayers(PipingInput input)
        {
            double            surfaceLevel      = input.SurfaceLine.GetZAtL(input.ExitPointL);
            PipingSoilProfile pipingSoilProfile = input.StochasticSoilProfile.SoilProfile;

            if (!pipingSoilProfile.GetConsecutiveAquiferLayersBelowLevel(surfaceLevel).Any())
            {
                yield return(Resources.PipingCalculationService_ValidateInput_No_aquifer_layer_at_ExitPointL_under_SurfaceLine);
            }
            else
            {
                VariationCoefficientLogNormalDistribution darcyPermeability = DerivedPipingInput.GetDarcyPermeability(input);
                if (IsInvalidDistributionValue(darcyPermeability.Mean) || IsInvalidDistributionValue(darcyPermeability.CoefficientOfVariation))
                {
                    yield return(Resources.PipingCalculationService_ValidateInput_Cannot_derive_DarcyPermeability);
                }

                VariationCoefficientLogNormalDistribution diameter70 = DerivedPipingInput.GetDiameterD70(input);
                if (IsInvalidDistributionValue(diameter70.Mean) || IsInvalidDistributionValue(diameter70.CoefficientOfVariation))
                {
                    yield return(Resources.PipingCalculationService_ValidateInput_Cannot_derive_Diameter70);
                }
            }
        }
 private static bool IsSurfaceLineProfileDefinitionComplete(PipingInput input)
 {
     return(input.SurfaceLine != null &&
            input.StochasticSoilProfile != null &&
            !double.IsNaN(input.ExitPointL));
 }
        private static IEnumerable <string> ValidateCoreSurfaceLineAndSoilProfileProperties(PipingInput input)
        {
            if (input.SurfaceLine == null)
            {
                yield return(Resources.PipingCalculationService_ValidateInput_No_SurfaceLine_selected);
            }

            if (input.StochasticSoilProfile == null)
            {
                yield return(Resources.PipingCalculationService_ValidateInput_No_StochasticSoilProfile_selected);
            }

            if (double.IsNaN(input.ExitPointL))
            {
                yield return(Resources.PipingCalculationService_ValidateInput_No_value_for_ExitPointL);
            }

            if (double.IsNaN(input.EntryPointL))
            {
                yield return(Resources.PipingCalculationService_ValidateInput_No_value_for_EntryPointL);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Creates the design variable for the volumic weight of the saturated coverage layer.
        /// </summary>
        /// <param name="pipingInput">The piping input.</param>
        /// <returns>The created <see cref="DesignVariable{LogNormalDistribution}"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="pipingInput"/> is <c>null</c>.</exception>
        public static DesignVariable <LogNormalDistribution> GetSaturatedVolumicWeightOfCoverageLayer(PipingInput pipingInput)
        {
            LogNormalDistribution thicknessCoverageLayer = DerivedPipingInput.GetThicknessCoverageLayer(pipingInput);
            LogNormalDistribution saturatedVolumicWeightOfCoverageLayer = DerivedPipingInput.GetSaturatedVolumicWeightOfCoverageLayer(pipingInput);

            if (double.IsNaN(thicknessCoverageLayer.Mean))
            {
                return(new DeterministicDesignVariable <LogNormalDistribution>(saturatedVolumicWeightOfCoverageLayer));
            }

            return(new LogNormalDistributionDesignVariable(saturatedVolumicWeightOfCoverageLayer)
            {
                Percentile = 0.05
            });
        }
Beispiel #9
0
 /// <summary>
 /// Creates the design variable for the total thickness of the aquifer layers at the exit point.
 /// </summary>
 /// <param name="pipingInput">The piping input.</param>
 /// <returns>The created <see cref="DesignVariable{LogNormalDistribution}"/>.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="pipingInput"/> is <c>null</c>.</exception>
 public static DesignVariable <LogNormalDistribution> GetThicknessAquiferLayer(PipingInput pipingInput)
 {
     return(new LogNormalDistributionDesignVariable(DerivedPipingInput.GetThicknessAquiferLayer(pipingInput))
     {
         Percentile = 0.95
     });
 }
Beispiel #10
0
 /// <summary>
 /// Creates the design variable for the Darcy-speed with which water flows through the aquifer layer.
 /// </summary>
 /// <param name="pipingInput">The piping input.</param>
 /// <returns>The created <see cref="VariationCoefficientDesignVariable{VariationCoefficientLogNormalDistribution}"/>.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="pipingInput"/> is <c>null</c>.</exception>
 public static VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> GetDarcyPermeability(PipingInput pipingInput)
 {
     return(new VariationCoefficientLogNormalDistributionDesignVariable(DerivedPipingInput.GetDarcyPermeability(pipingInput))
     {
         Percentile = 0.95
     });
 }
Beispiel #11
0
 /// <summary>
 /// Creates the design variable for the sieve size through which 70% of the grains of the top part of the aquifer pass.
 /// </summary>
 /// <param name="pipingInput">The piping input.</param>
 /// <returns>The created <see cref="VariationCoefficientDesignVariable{VariationCoefficientLogNormalDistribution}"/>.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="pipingInput"/> is <c>null</c>.</exception>
 public static VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> GetDiameter70(PipingInput pipingInput)
 {
     return(new VariationCoefficientLogNormalDistributionDesignVariable(DerivedPipingInput.GetDiameterD70(pipingInput))
     {
         Percentile = 0.05
     });
 }
Beispiel #12
0
        /// <summary>
        /// Creates the design variable for the effective thickness of the coverage layers at the exit point.
        /// </summary>
        /// <param name="pipingInput">The piping input.</param>
        /// <param name="generalInput">The general piping input.</param>
        /// <returns>The created <see cref="DesignVariable{LogNormalDistribution}"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static DesignVariable <LogNormalDistribution> GetEffectiveThicknessCoverageLayer(PipingInput pipingInput, GeneralPipingInput generalInput)
        {
            LogNormalDistribution thicknessCoverageLayer          = DerivedPipingInput.GetThicknessCoverageLayer(pipingInput);
            LogNormalDistribution effectiveThicknessCoverageLayer = DerivedPipingInput.GetEffectiveThicknessCoverageLayer(pipingInput, generalInput);

            if (double.IsNaN(thicknessCoverageLayer.Mean))
            {
                return(new DeterministicDesignVariable <LogNormalDistribution>(effectiveThicknessCoverageLayer));
            }

            return(new LogNormalDistributionDesignVariable(effectiveThicknessCoverageLayer)
            {
                Percentile = 0.05
            });
        }