Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc refactor/cleanup #1894

Merged
merged 9 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
402 changes: 201 additions & 201 deletions BuildResidentialHPXML/README.md

Large diffs are not rendered by default.

196 changes: 108 additions & 88 deletions BuildResidentialHPXML/measure.rb

Large diffs are not rendered by default.

414 changes: 207 additions & 207 deletions BuildResidentialHPXML/measure.xml

Large diffs are not rendered by default.

102 changes: 58 additions & 44 deletions BuildResidentialHPXML/resources/geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def self.create_single_family_detached(runner:,
# make polygons
polygon_floor = make_polygon(roof_nw_point, roof_ne_point, roof_se_point, roof_sw_point)
side_type = nil
if roof_type == Constants::RoofTypeGable
case roof_type
when Constants::RoofTypeGable
if length >= width
roof_w_point = OpenStudio::Point3d.new(0, width / 2.0, z + attic_height)
roof_e_point = OpenStudio::Point3d.new(length, width / 2.0, z + attic_height)
Expand All @@ -285,7 +286,7 @@ def self.create_single_family_detached(runner:,
polygon_e_wall = make_polygon(roof_e_point, roof_ne_point, roof_nw_point)
end
side_type = EPlus::SurfaceTypeWall
elsif roof_type == Constants::RoofTypeHip
when Constants::RoofTypeHip
if length >= width
roof_w_point = OpenStudio::Point3d.new(width / 2.0, width / 2.0, z + attic_height)
roof_e_point = OpenStudio::Point3d.new(length - width / 2.0, width / 2.0, z + attic_height)
Expand Down Expand Up @@ -330,7 +331,8 @@ def self.create_single_family_detached(runner:,
surface_e_wall.setSpace(attic_space)

# set these to the attic zone
if (attic_type == HPXML::AtticTypeVented) || (attic_type == HPXML::AtticTypeUnvented)
case attic_type
when HPXML::AtticTypeVented, HPXML::AtticTypeUnvented
# create attic zone
attic_zone = OpenStudio::Model::ThermalZone.new(model)
attic_space.setThermalZone(attic_zone)
Expand All @@ -340,7 +342,7 @@ def self.create_single_family_detached(runner:,
attic_space_name = HPXML::LocationAtticUnvented
end
attic_zone.setName(attic_space_name)
elsif attic_type == HPXML::AtticTypeConditioned
when HPXML::AtticTypeConditioned
attic_space.setThermalZone(conditioned_zone)
attic_space_name = HPXML::LocationConditionedSpace
end
Expand Down Expand Up @@ -379,20 +381,23 @@ def self.create_single_family_detached(runner:,
foundation_space = OpenStudio::Model::Space::fromFloorPrint(foundation_polygon, foundation_height, model)
foundation_space = foundation_space.get
assign_indexes(model: model, footprint_polygon: foundation_polygon, space: foundation_space)
if foundation_type == HPXML::FoundationTypeCrawlspaceVented
case foundation_type
when HPXML::FoundationTypeCrawlspaceVented
foundation_space_name = HPXML::LocationCrawlspaceVented
elsif foundation_type == HPXML::FoundationTypeCrawlspaceUnvented
when HPXML::FoundationTypeCrawlspaceUnvented
foundation_space_name = HPXML::LocationCrawlspaceUnvented
elsif foundation_type == HPXML::FoundationTypeCrawlspaceConditioned
when HPXML::FoundationTypeCrawlspaceConditioned
foundation_space_name = HPXML::LocationCrawlspaceConditioned
elsif foundation_type == HPXML::FoundationTypeBasementUnconditioned
when HPXML::FoundationTypeBasementUnconditioned
foundation_space_name = HPXML::LocationBasementUnconditioned
elsif foundation_type == HPXML::FoundationTypeBasementConditioned
when HPXML::FoundationTypeBasementConditioned
foundation_space_name = HPXML::LocationBasementConditioned
elsif foundation_type == HPXML::FoundationTypeAmbient
when HPXML::FoundationTypeAmbient
foundation_space_name = HPXML::LocationOutside
elsif foundation_type.start_with?(HPXML::FoundationTypeBellyAndWing)
foundation_space_name = HPXML::LocationManufacturedHomeUnderBelly
else
if foundation_type.start_with? HPXML::FoundationTypeBellyAndWing
foundation_space_name = HPXML::LocationManufacturedHomeUnderBelly
end
end
foundation_zone.setName(foundation_space_name)
foundation_space.setName(foundation_space_name)
Expand Down Expand Up @@ -814,17 +819,18 @@ def self.create_single_family_attached(model:,
# create foundation zone
foundation_zone = OpenStudio::Model::ThermalZone.new(model)

if foundation_type == HPXML::FoundationTypeCrawlspaceVented
case foundation_type
when HPXML::FoundationTypeCrawlspaceVented
foundation_space_name = HPXML::LocationCrawlspaceVented
elsif foundation_type == HPXML::FoundationTypeCrawlspaceUnvented
when HPXML::FoundationTypeCrawlspaceUnvented
foundation_space_name = HPXML::LocationCrawlspaceUnvented
elsif foundation_type == HPXML::FoundationTypeCrawlspaceConditioned
when HPXML::FoundationTypeCrawlspaceConditioned
foundation_space_name = HPXML::LocationCrawlspaceConditioned
elsif foundation_type == HPXML::FoundationTypeBasementUnconditioned
when HPXML::FoundationTypeBasementUnconditioned
foundation_space_name = HPXML::LocationBasementUnconditioned
elsif foundation_type == HPXML::FoundationTypeBasementConditioned
when HPXML::FoundationTypeBasementConditioned
foundation_space_name = HPXML::LocationBasementConditioned
elsif foundation_type == HPXML::FoundationTypeAmbient
when HPXML::FoundationTypeAmbient
foundation_space_name = HPXML::LocationOutside
end
foundation_zone.setName(foundation_space_name)
Expand Down Expand Up @@ -889,7 +895,8 @@ def self.create_single_family_attached(model:,
attic_space = get_attic_space(model: model, x: x, y: y, average_ceiling_height: average_ceiling_height, num_floors: num_floors, roof_pitch: roof_pitch, roof_type: roof_type, rim_joist_height: rim_joist_height)

# set these to the attic zone
if (attic_type == HPXML::AtticTypeVented) || (attic_type == HPXML::AtticTypeUnvented)
case attic_type
when HPXML::AtticTypeVented, HPXML::AtticTypeUnvented
# create attic zone
attic_zone = OpenStudio::Model::ThermalZone.new(model)
attic_space.setThermalZone(attic_zone)
Expand Down Expand Up @@ -1106,17 +1113,18 @@ def self.create_apartment(model:,
# create foundation zone
foundation_zone = OpenStudio::Model::ThermalZone.new(model)

if foundation_type == HPXML::FoundationTypeCrawlspaceVented
case foundation_type
when HPXML::FoundationTypeCrawlspaceVented
foundation_space_name = HPXML::LocationCrawlspaceVented
elsif foundation_type == HPXML::FoundationTypeCrawlspaceUnvented
when HPXML::FoundationTypeCrawlspaceUnvented
foundation_space_name = HPXML::LocationCrawlspaceUnvented
elsif foundation_type == HPXML::FoundationTypeCrawlspaceConditioned
when HPXML::FoundationTypeCrawlspaceConditioned
foundation_space_name = HPXML::LocationCrawlspaceConditioned
elsif foundation_type == HPXML::FoundationTypeBasementUnconditioned
when HPXML::FoundationTypeBasementUnconditioned
foundation_space_name = HPXML::LocationBasementUnconditioned
elsif foundation_type == HPXML::FoundationTypeBasementConditioned
when HPXML::FoundationTypeBasementConditioned
foundation_space_name = HPXML::LocationBasementConditioned
elsif foundation_type == HPXML::FoundationTypeAmbient
when HPXML::FoundationTypeAmbient
foundation_space_name = HPXML::LocationOutside
end
foundation_zone.setName(foundation_space_name)
Expand Down Expand Up @@ -1179,7 +1187,8 @@ def self.create_apartment(model:,
attic_space = get_attic_space(model: model, x: x, y: y, average_ceiling_height: average_ceiling_height, num_floors: num_floors, roof_pitch: roof_pitch, roof_type: roof_type, rim_joist_height: rim_joist_height)

# set these to the attic zone
if (attic_type == HPXML::AtticTypeVented) || (attic_type == HPXML::AtticTypeUnvented)
case attic_type
when HPXML::AtticTypeVented, HPXML::AtticTypeUnvented
# create attic zone
attic_zone = OpenStudio::Model::ThermalZone.new(model)
attic_space.setThermalZone(attic_zone)
Expand Down Expand Up @@ -1326,16 +1335,17 @@ def self.create_doors(runner:,

# Convert to 3D geometry; assign to surface
door_polygon = OpenStudio::Point3dVector.new
if facade == Constants::FacadeFront
case facade
when Constants::FacadeFront
multx = 1
multy = 0
elsif facade == Constants::FacadeBack
when Constants::FacadeBack
multx = -1
multy = 0
elsif facade == Constants::FacadeLeft
when Constants::FacadeLeft
multx = 0
multy = -1
elsif facade == Constants::FacadeRight
when Constants::FacadeRight
multx = 0
multy = 1
end
Expand Down Expand Up @@ -1602,19 +1612,20 @@ def self.create_windows_and_skylights(runner:,
leftx = skylight_bottom_left.x
lefty = skylight_bottom_left.y
bottomz = skylight_bottom_left.z
if (facade == Constants::FacadeFront) || (facade == Constants::FacadeNone)
case facade
when Constants::FacadeFront, Constants::FacadeNone
skylight_top_left = OpenStudio::Point3d.new(leftx, lefty + Math.cos(surface.tilt) * skylight_length, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_top_right = OpenStudio::Point3d.new(leftx + skylight_width, lefty + Math.cos(surface.tilt) * skylight_length, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_bottom_right = OpenStudio::Point3d.new(leftx + skylight_width, lefty, bottomz)
elsif facade == Constants::FacadeBack
when Constants::FacadeBack
skylight_top_left = OpenStudio::Point3d.new(leftx, lefty - Math.cos(surface.tilt) * skylight_length, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_top_right = OpenStudio::Point3d.new(leftx - skylight_width, lefty - Math.cos(surface.tilt) * skylight_length, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_bottom_right = OpenStudio::Point3d.new(leftx - skylight_width, lefty, bottomz)
elsif facade == Constants::FacadeLeft
when Constants::FacadeLeft
skylight_top_left = OpenStudio::Point3d.new(leftx + Math.cos(surface.tilt) * skylight_length, lefty, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_top_right = OpenStudio::Point3d.new(leftx + Math.cos(surface.tilt) * skylight_length, lefty - skylight_width, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_bottom_right = OpenStudio::Point3d.new(leftx, lefty - skylight_width, bottomz)
elsif facade == Constants::FacadeRight
when Constants::FacadeRight
skylight_top_left = OpenStudio::Point3d.new(leftx - Math.cos(surface.tilt) * skylight_length, lefty, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_top_right = OpenStudio::Point3d.new(leftx - Math.cos(surface.tilt) * skylight_length, lefty + skylight_width, bottomz + Math.sin(surface.tilt) * skylight_length)
skylight_bottom_right = OpenStudio::Point3d.new(leftx, lefty + skylight_width, bottomz)
Expand Down Expand Up @@ -1802,13 +1813,14 @@ def self.get_facade_for_surface(surface:)
# @return [Double] the absolute azimuth based on relative azimuth of the facade and building orientation
def self.get_azimuth_from_facade(facade:,
orientation:)
if facade == Constants::FacadeFront
case facade
when Constants::FacadeFront
return get_abs_azimuth(relative_azimuth: 0, building_orientation: orientation)
elsif facade == Constants::FacadeBack
when Constants::FacadeBack
return get_abs_azimuth(relative_azimuth: 180, building_orientation: orientation)
elsif facade == Constants::FacadeLeft
when Constants::FacadeLeft
return get_abs_azimuth(relative_azimuth: 90, building_orientation: orientation)
elsif facade == Constants::FacadeRight
when Constants::FacadeRight
return get_abs_azimuth(relative_azimuth: 270, building_orientation: orientation)
else
fail 'Unexpected facade.'
Expand Down Expand Up @@ -2290,16 +2302,17 @@ def self.add_window_to_wall(surface:,

# Convert to 3D geometry; assign to surface
window_polygon = OpenStudio::Point3dVector.new
if facade == Constants::FacadeFront
case facade
when Constants::FacadeFront
multx = 1
multy = 0
elsif facade == Constants::FacadeBack
when Constants::FacadeBack
multx = -1
multy = 0
elsif facade == Constants::FacadeLeft
when Constants::FacadeLeft
multx = 0
multy = -1
elsif facade == Constants::FacadeRight
when Constants::FacadeRight
multx = 0
multy = 1
end
Expand Down Expand Up @@ -2458,15 +2471,16 @@ def self.get_attic_space(model:,
attic_height = (y_tot / 2.0) * roof_pitch + rim_joist_height # Roof always has same orientation

side_type = nil
if roof_type == Constants::RoofTypeGable
case roof_type
when Constants::RoofTypeGable
roof_w_point = OpenStudio::Point3d.new(0, y_peak, average_ceiling_height * num_floors + attic_height)
roof_e_point = OpenStudio::Point3d.new(x, y_peak, average_ceiling_height * num_floors + attic_height)
polygon_w_roof = make_polygon(roof_w_point, roof_e_point, ne_point, nw_point)
polygon_e_roof = make_polygon(roof_e_point, roof_w_point, sw_point, se_point)
polygon_s_wall = make_polygon(roof_w_point, nw_point, sw_point)
polygon_n_wall = make_polygon(roof_e_point, se_point, ne_point)
side_type = EPlus::SurfaceTypeWall
elsif roof_type == Constants::RoofTypeHip
when Constants::RoofTypeHip
if y > 0
if x <= (y + y_rear)
roof_n_point = OpenStudio::Point3d.new(x / 2.0, y_rear - x / 2.0, average_ceiling_height * num_floors + attic_height)
Expand Down
Loading