Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReportUtilityBills: fix calculation of production credits #1555

Merged
merged 40 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c323744
Allow defaulting pv compensation type when battery only.
joseph-robertson Nov 15, 2023
cad0ae9
Change has_pv to has_production, and always request electricityproduc…
joseph-robertson Nov 15, 2023
7303c6e
Add sample file for scheduled battery and detailed rate scenarios.
joseph-robertson Nov 15, 2023
9322a7c
Latest results.
Nov 15, 2023
feb4af6
Stub request when generator, add notes, revert defaults changes.
joseph-robertson Nov 16, 2023
da40cd4
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Nov 21, 2023
96db087
Revert changes to hpxml_defaults.
joseph-robertson Nov 21, 2023
39ab9f9
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson May 28, 2024
a83e9fc
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson May 28, 2024
1271878
Run update_hpxmls on new sample file.
joseph-robertson May 28, 2024
2fd16f3
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 12, 2024
177bea4
Remove comments and update pvcompensation defaults for batteries and …
joseph-robertson Jun 12, 2024
cd7fdbf
Only default grid connection if PV is present, not other production.
joseph-robertson Jun 12, 2024
43ead27
Update the changelog. [ci skip]
joseph-robertson Jun 12, 2024
6e69d45
Latest results.
Jun 12, 2024
5ce59b4
Revert default changes and change has_production bool.
joseph-robertson Jun 12, 2024
c89def3
Revert more.
joseph-robertson Jun 12, 2024
a82c3ed
Update the changelog. [ci skip]
joseph-robertson Jun 12, 2024
c44e462
Latest results.
Jun 12, 2024
a085606
Try separating electric storage from produced. Again.
joseph-robertson Jun 13, 2024
f38b82f
Avoid requesting unused meters.
joseph-robertson Jun 13, 2024
5fe9b56
Latest results.
Jun 13, 2024
4f1b58f
Move cogeneration meter out of production.
joseph-robertson Jun 14, 2024
cc40e02
Update the changelog.
joseph-robertson Jun 14, 2024
da3f177
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 14, 2024
4c58736
Latest results.
Jun 14, 2024
d27db69
Fix issue in opposite sign for storage and cogeneration production.
joseph-robertson Jun 14, 2024
c235b29
Latest results.
Jun 14, 2024
a9f6086
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 17, 2024
7289248
Update the changelog.
joseph-robertson Jun 17, 2024
7477cee
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 17, 2024
5885d5d
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 18, 2024
9f02525
Make has_battery consistent with has_pv and has_generator.
joseph-robertson Jun 18, 2024
2af2dd5
Latest results.
Jun 18, 2024
cbb2412
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 20, 2024
d80111e
Revert has_battery change.
joseph-robertson Jun 20, 2024
45a08e9
Latest results.
Jun 20, 2024
d8cb50b
Merge branch 'master' into fix-bills-scheduled-battery2
joseph-robertson Jun 24, 2024
62fd9f5
Latest results.
Jun 24, 2024
2a88d87
Simplify changelog description. [ci skip]
shorowit Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ __New Features__

__Bugfixes__
- Allows additional flexibility for multiple `Attic`/`Foundation` elements.
- ReportUtilityBills measure:
- When PV is present, account for battery storage and generator production as Energy instead of PV Credit.
- Fixes not accounting for battery storage and generator production when PV is not present.

## OpenStudio-HPXML v1.8.1

