Skip to content

Commit

Permalink
Merge commit 'adca366a38bd208b63389e167366039d31a2fd2b' into latest-o…
Browse files Browse the repository at this point in the history
…s-hpxml
  • Loading branch information
joseph-robertson committed Sep 26, 2024
2 parents 27bfe04 + adca366 commit 4557d08
Show file tree
Hide file tree
Showing 26 changed files with 91 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>build_residential_schedule_file</name>
<uid>f770b2db-1a9f-4e99-99a7-7f3161a594b1</uid>
<version_id>1872e0df-889e-46ae-8cb9-849eadb97fda</version_id>
<version_modified>2024-09-13T21:54:22Z</version_modified>
<version_id>1fc75fd9-df4c-4ba6-8eff-2366ba375060</version_id>
<version_modified>2024-09-26T04:58:59Z</version_modified>
<xml_checksum>03F02484</xml_checksum>
<class_name>BuildResidentialScheduleFile</class_name>
<display_name>Schedule File Builder</display_name>
Expand Down Expand Up @@ -229,7 +229,7 @@
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>1E6EB1B1</checksum>
<checksum>85B9A7B9</checksum>
</file>
<file>
<filename>shower_cluster_size_probability.csv</filename>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,15 @@ def export(schedules_path:)
schedule_keys = table[0] + schedule_keys
schedule_rows = schedule_rows.map.with_index { |row, i| table[i + 1] + row }
end
CSV.open(schedules_path, 'w') do |csv|
csv << schedule_keys

# Note: We don't use the CSV library here because it's slow for large files
File.open(schedules_path, 'w') do |csv|
csv << "#{schedule_keys.join(',')}\n"
schedule_rows.each do |row|
csv << row
csv << "#{row.join(',')}\n"
end
end

return true
end

Expand Down
18 changes: 9 additions & 9 deletions resources/hpxml-measures/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>e5f1c576-9881-4a74-b9c0-d9a96ec4c6be</version_id>
<version_modified>2024-09-24T18:24:04Z</version_modified>
<version_id>871ee4d0-efe2-4846-80e1-cdc147901ebd</version_id>
<version_modified>2024-09-26T05:18:34Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -351,13 +351,13 @@
<filename>hpxml.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>C8198E51</checksum>
<checksum>278B0E8F</checksum>
</file>
<file>
<filename>hpxml_defaults.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>331D7C8E</checksum>
<checksum>AE852A11</checksum>
</file>
<file>
<filename>hpxml_schema/HPXML.xsd</filename>
Expand Down Expand Up @@ -591,7 +591,7 @@
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>14BD47A8</checksum>
<checksum>7BE6BB34</checksum>
</file>
<file>
<filename>simcontrols.rb</filename>
Expand Down Expand Up @@ -663,7 +663,7 @@
<filename>test_defaults.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>FA4AF769</checksum>
<checksum>1821AF01</checksum>
</file>
<file>
<filename>test_enclosure.rb</filename>
Expand All @@ -681,7 +681,7 @@
<filename>test_hotwater_appliance.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>9FD5D93B</checksum>
<checksum>A1E1E023</checksum>
</file>
<file>
<filename>test_hvac.rb</filename>
Expand Down Expand Up @@ -711,7 +711,7 @@
<filename>test_miscloads.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>C3D97554</checksum>
<checksum>974B3838</checksum>
</file>
<file>
<filename>test_pv.rb</filename>
Expand All @@ -735,7 +735,7 @@
<filename>test_validation.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>57009C9A</checksum>
<checksum>9310E9E6</checksum>
</file>
<file>
<filename>test_water_heater.rb</filename>
Expand Down
6 changes: 3 additions & 3 deletions resources/hpxml-measures/HPXMLtoOpenStudio/resources/hpxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ class BuildingHeader < BaseElement
:manualj_humidity_difference, # [Double] HVACSizingControl/ManualJInputs/HumidityDifference (grains)
:manualj_internal_loads_sensible, # [Double] HVACSizingControl/ManualJInputs/InternalLoadsSensible (Btu/hr)
:manualj_internal_loads_latent, # [Double] HVACSizingControl/ManualJInputs/InternalLoadsLatent (Btu/hr)
:manualj_num_occupants, # [Integer] HVACSizingControl/ManualJInputs/NumberofOccupants
:manualj_num_occupants, # [Double] HVACSizingControl/ManualJInputs/NumberofOccupants
:manualj_infiltration_shielding_class, # [Integer] HVACSizingControl/ManualJInputs/InfiltrationShieldingClass (1-5)
:manualj_infiltration_method, # [String] HVACSizingControl/ManualJInputs/InfiltrationMethod (HPXML::ManualJInfiltrationMethodXXX)
:natvent_days_per_week, # [Integer] NaturalVentilationAvailabilityDaysperWeek
Expand Down Expand Up @@ -2595,7 +2595,7 @@ def to_doc(building)
XMLHelper.add_element(manualj_sizing_inputs, 'HumidityDifference', @manualj_humidity_difference, :float, @manualj_humidity_difference_isdefaulted) unless @manualj_humidity_difference.nil?
XMLHelper.add_element(manualj_sizing_inputs, 'InternalLoadsSensible', @manualj_internal_loads_sensible, :float, @manualj_internal_loads_sensible_isdefaulted) unless @manualj_internal_loads_sensible.nil?
XMLHelper.add_element(manualj_sizing_inputs, 'InternalLoadsLatent', @manualj_internal_loads_latent, :float, @manualj_internal_loads_latent_isdefaulted) unless @manualj_internal_loads_latent.nil?
XMLHelper.add_element(manualj_sizing_inputs, 'NumberofOccupants', @manualj_num_occupants, :integer, @manualj_num_occupants_isdefaulted) unless @manualj_num_occupants.nil?
XMLHelper.add_element(manualj_sizing_inputs, 'NumberofOccupants', @manualj_num_occupants, :float, @manualj_num_occupants_isdefaulted) unless @manualj_num_occupants.nil?
XMLHelper.add_element(manualj_sizing_inputs, 'InfiltrationShieldingClass', @manualj_infiltration_shielding_class, :integer, @manualj_infiltration_shielding_class_isdefaulted) unless @manualj_infiltration_shielding_class.nil?
XMLHelper.add_element(manualj_sizing_inputs, 'InfiltrationMethod', @manualj_infiltration_method, :string, @manualj_infiltration_method_isdefaulted) unless @manualj_infiltration_method.nil?
end
Expand Down Expand Up @@ -2648,7 +2648,7 @@ def from_doc(building)
@manualj_humidity_difference = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/HumidityDifference', :float)
@manualj_internal_loads_sensible = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/InternalLoadsSensible', :float)
@manualj_internal_loads_latent = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/InternalLoadsLatent', :float)
@manualj_num_occupants = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/NumberofOccupants', :integer)
@manualj_num_occupants = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/NumberofOccupants', :float)
@manualj_infiltration_shielding_class = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/InfiltrationShieldingClass', :integer)
@manualj_infiltration_method = XMLHelper.get_value(building_summary, 'extension/HVACSizingControl/ManualJInputs/InfiltrationMethod', :string)
@extension_properties = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def self.apply_building_header_sizing(runner, hpxml_bldg, weather)
runner.registerWarning("ManualJInputs/InternalLoadsLatent (#{hpxml_bldg.header.manualj_internal_loads_latent}) does not match sum of conditioned spaces (#{sum_space_manualj_internal_loads_latent}).")
end

sum_space_manualj_num_occupants = hpxml_bldg.conditioned_spaces.map { |space| space.manualj_num_occupants.to_f }.sum.round
sum_space_manualj_num_occupants = hpxml_bldg.conditioned_spaces.map { |space| space.manualj_num_occupants.to_f }.sum
if hpxml_bldg.header.manualj_num_occupants.nil?
if sum_space_manualj_num_occupants > 0
hpxml_bldg.header.manualj_num_occupants = sum_space_manualj_num_occupants
Expand All @@ -348,7 +348,7 @@ def self.apply_building_header_sizing(runner, hpxml_bldg, weather)
space.manualj_num_occupants = (hpxml_bldg.header.manualj_num_occupants * space.floor_area / total_floor_area).round(2)
space.manualj_num_occupants_isdefaulted = true
end
elsif (hpxml_bldg.header.manualj_num_occupants - sum_space_manualj_num_occupants).abs >= 1 # Tolerance for rounding
elsif (hpxml_bldg.header.manualj_num_occupants - sum_space_manualj_num_occupants).abs >= 0.1
runner.registerWarning("ManualJInputs/NumberofOccupants (#{hpxml_bldg.header.manualj_num_occupants}) does not match sum of conditioned spaces (#{sum_space_manualj_num_occupants}).")
end

Expand Down Expand Up @@ -4292,7 +4292,7 @@ def self.get_weather_station_csv_data
zipcode_csv_filepath = File.join(File.dirname(__FILE__), 'data', 'zipcode_weather_stations.csv')

if $zip_csv_data.nil?
# Don't use the CSV library because it's much slower
# Note: We don't use the CSV library here because it's slow for large files
$zip_csv_data = File.readlines(zipcode_csv_filepath).map(&:strip)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,8 @@ def import(schedules_paths)
num_hrs_in_year = Calendar.num_hours_in_year(@year)
@schedules = {}
schedules_paths.each do |schedules_path|
columns = CSV.read(schedules_path).transpose
# Note: We don't use the CSV library here because it's slow for large files
columns = File.readlines(schedules_path).map(&:strip).map { |r| r.split(',') }.transpose
columns.each do |col|
col_name = col[0]
column = Columns.values.find { |c| c.name == col_name }
Expand Down Expand Up @@ -1348,11 +1349,11 @@ def import(schedules_paths)
def export()
return false if @output_schedules_path.nil?

CSV.open(@output_schedules_path, 'wb') do |csv|
csv << @tmp_schedules.keys
rows = @tmp_schedules.values.transpose
rows.each do |row|
csv << row
# Note: We don't use the CSV library here because it's slow for large files
File.open(@output_schedules_path, 'w') do |csv|
csv << "#{@tmp_schedules.keys.join(',')}\n"
@tmp_schedules.values.transpose.each do |row|
csv << "#{row.join(',')}\n"
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ def test_building
assert_equal(4, default_hpxml_bldg.header.manualj_num_occupants)

# Test defaults w/ NumberOfResidents provided and greater than Nbr+1
hpxml_bldg.building_occupancy.number_of_residents = 6
hpxml_bldg.building_occupancy.number_of_residents = 5.5
XMLHelper.write_file(hpxml.to_doc, @tmp_hpxml_path)
_default_hpxml, default_hpxml_bldg = _test_measure()
assert_equal(6, default_hpxml_bldg.header.manualj_num_occupants)
assert_equal(5.5, default_hpxml_bldg.header.manualj_num_occupants)

# Test defaults - DST in weather file
hpxml, hpxml_bldg = _create_hpxml('base-location-AMY-2012.xml')
Expand Down
Loading

0 comments on commit 4557d08

Please sign in to comment.