Skip to content

Commit 36350b9

Browse files
committed
Fixes possibility of missing surfaces in the results_design_load_details.csv output file. Bug introduced in #1836.
1 parent 76951e1 commit 36350b9

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

HPXMLtoOpenStudio/measure.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def run(model, runner, user_arguments)
121121
# Do these once upfront for the entire HPXML object
122122
epw_path, weather = process_weather(runner, hpxml, args)
123123
process_whole_sfa_mf_inputs(hpxml)
124-
hpxml_sch_map, hpxml_all_zone_loads, hpxml_all_space_loads = process_defaults_schedules_emissions_files(runner, weather, hpxml, args)
124+
hpxml_sch_map, design_loads_results_out = process_defaults_schedules_emissions_files(runner, weather, hpxml, args)
125125

126126
# Write updated HPXML object (w/ defaults) to file for inspection
127127
XMLHelper.write_file(hpxml.to_doc, args[:hpxml_defaults_path])
@@ -157,16 +157,13 @@ def run(model, runner, user_arguments)
157157

158158
# Write annual results output file
159159
# This is helpful if the user wants to get these results right away (e.g.,
160-
# they might be using the run_simulation.rb --skip-simulation argument.
161-
results_out = []
162-
Outputs.append_sizing_results(hpxml.buildings, results_out)
163-
Outputs.write_results_out_to_file(results_out, args[:output_format], args[:annual_output_file_path])
160+
# they might be using the run_simulation.rb --skip-simulation argument).
161+
annual_results_out = []
162+
Outputs.append_sizing_results(hpxml.buildings, annual_results_out)
163+
Outputs.write_results_out_to_file(annual_results_out, args[:output_format], args[:annual_output_file_path])
164164

165165
# Write design load details output file
166-
hpxml.buildings.each do |hpxml_bldg|
167-
HVACSizing.write_detailed_output(args[:output_format], args[:design_load_details_output_file_path],
168-
hpxml_bldg, hpxml_all_zone_loads[hpxml_bldg], hpxml_all_space_loads[hpxml_bldg])
169-
end
166+
HVACSizing.write_detailed_output(design_loads_results_out, args[:output_format], args[:design_load_details_output_file_path])
170167
rescue Exception => e
171168
runner.registerError("#{e.message}\n#{e.backtrace.join("\n")}")
172169
return false
@@ -273,7 +270,7 @@ def process_whole_sfa_mf_inputs(hpxml)
273270
# @param weather [WeatherFile] Weather object containing EPW information
274271
# @param hpxml [HPXML] HPXML object
275272
# @param args [Hash] Map of :argument_name => value
276-
# @return [Array<Hash, Hash, Hash>] Maps of HPXML Building => SchedulesFile object, HPXML Building => (Map of HPXML::Zones => DesignLoadValues object), HPXML Building => (Map of HPXML::Spaces => DesignLoadValues object)
273+
# @return [Array<Hash, Array>] Maps of HPXML Building => SchedulesFile object, Rows of design loads output data
277274
def process_defaults_schedules_emissions_files(runner, weather, hpxml, args)
278275
hpxml_sch_map = {}
279276
hpxml_all_zone_loads = {}
@@ -300,7 +297,14 @@ def process_defaults_schedules_emissions_files(runner, weather, hpxml, args)
300297
Schedule.check_emissions_references(hpxml.header, args[:hpxml_path])
301298
Schedule.validate_emissions_files(hpxml.header)
302299

303-
return hpxml_sch_map, hpxml_all_zone_loads, hpxml_all_space_loads
300+
# Compile design load outputs for subsequent writing
301+
# This needs to come before we collapse enclosure surfaces
302+
design_loads_results_out = []
303+
hpxml.buildings.each do |hpxml_bldg|
304+
HVACSizing.append_detailed_output(hpxml_bldg, hpxml_all_zone_loads[hpxml_bldg], hpxml_all_space_loads[hpxml_bldg], design_loads_results_out)
305+
end
306+
307+
return hpxml_sch_map, design_loads_results_out
304308
end
305309

