Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/NREL/OpenStudio-HPXML int…
Browse files Browse the repository at this point in the history
…o whole_building_common_spaces
  • Loading branch information
yzhou601 committed Oct 11, 2024
2 parents e0979da + 5b28c43 commit 5ee2c83
Show file tree
Hide file tree
Showing 13 changed files with 452 additions and 541 deletions.
26 changes: 13 additions & 13 deletions HPXMLtoOpenStudio/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>hpxm_lto_openstudio</name>
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
<version_id>def2ddd0-5df4-4ac3-91a5-f2b0b9f44158</version_id>
<version_modified>2024-10-11T23:30:30Z</version_modified>
<version_id>d0d216df-6a0f-4c40-aea7-868520ee3214</version_id>
<version_modified>2024-10-11T23:33:05Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -189,7 +189,7 @@
<filename>airflow.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>AAA32BAD</checksum>
<checksum>CA1394A8</checksum>
</file>
<file>
<filename>battery.rb</filename>
Expand All @@ -213,7 +213,7 @@
<filename>constructions.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>5D07F8B2</checksum>
<checksum>B3B897EB</checksum>
</file>
<file>
<filename>data/Xing_okstate_0664D_13659_Table_A-3.csv</filename>
Expand Down Expand Up @@ -345,19 +345,19 @@
<filename>geometry.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>1B96AD6A</checksum>
<checksum>86AC0076</checksum>
</file>
<file>
<filename>hotwater_appliances.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>E9F876DA</checksum>
<checksum>4A5DFE48</checksum>
</file>
<file>
<filename>hpxml.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>F5E75573</checksum>
<checksum>7B796423</checksum>
</file>
<file>
<filename>hpxml_schema/HPXML.xsd</filename>
Expand Down Expand Up @@ -387,7 +387,7 @@
<filename>hvac.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>3F8A3A86</checksum>
<checksum>CEDAF4B3</checksum>
</file>
<file>
<filename>hvac_sizing.rb</filename>
Expand Down Expand Up @@ -429,7 +429,7 @@
<filename>meta_measure.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>979E2224</checksum>
<checksum>F335EDC8</checksum>
</file>
<file>
<filename>minitest_helper.rb</filename>
Expand All @@ -447,7 +447,7 @@
<filename>model.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>DF90E119</checksum>
<checksum>41C15CE6</checksum>
</file>
<file>
<filename>output.rb</filename>
Expand Down Expand Up @@ -591,7 +591,7 @@
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>B73029E3</checksum>
<checksum>BB101800</checksum>
</file>
<file>
<filename>simcontrols.rb</filename>
Expand Down Expand Up @@ -627,7 +627,7 @@
<filename>waterheater.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>1E7D40B1</checksum>
<checksum>790B832E</checksum>
</file>
<file>
<filename>weather.rb</filename>
Expand Down Expand Up @@ -723,7 +723,7 @@
<filename>test_schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>703BFE7A</checksum>
<checksum>62B8CE90</checksum>
</file>
<file>
<filename>test_simcontrols.rb</filename>
Expand Down
43 changes: 24 additions & 19 deletions HPXMLtoOpenStudio/resources/airflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -635,27 +635,32 @@ def self.apply_natural_ventilation_and_whole_house_fan(runner, model, spaces, hp
# @param unavailable_periods [HPXML::UnavailablePeriods] Object that defines periods for, e.g., power outages or vacancies
# @return [TODO] TODO
def self.create_nv_and_whf_avail_sch(model, obj_name, num_days_per_week, unavailable_periods)
avail_sch = OpenStudio::Model::ScheduleRuleset.new(model)
sch_name = "#{obj_name} schedule"
avail_sch.setName(sch_name)
avail_sch.defaultDaySchedule.setName("#{sch_name} default day")
Schedule.set_schedule_type_limits(model, avail_sch, EPlus::ScheduleTypeLimitsOnOff)
on_rule = OpenStudio::Model::ScheduleRule.new(avail_sch)
on_rule.setName("#{sch_name} rule")
on_rule_day = on_rule.daySchedule
on_rule_day.setName("#{sch_name} avail day")
on_rule_day.addValue(OpenStudio::Time.new(0, 24, 0, 0), 1)
method_array = ['setApplyMonday', 'setApplyWednesday', 'setApplyFriday', 'setApplySaturday', 'setApplyTuesday', 'setApplyThursday', 'setApplySunday']
for i in 1..7 do
if num_days_per_week >= i
on_rule.public_send(method_array[i - 1], true)
end
end
on_rule.setStartDate(OpenStudio::Date::fromDayOfYear(1))
on_rule.setEndDate(OpenStudio::Date::fromDayOfYear(365))
avail_sch = Model.add_schedule_ruleset(
model,
name: sch_name,
limits: EPlus::ScheduleTypeLimitsOnOff
)

# Apply to days in this order: Mon, Wed, Fri, Sat, Tues, Thurs, Sun
apply_to_days = [0] * 7
apply_to_days[0] = 1 if num_days_per_week >= 7
apply_to_days[1] = 1 if num_days_per_week >= 1
apply_to_days[2] = 1 if num_days_per_week >= 5
apply_to_days[3] = 1 if num_days_per_week >= 2
apply_to_days[4] = 1 if num_days_per_week >= 6
apply_to_days[5] = 1 if num_days_per_week >= 3
apply_to_days[6] = 1 if num_days_per_week >= 4

Model.add_schedule_ruleset_rule(
avail_sch,
start_date: OpenStudio::Date::fromDayOfYear(1),
end_date: OpenStudio::Date::fromDayOfYear(365),
apply_to_days: apply_to_days,
hourly_values: [1] * 24
)

year = model.getYearDescription.assumedYear
Schedule.set_unavailable_periods(avail_sch, sch_name, unavailable_periods, year)
Schedule.set_unavailable_periods(model, avail_sch, sch_name, unavailable_periods)
return avail_sch
end

Expand Down
3 changes: 2 additions & 1 deletion HPXMLtoOpenStudio/resources/constructions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,8 @@ def self.apply_window_skylight_shading(model, window_or_skylight, sub_surface, s
sf_sch = Model.add_schedule_constant(
model,
name: sch_name,
value: sf_values[0][0]
value: sf_values[0][0],
limits: EPlus::ScheduleTypeLimitsFraction
)
else
sf_sch = HourlyByDaySchedule.new(model, sch_name, sf_values, sf_values, EPlus::ScheduleTypeLimitsFraction, false).schedule
Expand Down
8 changes: 2 additions & 6 deletions HPXMLtoOpenStudio/resources/geometry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,8 @@ def self.get_space_temperature_schedule(model, location, spaces)
sch = Model.add_schedule_constant(
model,
name: location,
value: nil
value: nil,
limits: EPlus::ScheduleTypeLimitsTemperature
)
sch.additionalProperties.setFeature('ObjectType', location)

Expand Down Expand Up @@ -1892,11 +1893,6 @@ def self.get_space_temperature_schedule(model, location, spaces)
end
end

# Schedule type limits compatible
schedule_type_limits = OpenStudio::Model::ScheduleTypeLimits.new(model)
schedule_type_limits.setUnitType('Temperature')
sch.setScheduleTypeLimits(schedule_type_limits)

# Sensors
if space_values[:indoor_weight] > 0
if not spaces[HPXML::LocationConditionedSpace].thermalZone.get.thermostatSetpointDualSetpoint.is_initialized
Expand Down
4 changes: 2 additions & 2 deletions HPXMLtoOpenStudio/resources/hotwater_appliances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ def self.apply(runner, model, weather, spaces, hpxml_bldg, hpxml_header, schedul
mw_temp_schedule = Model.add_schedule_constant(
model,
name: 'mixed water temperature schedule',
value: UnitConversions.convert(t_mix, 'F', 'C')
value: UnitConversions.convert(t_mix, 'F', 'C'),
limits: EPlus::ScheduleTypeLimitsTemperature
)
Schedule.set_schedule_type_limits(model, mw_temp_schedule, EPlus::ScheduleTypeLimitsTemperature)

# Create schedule
fixtures_schedule = nil
Expand Down
2 changes: 1 addition & 1 deletion HPXMLtoOpenStudio/resources/hpxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11208,7 +11208,7 @@ class HeatingPerformanceDataPoint < BaseElement
# @return [nil]
def delete
(@parent_object.heating_systems + @parent_object.heat_pumps).each do |heating_system|
heating_system.cooling_detailed_performance_data.delete(self)
heating_system.heating_detailed_performance_data.delete(self)
end
end

Expand Down
15 changes: 7 additions & 8 deletions HPXMLtoOpenStudio/resources/hvac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,8 @@ def self.apply_boiler(model, runner, heating_system, hvac_sequential_load_fracs,
supply_setpoint = Model.add_schedule_constant(
model,
name: "#{obj_name} hydronic heat supply setpoint",
value: UnitConversions.convert(design_temp, 'F', 'C')
value: UnitConversions.convert(design_temp, 'F', 'C'),
limits: EPlus::ScheduleTypeLimitsTemperature
)

setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(model, supply_setpoint)
Expand Down Expand Up @@ -2570,9 +2571,9 @@ def self.create_air_loop_unitary_system(model, obj_name, fan, htg_coil, clg_coil
cycle_fan_sch = Model.add_schedule_constant(
model,
name: "#{obj_name} auto fan schedule",
value: 0
) # 0 denotes that fan cycles on and off to meet the load (i.e., AUTO fan) as opposed to continuous operation
Schedule.set_schedule_type_limits(model, cycle_fan_sch, EPlus::ScheduleTypeLimitsOnOff)
value: 0, # 0 denotes that fan cycles on and off to meet the load (i.e., AUTO fan) as opposed to continuous operation
limits: EPlus::ScheduleTypeLimitsOnOff
)

air_loop_unitary = OpenStudio::Model::AirLoopHVACUnitarySystem.new(model)
air_loop_unitary.setName(obj_name + ' unitary system')
Expand Down Expand Up @@ -4603,10 +4604,8 @@ def self.get_sequential_load_schedule(model, fractions, unavailable_periods)
s = ScheduleConstant.new(model, sch_name, values[0], EPlus::ScheduleTypeLimitsFraction, unavailable_periods: unavailable_periods)
s = s.schedule
else
s = Schedule.create_ruleset_from_daily_season(model, values)
s.setName(sch_name)
Schedule.set_unavailable_periods(s, sch_name, unavailable_periods, model.getYearDescription.assumedYear)
Schedule.set_schedule_type_limits(model, s, EPlus::ScheduleTypeLimitsFraction)
s = Schedule.create_ruleset_from_daily_season(model, sch_name, values)
Schedule.set_unavailable_periods(model, s, sch_name, unavailable_periods)
end

return s
Expand Down
13 changes: 9 additions & 4 deletions HPXMLtoOpenStudio/resources/meta_measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Initialize OpenStudio objects (log, model, runner, etc.).
# Call run methods of OpenStudio Model measures.
# Report infos/warnings/errors to run.log file.
# Forward translate the model and call energyPlusOutputRequests methods.
# Forward translate the model, write IDF, and call energyPlusOutputRequests methods.
# Again, report any log messages to file.
# Simulate the IDF using the EnergyPlus CLI.
# Call run methods of OpenStudio ReportingMeasures.
Expand All @@ -15,12 +15,13 @@
# @param measures [Hash] Map of OpenStudio-HPXML measure directory name => List of measure argument hashes
# @param measures_dir [String] Parent directory path of all OpenStudio-HPXML measures
# @param debug [Boolean] If true, reports info statements from the runner results
# @param run_measures_only [Boolean] True applies only OpenStudio Model measures, skipping forward translation and the simulation
# @param run_measures_only [Boolean] True applies only OpenStudio Model measures, skipping IDF generation and the simulation
# @param skip_simulation [Boolean] True applies the OpenStudio Model measures and generates the IDF, but skips the simulation
# @param ep_input_format [String] EnergyPlus input file format (idf, epjson)
# @param suppress_print [Boolean] True reduces printed workflow output
# @return [Hash] Map of 'success' and 'runner' results
def run_hpxml_workflow(rundir, measures, measures_dir, debug: false,
run_measures_only: false, ep_input_format: 'idf', suppress_print: false)
def run_hpxml_workflow(rundir, measures, measures_dir, debug: false, run_measures_only: false,
skip_simulation: false, ep_input_format: 'idf', suppress_print: false)
rm_path(rundir)
FileUtils.mkdir_p(rundir)

Expand Down Expand Up @@ -99,6 +100,10 @@ def run_hpxml_workflow(rundir, measures, measures_dir, debug: false,
fail "Unexpected ep_input_format: #{ep_input_format}."
end

if skip_simulation
return { success: success, runner: runner }
end

if not model.getWeatherFile.path.is_initialized
print "Creating input unsuccessful.\n"
print "See #{File.join(rundir, 'run.log')} for details.\n"
Expand Down
Loading

0 comments on commit 5ee2c83

Please sign in to comment.