Skip to content

Commit

Permalink
Merge pull request #29 from NREL/add_desuperheater_flexibility
Browse files Browse the repository at this point in the history
Add desuperheater flexibility
  • Loading branch information
bpark1327 committed May 15, 2021
2 parents 61ea6f0 + 891335f commit 9921f6e
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 24 deletions.
52 changes: 28 additions & 24 deletions hpxml_version_translator/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,30 +339,29 @@ def get_pre_post_from_building_id(building_id):
enclosure.FoundationWalls.append(deepcopy(fw))
this_fw = enclosure.FoundationWalls.FoundationWall[-1]

try:
fw_boundary = location_map[str(fw.AdjacentTo)]
except KeyError:
fw_boundary = str(fw.AdjacentTo) # retain unchanged location name
try:
boundary_v3 = {'other housing unit': E.ExteriorAdjacentTo(fw_boundary),
'unconditioned basement': E.InteriorAdjacentTo(fw_boundary),
'living space': E.InteriorAdjacentTo(fw_boundary),
'ground': E.ExteriorAdjacentTo(fw_boundary),
'crawlspace': E.InteriorAdjacentTo(fw_boundary),
'attic': E.InteriorAdjacentTo(fw_boundary), # FIXME: double-check
'garage': E.InteriorAdjacentTo(fw_boundary),
'ambient': E.ExteriorAdjacentTo(fw_boundary)}[str(fw.AdjacentTo)]
add_after(
this_fw,
['SystemIdentifier',
'ExternalResource',
'AttachedToSpace'],
boundary_v3
)
except KeyError:
pass

if hasattr(this_fw, 'AdjacentTo'):
try:
fw_boundary = location_map[str(fw.AdjacentTo)]
except KeyError:
fw_boundary = str(fw.AdjacentTo) # retain unchanged location name
try:
boundary_v3 = {'other housing unit': E.ExteriorAdjacentTo(fw_boundary),
'unconditioned basement': E.InteriorAdjacentTo(fw_boundary),
'living space': E.InteriorAdjacentTo(fw_boundary),
'ground': E.ExteriorAdjacentTo(fw_boundary),
'crawlspace': E.InteriorAdjacentTo(fw_boundary),
'attic': E.InteriorAdjacentTo(fw_boundary), # FIXME: double-check
'garage': E.InteriorAdjacentTo(fw_boundary),
'ambient': E.ExteriorAdjacentTo(fw_boundary)}[str(fw.AdjacentTo)]
add_after(
this_fw,
['SystemIdentifier',
'ExternalResource',
'AttachedToSpace'],
boundary_v3
)
except KeyError:
pass
this_fw.remove(this_fw.AdjacentTo)

foundation.remove(fw)
Expand Down Expand Up @@ -874,9 +873,14 @@ def get_pre_post_from_building_id(building_id):
if watertype == 'indoor water ':
watertype._setText(str(watertype).rstrip())

# TODO: Adds desuperheater flexibility
# Adds desuperheater flexibility
# https://github.com/hpxmlwg/hpxml/pull/184

for el in root.xpath('//h:WaterHeatingSystem/h:RelatedHeatingSystem', **xpkw):
el.tag = f'{{{hpxml3_ns}}}RelatedHVACSystem'
for el in root.xpath('//h:WaterHeatingSystem/h:HasGeothermalDesuperheater', **xpkw):
el.tag = f'{{{hpxml3_ns}}}UsesDesuperheater'

# TODO: Allow insulation location to be layer-specific
# https://github.com/hpxmlwg/hpxml/pull/188

