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));
        }
        private static GlobalWarmingPotentialResult EvaluateEnvironmentalProductDeclarationByArea(IElementM elementM = null, EnvironmentalProductDeclarationField field = EnvironmentalProductDeclarationField.GlobalWarmingPotential)
        {
            if (elementM is IElement2D)
            {
                BH.Engine.Reflection.Compute.RecordNote($"Thickness properties for Area-based calculations are set according to the EPD properties of object {elementM.GetType()}, not the construction.");

                double        area          = (elementM as IElement2D).Area();
                List <double> epdVal        = elementM.GetEvaluationValue(field, QuantityType.Area);
                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] * area);
                    }
                }

                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 (area <= 0 || area == double.NaN)
                {
                    BH.Engine.Reflection.Compute.RecordError("Area cannot be calculated from object " + ((IBHoMObject)elementM).BHoM_Guid);
                    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));
            }
            else
            {
                BH.Engine.Reflection.Compute.RecordError("Area-based evaluations are not supported for objects of type: " + elementM.GetType() + ".");
                return(null);
            }
        }
        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));
        }
Exemplo n.º 4
0
        private static GlobalWarmingPotentialResult EvaluateEnvironmentalProductDeclarationByLength(IElementM elementM = null, EnvironmentalProductDeclarationField field = EnvironmentalProductDeclarationField.GlobalWarmingPotential)
        {
            if (elementM is IElement1D)
            {
                double        length        = (elementM as IElement1D).Length();
                List <double> epdVal        = elementM.GetEvaluationValue(field, QuantityType.Length);
                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 GlobalWarmingPotentialResult(((IBHoMObject)elementM).BHoM_Guid, field, 0, ObjectScope.Undefined, ObjectCategory.Undefined, Query.GetElementEpd(elementM), quantity));
            }
            else
            {
                BH.Engine.Reflection.Compute.RecordError("Length-based evaluations are not supported for objects of type: " + elementM.GetType() + ".");
                return(null);
            }
        }