Expand Down
6 changes: 3 additions & 3 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>381502ab-7765-4f0b-a10b-78f2efc7bfd3</version_id>
<version_modified>2024-06-17T18:00:58Z</version_modified>
<version_id>87813cc6-5733-47ec-91ec-3e2096b8bfa9</version_id>
<version_modified>2024-06-17T21:54:33Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -447,7 +447,7 @@
<filename>schedule_files/battery.csv</filename>
<filetype>csv</filetype>
<usage_type>resource</usage_type>
<checksum>C1350909</checksum>
<checksum>971B85EE</checksum>
</file>
<file>
<filename>schedule_files/hvac-variable-system-maximum-power-ratios-varied.csv</filename>
Expand Down
6 changes: 3 additions & 3 deletions HPXMLtoOpenStudio/resources/schedule_files/battery.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ battery
0
0
0
0
0
0
1
1
0.5
Expand Down Expand Up @@ -8759,3 +8756,6 @@ battery
0
0
0
0
0
0
28 changes: 20 additions & 8 deletions ReportUtilityBills/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,18 @@ def energyPlusOutputRequests(runner, user_arguments)
has_fuel = hpxml.has_fuels(Constants.FossilFuels, hpxml.to_doc)
has_fuel[HPXML::FuelTypeElectricity] = true

# Fuel outputs
# Has production
has_pv = @hpxml_buildings.select { |hpxml_bldg| !hpxml_bldg.pv_systems.empty? }.size > 0
has_battery = @model.getElectricLoadCenterStorageLiIonNMCBatterys.size > 0 # has modeled battery
joseph-robertson marked this conversation as resolved.
Show resolved Hide resolved
has_generator = @hpxml_buildings.select { |hpxml_bldg| !hpxml_bldg.generators.empty? }.size > 0

# Fuel outputs
fuels.each do |(fuel_type, is_production), fuel|
fuel.meters.each do |meter|
next unless has_fuel[hpxml_fuel_map[fuel_type]]
next if is_production && !has_pv
next if is_production && !has_pv # we don't need to request these meters if there isn't pv
next if meter.include?('ElectricStorage') && !has_battery # we don't need to request this meter if there isn't a modeled battery
next if meter.include?('Cogeneration') && !has_generator # we don't need to request this meter if there isn't a generator