Expand Down
79 changes: 79 additions & 0 deletions test/hpxml_files/desuperheater_flexibility.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<HPXML xmlns="http://hpxmlonline.com/2014/6" schemaVersion="2.3">
<XMLTransactionHeaderInformation>
<XMLType></XMLType>
<XMLGeneratedBy></XMLGeneratedBy>
<CreatedDateAndTime>2021-04-05T14:17:07.685077</CreatedDateAndTime>
<Transaction>create</Transaction>
</XMLTransactionHeaderInformation>
<SoftwareInfo/>
<Building>
<BuildingID id="bldg1"></BuildingID>
<ProjectStatus>
<EventType>audit</EventType>
</ProjectStatus>
<BuildingDetails>
<ClimateandRiskZones>
<WeatherStation>
<SystemIdentifiersInfo id='weather-station-1'/>
<Name>Golden, CO</Name>
</WeatherStation>
</ClimateandRiskZones>
<Systems>
<HVAC>
<HVACPlant>
<HeatingSystem>
<SystemIdentifier id='heating-system-1'/>
<HeatingSystemType>
<Boiler/>
</HeatingSystemType>
</HeatingSystem>
<HeatPump>
<SystemIdentifier id='heatpump-1'/>
<HeatPumpType>water-to-air</HeatPumpType>
</HeatPump>
</HVACPlant>
</HVAC>
<WaterHeating>
<WaterHeatingSystem>
<SystemIdentifier id='water-heater-1'/>
<HasGeothermalDesuperheater>true</HasGeothermalDesuperheater>
<RelatedHeatingSystem idref='heating-system-1'/>
</WaterHeatingSystem>
<WaterHeatingSystem>
<SystemIdentifier id='water-heater-2'/>
<HasGeothermalDesuperheater>false</HasGeothermalDesuperheater>
<RelatedHeatingSystem idref='heatpump-1'/>
</WaterHeatingSystem>
</WaterHeating>
</Systems>
</BuildingDetails>
</Building>
<Building>
<BuildingID id="bldg2"/>
<ProjectStatus>
<EventType>proposed workscope</EventType>
</ProjectStatus>
<BuildingDetails>
<Systems>
<HVAC>
<HVACPlant>
<HeatingSystem>
<SystemIdentifier id='heating-system-2'/>
<HeatingSystemType>
<Boiler/>
</HeatingSystemType>
</HeatingSystem>
</HVACPlant>
</HVAC>
<WaterHeating>
<WaterHeatingSystem>
<SystemIdentifier id='water-heater-3'/>
<HasGeothermalDesuperheater>true</HasGeothermalDesuperheater>
<RelatedHeatingSystem idref='heating-system-2'/>
</WaterHeatingSystem>
</WaterHeating>
</Systems>
</BuildingDetails>
</Building>
</HPXML>
20 changes: 20 additions & 0 deletions test/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,23 @@ def test_deprecated_items():
assert wh2.AnnualEnergyUse.ConsumptionInfo.ConsumptionType.Water.WaterType == 'indoor water'
assert wh2.AnnualEnergyUse.ConsumptionInfo.ConsumptionType.Water.UnitofMeasure == 'gal'
assert wh2.AnnualEnergyUse.ConsumptionInfo.ConsumptionDetail.Consumption == 600


def test_desuperheater_flexibility():
root = convert_hpxml_and_parse(hpxml_dir / 'desuperheater_flexibility.xml')

whsystem1 = root.Building[0].BuildingDetails.Systems.WaterHeating.WaterHeatingSystem[0]
assert not hasattr(whsystem1, 'HasGeothermalDesuperheater')
assert whsystem1.UsesDesuperheater
assert not hasattr(whsystem1, 'RelatedHeatingSystem')
assert whsystem1.RelatedHVACSystem.attrib['idref'] == 'heating-system-1'
whsystem2 = root.Building[0].BuildingDetails.Systems.WaterHeating.WaterHeatingSystem[1]
assert not hasattr(whsystem2, 'HasGeothermalDesuperheater')
assert not whsystem2.UsesDesuperheater
assert not hasattr(whsystem2, 'RelatedHeatingSystem')
assert whsystem2.RelatedHVACSystem.attrib['idref'] == 'heatpump-1'
whsystem3 = root.Building[1].BuildingDetails.Systems.WaterHeating.WaterHeatingSystem[0]
assert not hasattr(whsystem3, 'HasGeothermalDesuperheater')
assert whsystem3.UsesDesuperheater
assert not hasattr(whsystem3, 'RelatedHeatingSystem')
assert whsystem3.RelatedHVACSystem.attrib['idref'] == 'heating-system-2'

0 comments on commit 9921f6e

Please sign in to comment.