Ejemplo n.º 1
0
        //This function pulls in the data from GREET that can be classified as user input, meaning it was a custom user value
        //In order to change the values in GREET you go into the data editor tab, and select either the pathway or resource
        //You want to change (in this case we are only looking at resources) and then change the values and hit apply
        //After you apply the changes, you can hit the pull user values button and it will allow you to update values in real time
        public void pullUserParameterValues()
        {
            IGDataDictionary <int, IResource> resources = ResultsAccess.controler.CurrentProject.Data.Resources;
            IGDataDictionary <int, IPathway>  pathways  = ResultsAccess.controler.CurrentProject.Data.Pathways;

            //The number value that goes into ValueForKey is the ID number for the pathway you are looking to use
            IPathway myPathway = pathways.ValueForKey(CRUDE_PATHWAY_ID);
            // Grab the int id for the resource
            int       productID = myPathway.MainOutputResourceID;
            IResource resource  = resources.ValueForKey(productID);

            label11.Text = resource.Density.UserValue.ToString();

            //The number value that goes into ValueForKey is the ID number for the pathway you are looking to use
            myPathway = pathways.ValueForKey(COAL_PATHWAY_ID);
            // Grab the int id for the resource
            productID    = myPathway.MainOutputResourceID;
            resource     = resources.ValueForKey(productID);
            label10.Text = resource.LowerHeatingValue.UserValue.ToString();

            //The number value that goes into ValueForKey is the ID number for the pathway you are looking to use
            myPathway = pathways.ValueForKey(LSDIESEL_PATHWAY_ID);
            // Grab the int id for the resource
            productID   = myPathway.MainOutputResourceID;
            resource    = resources.ValueForKey(productID);
            label9.Text = resource.SulfurRatio.UserValue.ToString();
        }
