NREL / OCHRE

A Python-based building energy modeling (BEM) tool designed to model flexible loads in residential buildings
https://www.nrel.gov/grid/ochre.html
BSD 3-Clause "New" or "Revised" License
40 stars 4 forks source link

Update to work with ResStock 3.1/OS-HPXML 1.6.0 #28

Closed jmaguire1 closed 1 month ago

jmaguire1 commented 1 year ago

Looks like there's some breaking changes in the most recent release of OS-HPXML. Lighting is the first one we hit, but there's probably several breaking changes. See: https://github.com/NREL/OpenStudio-HPXML/releases/tag/v1.6.0

jmaguire1 commented 1 year ago

7/13: @mnblonsky has this running! Currently running through project_national and project_ochre, about 90% of runs in project_national are completing successfully. Need to make sure we gracefully error for the remaining 10%.

mnblonsky commented 1 year ago

I got 5 errors (across 9 buildings) when running 300 buildings with project_national:

@jmaguire1 I think maybe we keep this issue open until these are resolved, but I don't think they're high priority anymore?

mnblonsky commented 1 year ago

The new changes caused old HPXML files (OS-HPXML 1.5) to fail. That means ResStock 3.0 and BEopt 3.0 files aren't working. I'm working on a fix to that today.

pemami4911 commented 1 year ago

Hi @mnblonsky , I'm getting this error trying to load an HPXML file created with ResStock 3.0:

Traceback (most recent call last):
  File "/Users/pemami/Workspace/ochre_gym/test/test_reset_env.py", line 9, in setUp
    self.env = ochre_gym.load(
  File "/Users/pemami/Workspace/ochre_gym/ochre_gym/__init__.py", line 202, in load
    env = OchreEnv(exp_config, dwelling_args, logger)
  File "/Users/pemami/Workspace/ochre_gym/ochre_gym/ochre_env.py", line 51, in __init__
    self.dwelling = Dwelling(experiment_args['env_name'], **dwelling_args)
  File "/opt/miniconda3/envs/ochre_official/lib/python3.9/site-packages/ochre/Dwelling.py", line 71, in __init__
    properties, weather_station = load_hpxml(**house_args)
  File "/opt/miniconda3/envs/ochre_official/lib/python3.9/site-packages/ochre/utils/hpxml.py", line 1558, in load_hpxml
    zones['Indoor'].update(parse_indoor_infiltration(hpxml, construction, equipment_dict))
  File "/opt/miniconda3/envs/ochre_official/lib/python3.9/site-packages/ochre/utils/hpxml.py", line 412, in parse_indoor_infiltration
    inf = indoor_infiltration['AirInfiltrationMeasurement']
KeyError: 'AirInfiltrationMeasurement'

In my HPXML file, the SystemIdentifier id is AirInfiltrationMeasurement1 but the code seems to expect AirInfiltrationMeasurement.

here's the relevant snipped in my HPXML file:

<Enclosure>
      <AirInfiltration>
        <AirInfiltrationMeasurement>
          <SystemIdentifier id='AirInfiltrationMeasurement1'/>
          <HousePressure>50.0</HousePressure>
          <BuildingAirLeakage>
            <UnitofMeasure>ACH</UnitofMeasure>
            <AirLeakage>5.0</AirLeakage>
          </BuildingAirLeakage>
          <InfiltrationVolume>17432.0</InfiltrationVolume>
          <InfiltrationHeight dataSource='software'>8.0</InfiltrationHeight>
        </AirInfiltrationMeasurement>
      </AirInfiltration>

Many of the SystemIdentifiers have these digits (1/2/3/etc.) after the name. Is this an issue with how the HPXML file was created or with how OCHRE now parses HPXML files?

mnblonsky commented 1 year ago

@pemami4911, can you send me the HPXML file? This was one of the errors that I thought we had fixed, but this could be an edge case that we missed.

jmaguire1 commented 1 year ago

@pemami4911: If you could also send the buildstock.csv file (or post them here) and tell us which run this error occurs for, that would be helpful so we can make sure we get the root cause of the issue.

pemami4911 commented 1 year ago

Here is the buildstock.csv file (with just the one building in it): buildstock.csv

And the generated HPXML file (remove the .txt, Github doesn't allow .xml uploads): home.xml.txt

jmaguire1 commented 1 year ago

Thanks! @mnblonsky will take a look and let you know when we've come up with a fix.

I'd also recommend that you might want to use this branch of ResStock: https://github.com/NREL/resstock/tree/ochre-validation going forward. Michael and I created a stable branch for testing purposes, so that our validation results aren't affected by more recent developments in ResStock. While everything should work with develop, there will be times where ResStock makes a breaking change and it takes us a little while to make a corresponding update. We'll try to periodically update this branch, but it's probably a little bit safer to use this (unless you need a newly added feature. @pemami4911

pemami4911 commented 1 year ago

Oh awesome, will switch to using this one. Thanks!

mnblonsky commented 1 year ago

@pemami4911 I just pushed a fix. We'll merge that into dev soon. You're welcome to keep using ResStock 3.0 if you prefer.

The issue had to do with how we're parsing the HPXML file. ResStock always included an extension in the AirInfiltration element, but BEopt does not. When there's only 1 element, we used to use the SystemIdentifier, but we didn't if there was 2 or more elements with different names, i.e. AirInfiltrationMeasurement and extension. That's changed now, and we'll only use the SystemIdentifier if there's elements with the same name, e.g. for Wall elements. Hopefully this fixes a lot of potential future issues too...

jmaguire1 commented 1 year ago

It's merged! Thanks for the quick fix @mnblonsky. @pemami4911 if you find any other issues do let us know and we'll work out a fix! They might not all be this quick, but we'll try to do them ASAP.

pemami4911 commented 1 year ago

Thanks for the fast fix!