Issue with the extract time period function in the runEnergySimulation component

1. Issue

As shown below, in some situations, in the IDF file generated from GH+LB+HB workflow in which generator system object is created, the last output variable DISTRIBUTIONSYSTEM,Electric Load Center Produced Electric Energy is wrongly written as the following, in which the last word “Simple” should be one of the four time period words, i.e. “hourly”, “daily”, “monthly”, and “annual”.

Output:Variable,My_PV_generator_system:DISTRIBUTIONSYSTEM,Electric Load Center Produced Electric Energy, Simple;

This could result in:

  1. Error while running EnergyPlus simulation through LB+HB.
  2. The time period of this output variable been interpreted as “hourly” by E+, rather than that been specified for the rest of the output variables through the EPOutput component.

Related discussion is shown in the following post on UnmetHours.com:
https://unmethours.com/question/33400/severe-error-failed-to-match-against-any-enum-values/

2. Source of error

The following function is to extract the time period from the last word of the last output variable specified by the user (line 1926 to 1932 in the code for runEnergySimulation, v 0.0.63, JAN_20_2018, or line 1937 to 1943 in the code for runEnergySimulation, v 0.0.63, JUL_24_2018 ) :

   def extracttimeperiod(simulationOutputs):
        try:
            timeperiod = simulationOutputs[-1].split(',')[-1]
            HBgeneratortimeperiod = timeperiod.replace(";","")
            return HBgeneratortimeperiod
        except:
            pass

However, the last output variable specified by the user may not be one ended with a time period. E.g:

Output:Variable,*,Surface Outside Face Incident Ground Diffuse Solar Radiation Rate per Area, annual;
Output:Diagnostics,DisplayExtraWarnings;
Output:SQLite, Simple;

3. Solution
3.1 Solution A
Rearrange the order of the additional output variables in the GH+LB+HB workflow so that the last one is one ended with a time period:

Output:Diagnostics,DisplayExtraWarnings;
Output:SQLite, Simple;
Output:Variable,*,Surface Outside Face Incident Ground Diffuse Solar Radiation Rate per Area, annual;

3.2 Solution B
Revise the function to loop through all output variables, and see if the last word matches one of the four time periods (I’m sure the code can be written more succinctly):

   def extracttimeperiod(simulationOutputs):
        try:
            timePeriods = ['hourly', 'daily', 'monthly', 'annual']

            for output in simulationOutputs:
                endWord = output.split(',')[-1].strip().replace(";","")
                print endWord
                if endWord in timePeriods:
                    HBgeneratortimeperiod = endWord
            return HBgeneratortimeperiod

        except:
            pass

An example file with the code revised is attached here as reference.

Appreciate if the development team can take a look and see if the code revision is necessary.

test_extract_timePeriod_issue.gh (1.0 MB)

@Grasshope, As usual you have find an issue and you have already find the solution to solve it. Why don’t you send a pull request to GitHub? :slight_smile:

Noted with thanks, @mostapha.

Let me take a look on how to use GitHub as I don’t have much experience in this regard. I though only the main contributors can submit pull request…

Shall I submit this type of post as an “issue” on GitHub for discussion first?

Hi @Grasshope, In these cases that there is an obvious issues you can just send a pull request and explain the issue. Looking forward to your PR. Let us know if you have any questions.