Skip to content

Conversation

@gugrimm
Copy link
Contributor

@gugrimm gugrimm commented Dec 16, 2025

Related Issue

Closes #525

Description

This pull request standardizes the handling of energy storage units across the codebase by consistently using a normalized state of charge (soc between 0 and 1) and a new capacity field (in MWh) instead of the previously used max_soc. It updates storage models, strategies, and scenario loaders to use these new conventions, ensuring calculations and constraints are based on normalized values and absolute capacity. This improves clarity, correctness, and interoperability between different modules.

Core data model updates:

  • Replaced max_soc with capacity in the SupportsMinMaxCharge class and related storage classes, and updated all references accordingly. The soc is now always a float between 0 and 1, and all calculations are adjusted to use capacity for absolute values.
  • Updated docstrings and function arguments to clarify that soc is normalized and to document the new capacity field.

Calculation and logic changes:

  • Adjusted all calculations involving state of charge, charging/discharging, and energy deltas to use normalized soc and scale by capacity. This affects dispatch planning, bid calculations, and reward functions.
  • Updated optimization models and constraints to use capacity and normalized soc, including Pyomo model bounds and initializations.

Scenario and loader updates:

  • Modified all scenario loaders (loader_amiris.py, loader_csv.py, loader_oeds.py, loader_pypsa.py, oeds/infrastructure.py) to output capacity and normalized initial_soc, and to require the capacity field in input data.

These changes make the codebase more robust and less error-prone by enforcing a clear separation between normalized and absolute values for storage units.

Checklist

  • Documentation updated (docstrings, READMEs, user guides, inline comments, doc folder updates etc.)
  • New unit/integration tests added (not applicable)
  • Changes noted in release notes (if any)
  • Consent to release this PR's code under the GNU Affero General Public License v3.0

Copy link
Member

@maurerle maurerle left a comment

Choose a reason for hiding this comment

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

Looks good!
I like this and do not see anything major..
Except for the major change, as all examples have to be adjusted.

Maybe we can add a warning in the csv_loader as well if capacity is not configured for a storage_unit?

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 77.50000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.27%. Comparing base (971f652) to head (708deb2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
assume/units/storage.py 66.66% 4 Missing ⚠️
assume/scenario/loader_csv.py 0.00% 2 Missing ⚠️
assume/strategies/flexable.py 66.66% 2 Missing ⚠️
assume/units/dst_components.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #709      +/-   ##
==========================================
- Coverage   81.30%   81.27%   -0.04%     
==========================================
  Files          54       54              
  Lines        8035     8046      +11     
==========================================
+ Hits         6533     6539       +6     
- Misses       1502     1507       +5     
Flag Coverage Δ
pytest 81.27% <77.50%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gugrimm gugrimm marked this pull request as ready for review December 22, 2025 15:31
@gugrimm
Copy link
Contributor Author

gugrimm commented Dec 23, 2025

I added a check for the 'capacity' column to be present in storage_units.csv

@kim-mskw kim-mskw merged commit 0e2aa1a into main Dec 23, 2025
7 of 9 checks passed
@kim-mskw kim-mskw deleted the SoC-naming branch December 23, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SoC name is misleading as it is used with absolute values

5 participants