306310
# Creates a full OpenStudio model that represents the given HPXML individual dwelling by

HPXMLtoOpenStudio/measure.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<schema_version>3.1</schema_version>
44
<name>hpxm_lto_openstudio</name>
55
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
6-
<version_id>64c3bdea-b4b3-4254-9b2a-23987ae4e9f3</version_id>
7-
<version_modified>2024-10-25T00:51:54Z</version_modified>
6+
<version_id>3fc03854-d418-4b79-a205-a24e0a715c1e</version_id>
7+
<version_modified>2024-10-30T01:52:33Z</version_modified>
88
<xml_checksum>D8922A73</xml_checksum>
99
<class_name>HPXMLtoOpenStudio</class_name>
1010
<display_name>HPXML to OpenStudio Translator</display_name>
@@ -183,7 +183,7 @@
183183
<filename>measure.rb</filename>
184184
<filetype>rb</filetype>
185185
<usage_type>script</usage_type>
186-
<checksum>E1E63AE7</checksum>
186+
<checksum>779C018D</checksum>
187187
</file>
188188
<file>
189189
<filename>airflow.rb</filename>
@@ -393,7 +393,7 @@
393393
<filename>hvac_sizing.rb</filename>
394394
<filetype>rb</filetype>
395395
<usage_type>resource</usage_type>
396-
<checksum>CD77F9C7</checksum>
396+
<checksum>485A43BF</checksum>
397397
</file>
398398
<file>
399399
<filename>internal_gains.rb</filename>

HPXMLtoOpenStudio/resources/hvac_sizing.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4892,17 +4892,16 @@ def self.assign_to_hpxml_obj(hpxml_object, loads)
48924892
end
48934893
end
48944894

4895-
# Writes a output file with additional detailed information needed to fill out, e.g., an ACCA Form J1.
4895+
# Appends additional detailed information needed to fill out, e.g., an ACCA Form J1 to the provided array
4896+
# for eventual writing to an output file.
48964897
#
4897-
# @param output_format [String] Detailed output file format ('csv', 'json', or 'msgpack')
4898-
# @param output_file_path [String] Detailed output file path
48994898
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
49004899
# @param all_zone_loads [Hash] Map of HPXML::Zones => DesignLoadValues object
49014900
# @param all_space_loads [Hash] Map of HPXML::Spaces => DesignLoadValues object
4901+
# @param results_out [Array] Rows of output data
49024902
# @return [nil]
4903-
def self.write_detailed_output(output_format, output_file_path, hpxml_bldg, all_zone_loads, all_space_loads)
4903+
def self.append_detailed_output(hpxml_bldg, all_zone_loads, all_space_loads, results_out)
49044904
line_break = nil
4905-
results_out = []
49064905

49074906
orientation_map = { HPXML::OrientationEast => 'E',
49084907
HPXML::OrientationNorth => 'N',
@@ -5048,7 +5047,15 @@ def self.get_surfaces_with_property(obj, additional_property_type)
50485047
all_space_loads.values.each_with_index do |space_loads, i|
50495048
results_out << [space_col_names[i]] + space_loads.HourlyFenestrationLoads.map { |l| l.round }
50505049
end
5050+
end
50515051

5052+
# Writes an output file for the given rows of output data.
5053+
#
5054+
# @param results_out [Array] Rows of output data
5055+
# @param output_format [String] Detailed output file format ('csv', 'json', or 'msgpack')
5056+
# @param output_file_path [String] Detailed output file path
5057+
# @return [nil]
5058+
def self.write_detailed_output(results_out, output_format, output_file_path)
50525059
if ['csv'].include? output_format
50535060
if File.exist? output_file_path
50545061
# Separate from existing data

0 commit comments

Comments
 (0)