Skip to content

Retail rates dispatch grid export#1303

Merged
brtietz merged 20 commits into
developfrom
retail_rates_grid_export_tests
Apr 4, 2025
Merged

Retail rates dispatch grid export#1303
brtietz merged 20 commits into
developfrom
retail_rates_grid_export_tests

Conversation

@brtietz

@brtietz brtietz commented Mar 25, 2025

Copy link
Copy Markdown
Collaborator

Add logic to retail rates dispatch that will discharge power to the grid if the checkbox is checked and if a time of use period (or time series sell rate) has a sell rate greater than the buy rate that day.

Test file:
nbt_sam_analysis_pr_test.zip
Expect to see a meaningful amount (~29 kWh) of battery to grid export in August, but not other months. Feel free to experiment with time of use rates to create more substantial grid discharge.

Pairs with NatLabRockies/SAM#2041

Fixes NatLabRockies/SAM#2040

@coveralls

coveralls commented Mar 25, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 14251804098

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 12 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 54.711%

Files with Coverage Reduction New Missed Lines %
ssc/shared/lib_battery_dispatch_automatic_btm.cpp 12 90.84%
Totals Coverage Status
Change from base Build 14236728494: 0.01%
Covered Lines: 64227
Relevant Lines: 117393

💛 - Coveralls

@cpaulgilman cpaulgilman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. I'm having a hard time coming up with a scenario where battery to grid adds a lot of value, but I am seeing the battery discharge to grid.

For the attached file, I would expect battery to discharge to grid during TOU period 2 (Noon-3pm) with a sell rate of $1/kWh, but the battery only discharges to grid at a very low rate when it is also discharging to the load ("Discharge battery only when load exceeds system output" is unchecked). Is this the desired behavior?

image

batt-to-grid-test.zip

@brtietz

brtietz commented Mar 25, 2025

Copy link
Copy Markdown
Collaborator Author

@cpaulgilman That's a good test - thanks for including it. This is not the intended behavior and highlights a bug in the lib_utility_rate_equations rate_data::get_composite_tou_sell_rate function - where these sell rates are being interpreted as 0 even though they shouldn't be. I'll push a solution to this branch so the battery discharges with the high sell rate you've specified in the case.

sjanzou and others added 2 commits March 26, 2025 02:27
CMPvsamv1BatteryIntegration_cmod_pvsamv1.ResidentialDCBatteryModelPriceSignalDispatchGridExport
/Users/imacuser/Public/Projects/GitHub/NREL/ssc/test/ssc_test/cmod_battery_pvsamv1_test.cpp:1248: Failure
The difference between batt_stats.peakKwCharge and peakKwCharge is 0.24956223857071747, which exceeds m_error_tolerance_lo, where
batt_stats.peakKwCharge evaluates to -4.1395622385707176,
peakKwCharge evaluates to -3.8900000000000001, and
m_error_tolerance_lo evaluates to 0.10000000000000001.
[  FAILED  ] CMPvsamv1BatteryIntegration_cmod_pvsamv1.ResidentialDCBatteryModelPriceSignalDispatchGridExport (31634 ms)
@sjanzou

sjanzou commented Mar 28, 2025

Copy link
Copy Markdown
Collaborator

The following four tests are now failing on Ubuntu

[ FAILED ] 4 tests, listed below:
[ FAILED ] lib_utility_rate_test.test_tiered_tou_cost_estimates
[ FAILED ] lib_utility_rate_test.test_tiered_sell_rates
[ FAILED ] lib_utility_rate_test.test_simple_demand_charges
[ FAILED ] lib_utility_rate_test.test_demand_monthly_tou_demand_charges

@cpaulgilman

Copy link
Copy Markdown
Collaborator

I'll push a solution to this branch so the battery discharges with the high sell rate you've specified in the case.

Thanks!

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we holding off merging this until the Mac tolerance is at a value for the tests to pass?

Comment thread shared/lib_battery_dispatch.cpp Outdated
{
if (a.ExportPerKWh() == b.ExportPerKWh())
{
return a.ExportPerKWh() > b.ExportPerKWh();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brtietz , can you explain the logic here? If the two grid points are equal then return false - always?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a typo. I corrected the tiebreaker to ExportPrice (total paid by utility to discharge at full power) Good catch!

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With latest commit. all 776 tests pass locally on MacOS 15.3.2
image

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With latest commit all tests (except landbosse - since I do not have installed for release build) are passing on windows - not sure why the Windows runners are failing...

image

@dguittet

dguittet commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator

Trying to fix windows runner... bash commands on the Windows bash shell seem to not always be the same as for unix...

@brtietz brtietz merged commit f14b644 into develop Apr 4, 2025
@brtietz brtietz deleted the retail_rates_grid_export_tests branch April 4, 2025 14:39
@cpaulgilman

Copy link
Copy Markdown
Collaborator

PR reviewed for Help revisions -- I made a few minor edits, but no major revisions required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add discharge to grid capability to retail rates dispatch

5 participants