// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of the DAM Engine.
//
// The DAM Engine is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Linq.Expressions;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.General.Results;
using Deltares.DamEngine.Data.Geotechnics;
using Deltares.DamEngine.Data.Standard.Calculation;
using Deltares.DamEngine.Data.Standard.Language;
using Deltares.DamEngine.Data.Standard.Validation;
namespace Deltares.DamEngine.Data.Design
{
///
/// Does uplift occur or not
///
public struct UpliftSituation
{
public bool IsUplift;
public double Pl3MinUplift;
public double Pl3HeadAdjusted;
public double Pl3LocationXMinUplift;
public double Pl4MinUplift;
public double Pl4HeadAdjusted;
public double Pl4LocationXMinUplift;
}
[Serializable]
public class ScenarioException : Exception
{
public ScenarioException(string message) : base(message)
{
}
}
///
/// Calculation scenario class
///
public class DesignScenario
{
#region Performance optimization: Extract expression so it only has to be generated once.
private static readonly Expression> ExpressionLocationScenarioId = x => x.LocationScenarioID;
private static readonly Expression> ExpressionRiverLevel = x => x.RiverLevel;
private static readonly Expression> ExpressionRiverLevelLow = x => x.RiverLevelLow;
private static readonly Expression> ExpressionDikeTableHeight = x => x.DikeTableHeight;
private static readonly Expression> ExpressionRequiredSafetyFactorStabilityInnerSlope = x => x.RequiredSafetyFactorStabilityInnerSlope;
private static readonly Expression> ExpressionRequiredSafetyFactorStabilityOuterSlope = x => x.RequiredSafetyFactorStabilityOuterSlope;
private static readonly Expression> ExpressionRequiredSafetyFactorPiping = x => x.RequiredSafetyFactorPiping;
private static readonly Expression> ExpressionRequiredProbabilityOfFailurePiping = x => x.RequiredProbabilityOfFailurePiping;
private static readonly Expression> ExpressionUpliftCriterionPiping = x => x.UpliftCriterionPiping;
private static readonly Expression> ExpressionUpliftCriterionStability = x => x.UpliftCriterionStability;
private static readonly Expression> ExpressionPlLineOffsetBelowDikeTopAtRiver = x => x.PlLineOffsetBelowDikeTopAtRiver;
private static readonly Expression> ExpressionPlLineOffsetBelowDikeTopAtPolder = x => x.PlLineOffsetBelowDikeTopAtPolder;
private static readonly Expression> ExpressionPlLineOffsetBelowShoulderBaseInside = x => x.PlLineOffsetBelowShoulderBaseInside;
private static readonly Expression> ExpressionPlLineOffsetBelowDikeToeAtPolder = x => x.PlLineOffsetBelowDikeToeAtPolder;
private static readonly Expression> ExpressionUsePlLineOffsetBelowDikeCrestMiddle = x => x.UsePlLineOffsetBelowDikeCrestMiddle;
private static readonly Expression> ExpressionPlLineOffsetBelowDikeCrestMiddle = x => x.PlLineOffsetBelowDikeCrestMiddle;
private static readonly Expression> ExpressionUsePlLineOffsetFactorBelowShoulderCrest = x => x.UsePlLineOffsetFactorBelowShoulderCrest;
private static readonly Expression> ExpressionPlLineOffsetFactorBelowShoulderCrest = x => x.PlLineOffsetFactorBelowShoulderCrest;
private static readonly Expression> ExpressionHeadPl3 = x => x.HeadPl3;
private static readonly Expression> ExpressionHeadPl4 = x => x.HeadPl4;
private static readonly Expression> ExpressionWaterHeightDecimeringsHoogte = x => x.WaterHeightDecimeringsHoogte;
private static readonly Expression> ExpressionMaxWaterLevel = x => x.MaxWaterLevel;
#endregion
private CalculationResult calculationResult = CalculationResult.NoRun;
private Location location = null;
private readonly List calculationResults = new List();
private Dictionary stabilityUpliftSituations;
private Dictionary pipingResults;
private Dictionary mStabResults;
private Dictionary failureProbabilitiesStability;
private Dictionary safetyFactorsPiping;
private Dictionary failureProbabilitiesPiping;
private Dictionary redesignedSurfaceLines;
private Dictionary resultMessages;
private string locationScenarioId;
private double riverLevel;
private double? riverLevelLow;
private double? dikeTableHeight;
private double? plLineOffsetBelowDikeTopAtRiver;
private double? plLineOffsetBelowDikeTopAtPolder;
private double? plLineOffsetBelowShoulderBaseInside;
private double? plLineOffsetBelowDikeToeAtPolder;
private bool? usePlLineOffsetBelowDikeCrestMiddle;
private double? plLineOffsetBelowDikeCrestMiddle;
private bool? usePlLineOffsetFactorBelowShoulderCrest;
private double? plLineOffsetFactorBelowShoulderCrest;
private double? headPl3;
private double? headPl4;
private double? waterHeightDecimeringsHoogte;
private double? maxWaterLevel;
public CalculationResult CalculationResult
{
get { return calculationResult; }
set { calculationResult = value; }
}
public IList NwoResults { get; set; }
public List CalculationResults
{
get { return calculationResults; }
}
///
/// Constructor
///
public DesignScenario()
{
ClearResults();
ClearErrors();
ClearstabilityUpliftSituations();
ModelFactors = new ModelFactors();
}
///
/// Clears the results
///
public void ClearstabilityUpliftSituations()
{
stabilityUpliftSituations = new Dictionary();
}
///
/// Clears the errors.
///
public void ClearErrors()
{
Errors = new StringCollection();
}
///
/// Clears the results
///
public void ClearResults()
{
calculationResult = CalculationResult.NoRun;
pipingResults = new Dictionary();
mStabResults = new Dictionary();
safetyFactorsPiping = new Dictionary();
resultMessages = new Dictionary();
failureProbabilitiesStability = new Dictionary();
failureProbabilitiesPiping = new Dictionary();
redesignedSurfaceLines = new Dictionary();
NwoResults = new List();
calculationResults.Clear();
}
///
/// Gets or sets the location scenario identifier.
///
///
/// The location scenario identifier.
///
public string LocationScenarioID
{
get
{
return locationScenarioId;
}
set
{
locationScenarioId = value;
}
}
[Browsable(false)]
public StringCollection Errors { get; private set; }
///
/// Gets or sets the river level.
///
///
/// The river level.
///
[Description("River level")]
public double RiverLevel
{
get
{
return riverLevel;
}
set
{
riverLevel = value;
}
}
///
/// Gets or sets the river level low.
///
///
/// The river level low.
///
[Description("River level low")]
public double? RiverLevelLow
{
get
{
return riverLevelLow;
}
set
{
riverLevelLow = value;
}
}
///
/// Gets or sets the height of the dike table.
///
///
/// The height of the dike table.
///
[Description("Dike table height")]
public double? DikeTableHeight
{
get
{
return dikeTableHeight;
}
set
{
dikeTableHeight = value;
}
}
///
/// Gets or sets the required safety factor stability inner slope.
///
///
/// The required safety factor stability inner slope.
///
[Description("Required safety factor stability inner slope")]
public double? RequiredSafetyFactorStabilityInnerSlope
{
get { return ModelFactors.RequiredSafetyFactorStabilityInnerSlope; }
set
{
ModelFactors.RequiredSafetyFactorStabilityInnerSlope = value;
}
}
///
/// Gets or sets the required safety factor stability outer slope.
///
///
/// The required safety factor stability outer slope.
///
[Description("Required safety factor stability outer slope")]
public double? RequiredSafetyFactorStabilityOuterSlope
{
get { return ModelFactors.RequiredSafetyFactorStabilityOuterSlope; }
set
{
ModelFactors.RequiredSafetyFactorStabilityOuterSlope = value;
}
}
///
/// Gets or sets the required safety factor piping.
///
///
/// The required safety factor piping.
///
[Description("Required safety factor piping")]
public double? RequiredSafetyFactorPiping
{
get { return ModelFactors.RequiredSafetyFactorPiping; }
set
{
ModelFactors.RequiredSafetyFactorPiping = value;
}
}
///
/// Gets or sets the required probability of failure piping.
///
///
/// The required probability of failure piping.
///
[Description("Required probability of failure piping")]
public double? RequiredProbabilityOfFailurePiping
{
get { return ModelFactors.RequiredProbabilityOfFailurePiping; }
set
{
ModelFactors.RequiredProbabilityOfFailurePiping = value;
}
}
///
/// Gets or sets the uplift criterion piping.
///
///
/// The uplift criterion piping.
///
[Description("Uplift criterion piping")]
public double? UpliftCriterionPiping
{
get { return ModelFactors.UpliftCriterionPiping; }
set
{
ModelFactors.UpliftCriterionPiping = value;
}
}
///
/// Gets or sets the uplift criterion stability.
///
///
/// The uplift criterion stability.
///
[Description("Uplift criterion stability")]
public double? UpliftCriterionStability
{
get { return ModelFactors.UpliftCriterionStability; }
set
{
ModelFactors.UpliftCriterionStability = value;
}
}
public double? PlLineOffsetBelowDikeTopAtRiver
{
get
{
return plLineOffsetBelowDikeTopAtRiver;
}
set
{
plLineOffsetBelowDikeTopAtRiver = value;
}
}
///
/// Gets or sets the pl line offset below dike top at polder.
///
///
/// The pl line offset below dike top at polder.
///
public double? PlLineOffsetBelowDikeTopAtPolder
{
get
{
return plLineOffsetBelowDikeTopAtPolder;
}
set
{
plLineOffsetBelowDikeTopAtPolder = value;
}
}
///
/// Gets or sets the pl line offset below shoulder base inside.
///
///
/// The pl line offset below shoulder base inside.
///
public double? PlLineOffsetBelowShoulderBaseInside
{
get
{
return plLineOffsetBelowShoulderBaseInside;
}
set
{
plLineOffsetBelowShoulderBaseInside = value;
}
}
///
/// Gets or sets the pl line offset below dike toe at polder.
///
///
/// The pl line offset below dike toe at polder.
///
public double? PlLineOffsetBelowDikeToeAtPolder
{
get
{
return plLineOffsetBelowDikeToeAtPolder;
}
set
{
plLineOffsetBelowDikeToeAtPolder = value;
}
}
///
/// Gets or sets the use pl line offset below dike crest middle.
///
///
/// The use pl line offset below dike crest middle.
///
public bool? UsePlLineOffsetBelowDikeCrestMiddle
{
get
{
return usePlLineOffsetBelowDikeCrestMiddle;
}
set
{
usePlLineOffsetBelowDikeCrestMiddle = value;
}
}
///
/// Gets or sets the pl line offset below dike crest middle.
///
///
/// The pl line offset below dike crest middle.
///
public double? PlLineOffsetBelowDikeCrestMiddle
{
get { return plLineOffsetBelowDikeCrestMiddle; }
set
{
plLineOffsetBelowDikeCrestMiddle = value;
}
}
///
/// Gets or sets the use pl line offset factor below shoulder crest.
///
///
/// The use pl line offset factor below shoulder crest.
///
public bool? UsePlLineOffsetFactorBelowShoulderCrest
{
get
{
return usePlLineOffsetFactorBelowShoulderCrest;
}
set
{
usePlLineOffsetFactorBelowShoulderCrest = value;
}
}
///
/// Gets or sets the pl line offset factor below shoulder crest.
///
///
/// The pl line offset factor below shoulder crest.
///
public double? PlLineOffsetFactorBelowShoulderCrest
{
get { return plLineOffsetFactorBelowShoulderCrest; }
set
{
plLineOffsetFactorBelowShoulderCrest = value;
}
}
///
/// Gets or sets the head PL3.
///
///
/// The head PL3.
///
public double? HeadPl3
{
get
{
return headPl3;
}
set
{
headPl3 = value;
}
}
///
/// Gets or sets the head PL4.
///
///
/// The head PL4.
///
public double? HeadPl4
{
get
{
return headPl4;
}
set
{
headPl4 = value;
}
}
///
/// Gets or sets the water height decimerings hoogte.
///
///
/// The water height decimerings hoogte.
///
public double? WaterHeightDecimeringsHoogte
{
get
{
return waterHeightDecimeringsHoogte;
}
set
{
waterHeightDecimeringsHoogte = value;
}
}
///
/// Gets or sets the maximum water level.
///
///
/// The maximum water level.
///
public double? MaxWaterLevel
{
get
{
return maxWaterLevel;
}
set
{
maxWaterLevel = value;
}
}
///
/// Gets or sets the model factors.
///
///
/// The model factors.
///
public ModelFactors ModelFactors { get; set; }
/// Aggregation relationship.
public Location Location
{
get { return location; }
set { location = value; }
}
///
/// Get uplift criterion for this scenario; return default value if not available
///
/// default value if not available
/// uplift criterion for this scenario
public double GetUpliftCriterionStability(double? defaultUpliftCriterionStability)
{
if ((defaultUpliftCriterionStability == null) && (ModelFactors.UpliftCriterionStability == null))
{
throw new ScenarioException(String.Format(LocalizationManager.GetTranslatedText(this, "NoUpliftCriterionForStability"), Location.Name, ToString()));
}
return (ModelFactors.UpliftCriterionStability == null ? defaultUpliftCriterionStability.Value
: ModelFactors.UpliftCriterionStability.Value);
}
///
/// Get uplift criterion for this scenario; return default value if not available
///
/// default value if not available
/// uplift criterion for this scenario
public double GetUpliftCriterionPiping(double? defaultUpliftCriterionPiping)
{
if ((defaultUpliftCriterionPiping == null) && (ModelFactors.UpliftCriterionPiping == null))
{
throw new ScenarioException(String.Format(LocalizationManager.GetTranslatedText(this, "NoUpliftCriterionForPiping"), Location.Name, ToString()));
}
return (ModelFactors.UpliftCriterionPiping == null ? defaultUpliftCriterionPiping.Value : ModelFactors.UpliftCriterionPiping.Value);
}
///
/// Get required safety factor for this scenario; return default value if not available
///
/// default value if not available
/// uplift criterion for this scenario
public double GetRequiredSafetyFactorPiping(double? defaultRequiredSafetyFactorPiping)
{
if ((defaultRequiredSafetyFactorPiping == null) && (ModelFactors.RequiredSafetyFactorPiping == null))
{
throw new ScenarioException(String.Format(LocalizationManager.GetTranslatedText(this, "NoRequiredSafetyFactorPiping"), Location.Name, ToString()));
}
return (ModelFactors.RequiredSafetyFactorPiping == null ? defaultRequiredSafetyFactorPiping.Value : ModelFactors.RequiredSafetyFactorPiping.Value);
}
///
/// Determines whether [is pl line offset factor below shoulder crest valid].
///
///
[Validate]
public ValidationResult[] IsPlLineOffsetFactorBelowShoulderCrestValid()
{
if (UsePlLineOffsetFactorBelowShoulderCrest.HasValue && UsePlLineOffsetFactorBelowShoulderCrest.Value &&
PlLineOffsetFactorBelowShoulderCrest.HasValue)
{
if (PlLineOffsetFactorBelowShoulderCrest.Value < DamGlobalConstants.PlLineOffsetFactorBelowShoulderCrestMinValue)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "PlLineOffsetFactorBelowShoulderCrestTooSmall"),
this)
};
}
if (PlLineOffsetFactorBelowShoulderCrest.Value > DamGlobalConstants.PlLineOffsetFactorBelowShoulderCrestMaxValue)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "PlLineOffsetFactorBelowShoulderCrestTooLarge"),
this)
};
}
}
return new ValidationResult[0];
}
///
/// Get stability uplift situation
///
///
///
private UpliftSituation? GetStabilityUpliftSituation(Object objectAsKey)
{
return objectAsKey != null && stabilityUpliftSituations.ContainsKey(objectAsKey) ? stabilityUpliftSituations[objectAsKey] : null;
}
///
/// Get stability uplift situation
///
///
///
///
public UpliftSituation? GetStabilityUpliftSituation(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetStabilityUpliftSituation(objectAsKey);
}
///
/// Set stability uplift situation
///
///
///
private void SetStabilityUpliftSituation(Object objectAsKey, UpliftSituation upliftSituation)
{
stabilityUpliftSituations[objectAsKey] = upliftSituation;
}
///
/// Set stability uplift situation
///
///
///
///
public void SetStabilityUpliftSituation(SoilProfile1D soilProfile, string soilGeometry2DName, UpliftSituation upliftSituation)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetStabilityUpliftSituation(objectAsKey, upliftSituation);
}
///
/// Get PipingResults
///
///
///
private PipingResults? GetPipingResults(Object objectAsKey)
{
if (objectAsKey != null)
{
return pipingResults.ContainsKey(objectAsKey) ? pipingResults[objectAsKey] : null;
}
return null;
}
///
/// Get PipingResults
///
///
///
///
public PipingResults? GetPipingResults(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetPipingResults(objectAsKey);
}
///
/// Set PipingResults
///
///
///
private void SetPipingResults(Object objectAsKey, PipingResults? pipingResults)
{
this.pipingResults[objectAsKey] = pipingResults;
}
///
/// Set PipingResults
///
///
///
///
public void SetPipingResults(SoilProfile1D soilProfile, string soilGeometry2DName, PipingResults? pipingResults)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetPipingResults(objectAsKey, pipingResults);
}
///
/// Get MStabResults
///
///
///
private MStabResults? GetMStabResults(Object objectAsKey)
{
if (objectAsKey != null)
{
return mStabResults.ContainsKey(objectAsKey) ? mStabResults[objectAsKey] : null;
}
return null;
}
///
/// Get MStabResults
///
///
///
///
public MStabResults? GetMStabResults(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetMStabResults(objectAsKey);
}
///
/// Set MStabResults
///
///
///
private void SetMStabResults(Object objectAsKey, MStabResults? mStabResults)
{
this.mStabResults[objectAsKey] = mStabResults;
}
///
/// Set MStabResults
///
///
///
///
public void SetMStabResults(SoilProfile1D soilProfile, string soilGeometry2DName, MStabResults? mStabResults)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetMStabResults(objectAsKey, mStabResults);
}
///
/// Get Safety Factor Piping
///
///
///
private double? GetSafetyFactorPiping(Object objectAsKey)
{
if (objectAsKey != null)
{
return safetyFactorsPiping.ContainsKey(objectAsKey) ? safetyFactorsPiping[objectAsKey] : null;
}
return null;
}
///
/// Get Safety Factor Piping
///
///
///
///
public double? GetSafetyFactorPiping(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetSafetyFactorPiping(objectAsKey);
}
///
/// Set Safety Factor Piping
///
///
///
private void SetSafetyFactorPiping(Object objectAsKey, double? safetyFactor)
{
safetyFactorsPiping[objectAsKey] = safetyFactor;
}
///
/// Set Safety Factor Piping
///
///
///
///
public void SetSafetyFactorPiping(SoilProfile1D soilProfile, string soilGeometry2DName, double? safetyFactor)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetSafetyFactorPiping(objectAsKey, safetyFactor);
}
///
/// Get Failure Probability piping
///
///
///
private double? GetFailureProbabilityPiping(Object objectAsKey)
{
if (objectAsKey != null)
{
return failureProbabilitiesPiping.ContainsKey(objectAsKey) ? failureProbabilitiesPiping[objectAsKey] : null;
}
return null;
}
///
/// Get Failure Probability piping
///
///
///
///
public double? GetFailureProbabilityPiping(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetFailureProbabilityPiping(objectAsKey);
}
///
/// Set Failure Probability piping
///
///
///
///
public void SetFailureProbabilityPiping(SoilProfile1D soilProfile, string soilGeometry2DName, double? failureProbability)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetFailureProbabilityPiping(objectAsKey, failureProbability);
}
///
/// Set Failure Probability piping
///
///
///
private void SetFailureProbabilityPiping(Object objectAsKey, double? failureProbability)
{
failureProbabilitiesPiping[objectAsKey] = failureProbability;
}
///
/// Get Result Message
///
///
///
private string GetResultMessage(Object objectAsKey)
{
if (objectAsKey != null)
{
return resultMessages.ContainsKey(objectAsKey) ? resultMessages[objectAsKey] : null;
}
return null;
}
///
/// Get Result Message
///
///
///
///
public string GetResultMessage(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetResultMessage(objectAsKey);
}
///
/// Set Result Message
///
///
///
private void SetResultMessage(Object objectAsKey, string resultMessage)
{
resultMessages[objectAsKey] = resultMessage;
}
///
/// Set Result Message
///
///
///
///
public void SetResultMessage(SoilProfile1D soilProfile, string soilGeometry2DName, string resultMessage)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetResultMessage(objectAsKey, resultMessage);
}
///
/// Return the safety factor for calculation type of most probable soil profile
///
///
///
public double? GetMostProbableSafetyFactor(FailureMechanismSystemType? failureMechanismType)
{
SoilProfile1D soilProfile = Location.Segment.GetMostProbableProfile(failureMechanismType);
string soilGeometry2DName = Location.Segment.GetMostProbableGeometry2DName(failureMechanismType);
switch (failureMechanismType)
{
case FailureMechanismSystemType.Piping:
return GetSafetyFactorPiping(soilProfile, soilGeometry2DName);
case FailureMechanismSystemType.StabilityInside:
case FailureMechanismSystemType.StabilityOutside:
MStabResults? mstabResults = GetMStabResults(soilProfile, soilGeometry2DName);
double? safetyFactor = null;
if (mstabResults != null)
{
safetyFactor = mstabResults.Value.zone1.safetyFactor;
}
return safetyFactor;
}
return null;
}
///
/// Return probability stability
///
///
///
private double? GetFailureProbabilityStability(Object objectAsKey)
{
if (objectAsKey != null)
{
return failureProbabilitiesStability.ContainsKey(objectAsKey) ? failureProbabilitiesStability[objectAsKey] : null;
}
return null;
}
///
/// Return probability stability
///
///
///
///
public double? GetFailureProbabilityStability(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetFailureProbabilityStability(objectAsKey);
}
///
/// Set probability stability
///
///
///
private void SetFailureProbabilityStability(Object objectAsKey, double? failureProbability)
{
failureProbabilitiesStability[objectAsKey] = failureProbability;
}
///
/// Set probability stability
///
///
///
///
public void SetFailureProbabilityStability(SoilProfile1D soilProfile, string soilGeometry2DName, double? failureProbability)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetFailureProbabilityStability(objectAsKey, failureProbability);
}
///
/// Get Redesigned surfaceline
///
///
///
private SurfaceLine2 GetRedesignedSurfaceLine(Object objectAsKey)
{
if (objectAsKey != null)
{
return redesignedSurfaceLines.ContainsKey(objectAsKey) ? redesignedSurfaceLines[objectAsKey] : null;
}
return null;
}
///
/// Get Redesigned surfaceline
///
///
///
///
public SurfaceLine2 GetRedesignedSurfaceLine(SoilProfile1D soilProfile, string soilGeometry2DName)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
return GetRedesignedSurfaceLine(objectAsKey);
}
///
/// Set Redesigned surfaceline
///
///
///
private void SetRedesignedSurfaceLine(Object objectAsKey, SurfaceLine2 surfaceLine)
{
redesignedSurfaceLines[objectAsKey] = surfaceLine;
}
///
/// Set Redesigned surfaceline
///
///
///
///
public void SetRedesignedSurfaceLine(SoilProfile1D soilProfile, string soilGeometry2DName, SurfaceLine2 surfaceLine)
{
Object objectAsKey = GetObjectAsKey(soilProfile, soilGeometry2DName);
SetRedesignedSurfaceLine(objectAsKey, surfaceLine);
}
///
/// Get Most recent surfaceline
///
///
///
private SurfaceLine2 GetMostRecentSurfaceLine(Object objectAsKey)
{
if (objectAsKey != null)
{
return redesignedSurfaceLines.ContainsKey(objectAsKey) ? redesignedSurfaceLines[objectAsKey] ?? Location.LocalXZSurfaceLine2 : Location.LocalXZSurfaceLine2;
}
return null;
}
///
/// Get Most recent surfaceline
///
///
///
///
public SurfaceLine2 GetMostRecentSurfaceLine(SoilProfile soilProfile, string soilGeometry2DName)
{
var profile1D = soilProfile as SoilProfile1D;
Object objectAsKey = GetObjectAsKey(profile1D, soilGeometry2DName);
return GetMostRecentSurfaceLine(objectAsKey);
}
///
/// Determine object key based on either 1d-soilprofile or 2d-geometry
///
///
///
///
///
private Object GetObjectAsKey(SoilProfile1D soilProfile, string soilGeometry2DName)
{
if (soilProfile != null)
{
return soilProfile;
}
return soilGeometry2DName;
}
///
/// Implementation of ToString
///
///
public override string ToString()
{
return String.Format("Location={0}, ID={1} RiverLevel={2} RiverLevelLow={3} DikeTableHeight={4} SafetyFactorStabilityInnerSlope={5} RequiredSafetyFactorStabilityOuterSlope={6} WaterHeightDecimeringsHoogte= {7} MaxWaterheight={8} ProbabilityOfFailureStabilityInnerslope={9} ProbabilityOfFailurePiping={10} PlLineOffsetBelowDikeTopAtRiver={11} PlLineOffsetBelowDikeToeAtPolder={12} PlLineOffsetBelowDikeTopAtPolder={13} PlLineOffsetBelowShoulderBaseInside={14} UsePlLineOffsetBelowDikeCrestMiddle {15} PlLineOffsetBelowDikeCrestMiddle {16} UsePlLineOffsetFactorBelowShoulderCrest {17} PlLineOffsetFactorBelowShoulderCrest {18} HeadPl3={19} HeadPl4={20}",
Location.Name, LocationScenarioID, RiverLevel,
RiverLevelLow.HasValue ? RiverLevelLow.ToString() : "?",
DikeTableHeight.HasValue ? DikeTableHeight.ToString() : "?",
ModelFactors.RequiredSafetyFactorStabilityInnerSlope.HasValue ? ModelFactors.RequiredSafetyFactorStabilityInnerSlope.ToString() : "?",
ModelFactors.RequiredSafetyFactorStabilityOuterSlope.HasValue ? ModelFactors.RequiredSafetyFactorStabilityOuterSlope.ToString() : "?",
WaterHeightDecimeringsHoogte.HasValue ? WaterHeightDecimeringsHoogte.ToString() : "?",
MaxWaterLevel.HasValue ? MaxWaterLevel.ToString() : "?",
ModelFactors.RequiredProbabilityOfFailureStabilityInnerslope.HasValue ? ModelFactors.RequiredProbabilityOfFailureStabilityInnerslope.ToString() : "?",
ModelFactors.RequiredProbabilityOfFailurePiping.HasValue ? ModelFactors.RequiredProbabilityOfFailurePiping.ToString() : "?",
PlLineOffsetBelowDikeTopAtRiver.HasValue ? PlLineOffsetBelowDikeToeAtPolder.ToString() : "?",
PlLineOffsetBelowDikeToeAtPolder.HasValue ? MaxWaterLevel.ToString() : "?",
PlLineOffsetBelowDikeTopAtPolder.HasValue ? PlLineOffsetBelowDikeTopAtPolder.ToString() : "?",
PlLineOffsetBelowShoulderBaseInside.HasValue ? PlLineOffsetBelowShoulderBaseInside.ToString() : "?",
UsePlLineOffsetBelowDikeCrestMiddle.HasValue ? UsePlLineOffsetBelowDikeCrestMiddle.ToString() : "?",
PlLineOffsetBelowDikeCrestMiddle.HasValue ? PlLineOffsetBelowDikeCrestMiddle.ToString() : "?",
UsePlLineOffsetFactorBelowShoulderCrest.HasValue ? UsePlLineOffsetFactorBelowShoulderCrest.ToString() : "?",
PlLineOffsetFactorBelowShoulderCrest.HasValue ? PlLineOffsetFactorBelowShoulderCrest.ToString() : "?",
HeadPl3.HasValue ? HeadPl3.ToString() : "?",
HeadPl4.HasValue ? HeadPl4.ToString() : "?");
}
///
/// Determine waterlevels based on waterlevel, max waterlevel and decimeringshoogte
///
///
public double[] DetermineProperWaterlevelsForProbabilisticAdvanced()
{
double[] waterLevels = new double[3];
waterLevels[0] = (double)MaxWaterLevel;
waterLevels[1] = (double)MaxWaterLevel;
waterLevels[2] = (double)MaxWaterLevel;
if (MaxWaterLevel > RiverLevel + WaterHeightDecimeringsHoogte)
{
waterLevels[0] = (double)(RiverLevel + WaterHeightDecimeringsHoogte);
waterLevels[1] = (double)RiverLevel;
waterLevels[2] = (double)(RiverLevel - WaterHeightDecimeringsHoogte);
}
else
{
if (MaxWaterLevel > RiverLevel)
{
waterLevels[0] = (double)MaxWaterLevel;
waterLevels[1] = (double)RiverLevel;
waterLevels[2] = (double)(RiverLevel - WaterHeightDecimeringsHoogte);
}
else
{
if (MaxWaterLevel > RiverLevel - WaterHeightDecimeringsHoogte)
{
waterLevels[0] = (double)MaxWaterLevel;
waterLevels[1] = (double)MaxWaterLevel;
waterLevels[2] = (double)(RiverLevel - WaterHeightDecimeringsHoogte);
}
}
}
return waterLevels;
}
public Dictionary GetParametersAsNameValuePairs()
{
var numberFormatInfo = new NumberFormatInfo();
numberFormatInfo.NumberDecimalSeparator = ".";
var nameValuePairs = new Dictionary();
nameValuePairs.Add(ScenarioParameterNames.LocationScenarioId, LocationScenarioID);
nameValuePairs.Add(ScenarioParameterNames.RiverLevel, RiverLevel.ToString(numberFormatInfo));
if (RiverLevelLow != null)
{
nameValuePairs.Add(ScenarioParameterNames.RiverLevelLow, RiverLevelLow.Value.ToString(numberFormatInfo));
}
if (DikeTableHeight != null)
{
nameValuePairs.Add(ScenarioParameterNames.DikeTableHeight, DikeTableHeight.Value.ToString(numberFormatInfo));
}
if (WaterHeightDecimeringsHoogte != null)
{
nameValuePairs.Add(ScenarioParameterNames.WaterHeightDecimeringsHoogte, WaterHeightDecimeringsHoogte.Value.ToString(numberFormatInfo));
}
if (MaxWaterLevel != null)
{
nameValuePairs.Add(ScenarioParameterNames.MaxWaterLevel, MaxWaterLevel.Value.ToString(numberFormatInfo));
}
if (ModelFactors != null)
{
if (ModelFactors.RequiredSafetyFactorStabilityInnerSlope != null)
{
nameValuePairs.Add(ScenarioParameterNames.RequiredSafetyFactorStabilityInnerSlope, ModelFactors.RequiredSafetyFactorStabilityInnerSlope.Value.ToString(numberFormatInfo));
}
if (ModelFactors.RequiredSafetyFactorStabilityOuterSlope != null)
{
nameValuePairs.Add(ScenarioParameterNames.RequiredSafetyFactorStabilityOuterSlope, ModelFactors.RequiredSafetyFactorStabilityOuterSlope.Value.ToString(numberFormatInfo));
}
if (ModelFactors.RequiredSafetyFactorPiping != null)
{
nameValuePairs.Add(ScenarioParameterNames.RequiredSafetyFactorPiping, ModelFactors.RequiredSafetyFactorPiping.Value.ToString(numberFormatInfo));
}
if (ModelFactors.RequiredProbabilityOfFailureStabilityInnerslope != null)
{
nameValuePairs.Add(ScenarioParameterNames.RequiredProbabilityOfFailureStabilityInnerslope, ModelFactors.RequiredProbabilityOfFailureStabilityInnerslope.Value.ToString(numberFormatInfo));
}
if (ModelFactors.RequiredProbabilityOfFailureStabilityOuterslope != null)
{
nameValuePairs.Add(ScenarioParameterNames.RequiredProbabilityOfFailureStabilityOuterslope, ModelFactors.RequiredProbabilityOfFailureStabilityOuterslope.Value.ToString(numberFormatInfo));
}
if (ModelFactors.RequiredProbabilityOfFailurePiping != null)
{
nameValuePairs.Add(ScenarioParameterNames.RequiredProbabilityOfFailurePiping, ModelFactors.RequiredProbabilityOfFailurePiping.Value.ToString(numberFormatInfo));
}
if (ModelFactors.UpliftCriterionPiping != null)
{
nameValuePairs.Add(ScenarioParameterNames.UpliftCriterionPiping, ModelFactors.UpliftCriterionPiping.Value.ToString(numberFormatInfo));
}
if (ModelFactors.UpliftCriterionStability != null)
{
nameValuePairs.Add(ScenarioParameterNames.UpliftCriterionStability, ModelFactors.UpliftCriterionStability.Value.ToString(numberFormatInfo));
}
}
if (PlLineOffsetBelowDikeTopAtRiver != null)
{
nameValuePairs.Add(ScenarioParameterNames.PlLineOffsetBelowDikeTopAtRiver, PlLineOffsetBelowDikeTopAtRiver.Value.ToString(numberFormatInfo));
}
if (PlLineOffsetBelowDikeTopAtPolder != null)
{
nameValuePairs.Add(ScenarioParameterNames.PlLineOffsetBelowDikeTopAtPolder, PlLineOffsetBelowDikeTopAtPolder.Value.ToString(numberFormatInfo));
}
if (PlLineOffsetBelowShoulderBaseInside != null)
{
nameValuePairs.Add(ScenarioParameterNames.PlLineOffsetBelowShoulderBaseInside, PlLineOffsetBelowShoulderBaseInside.Value.ToString(numberFormatInfo));
}
if (PlLineOffsetBelowDikeToeAtPolder != null)
{
nameValuePairs.Add(ScenarioParameterNames.PlLineOffsetBelowDikeToeAtPolder, PlLineOffsetBelowDikeToeAtPolder.Value.ToString(numberFormatInfo));
}
if (PlLineOffsetBelowDikeCrestMiddle != null)
{
nameValuePairs.Add(ScenarioParameterNames.PlLineOffsetBelowDikeCrestMiddle, PlLineOffsetBelowDikeCrestMiddle.Value.ToString(numberFormatInfo));
}
if (PlLineOffsetFactorBelowShoulderCrest != null)
{
nameValuePairs.Add(ScenarioParameterNames.PlLineOffsetFactorBelowShoulderCrest, PlLineOffsetFactorBelowShoulderCrest.Value.ToString(numberFormatInfo));
}
if (UsePlLineOffsetBelowDikeCrestMiddle != null)
{
nameValuePairs.Add(ScenarioParameterNames.UsePlLineOffsetBelowDikeCrestMiddle, UsePlLineOffsetBelowDikeCrestMiddle.Value.ToString());
}
if (UsePlLineOffsetFactorBelowShoulderCrest != null)
{
nameValuePairs.Add(ScenarioParameterNames.UsePlLineOffsetFactorBelowShoulderCrest, UsePlLineOffsetFactorBelowShoulderCrest.Value.ToString());
}
if (HeadPl3 != null)
{
nameValuePairs.Add(ScenarioParameterNames.HeadPl3, HeadPl3.Value.ToString(numberFormatInfo));
}
if (HeadPl4 != null)
{
nameValuePairs.Add(ScenarioParameterNames.HeadPl4, HeadPl4.Value.ToString(numberFormatInfo));
}
return nameValuePairs;
}
public void SetParameterFromNameValuePair(string parameterName, string parameterValue)
{
var numberFormatInfo = new NumberFormatInfo();
numberFormatInfo.NumberDecimalSeparator = ".";
if (parameterName.Equals(ScenarioParameterNames.LocationScenarioId))
LocationScenarioID = parameterValue;
if (parameterName.Equals(ScenarioParameterNames.RiverLevel))
RiverLevel = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RiverLevelLow))
RiverLevelLow = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.DikeTableHeight))
DikeTableHeight = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.WaterHeightDecimeringsHoogte))
WaterHeightDecimeringsHoogte = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.MaxWaterLevel))
MaxWaterLevel = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RequiredSafetyFactorStabilityInnerSlope))
ModelFactors.RequiredSafetyFactorStabilityInnerSlope = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RequiredSafetyFactorStabilityOuterSlope))
ModelFactors.RequiredSafetyFactorStabilityOuterSlope = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RequiredSafetyFactorPiping))
ModelFactors.RequiredSafetyFactorPiping = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RequiredProbabilityOfFailureStabilityInnerslope))
ModelFactors.RequiredProbabilityOfFailureStabilityInnerslope = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RequiredProbabilityOfFailureStabilityOuterslope))
ModelFactors.RequiredProbabilityOfFailureStabilityOuterslope = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.RequiredProbabilityOfFailurePiping))
ModelFactors.RequiredProbabilityOfFailurePiping = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.UpliftCriterionPiping))
ModelFactors.UpliftCriterionPiping = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.UpliftCriterionStability))
ModelFactors.UpliftCriterionStability = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.PlLineOffsetBelowDikeTopAtRiver))
PlLineOffsetBelowDikeTopAtRiver = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.PlLineOffsetBelowDikeTopAtPolder))
PlLineOffsetBelowDikeTopAtPolder = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.PlLineOffsetBelowShoulderBaseInside))
PlLineOffsetBelowShoulderBaseInside = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.PlLineOffsetBelowDikeToeAtPolder))
PlLineOffsetBelowDikeToeAtPolder = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.PlLineOffsetBelowDikeCrestMiddle))
PlLineOffsetBelowDikeCrestMiddle = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.PlLineOffsetFactorBelowShoulderCrest))
PlLineOffsetFactorBelowShoulderCrest = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.UsePlLineOffsetBelowDikeCrestMiddle))
UsePlLineOffsetBelowDikeCrestMiddle = Convert.ToBoolean(parameterValue);
if (parameterName.Equals(ScenarioParameterNames.UsePlLineOffsetFactorBelowShoulderCrest))
UsePlLineOffsetFactorBelowShoulderCrest = Convert.ToBoolean(parameterValue);
if (parameterName.Equals(ScenarioParameterNames.HeadPl3))
HeadPl3 = Convert.ToDouble(parameterValue, numberFormatInfo);
if (parameterName.Equals(ScenarioParameterNames.HeadPl4))
HeadPl4 = Convert.ToDouble(parameterValue, numberFormatInfo);
}
}
public static class ScenarioParameterNames
{
public const string LocationScenarioId = "LocationScenarioId";
public const string RiverLevel = "RiverLevel";
public const string RiverLevelLow = "RiverLevelLow";
public const string DikeTableHeight = "DikeTableHeight";
public const string WaterHeightDecimeringsHoogte = "WaterHeightDecimeringsHoogte";
public const string MaxWaterLevel = "MaxWaterLevel";
public const string RequiredSafetyFactorStabilityInnerSlope = "RequiredSafetyFactorStabilityInnerSlope";
public const string RequiredSafetyFactorStabilityOuterSlope = "RequiredSafetyFactorStabilityOuterSlope";
public const string RequiredSafetyFactorPiping = "RequiredSafetyFactorPiping";
public const string RequiredProbabilityOfFailureStabilityInnerslope = "RequiredProbabilityOfFailureStabilityInnerslope";
public const string RequiredProbabilityOfFailureStabilityOuterslope = "RequiredProbabilityOfFailureStabilityOuterslope";
public const string RequiredProbabilityOfFailurePiping = "RequiredProbabilityOfFailurePiping";
public const string UpliftCriterionPiping = "UpliftCriterionPiping";
public const string UpliftCriterionStability = "UpliftCriterionStability";
public const string PlLineOffsetBelowDikeTopAtRiver = "PLLineOffsetBelowDikeTopAtRiver";
public const string PlLineOffsetBelowDikeTopAtPolder = "PLLineOffsetBelowDikeTopAtPolder";
public const string PlLineOffsetBelowShoulderBaseInside = "PLLineOffsetBelowShoulderBaseInside";
public const string PlLineOffsetBelowDikeToeAtPolder = "PLLineOffsetBelowDikeToeAtPolder";
public const string PlLineOffsetBelowDikeCrestMiddle = "PlLineOffsetBelowDikeCrestMiddle";
public const string PlLineOffsetFactorBelowShoulderCrest = "PlLineOffsetFactorBelowShoulderCrest";
public const string UsePlLineOffsetBelowDikeCrestMiddle = "UsePlLineOffsetBelowDikeCrestMiddle";
public const string UsePlLineOffsetFactorBelowShoulderCrest = "UsePlLineOffsetFactorBelowShoulderCrest";
public const string HeadPl3 = "HeadPL3";
public const string HeadPl4 = "HeadPL4";
}
}