Skip to content

Commit 140dfe3

Browse files
committed
Replace error-check with unit tests. Allow PV w/ MaxPowerOutput=0 to run successfully.
1 parent cac7620 commit 140dfe3

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

HPXMLtoOpenStudio/measure.xml

+3-3
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>5ca1d59c-7e04-4173-a237-344775b19e8b</version_id>
7-
<version_modified>2025-02-17T23:51:11Z</version_modified>
6+
<version_id>9cdacdbb-7289-4d0f-a517-3922cf3a30fa</version_id>
7+
<version_modified>2025-02-18T17:48:09Z</version_modified>
88
<xml_checksum>D8922A73</xml_checksum>
99
<class_name>HPXMLtoOpenStudio</class_name>
1010
<display_name>HPXML to OpenStudio Translator</display_name>
@@ -465,7 +465,7 @@
465465
<filename>pv.rb</filename>
466466
<filetype>rb</filetype>
467467
<usage_type>resource</usage_type>
468-
<checksum>9D9BD68D</checksum>
468+
<checksum>C2C1C9BA</checksum>
469469
</file>
470470
<file>
471471
<filename>schedule_files/README.md</filename>

HPXMLtoOpenStudio/resources/pv.rb

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def self.apply_pv_system(model, hpxml_bldg, pv_system)
3737

3838
# Apply unit multiplier
3939
max_power = pv_system.max_power_output * unit_multiplier
40+
return if max_power <= 0
4041

4142
if pv_system.is_shared_system
4243
# Apportion to single dwelling unit by # bedrooms

ReportSimulationOutput/measure.rb

-14
Original file line numberDiff line numberDiff line change
@@ -1433,20 +1433,6 @@ def check_for_errors(runner)
14331433
return false
14341434
end
14351435

1436-
# Check total vs net energy use
1437-
has_pv = @hpxml_bldgs.count { |hpxml_bldg| !hpxml_bldg.pv_systems.empty? } > 0
1438-
if has_pv
1439-
if @totals[TE::Total].annual_output == @totals[TE::Net].annual_output
1440-
runner.registerError('Building has PV but total/net energy uses are equal.')
1441-
return false
1442-
end
1443-
else
1444-
if @totals[TE::Total].annual_output != @totals[TE::Net].annual_output
1445-
runner.registerError('Building does not have PV but total/net energy uses are different.')
1446-
return false
1447-
end
1448-
end
1449-
14501436
# Check sum of electricity produced end use outputs match total output from meter
14511437
sum_elec_prod_annual = @end_uses.select { |k, eu| k[0] == FT::Elec && eu.is_negative }.map { |_k, eu| eu.annual_output.to_f }.sum(0.0) # Negative value
14521438
if (sum_elec_prod_annual - meter_elec_produced).abs > tol

ReportSimulationOutput/measure.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<schema_version>3.1</schema_version>
44
<name>report_simulation_output</name>
55
<uid>df9d170c-c21a-4130-866d-0d46b06073fd</uid>
6-
<version_id>a82d29da-4213-4138-874d-153fecede29b</version_id>
7-
<version_modified>2025-02-18T15:37:37Z</version_modified>
6+
<version_id>8b5a1812-c7f9-4efd-b090-2fe0d74f0bcb</version_id>
7+
<version_modified>2025-02-18T17:50:35Z</version_modified>
88
<xml_checksum>9BF1E6AC</xml_checksum>
99
<class_name>ReportSimulationOutput</class_name>
1010
<display_name>HPXML Simulation Output Report</display_name>
@@ -1972,13 +1972,13 @@
19721972
<filename>measure.rb</filename>
19731973
<filetype>rb</filetype>
19741974
<usage_type>script</usage_type>
1975-
<checksum>5184BE90</checksum>
1975+
<checksum>8BAA16E7</checksum>
19761976
</file>
19771977
<file>
19781978
<filename>test_report_sim_output.rb</filename>
19791979
<filetype>rb</filetype>
19801980
<usage_type>test</usage_type>
1981-
<checksum>E47AF447</checksum>
1981+
<checksum>97D742B1</checksum>
19821982
</file>
19831983
</files>
19841984
</measure>

ReportSimulationOutput/tests/test_report_sim_output.rb

+9
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ def test_annual_only
629629
actual_fridge_energy_use = actual_annual_rows["End Use: #{FT::Elec}: #{EUT::Refrigerator} (MBtu)"]
630630
rated_fridge_energy_use = UnitConversions.convert(hpxml.buildings[0].refrigerators[0].rated_annual_kwh, 'kWh', 'MBtu')
631631
assert_in_epsilon(0.93, actual_fridge_energy_use / rated_fridge_energy_use, 0.1)
632+
633+
# Verify Total/Net outputs when no PV
634+
actual_annual_rows = _get_annual_values(annual_csv)
635+
assert_equal(actual_annual_rows["Energy Use: #{TE::Total} (MBtu)"], actual_annual_rows["Energy Use: #{TE::Net} (MBtu)"])
636+
assert_equal(actual_annual_rows["Fuel Use: #{FT::Elec}: #{TE::Total} (MBtu)"], actual_annual_rows["Fuel Use: #{FT::Elec}: #{TE::Net} (MBtu)"])
632637
end
633638

634639
def test_annual_only2
@@ -702,6 +707,10 @@ def test_timeseries_hourly_total_energy
702707
assert_equal(1, _check_for_constant_timeseries_step(timeseries_cols[0]))
703708
_check_for_nonzero_avg_timeseries_value(timeseries_csv, ["Energy Use: #{TE::Total}",
704709
"Energy Use: #{TE::Net}"])
710+
# Verify Total/Net outputs when PV
711+
actual_annual_rows = _get_annual_values(annual_csv)
712+
assert_operator(actual_annual_rows["Energy Use: #{TE::Total} (MBtu)"], :>, actual_annual_rows["Energy Use: #{TE::Net} (MBtu)"])
713+
assert_operator(actual_annual_rows["Fuel Use: #{FT::Elec}: #{TE::Total} (MBtu)"], :>, actual_annual_rows["Fuel Use: #{FT::Elec}: #{TE::Net} (MBtu)"])
705714
end
706715

707716
def test_timeseries_hourly_fuels

0 commit comments

Comments
 (0)