Ejemplo n.º 2
0
        public void pullGREETParameterValues()
        {
            //You need to create these dictionaries in order to pull out the values you want
            IGDataDictionary <int, IResource> resources = ResultsAccess.controler.CurrentProject.Data.Resources;
            IGDataDictionary <int, IPathway>  pathways  = ResultsAccess.controler.CurrentProject.Data.Pathways;

            //The number value that goes into ValueForKey is the ID number for the pathway you are looking to use
            IPathway myPathway = pathways.ValueForKey(CRUDE_PATHWAY_ID);
            // Grab the int id for the resource
            int       productID = myPathway.MainOutputResourceID;
            IResource resource  = resources.ValueForKey(productID);

            label4.Text = resource.Density.GreetValue.ToString();

            //The number value that goes into ValueForKey is the ID number for the pathway you are looking to use
            myPathway = pathways.ValueForKey(COAL_PATHWAY_ID);
            // Grab the int id for the resource
            productID   = myPathway.MainOutputResourceID;
            resource    = resources.ValueForKey(productID);
            label5.Text = resource.LowerHeatingValue.GreetValue.ToString();

            //The number value that goes into ValueForKey is the ID number for the pathway you are looking to use
            myPathway = pathways.ValueForKey(LSDIESEL_PATHWAY_ID);
            // Grab the int id for the resource
            productID   = myPathway.MainOutputResourceID;
            resource    = resources.ValueForKey(productID);
            label7.Text = resource.SulfurRatio.GreetValue.ToString();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This function is pulling the BTUPerGal for Conventional Diesel so it can be used to calculate the gallons per trip. (This is ultimately recalculated in the Results code)
        /// </summary>
        /// <returns> The total BTUs per Gallon of conventional diesel </returns>
        public double getApproxBTUperGAL()
        {
            IGDataDictionary <int, IResource> resources = ResultsAccess.controler.CurrentProject.Data.Resources;
            IGDataDictionary <int, IPathway>  pathways  = ResultsAccess.controler.CurrentProject.Data.Pathways;
            IGDataDictionary <int, IMix>      mixes     = ResultsAccess.controler.CurrentProject.Data.Mixes;
            IPathway myPathway = pathways.ValueForKey(CD_PATH_ID);
            int      productID = myPathway.MainOutputResourceID;

            productID = myPathway.MainOutputResourceID;
            IResource ConvDiesel = resources.ValueForKey(productID);

            if (ConvDiesel.LowerHeatingValue.UserValue == 0)
            {
                return((ConvDiesel.LowerHeatingValue.GreetValue) * (1 / GALLONS_PER_CUBIC_METER) * (1 / JOULES_PER_BTU));
            }
            else
            {
                return((ConvDiesel.LowerHeatingValue.UserValue) * (1 / GALLONS_PER_CUBIC_METER) * (1 / JOULES_PER_BTU));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Invoked when a pathway is selected in order to represent the life cycle results
        /// for the product produced by this pathway and defined as it's main output (which is
        /// equivalent to the main output of the last process in the pathway)
        /// </summary>
        /// <param name="name">Name of the pathway, will simply be displayed as is</param>
        /// <param name="results">Result object from the pathway for the desired productID</param>
        /// <returns>Returns 0 if succeed</returns>
        public int SetResults(System.IO.StreamWriter file, string pathwayName, string processName, Guid outputID, IResults results, int i)
        {
            if (i != 0)
            {
                file.Write(",\n");
            }
            else
            {
                file.Write("\n");
            }

            //Check that the resuls object is non null
            if (results == null)
            {
                return(-1);
            }

            file.WriteLine("\t{");
            file.WriteLine("\t\t\"i\": \"{0}\",", i);
            file.WriteLine("\t\t\"Pathway\": \"{0}\",", pathwayName);
            file.WriteLine("\t\t\"Process\": \"{0}\",", processName);
            file.WriteLine("\t\t\"OutputID\": \"{0}\",", outputID);

            //Get an instance of the data object that we are going to use to look for a Resource
            IData data = ResultsAccess.controler.CurrentProject.Data;
            //Gets the dictionary of IGases object indexed by IGas.Id
            IGDataDictionary <int, IGas>      gases     = ResultsAccess.controler.CurrentProject.Data.Gases;
            IGDataDictionary <int, IResource> resources = ResultsAccess.controler.CurrentProject.Data.Resources;

            file.Write("\t\t\"WTPEmis\": {");
            int ii = 0;

            foreach (KeyValuePair <int, IValue> emission in results.WellToProductEmissions())
            {
                if (ii != 0)
                {
                    file.Write(",\n");
                }
                else
                {
                    file.Write("\n");
                }
                IGas gas = gases.ValueForKey(emission.Key);
                //Format the value nicely using the quantity and the unit as well as the preferences defined by the user in the main UI GREET preferences
                file.Write("\t\t\t\"{0}\": {{\"val\":{1},\"units\":\"{2}\"}}", gas.Name, emission.Value.Value, emission.Value.UnitExpression);
                ii++;
            }

            file.Write("\n\t\t},\n\t\t\"OnSiteEmis\": {");
            ii = 0;
            foreach (KeyValuePair <int, IValue> emission in results.OnSiteEmissions())
            {
                if (ii != 0)
                {
                    file.Write(",\n");
                }
                else
                {
                    file.Write("\n");
                }
                IGas gas = gases.ValueForKey(emission.Key);
                //Format the value nicely using the quantity and the unit as well as the preferences defined by the user in the main UI GREET preferences
                file.Write("\t\t\t\"{0}\": {{\"val\":{1},\"units\":\"{2}\"}}", gas.Name, emission.Value.Value, emission.Value.UnitExpression);
                ii++;
            }

            file.Write("\n\t\t},\n\t\t\"WTPResources\": {");
            ii = 0;
            foreach (KeyValuePair <int, IValue> resUse in results.WellToProductResources())
            {
                if (ii != 0)
                {
                    file.Write(",\n");
                }
                else
                {
                    file.Write("\n");
                }
                IResource res = resources.ValueForKey(resUse.Key);
                //Format the value nicely using the quantity and the unit as well as the preferences defined by the user in the main UI GREET preferences
                file.Write("\t\t\t\"{0}\": {{\"val\":{1},\"units\":\"{2}\"}}", res.Name, resUse.Value.Value, resUse.Value.UnitExpression);
                ii++;
            }

            file.Write("\n\t\t},\n\t\t\"OnSiteResources\": {");
            ii = 0;
            foreach (KeyValuePair <int, IValue> resUse in results.OnSiteResources())
            {
                if (ii != 0)
                {
                    file.Write(",\n");
                }
                else
                {
                    file.Write("\n");
                }
                IResource res = resources.ValueForKey(resUse.Key);
                //Format the value nicely using the quantity and the unit as well as the preferences defined by the user in the main UI GREET preferences
                file.Write("\t\t\t\"{0}\": {{\"val\":{1},\"units\":\"{2}\"}}", res.Name, resUse.Value.Value, resUse.Value.UnitExpression);
                ii++;
            }
            file.Write("\n\t\t},\n");

            //Displays the functional unit for this results, very important in order to know if we are looking at results
            //per joule of product, or per cubic meters of product, or per kilograms of prododuct
            file.Write("\t\t\"FunctionalUnit\": \"{0}\"\n\t}}", results.FunctionalUnit);
            //If the user wants to see results in a different functional unit, the IValue quantity must be converted to the desired functional unit

            return(0);
        }