Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.42 KB | None | 0 0
  1.     Drivers driver = Drivers.Marine;//this.riskForm.Driver;
  2.     CoatingQualities coatingQuality = CoatingQualities.Medium;//this.riskForm.CoatingQuality;
  3.     InsulationTypes insulationType = InsulationTypes.MineralWool;//this.riskForm.InsulationType;
  4.     InsulationConditions insulationCondition = InsulationConditions.Average;//this.riskForm.InsulationCondition;
  5.     Complexities complexity = Complexities.Average;//this.riskForm.Complexity;
  6.     bool interfacePenalty = true;//this.riskForm.InterfacePenalty;
  7.     bool pipeSupport = false;//this.riskForm.PipeSupport;
  8.  
  9.     Pipe pipe = element as Pipe;
  10.  
  11.     float press = 0.0f, temp = 0.0f; double minWall = pipe.minWallThickness;
  12.     bool designOrFabricationPenalty = false, presenceOfCracking = false;
  13.     double allowedStress = 9000, weldJointEfficiency = 0.5, tensileStrength = 0, yieldStrength = 56104;
  14.     PhDsoft.C4D.MainApplication.BusinessLogic.Plant3DImporting.ComputeMinimumPipingThicknessCommand dImporting = new BusinessLogic.Plant3DImporting.ComputeMinimumPipingThicknessCommand(this.document.Application);
  15.     if ((lastPressure) > pipe.DesignPressure && lastTemperature >= pipe.DesignTemperature)
  16.     {
  17.         press = (float)(lastPressure);
  18.         temp = lastTemperature;
  19.         minWall = dImporting.ComputeMinimumWallThickness4RealTime(pipe, press, temp);
  20.     }
  21.     else if ((lastPressure) > pipe.DesignPressure && lastTemperature < pipe.DesignTemperature)
  22.     {
  23.         press = (float)(lastPressure);
  24.         temp = lastTemperature;
  25.         minWall = dImporting.ComputeMinimumWallThickness4RealTime(pipe, press, pipe.DesignTemperature);
  26.     }
  27.     else if ((lastPressure) <= pipe.DesignPressure && lastTemperature > pipe.DesignTemperature)
  28.     {
  29.         press = (float)(lastPressure);
  30.         temp = lastTemperature;
  31.         minWall = dImporting.ComputeMinimumWallThickness4RealTime(pipe, pipe.DesignPressure, temp);
  32.     }
  33.  
  34.     //lastRead = 6.1f;
  35.     /*double lastRead = 5;*///pipe.Thickness - (rnd.Next(0, 50) * 0.1);
  36.                             //lastRead = 2;
  37.     var compType = this.ComputeComponentType(pipe.NominalDiameter);
  38.  
  39.     //pipe.OperatingTemperature
  40.     List<InspectionEffectiveness> inspectionEffectivenessesList = new List<InspectionEffectiveness>();
  41.     inspectionEffectivenessesList.Add(new InspectionEffectiveness { inspectionCategory = InspectionCategories.D, id = 1 });
  42.     inspectionEffectivenessesList.Add(new InspectionEffectiveness { inspectionCategory = InspectionCategories.C, id = 2 });
  43.     inspectionEffectivenessesList.Add(new InspectionEffectiveness { inspectionCategory = InspectionCategories.B, id = 3 });
  44.     //inspectionEffectivenessesList.Add(new InspectionEffectiveness { inspectionCategory = InspectionCategories.A, id = 4 });
  45.  
  46.     DamageFactorExternalCorrosion damageFactorExternalCorrosion = new DamageFactorExternalCorrosion(lastRead, pipe.Campaign.Date, lastTemperature, driver, interfacePenalty, designOrFabricationPenalty,
  47.         new DateTime(2017, 03, 17), lastRead, pipe.Campaign.Date,
  48.         coatingQuality, allowedStress, weldJointEfficiency, minWall, tensileStrength, yieldStrength, minWall, inspectionEffectivenessesList);
  49.  
  50.     DamageFactorExternalCLSCC damageFactorExternalCLSCC = new DamageFactorExternalCLSCC(pipe.Campaign.Date, lastTemperature, driver, new DateTime(2017, 03, 17), pipe.Campaign.Date,
  51.         coatingQuality, inspectionEffectivenessesList, presenceOfCracking);
  52.  
  53.     List<ExternalDamageFactor> externalDamageFactors = new List<ExternalDamageFactor>();
  54.     externalDamageFactors.Add(damageFactorExternalCorrosion);
  55.     //externalDamageFactors.Add(damageFactorCUIF);
  56.     externalDamageFactors.Add(damageFactorExternalCLSCC);
  57.     //externalDamageFactors.Add(damageFactorCUICLSCC);
  58.  
  59.     ProbabilityOfFailure probabilityOfFailure = new ProbabilityOfFailure(500, -1, EquipmentTypes.Pipe, compType);
  60.     Double totalDamageFactor = probabilityOfFailure.GetTotalDamageFactor(externalDamageFactors, new List<ThinningDamageFactor>(), false, new List<SCCDamageFactor>());
  61.     Double pfValue = probabilityOfFailure.GetProbabilityFailure(externalDamageFactors, null, false, null);
  62.  
  63.     List<Double> otherComponentMass = new List<double>();
  64.     otherComponentMass.Add(50);
  65.     otherComponentMass.Add(30);
  66.  
  67.     ConsequenceAnalysisLevelOne consequenceAnalysisLevelOne = new ConsequenceAnalysisLevelOne(RepresentativeFluids.ACID, StoredFluidPhase.GAS,
  68.         EquipmentTypes.Pipe, compType, lastTemperature, lastTemperature, pipe.NominalDiameter, lastPressure, 101.325, 0.1, 1000, otherComponentMass, 0.15, DetectionClassification.B,
  69.         IsolationClassification.B, new Costs(5000, 20000, 14, 15, 16, 17), 5.2, null);
  70.     consequenceAnalysisLevelOne.Init();
  71.     RiskAnalysis risk = new RiskAnalysis();
  72.     var final = consequenceAnalysisLevelOne.FinalConsequenceArea();
  73.     Double riskFinancial = risk.DeterminateRisk(pfValue, consequenceAnalysisLevelOne.TotalFinancialConsequence());
  74.     Double riskArea = risk.DeterminateRisk(pfValue, consequenceAnalysisLevelOne.FinalConsequenceArea());
  75.  
  76.     var riskMatrixFinancial = risk.RiskMatrixFinancial(totalDamageFactor, consequenceAnalysisLevelOne.TotalFinancialConsequence(), PhDSoft.Utils.Enum.RiskMatrix.Unbalanced);
  77.     var riskMatrixArea = risk.RiskMatrixAreaBased(totalDamageFactor, consequenceAnalysisLevelOne.FinalConsequenceArea(), PhDSoft.Utils.Enum.RiskMatrix.Unbalanced);
  78.  
  79.     (pipe as PipingStructureElement).FinancialRisk = riskMatrixFinancial.Item1;
  80.     (pipe as PipingStructureElement).AreaRisk = riskMatrixArea.Item1;
  81.  
  82.     int key = ClassifyElement(risk.RiskMatrixAreaBased(totalDamageFactor, consequenceAnalysisLevelOne.FinalConsequenceArea(), PhDSoft.Utils.Enum.RiskMatrix.Unbalanced));
  83.  
  84.     List<string> elementTypeNamesToRefresh = new List<string>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement