Skip to content

Commit

Permalink
Merge pull request #128 from NREL/fix/infiltration_design_day_scheduels
Browse files Browse the repository at this point in the history
fix infiltration design day schedule inversion
  • Loading branch information
DavidGoldwasser authored Oct 24, 2023
2 parents e20645a + 033912d commit ad8065f
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 75 deletions.
28 changes: 21 additions & 7 deletions lib/measures/set_nist_infiltration_correlations/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
OpenStudio(R), Copyright (c) 2008, 2023 Alliance for Sustainable Energy, LLC.
OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
(1) Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Redistribution of this software, without modification, must refer to the software by the same designation. Redistribution of a modified version of this software (i) may not refer to the modified version by the same designation, or by any confusingly similar designation, and (ii) must refer to the underlying software originally provided by Alliance as “OpenStudio®”. Except to comply with the foregoing, the term “OpenStudio®”, or any confusingly similar designation may not be used to refer to any modified version of this software or any modified version of the underlying software originally provided by Alliance without the prior written consent of Alliance.
(3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse
or promote products derived from this software without specific prior written permission from the
respective party.

4. The name of the copyright holder(s), any contributors, the United States Government, the United States Department of Energy, or any of their employees may not be used to endorse or promote products derived from this software without specific prior written permission from the respective party.
(4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other
derivative works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar
designation without specific prior written permission from Alliance for Sustainable Energy, LLC.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT,
OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93 changes: 66 additions & 27 deletions lib/measures/set_nist_infiltration_correlations/measure.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# *******************************************************************************
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
# See also https://openstudio.net/license
# OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# (3) Neither the name of the copyright holder nor the names of any contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission from the respective party.
#
# (4) Other than as required in clauses (1) and (2), distributions in any form
# of modifications or other derivative works may not use the "OpenStudio"
# trademark, "OS", "os", or any other confusingly similar designation without
# specific prior written permission from Alliance for Sustainable Energy, LLC.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

require 'csv'
Expand Down Expand Up @@ -114,44 +144,53 @@ def infer_nist_building_type(model)
return results
end

# method to invert a schedule day
def invert_schedule_day(old_schedule_day, new_schedule_day, new_schedule_name)
new_schedule_day.setName("#{new_schedule_name}")
for index in 0..old_schedule_day.times.size-1
old_value = old_schedule_day.values[index]
if old_value == 0
new_value = 1
else
new_value = 0
end
new_schedule_day.addValue(old_schedule_day.times[index], new_value)
end

return new_schedule_day
end

# method to invert a schedule ruleset
def invert_schedule_ruleset(schedule_ruleset, new_schedule_name)
model = schedule_ruleset.model
new_schedule = OpenStudio::Model::ScheduleRuleset.new(model, 0.0)
new_schedule.setName(new_schedule_name)

# change summer design day
summer_design_day_schedule = schedule_ruleset.summerDesignDaySchedule
new_summer_design_day_schedule = OpenStudio::Model::ScheduleDay.new(model)
invert_schedule_day(summer_design_day_schedule, new_summer_design_day_schedule, "#{new_schedule_name} Summer Design Day Schedule")
new_schedule.setSummerDesignDaySchedule(new_summer_design_day_schedule)

# change winter design day
winter_design_day_schedule = schedule_ruleset.winterDesignDaySchedule
new_winter_design_day_schedule = OpenStudio::Model::ScheduleDay.new(model)
invert_schedule_day(winter_design_day_schedule, new_winter_design_day_schedule, "#{new_schedule_name} Winter Design Day Schedule")
new_schedule.setWinterDesignDaySchedule(new_winter_design_day_schedule)

# change the default day values
default_day_schedule = schedule_ruleset.defaultDaySchedule
new_default_day_schedule = new_schedule.defaultDaySchedule
new_default_day_schedule.setName("#{new_schedule_name} Default Day Schedule")
for index in 0..default_day_schedule.times.size-1
old_value = default_day_schedule.values[index]
if old_value == 0
new_value = 1
else
new_value = 0
end
new_default_day_schedule.addValue(default_day_schedule.times[index], new_value)
end
invert_schedule_day(default_day_schedule, new_default_day_schedule, "#{new_schedule_name} Default Day Schedule")

# change for schedule rules
schedule_ruleset.scheduleRules.each_with_index do |rule, i|
old_day_schedule = rule.daySchedule
new_day_schedule = OpenStudio::Model::ScheduleDay.new(model)
new_day_schedule.setName("#{new_schedule_name} Schedule Day #{i}")
index = 0
for index in 0..old_day_schedule.times.size-1
old_value = old_day_schedule.values[index]
if old_value == 0
new_value = 1
else
new_value = 0
end
new_day_schedule.addValue(old_day_schedule.times[index], new_value)
end
old_schedule_day = rule.daySchedule
new_schedule_day = OpenStudio::Model::ScheduleDay.new(model)
invert_schedule_day(old_schedule_day, new_schedule_day, "#{new_schedule_name} Schedule Day #{i}")

new_rule = OpenStudio::Model::ScheduleRule.new(new_schedule, new_day_schedule)
new_rule.setName("#{new_day_schedule.name} Rule")
new_rule = OpenStudio::Model::ScheduleRule.new(new_schedule, new_schedule_day)
new_rule.setName("#{new_schedule_day.name} Rule")
new_rule.setApplySunday(rule.applySunday)
new_rule.setApplyMonday(rule.applyMonday)
new_rule.setApplyTuesday(rule.applyTuesday)
Expand Down
78 changes: 39 additions & 39 deletions lib/measures/set_nist_infiltration_correlations/measure.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.0</schema_version>
<schema_version>3.1</schema_version>
<name>set_nist_infiltration_correlations</name>
<uid>b74a4a45-8553-4e94-860f-35b217a04879</uid>
<version_id>835623bd-29ab-4caa-9a94-2607823cfc60</version_id>
<version_modified>20230602T160044Z</version_modified>
<version_id>ce0c799c-cf11-4505-95b3-afaf5d58647b</version_id>
<version_modified>2023-08-11T17:01:19Z</version_modified>
<xml_checksum>A54BB41C</xml_checksum>
<class_name>SetNISTInfiltrationCorrelations</class_name>
<display_name>SetNISTInfiltrationCorrelations</display_name>
Expand Down Expand Up @@ -262,18 +262,24 @@
</attribute>
</attributes>
<files>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>26A358DA</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>7B4E3347</checksum>
</file>
<file>
<filename>README.md.erb</filename>
<filetype>erb</filetype>
<usage_type>readmeerb</usage_type>
<checksum>F1C26127</checksum>
</file>
<file>
<filename>Data-NISTInfiltrationCorrelations.csv</filename>
<filetype>csv</filetype>
<usage_type>resource</usage_type>
<checksum>FC1FA7E1</checksum>
</file>
<file>
<filename>Data-NISTInfiltrationCorrelations.xlsx</filename>
<filetype>xlsx</filetype>
Expand All @@ -286,6 +292,23 @@
<usage_type>doc</usage_type>
<checksum>0B901E1A</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>3.4.0</identifier>
<min_compatible>3.4.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F79A9B8A</checksum>
</file>
<file>
<filename>Data-NISTInfiltrationCorrelations.csv</filename>
<filetype>csv</filetype>
<usage_type>resource</usage_type>
<checksum>FC1FA7E1</checksum>
</file>
<file>
<filename>bldg0000003.osm</filename>
<filetype>osm</filetype>
Expand All @@ -298,6 +321,12 @@
<usage_type>test</usage_type>
<checksum>6274AD32</checksum>
</file>
<file>
<filename>bldg0000005.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>2174B2C9</checksum>
</file>
<file>
<filename>bldg0000025.osm</filename>
<filetype>osm</filetype>
Expand Down Expand Up @@ -334,40 +363,11 @@
<usage_type>test</usage_type>
<checksum>761CC6B3</checksum>
</file>
<file>
<filename>bldg0000005.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>2174B2C9</checksum>
</file>
<file>
<filename>README.md</filename>
<filetype>md</filetype>
<usage_type>readme</usage_type>
<checksum>7B4E3347</checksum>
</file>
<file>
<filename>LICENSE.md</filename>
<filetype>md</filetype>
<usage_type>license</usage_type>
<checksum>BFFB1AA6</checksum>
</file>
<file>
<filename>nist_infiltration_correlations_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>BB86A4F3</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>3.4.0</identifier>
<min_compatible>3.4.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F5790FA9</checksum>
<checksum>E2AA7EF4</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# *******************************************************************************
# OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
# See also https://openstudio.net/license
# OpenStudio(R), Copyright (c) 2008-2023, Alliance for Sustainable Energy, LLC.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# (1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# (2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# (3) Neither the name of the copyright holder nor the names of any contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission from the respective party.
#
# (4) Other than as required in clauses (1) and (2), distributions in any form
# of modifications or other derivative works may not use the "OpenStudio"
# trademark, "OS", "os", or any other confusingly similar designation without
# specific prior written permission from Alliance for Sustainable Energy, LLC.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# *******************************************************************************

require 'openstudio'
Expand Down

0 comments on commit ad8065f

Please sign in to comment.