result << OpenStudio::IdfObject.load("Output:Meter,#{meter},monthly;").get
if fuel_type == FT::Elec && @hpxml_header.utility_bill_scenarios.has_detailed_electric_rates
Expand Down Expand Up @@ -702,8 +708,8 @@ def get_utility_bills(fuels, utility_rates, utility_bills, utility_bill_scenario
# @return [TODO] TODO
def setup_fuel_outputs()
fuels = {}
fuels[[FT::Elec, false]] = Fuel.new(meters: ["#{EPlus::FuelTypeElectricity}:Facility"], units: UtilityBills.get_fuel_units(HPXML::FuelTypeElectricity))
fuels[[FT::Elec, true]] = Fuel.new(meters: ["#{EPlus::FuelTypeElectricity}Produced:Facility"], units: UtilityBills.get_fuel_units(HPXML::FuelTypeElectricity))
fuels[[FT::Elec, false]] = Fuel.new(meters: ["#{EPlus::FuelTypeElectricity}:Facility", "ElectricStorage:#{EPlus::FuelTypeElectricity}Produced", "Cogeneration:#{EPlus::FuelTypeElectricity}Produced"], units: UtilityBills.get_fuel_units(HPXML::FuelTypeElectricity))
fuels[[FT::Elec, true]] = Fuel.new(meters: ["Photovoltaic:#{EPlus::FuelTypeElectricity}Produced", "PowerConversion:#{EPlus::FuelTypeElectricity}Produced"], units: UtilityBills.get_fuel_units(HPXML::FuelTypeElectricity))
fuels[[FT::Gas, false]] = Fuel.new(meters: ["#{EPlus::FuelTypeNaturalGas}:Facility"], units: UtilityBills.get_fuel_units(HPXML::FuelTypeNaturalGas))
fuels[[FT::Oil, false]] = Fuel.new(meters: ["#{EPlus::FuelTypeOil}:Facility"], units: UtilityBills.get_fuel_units(HPXML::FuelTypeOil))
fuels[[FT::Propane, false]] = Fuel.new(meters: ["#{EPlus::FuelTypePropane}:Facility"], units: UtilityBills.get_fuel_units(HPXML::FuelTypePropane))
Expand Down Expand Up @@ -749,7 +755,7 @@ def get_outputs(fuels, utility_bill_scenario)

timeseries_freq = 'monthly'
timeseries_freq = 'hourly' if fuel_type == FT::Elec && !utility_bill_scenario.elec_tariff_filepath.nil?
fuel.timeseries = get_report_meter_data_timeseries(fuel.meters, unit_conv, 0, timeseries_freq)
fuel.timeseries = get_report_meter_data_timeseries(fuel.meters, unit_conv, timeseries_freq)
end
end

Expand All @@ -760,7 +766,7 @@ def get_outputs(fuels, utility_bill_scenario)
# @param unit_adder [TODO] TODO
# @param timeseries_freq [TODO] TODO
# @return [TODO] TODO
def get_report_meter_data_timeseries(meter_names, unit_conv, unit_adder, timeseries_freq)
def get_report_meter_data_timeseries(meter_names, unit_conv, timeseries_freq)
msgpack_timeseries_name = { 'hourly' => 'Hourly',
'monthly' => 'Monthly' }[timeseries_freq]
begin
Expand All @@ -771,12 +777,18 @@ def get_report_meter_data_timeseries(meter_names, unit_conv, unit_adder, timeser
return [0.0]
end
indexes = cols.each_index.select { |i| meter_names.include? cols[i]['Variable'] }
meter_names = indexes.each.collect { |i| cols[i]['Variable'] }
indexes = Hash[indexes.zip(meter_names)]

vals = []
rows.each do |row|
row = row[row.keys[0]]
val = 0.0
indexes.each do |i|
val += row[i] * unit_conv + unit_adder
indexes.each do |i, meter_name|
r = row[i]
r *= -1 if ["ElectricStorage:#{EPlus::FuelTypeElectricity}Produced", "Cogeneration:#{EPlus::FuelTypeElectricity}Produced"].include?(meter_name) # positive for this meter means producing

val += r * unit_conv
end
vals << val
end
Expand Down
16 changes: 11 additions & 5 deletions ReportUtilityBills/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>report_utility_bills</name>
<uid>ca88a425-e59a-4bc4-af51-c7e7d1e960fe</uid>
<version_id>2b64d6ee-3ffd-4cc9-8d03-d4d074889bd0</version_id>
<version_modified>2024-06-05T21:34:48Z</version_modified>
<version_id>83f4626c-58a4-4b5d-a678-6fc6e2191393</version_id>
<version_modified>2024-06-14T18:08:56Z</version_modified>
<xml_checksum>15BF4E57</xml_checksum>
<class_name>ReportUtilityBills</class_name>
<display_name>Utility Bills Report</display_name>
Expand Down Expand Up @@ -180,7 +180,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>AD1D9C67</checksum>
<checksum>CD8AE948</checksum>
</file>
<file>
<filename>detailed_rates/Sample Flat Rate Min Annual Charge.json</filename>
Expand Down Expand Up @@ -254,6 +254,12 @@
<usage_type>resource</usage_type>
<checksum>4508028D</checksum>
</file>
<file>
<filename>detailed_rates/Sample Time-of-Use Rate High Peak.json</filename>
<filetype>json</filetype>
<usage_type>resource</usage_type>
<checksum>1F5FA05C</checksum>
</file>
<file>
<filename>detailed_rates/Sample Time-of-Use Rate Min Annual Charge.json</filename>
<filetype>json</filetype>
Expand Down Expand Up @@ -300,7 +306,7 @@
<filename>util.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>4286D643</checksum>
<checksum>07D9572B</checksum>
</file>
<file>
<filename>Contains Demand Charges.json</filename>
Expand Down Expand Up @@ -342,7 +348,7 @@
<filename>test_report_utility_bills.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>CDF8B24F</checksum>
<checksum>7B65C730</checksum>
</file>
</files>
</measure>
Loading