private static EnvironmentalMetricResult EvaluateEnvironmentalProductDeclarationByVolume(IElementM elementM, List <LifeCycleAssessmentPhases> phases, EnvironmentalProductDeclarationField field = EnvironmentalProductDeclarationField.GlobalWarmingPotential, bool exactMatch = false) { List <double> epdVal = elementM.GetEvaluationValue(field, phases, QuantityType.Volume, exactMatch); double volume = elementM.ISolidVolume(); List <double> volumeByRatio = elementM.IMaterialComposition().Ratios.Select(x => volume * x).ToList(); 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] * volumeByRatio[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); } if (volume <= 0) { BH.Engine.Reflection.Compute.RecordError("Volume 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)); }
public static double Mass(this IElementM elementM) { if (elementM == null) { BH.Engine.Reflection.Compute.RecordError("Cannot query the mass of a null element."); return(0); } MaterialComposition mat = elementM.IMaterialComposition(); return(elementM.ISolidVolume() * mat.Materials.Zip(mat.Ratios, (m, r) => r * m.Density()).Sum()); }
private static EnvironmentalMetricResult EvaluateEnvironmentalProductDeclarationByMass(IElementM elementM, List <LifeCycleAssessmentPhases> phases, EnvironmentalProductDeclarationField field = EnvironmentalProductDeclarationField.GlobalWarmingPotential, bool exactMatch = false) { double volume = elementM.ISolidVolume(); List <double> epdVal = elementM.GetEvaluationValue(field, phases, QuantityType.Mass, exactMatch); List <double> gwpByMaterial = new List <double>(); List <double> volumeByRatio = elementM.IMaterialComposition().Ratios.Select(x => volume * x).ToList(); List <double> densityOfMassEpd = Query.GetEPDDensity(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 EnvironmentalMetricResult(((IBHoMObject)elementM).BHoM_Guid, field, 0, ObjectScope.Undefined, ObjectCategory.Undefined, phases, Query.GetElementEpd(elementM), quantity, field)); }
public static double DepletionOfAbioticResources(IElementM elementM, IEnvironmentalProductDeclarationData epd) { QuantityType qt = epd.QuantityType; if (qt != QuantityType.Mass) { Reflection.Compute.RecordError("This method only works with Mass-based QuantityType EPDs. Please provide a different EPD."); return(double.NaN); } else { double volume = elementM.ISolidVolume(); double density = epd.Density; double depletionOfAbioticResources = System.Convert.ToDouble(epd.DepletionOfAbioticResources); if (volume <= 0 || volume == double.NaN) { Reflection.Compute.RecordError("Volume cannot be calculated from object " + ((IBHoMObject)elementM).BHoM_Guid); return(double.NaN); } if (density <= 0 || density == double.NaN) { Reflection.Compute.RecordError("EPD does not contain a value for Density"); return(double.NaN); } if (depletionOfAbioticResources <= 0 || depletionOfAbioticResources == double.NaN) { Reflection.Compute.RecordError("EPD does not contain a value for DepletionOfAbioticResources"); return(double.NaN); } return(volume * density * depletionOfAbioticResources); } /***************************************************/ }
public static double Mass(this IElementM elementM) { MaterialComposition mat = elementM.IMaterialComposition(); return(elementM.ISolidVolume() * mat.Materials.Zip(mat.Ratios, (m, r) => r * m.Density()).Sum()); }