Skip to content

Conversation

@paulf81
Copy link
Collaborator

@paulf81 paulf81 commented Dec 10, 2025

This PR accomplishes 3 things:

  1. A bug in the logic of the BatteryPriceSOCController is corrected and tests are updated to pass
  2. BatteryPriceSOCController is updated to allow for non-4 hour battery durations (up to 12). A new test is added to test a non-4 hour battery configuration as well.
  3. The docstring of BatteryPriceSOCController is made a bit more descriptive for future reference (contrast with similar controllers)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the BatteryPriceSOCController to support batteries with variable durations (up to 12 hours) rather than being hardcoded for 4-hour batteries. It fixes a critical bug in the SOC threshold logic and improves documentation.

Key Changes:

  • Fixed bug where discharge/charge logic used incorrect SOC comparisons (lines 248, 252 in controller)
  • Added dynamic duration calculation based on energy_capacity/power_capacity ratio
  • Enhanced class-level docstring with comprehensive algorithm explanation
  • Updated existing tests and added new 2-hour battery test case

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
hycon/controllers/battery_controller.py Added duration calculation, validation, and comprehensive docstring; fixed SOC comparison logic in compute_controls
tests/battery_test.py Updated test assertions to match corrected logic; added new test for 2-hour battery configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@misi9170 misi9170 left a comment

Choose a reason for hiding this comment

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

Overall, this looks good to me. Some of the Copilot comments are probably worth addressing, and I've weighed in on a couple. Feel free to re-request my review when you're happy and I'll go through once more to approve.

@misi9170 misi9170 changed the title Feature/mulitple durations Enable battery SOC controller to handle multiple battery durations [+bugfix] Dec 10, 2025
@misi9170 misi9170 added bug Something isn't working enhancement New feature or request labels Dec 10, 2025
@paulf81 paulf81 requested a review from misi9170 December 10, 2025 22:20
@paulf81
Copy link
Collaborator Author

paulf81 commented Dec 10, 2025

on

incoming... think I was on your heels going back through comments

@misi9170 misi9170 changed the title Enable battery SOC controller to handle multiple battery durations [+bugfix] Enable BatteryPriceSOCController to handle multiple battery durations [+bugfix for high/low SOC] Dec 11, 2025
@misi9170 misi9170 merged commit 3fba8b1 into NREL:develop Dec 11, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants