Skip to content

Commit

Permalink
Merge branch 'master' into update_oshpxml
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerket committed Aug 14, 2019
2 parents f982477 + 3f149a2 commit e07edee
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ def get_hpxml_file_site_neighbor_values(hpxml_file, site_neighbors_values)
site_neighbors_values << { :azimuth => 0,
:distance => 10 }
site_neighbors_values << { :azimuth => 180,
:distance => 15 }
:distance => 15,
:height => 12 }
elsif ['invalid_files/bad-site-neighbor-azimuth.xml'].include? hpxml_file
site_neighbors_values[0][:azimuth] = 145
end
Expand Down
9 changes: 5 additions & 4 deletions measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1468,26 +1468,27 @@ def self.add_thermal_mass(runner, model, building)

def self.add_neighbors(runner, model, building, length)
# Get the max z-value of any model surface
height = -9e99
default_height = -9e99
model.getSpaces.each do |space|
z_origin = space.zOrigin
space.surfaces.each do |surface|
surface.vertices.each do |vertex|
surface_z = vertex.z + z_origin
next if surface_z < height
next if surface_z < default_height

height = surface_z
default_height = surface_z
end
end
end
height = UnitConversions.convert(height, "m", "ft")
default_height = UnitConversions.convert(default_height, "m", "ft")
z_origin = 0 # shading surface always starts at grade

shading_surfaces = []
building.elements.each("BuildingDetails/BuildingSummary/Site/extension/Neighbors/NeighborBuilding") do |neighbor_building|
neighbor_building_values = HPXML.get_neighbor_building_values(neighbor_building: neighbor_building)
azimuth = neighbor_building_values[:azimuth]
distance = neighbor_building_values[:distance]
height = neighbor_building_values[:height].nil? ? default_height : neighbor_building_values[:height]

shading_surface = OpenStudio::Model::ShadingSurface.new(add_wall_polygon(length, height, z_origin, azimuth), model)
shading_surface.additionalProperties.setFeature("Azimuth", azimuth)
Expand Down
13 changes: 13 additions & 0 deletions resources/EPvalidator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def self.run_validator(hpxml_doc)
"/HPXML/Building/BuildingDetails/BuildingSummary/BuildingConstruction/NumberofBedrooms" => one,
"/HPXML/Building/BuildingDetails/BuildingSummary/BuildingConstruction/ConditionedFloorArea" => one,
"/HPXML/Building/BuildingDetails/BuildingSummary/BuildingConstruction/ConditionedBuildingVolume" => one,
"/HPXML/Building/BuildingDetails/BuildingSummary/Site/extension/Neighbors" => zero_or_one, # See [Neighbors]

"/HPXML/Building/BuildingDetails/ClimateandRiskZones/WeatherStation" => one, # See [WeatherStation]

Expand Down Expand Up @@ -90,6 +91,18 @@ def self.run_validator(hpxml_doc)
"/HPXML/Building/BuildingDetails/MiscLoads/PlugLoad[PlugLoadType='TV other']" => zero_or_one, # See [Television]
},

# [Neighbors]
"/HPXML/Building/BuildingDetails/BuildingSummary/Site/extension/Neighbors" => {
"NeighborBuilding" => one_or_more, # See [NeighborBuilding]
},

# [NeighborBuilding]
"/HPXML/Building/BuildingDetails/BuildingSummary/Site/extension/Neighbors/NeighborBuilding" => {
"Azimuth" => one,
"Distance" => one,
"Height" => zero_or_one # if omitted, the neighbor is the same height as the main building
},

# [WeatherStation]
"/HPXML/Building/BuildingDetails/ClimateandRiskZones/WeatherStation" => {
"SystemIdentifier" => one, # Required by HPXML schema
Expand Down
5 changes: 4 additions & 1 deletion resources/hpxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ def self.get_site_values(site:)
def self.add_site_neighbor(hpxml:,
azimuth:,
distance:,
height: nil,
**remainder)
neighbors = XMLHelper.create_elements_as_needed(hpxml, ["Building", "BuildingDetails", "BuildingSummary", "Site", "extension", "Neighbors"])
neighbor_building = XMLHelper.add_element(neighbors, "NeighborBuilding")
XMLHelper.add_element(neighbor_building, "Azimuth", Integer(azimuth))
XMLHelper.add_element(neighbor_building, "Distance", Float(distance))
XMLHelper.add_element(neighbor_building, "Height", Float(height)) unless height.nil?

return neighbor_building
end
Expand All @@ -98,7 +100,8 @@ def self.get_neighbor_building_values(neighbor_building:)
return nil if neighbor_building.nil?

return { :azimuth => to_integer_or_nil(XMLHelper.get_value(neighbor_building, "Azimuth")),
:distance => to_float_or_nil(XMLHelper.get_value(neighbor_building, "Distance")) }
:distance => to_float_or_nil(XMLHelper.get_value(neighbor_building, "Distance")),
:height => to_float_or_nil(XMLHelper.get_value(neighbor_building, "Height")) }
end

def self.add_building_occupancy(hpxml:,
Expand Down
1 change: 1 addition & 0 deletions tests/base-site-neighbors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<NeighborBuilding>
<Azimuth>180</Azimuth>
<Distance>15.0</Distance>
<Height>12.0</Height>
</NeighborBuilding>
</Neighbors>
</extension>
Expand Down
1 change: 1 addition & 0 deletions tests/invalid_files/bad-site-neighbor-azimuth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<NeighborBuilding>
<Azimuth>180</Azimuth>
<Distance>15.0</Distance>
<Height>12.0</Height>
</NeighborBuilding>
</Neighbors>
</extension>
Expand Down

0 comments on commit e07edee

Please sign in to comment.