private static GlobalWarmingPotentialResult EvaluateEnvironmentalProductDeclarationByMass(IElementM elementM = null, EnvironmentalProductDeclarationField field = EnvironmentalProductDeclarationField.GlobalWarmingPotential) { double volume = elementM.ISolidVolume(); List <double> epdVal = elementM.GetEvaluationValue(field, QuantityType.Mass); List <double> gwpByMaterial = new List <double>(); List <double> volumeByRatio = elementM.IMaterialComposition().Ratios.Select(x => volume * x).ToList(); List <double> densityOfMassEpd = Query.GetElementDensity(elementM); List <double> massOfObj = new List <double>(); if (densityOfMassEpd == null) { BH.Engine.Reflection.Compute.RecordError("Density could not be found. Material density is required for all objects using Mass-based evaluations."); return(null); } for (int x = 0; x < volumeByRatio.Count; x++) { massOfObj.Add(volumeByRatio[x] * densityOfMassEpd[x]); } for (int x = 0; x < epdVal.Count; x++) { if (double.IsNaN(epdVal[x])) { gwpByMaterial.Add(double.NaN); } else { gwpByMaterial.Add(epdVal[x] * massOfObj[x]); } } if (epdVal == null || epdVal.Where(x => !double.IsNaN(x)).Sum() <= 0) { BH.Engine.Reflection.Compute.RecordError($"No value for {field} can be found within the supplied EPD."); return(null); } double quantity = gwpByMaterial.Where(x => !double.IsNaN(x)).Sum(); return(new GlobalWarmingPotentialResult(((IBHoMObject)elementM).BHoM_Guid, field, 0, ObjectScope.Undefined, ObjectCategory.Undefined, Query.GetElementEpd(elementM), quantity)); }
public static List <double> GetEvaluationValue(this Construction construction, EnvironmentalProductDeclarationField field, List <LifeCycleAssessmentPhases> phases, QuantityType type, bool exactMatch = false) { if (construction == null) { return(new List <double>()); } List <double> quantityTypeValue = construction.GetQuantityTypeValue(type); List <double> epdVal = construction.Layers.Select(x => { var epd = x.Material.Properties.Where(y => y is EnvironmentalProductDeclaration).FirstOrDefault() as EnvironmentalProductDeclaration; if (epd.QuantityType == type && (epd.EnvironmentalMetric.Where(z => z.Phases.Where(a => phases.Contains(a)).Count() != 0).FirstOrDefault() != null)) { return(GetEvaluationValue(epd, field, phases, exactMatch)); } else { return(double.NaN); } }).ToList(); //Division of GWP constant by QTV List <double> normalisedEpdVal = new List <double>(); for (int x = 0; x < epdVal.Count; x++) { if (double.IsNaN(epdVal[x])) { normalisedEpdVal.Add(double.NaN); } else { normalisedEpdVal.Add(epdVal[x] / quantityTypeValue[x]); } } return(normalisedEpdVal); }
public static double GetEvaluationValue(this EnvironmentalProductDeclaration epd, EnvironmentalProductDeclarationField field, List <LifeCycleAssessmentPhases> phases, bool exactMatch = false) { if (epd == null) { return(double.NaN); } IEnumerable <EnvironmentalMetric> filteredMetrics = epd.EnvironmentalMetric.Where(x => x.Field == field); if (filteredMetrics.Count() == 0) { BH.Engine.Reflection.Compute.RecordError("No metrics of the specified Field could be found."); return(double.NaN); } filteredMetrics = filteredMetrics.Where(x => x.GetType().IsAssignableFrom(typeof(EnvironmentalMetric))); if (filteredMetrics.Count() == 0) { BH.Engine.Reflection.Compute.RecordError("No Environmental Metrics could be found."); return(double.NaN); } if (!filteredMetrics.SelectMany(x => x.Phases).IsContaining(phases, exactMatch)) { BH.Engine.Reflection.Compute.RecordError("There are no matching phases found within the Environmental Metrics of the provided EPDs."); return(double.NaN); } return(filteredMetrics.First().Quantity); }
public static double EvaluateReferenceValue(double referenceValue, IEnvironmentalProductDeclarationData epd, EnvironmentalProductDeclarationField field) { if (epd == null) { BH.Engine.Reflection.Compute.RecordError("No EPD provided. Please provide a reference EPD."); } double epdValue = Query.GetEvaluationValue(epd, field); if (referenceValue <= 0) { BH.Engine.Reflection.Compute.RecordError("No evaluation value was found within the EPD. Please try another."); } double qtValue = epd.QuantityTypeValue; string qt = System.Convert.ToString(Query.GetFragmentQuantityType(epd)); BH.Engine.Reflection.Compute.RecordNote($"Result is created by multiplying the ReferenceValue of {referenceValue} by the units of {qt} QuantityType extracted from " + epd.Name + " divided by {qtValue}."); double result = (referenceValue * epdValue) / qtValue; return(result); }
public static double GetEvaluationValue(this IEnvironmentalProductDeclarationData epd, EnvironmentalProductDeclarationField field) { if (epd == null) { return(double.NaN); } switch (field) { case EnvironmentalProductDeclarationField.AcidificationPotential: return(epd.AcidificationPotential); case EnvironmentalProductDeclarationField.DepletionOfAbioticResourcesFossilFuels: return(epd.DepletionOfAbioticResourcesFossilFuels); case EnvironmentalProductDeclarationField.EutrophicationPotential: return(epd.EutrophicationPotential); case EnvironmentalProductDeclarationField.GlobalWarmingPotential: return(epd.GlobalWarmingPotential); case EnvironmentalProductDeclarationField.OzoneDepletionPotential: return(epd.OzoneDepletionPotential); case EnvironmentalProductDeclarationField.PhotochemicalOzoneCreationPotential: return(epd.PhotochemicalOzoneCreationPotential); default: return(double.NaN); } }
public static List <double> GetEvaluationValue(this Construction construction, EnvironmentalProductDeclarationField field, QuantityType type) { if (construction == null) { return(new List <double>()); } List <double> quantityTypeValue = construction.GetQuantityTypeValue(type); List <double> epdVal = construction.Layers.Select(x => { var epd = x.Material.Properties.Where(y => y is IEnvironmentalProductDeclarationData).FirstOrDefault() as IEnvironmentalProductDeclarationData; if (epd.QuantityType == type) { return(GetEvaluationValue(epd, field)); } else { return(double.NaN); } }).ToList(); //Division of GWP constant by QTV List <double> normalisedEpdVal = new List <double>(); for (int x = 0; x < epdVal.Count; x++) { if (double.IsNaN(epdVal[x])) { normalisedEpdVal.Add(double.NaN); } else { normalisedEpdVal.Add(epdVal[x] / quantityTypeValue[x]); } } return(normalisedEpdVal); }
public static LifeCycleAssessmentResult EvaluateLifeCycleAssessment(ProjectLifeCycleAssessment lca, EnvironmentalProductDeclarationField field, List <LifeCycleAssessmentPhases> phases, bool exactMatch = false) { if (lca == null) { return(null); } List <LifeCycleAssessmentElementResult> results = new List <LifeCycleAssessmentElementResult>(); results.AddRange(lca.StructuresScope.EvaluateLifeCycleAssessmentScope(field, phases, exactMatch)); results.AddRange(lca.FoundationsScope.EvaluateLifeCycleAssessmentScope(field, phases, exactMatch)); results.AddRange(lca.EnclosuresScope.EvaluateLifeCycleAssessmentScope(field, phases, exactMatch)); results.AddRange(lca.MEPScope.EvaluateLifeCycleAssessmentScope(field, phases, exactMatch)); results.AddRange(lca.TenantImprovementScope.EvaluateLifeCycleAssessmentScope(field, phases, exactMatch)); return(new LifeCycleAssessmentResult(lca.BHoM_Guid, field, 0, lca.LifeCycleAssessmentScope, new System.Collections.ObjectModel.ReadOnlyCollection <LifeCycleAssessmentElementResult>(results), results.TotalFieldQuantity())); }
private static EnvironmentalMetricResult EvaluateEnvironmentalProductDeclarationByLength(IElementM elementM, List <LifeCycleAssessmentPhases> phases, EnvironmentalProductDeclarationField field = EnvironmentalProductDeclarationField.GlobalWarmingPotential, bool exactMatch = false) { if (elementM is IElement1D) { double length = (elementM as IElement1D).Length(); List <double> epdVal = elementM.GetEvaluationValue(field, phases, QuantityType.Length, exactMatch); List <double> gwpByMaterial = new List <double>(); for (int x = 0; x < epdVal.Count; x++) { if (double.IsNaN(epdVal[x])) { gwpByMaterial.Add(double.NaN); } else { gwpByMaterial.Add(epdVal[x] * length); } } if (epdVal == null || epdVal.Where(x => !double.IsNaN(x)).Sum() <= 0) { BH.Engine.Reflection.Compute.RecordError($"No value for {field} can be found within the supplied EPD."); return(null); } if (length <= 0 || length == double.NaN) { BH.Engine.Reflection.Compute.RecordError("Length cannot be calculated from object " + ((IBHoMObject)elementM).BHoM_Guid); return(null); } double quantity = gwpByMaterial.Where(x => !double.IsNaN(x)).Sum(); return(new EnvironmentalMetricResult(((IBHoMObject)elementM).BHoM_Guid, field, 0, ObjectScope.Undefined, ObjectCategory.Undefined, phases, Query.GetElementEpd(elementM), quantity, field)); } else { BH.Engine.Reflection.Compute.RecordError("Length-based evaluations are not supported for objects of type: " + elementM.GetType() + "."); return(null); } }