Exemple #1
0
        public static List <double> GetEPDDensity(this EnvironmentalProductDeclaration epd)
        {
            // EPD null check
            if (epd == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No EPD was provided. Returning NaN.");
                return(new List <double>());
            }

            // Get list of all EPD Density Fragments
            List <IFragment> densityFragment = epd.GetAllFragments().Where(x => typeof(EPDDensity).IsAssignableFrom(x.GetType())).ToList();

            if (densityFragment.Count <= 0)
            {
                BH.Engine.Reflection.Compute.RecordError("No EPDDensity Fragment could be found within the EPD. AddFragment and try again.");
                return(new List <double>());
            }

            List <double> density = epd.GetAllFragments().Where(x => typeof(EPDDensity).IsAssignableFrom(x.GetType())).Select(y => (y as EPDDensity).Density).ToList();

            if (density.Count <= 0)
            {
                BH.Engine.Reflection.Compute.RecordError("No density values could be found within the EPDDensity Fragments. Please check these values and try again.");
                return(new List <double>());
            }

            return(density);
        }
        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);
        }
Exemple #3
0
 public static QuantityType GetEPDQuantityType(this EnvironmentalProductDeclaration epd)
 {
     if (epd == null)
     {
         BH.Engine.Reflection.Compute.RecordError("No EPD was provided.");
     }
     return(epd.QuantityType);
 }
Exemple #4
0
        public static List <EnvironmentalMetric> GetEnvironmentalMetric(this EnvironmentalProductDeclaration epd)
        {
            List <EnvironmentalMetric> em = new List <EnvironmentalMetric>();

            if (epd == null)
            {
                return(new List <EnvironmentalMetric>());
            }

            em = epd.EnvironmentalMetric.ToList();

            return(em);
        }
Exemple #5
0
        public static double GetQuantityTypeValue(this EnvironmentalProductDeclaration epd)
        {
            if (epd == null)
            {
                BH.Engine.Reflection.Compute.RecordWarning("The Environmental Product Declaration QuantityTypeValue could not be assessed. Returning default value of 1.");
                return(1);
            }
            else
            {
                double qtv = epd.QuantityTypeValue;

                return(qtv);
            }
        }
Exemple #6
0
        /***************************************************/
        /****           Public Methods                  ****/
        /***************************************************/

        public static EnvironmentalProductDeclaration ToEnvironmentalProductDeclarationData(this CustomObject obj)
        {
            EnvironmentalProductDeclaration epd = new EnvironmentalProductDeclaration
            {
                Id   = obj.PropertyValue("_id")?.ToString() ?? "",
                Name = obj.PropertyValue("Name")?.ToString() ?? "",
                DepletionOfAbioticResourcesFossilFuels = obj.PropertyValue("PrimaryEnergyDemand") != null?System.Convert.ToDouble(obj.PropertyValue("PrimaryEnergyDemand")) : double.NaN,
                                                             EutrophicationPotential = obj.PropertyValue("EutrophicationPotential") != null?System.Convert.ToDouble(obj.PropertyValue("EutrophicationPotential")) : double.NaN,
                                                                                           AcidificationPotential = obj.PropertyValue("AcidificationPotential") != null?System.Convert.ToDouble(obj.PropertyValue("AcidificationPotential")) : double.NaN,
                                                                                                                        PhotochemicalOzoneCreationPotential = obj.PropertyValue("SmogPotential") != null?System.Convert.ToDouble(obj.PropertyValue("SmogPotential")) : double.NaN,
                                                                                                                                                                  OzoneDepletionPotential = obj.PropertyValue("OzoneDepletionPotential") != null?System.Convert.ToDouble(obj.PropertyValue("OzoneDepletionPotential")) : double.NaN,
                                                                                                                                                                                                GlobalWarmingPotential = obj.PropertyValue("GlobalWarmingPotential") != null?System.Convert.ToDouble(obj.PropertyValue("GlobalWarmingPotential")) : double.NaN,
                                                                                                                                                                                                                             Description    = obj.PropertyValue("Description")?.ToString() ?? "",
                                                                                                                                                                                                                             BiogenicCarbon = obj.PropertyValue("BiogenicCarbon") != null?System.Convert.ToDouble(obj.PropertyValue("BiogenicCarbon")) : double.NaN,
                                                                                                                                                                                                                                                  Density = obj.PropertyValue("Density") != null?System.Convert.ToDouble(obj.PropertyValue("Density")) : 0,
                                                                                                                                                                                                                                                                EndOfLifeTreatment = obj.PropertyValue("EolTreatment")?.ToString() ?? "",
            };

            return(epd);
        }
        public static List <double> GetEnvironmentalMetricValue(this EnvironmentalProductDeclaration epd, EnvironmentalProductDeclarationField field)
        {
            // EPD Null Check
            if (epd == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No EPD found. Returning double.NaN.");
                return(new List <double>());
            }

            // EPD Environmental Metric null check
            if (epd.EnvironmentalMetric.Count <= 0)
            {
                BH.Engine.Reflection.Compute.RecordError("No Environmental Metrics have been found. Returning double.NaN.");
                return(new List <double>());
            }

            // get the Quantity Values
            List <double> quantity = (List <double>)epd.EnvironmentalMetric.Select(x => x.Quantity);

            return(quantity);
        }
        public static List <List <LifeCycleAssessmentPhases> > GetEPDPhases(this EnvironmentalProductDeclaration epd)
        {
            // EPD null check
            if (epd == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No EPD was provided.");
                return(new List <List <LifeCycleAssessmentPhases> >());
            }

            // Get list of all EPD EnvironmentalMetrics
            List <EnvironmentalMetric> metrics = epd.EnvironmentalMetric;
            List <List <LifeCycleAssessmentPhases> > phases = metrics.Select(x => x.Phases).Distinct().ToList();

            if (phases.Count <= 0)
            {
                BH.Engine.Reflection.Compute.RecordError("No Phases have been found within the EPD.");
                return(new List <List <LifeCycleAssessmentPhases> >());
            }

            return(phases);
        }
        public static string MaterialEndOfLifeTreatment(this EnvironmentalProductDeclaration epd)
        {
            // EPD null check
            if (epd == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No EPD has been provided.");
                return(null);
            }

            // AdditionalEPDData fragment
            AdditionalEPDData dataFragment = (AdditionalEPDData)Base.Query.GetAllFragments(epd).Where(x => typeof(AdditionalEPDData).IsAssignableFrom(x.GetType())).FirstOrDefault();

            // AdditionalEPDData fragment null check
            if (dataFragment == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No AdditionalEPDData fragment has been found. Have you tried AddFragment on the selected EPD?");
                return(null);
            }

            string endOfLife = dataFragment.EndOfLifeTreatment;

            return(endOfLife);
        }
Exemple #10
0
        public static double EvaluateReferenceValue(double referenceValue, EnvironmentalProductDeclaration epd, EnvironmentalProductDeclarationField field, List <LifeCycleAssessmentPhases> phases, bool exactMatch = false)
        {
            if (epd == null)
            {
                BH.Engine.Reflection.Compute.RecordError("No EPD provided. Please provide a reference EPD.");
            }

            double epdValue = Query.GetEvaluationValue(epd, field, phases, exactMatch);

            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.GetEPDQuantityType(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);
        }