Skip to content

Commit

Permalink
Merge pull request #439 from NREL/singleunit
Browse files Browse the repository at this point in the history
Single-Unit Geometry
  • Loading branch information
aspeake committed Feb 9, 2021
2 parents ed7d523 + e1d985f commit 2ee311f
Show file tree
Hide file tree
Showing 500 changed files with 424,423 additions and 953,069 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## ResStock v2.5.0 (pending)

Features

- Model multifamily and single-family attached buildings as individual dwelling units ([#439](https://github.com/NREL/resstock/pull/439))

## ResStock v2.4.0

###### January 27, 2021 - [Diff](https://github.com/NREL/OpenStudio-BuildStock/compare/v2.3.0...v2.4.0)

Features
Expand Down
2 changes: 0 additions & 2 deletions measures/BuildExistingModel/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ def run(model, runner, user_arguments)
runner.registerInfo("The weather station WMO has not been set appropriately in the EPW weather file header.")
end
end
register_value(runner, "units_represented", "#{model.getBuilding.additionalProperties.getFeatureAsInteger("Total Units Represented").get}")
register_value(runner, "units_modeled", "#{model.getBuilding.additionalProperties.getFeatureAsInteger("Total Units Modeled").get}")

# Determine weight
if number_of_buildings_represented.is_initialized
Expand Down
6 changes: 3 additions & 3 deletions measures/BuildExistingModel/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>build_existing_model</name>
<uid>dedf59bb-3b88-4f16-8755-2c1ff5519cbf</uid>
<version_id>589f537a-de41-4f1c-8997-86951e87356a</version_id>
<version_modified>20201209T001937Z</version_modified>
<version_id>c26430a3-f4e7-4053-8320-df9478ceac30</version_id>
<version_modified>20201221T160302Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildExistingModel</class_name>
<display_name>Build Existing Model</display_name>
Expand Down Expand Up @@ -81,7 +81,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F22ACF6E</checksum>
<checksum>ECB064F0</checksum>
</file>
</files>
</measure>
6 changes: 3 additions & 3 deletions measures/PowerOutage/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>process_power_outage</name>
<uid>6b822ead-80f5-4d8d-9642-25a4e0d74304</uid>
<version_id>54acb969-8bcd-49fe-9bda-acc7d587c33f</version_id>
<version_modified>20200715T232323Z</version_modified>
<version_id>cb3c99f5-47ee-4ab5-af30-05ba9e794e7b</version_id>
<version_modified>20200804T161333Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>ProcessPowerOutage</class_name>
<display_name>Set Residential Power Outage</display_name>
Expand Down Expand Up @@ -83,7 +83,7 @@
<filename>power_outage_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>6A3FED12</checksum>
<checksum>0C28662D</checksum>
</file>
</files>
</measure>
5 changes: 3 additions & 2 deletions measures/PowerOutage/tests/power_outage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ def test_outage_more_than_one_day
end

def test_outage_less_than_one_day_dst_mf
num_units = 1
args_hash = {}
args_hash["otg_date"] = "June 2"
args_hash["otg_hr"] = 8
args_hash["otg_len"] = 8
expected_num_del_objects = {}
expected_num_new_objects = { "ScheduleRule" => 10, "ScheduleDay" => 10, "ScheduleFixedInterval" => 1 }
expected_num_new_objects = { "ScheduleRule" => 6, "ScheduleDay" => 6, "ScheduleFixedInterval" => 1 }
expected_values = {}
_test_measure("MF_Successful_EnergyPlus_Run_TMY_Appl_PV.osm", args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, 27)
_test_measure("MF_Successful_EnergyPlus_Run_TMY_Appl_PV.osm", args_hash, expected_num_del_objects, expected_num_new_objects, expected_values, 22)
end

def test_outage_short_run_period
Expand Down
76 changes: 7 additions & 69 deletions measures/SimulationOutputReport/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ def run(runner, user_arguments)

report_sim_output(runner, "total_site_electricity_kwh", electricity.total_end_uses[0] + electricity.photovoltaics[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_heating_kwh", electricity.heating[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_central_system_heating_kwh", electricity.central_heating[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_heating_supplemental_kwh", electricity.heating_supplemental[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_cooling_kwh", electricity.cooling[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_central_system_cooling_kwh", electricity.central_cooling[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_interior_lighting_kwh", electricity.interior_lighting[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_exterior_lighting_kwh", electricity.exterior_lighting[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_exterior_holiday_lighting_kwh", electricity.exterior_holiday_lighting[0], "GJ", elec_site_units)
Expand All @@ -184,18 +182,14 @@ def run(runner, user_arguments)
return false
end

total_units_represented = 0
units.each do |unit|
unit_name = unit.name.to_s.upcase
total_units_represented += output_meters.get_units_represented(unit)

modeledElectricityFansHeating = output_meters.add_unit(sqlFile, modeledElectricityFansHeating, 1, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYFANSHEATING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityFansCooling = output_meters.add_unit(sqlFile, modeledElectricityFansCooling, 1, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYFANSCOOLING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityPumpsHeating = output_meters.add_unit(sqlFile, modeledElectricityPumpsHeating, 1, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYPUMPSHEATING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityPumpsCooling = output_meters.add_unit(sqlFile, modeledElectricityPumpsCooling, 1, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYPUMPSCOOLING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityFansHeating = output_meters.add_unit(sqlFile, modeledElectricityFansHeating, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYFANSHEATING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityFansCooling = output_meters.add_unit(sqlFile, modeledElectricityFansCooling, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYFANSCOOLING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityPumpsHeating = output_meters.add_unit(sqlFile, modeledElectricityPumpsHeating, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYPUMPSHEATING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityPumpsCooling = output_meters.add_unit(sqlFile, modeledElectricityPumpsCooling, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('#{unit_name}:ELECTRICITYPUMPSCOOLING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
end
modeledElectricityPumpsHeating = output_meters.add_unit(sqlFile, modeledElectricityPumpsHeating, 1, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('CENTRAL:ELECTRICITYPUMPSHEATING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")
modeledElectricityPumpsCooling = output_meters.add_unit(sqlFile, modeledElectricityPumpsCooling, 1, "SELECT VariableValue/1000000000 FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableType='Sum' AND VariableName IN ('CENTRAL:ELECTRICITYPUMPSCOOLING') AND ReportingFrequency='Run Period' AND VariableUnits='J') AND TimeIndex IN (SELECT TimeIndex FROM Time WHERE EnvironmentPeriodIndex='#{env_period_ix}')")

electricityFans = 0.0
unless sqlFile.electricityFans.empty?
Expand All @@ -221,17 +215,14 @@ def run(runner, user_arguments)
return false
end
report_sim_output(runner, "electricity_pumps_heating_kwh", electricity.pumps_heating[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_central_system_pumps_heating_kwh", electricity.central_pumps_heating[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_pumps_cooling_kwh", electricity.pumps_cooling[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_central_system_pumps_cooling_kwh", electricity.central_pumps_cooling[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_water_systems_kwh", electricity.water_systems[0], "GJ", elec_site_units)
report_sim_output(runner, "electricity_pv_kwh", electricity.photovoltaics[0], "GJ", elec_site_units)

# NATURAL GAS

report_sim_output(runner, "total_site_natural_gas_therm", natural_gas.total_end_uses[0], "GJ", gas_site_units)
report_sim_output(runner, "natural_gas_heating_therm", natural_gas.heating[0], "GJ", gas_site_units)
report_sim_output(runner, "natural_gas_central_system_heating_therm", natural_gas.central_heating[0], "GJ", gas_site_units)
unless include_enduse_subcategories
report_sim_output(runner, "natural_gas_interior_equipment_therm", natural_gas.interior_equipment[0], "GJ", gas_site_units)
end
Expand All @@ -241,14 +232,12 @@ def run(runner, user_arguments)

report_sim_output(runner, "total_site_fuel_oil_mbtu", fuel_oil.total_end_uses[0], "GJ", other_fuel_site_units)
report_sim_output(runner, "fuel_oil_heating_mbtu", fuel_oil.heating[0], "GJ", other_fuel_site_units)
report_sim_output(runner, "fuel_oil_central_system_heating_mbtu", fuel_oil.central_heating[0], "GJ", other_fuel_site_units)
report_sim_output(runner, "fuel_oil_water_systems_mbtu", fuel_oil.water_systems[0], "GJ", other_fuel_site_units)

# PROPANE

report_sim_output(runner, "total_site_propane_mbtu", propane.total_end_uses[0], "GJ", other_fuel_site_units)
report_sim_output(runner, "propane_heating_mbtu", propane.heating[0], "GJ", other_fuel_site_units)
report_sim_output(runner, "propane_central_system_heating_mbtu", propane.central_heating[0], "GJ", other_fuel_site_units)
unless include_enduse_subcategories
report_sim_output(runner, "propane_interior_equipment_mbtu", propane.interior_equipment[0], "GJ", other_fuel_site_units)
end
Expand All @@ -267,13 +256,6 @@ def run(runner, user_arguments)
propane.total_end_uses[0] +
wood.total_end_uses[0]

if units.length == total_units_represented
err = totalSiteEnergy - sqlFile.totalSiteEnergy.get
if err.abs > 0.5
runner.registerError("Disaggregated total site energy (#{totalSiteEnergy} GJ) relative to building total site energy (#{sqlFile.totalSiteEnergy.get} GJ): #{err} GJ.")
return false
end
end
report_sim_output(runner, "total_site_energy_mbtu", totalSiteEnergy + electricity.photovoltaics[0], "GJ", total_site_units)

# LOADS NOT MET
Expand Down Expand Up @@ -500,11 +482,6 @@ def get_cost_multiplier(cost_mult_type, model, runner)
units.each do |unit|
next if unit.spaces.empty?

units_represented = 1
if unit.additionalProperties.getFeatureAsInteger("Units Represented").is_initialized
units_represented = unit.additionalProperties.getFeatureAsInteger("Units Represented").get
end

cost_mult = 0.0
if cost_mult_type == "Fixed (1)"
cost_mult += 1.0
Expand Down Expand Up @@ -849,22 +826,10 @@ def get_cost_multiplier(cost_mult_type, model, runner)
end
end # spaces

cost_mult *= units_represented
total_cost_mult += cost_mult
end # units
cost_mult = total_cost_mult

total_units_represented = 0
units.each do |unit|
units_represented = 1
if unit.additionalProperties.getFeatureAsInteger("Units Represented").is_initialized
units_represented = unit.additionalProperties.getFeatureAsInteger("Units Represented").get
end
total_units_represented += units_represented
end

collapsed_factor = Float(total_units_represented) / units.length

if cost_mult_type == "Wall Area, Above-Grade, Conditioned (ft^2)"
# Walls between conditioned space and 1) outdoors or 2) unconditioned space
model.getSurfaces.each do |surface|
Expand Down Expand Up @@ -901,36 +866,9 @@ def get_cost_multiplier(cost_mult_type, model, runner)
next if surface.surfaceType.downcase != "wall"
next if surface.outsideBoundaryCondition.downcase != "ground" and surface.outsideBoundaryCondition.downcase != "foundation"

foundation_walls << surface
# Collapsed foundation wall area (walls below units + corridor)
cost_mult += UnitConversions.convert(surface.grossArea, "m^2", "ft^2")
end

model.getSurfaces.each do |surface|
space = surface.space.get
next if surface.surfaceType.downcase != "floor"
next if surface.outsideBoundaryCondition.downcase == "ground" or surface.outsideBoundaryCondition.downcase == "foundation"
next if space.zOrigin != 0

floor_surface = surface

units_represented = 1
if space.buildingUnit.is_initialized
unit = space.buildingUnit.get
if unit.additionalProperties.getFeatureAsInteger("Units Represented").is_initialized
units_represented = unit.additionalProperties.getFeatureAsInteger("Units Represented").get
end
end

next if units_represented <= 1 # Walls under collapsed units are already added

connected_found_walls = Geometry.get_walls_connected_to_floor(foundation_walls, floor_surface, same_space = false)
connected_found_walls.each do |surface|
# Add the collapsed walls below units
cost_mult += UnitConversions.convert(surface.grossArea, "m^2", "ft^2") * (units_represented - 1)
end
end

elsif cost_mult_type == "Floor Area, Conditioned (ft^2)"
# Floors of conditioned zone
model.getSurfaces.each do |surface|
Expand Down Expand Up @@ -958,7 +896,7 @@ def get_cost_multiplier(cost_mult_type, model, runner)
next if adjacent_space.nil?
next if not is_space_conditioned(adjacent_space)

cost_mult += UnitConversions.convert(surface.grossArea, "m^2", "ft^2") * collapsed_factor
cost_mult += UnitConversions.convert(surface.grossArea, "m^2", "ft^2")
end

elsif cost_mult_type == "Floor Area, Lighting (ft^2)"
Expand All @@ -981,7 +919,7 @@ def get_cost_multiplier(cost_mult_type, model, runner)
next if surface.surfaceType.downcase != "roofceiling"
next if surface.outsideBoundaryCondition.downcase != "outdoors"

cost_mult += UnitConversions.convert(surface.grossArea, "m^2", "ft^2") * collapsed_factor
cost_mult += UnitConversions.convert(surface.grossArea, "m^2", "ft^2")
end

elsif cost_mult_type == "Window Area (ft^2)"
Expand All @@ -1008,7 +946,7 @@ def get_cost_multiplier(cost_mult_type, model, runner)
surface.subSurfaces.each do |sub_surface|
next if not sub_surface.subSurfaceType.downcase.include? "door"

cost_mult += UnitConversions.convert(sub_surface.grossArea, "m^2", "ft^2") * collapsed_factor
cost_mult += UnitConversions.convert(sub_surface.grossArea, "m^2", "ft^2")
end
end

Expand Down
8 changes: 4 additions & 4 deletions measures/SimulationOutputReport/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>simulation_output_report</name>
<uid>fc337100-8634-404e-8966-01243d292a79</uid>
<version_id>68ae8c8a-440d-42af-95f8-61b2886a3ad8</version_id>
<version_modified>20210126T201925Z</version_modified>
<version_id>f9f570e1-7937-4d4f-9eb7-0c608b0f4e56</version_id>
<version_modified>20210205T210653Z</version_modified>
<xml_checksum>2C8A3EEF</xml_checksum>
<class_name>SimulationOutputReport</class_name>
<display_name>Simulation Output Report</display_name>
Expand Down Expand Up @@ -57,13 +57,13 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F530F923</checksum>
<checksum>3A118833</checksum>
</file>
<file>
<filename>simulation_output_report_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>07F7BA35</checksum>
<checksum>2714AA75</checksum>
</file>
</files>
</measure>
Loading

0 comments on commit 2ee311f

Please sign in to comment.