NatLabRockies / NatLabRockies/SAM
SAM crashes when REopt optimization energy rates include kWh/kW units
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 486
- Forks
- 219
- Avg merge
- 10h 10m
- Merged PRs (30d)
- 2
Description
Describe the bug
When the maximum usage units on the Electricity Rates page are "kWh/kW" in the energy rates table, running the REopt optimization from the Battery Cell and System page causes SAM to crash.
For examples with kWh/kW units, see Duke Energy Large General Servcice (LGS) rates.
To Reproduce
Steps to reproduce the behavior:
- Open example file kwh-kw-max-usage-units.zip
- Note kWh/kW units in energy rate table on Electricity Rates page.
- On Battery Cell and System page, click Get size and dispatch.
- SAM crashes.
Expected behavior
REopt optimization should either run work kWh/kW units, or SAM should display an error message like "REopt optmization does not support kWh/kW maximum usage units for energy rates."
Operating System and Version
SAM 2025.4.16 r1 for Windows.
Additional context
This seems like it should be handled as an error by Line 97 of try_get_rate_structure() in cmod_utilityrate5_eqns.cpp:
But perhaps this REopt error handling issue is preventing the error from being displayed correctly: https://github.com/NatLabRockies/SAM/issues/2131.
See also:
- REopt time series sell rates: https://github.com/NatLabRockies/SAM/issues/2119
- Other unique rate components from Duke Energy: https://github.com/NatLabRockies/SAM/issues/615
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with kwh-kw-max-usage-units.zip by using Get size and dispatch on the Battery Cell and System page. Start in cmod_utilityrate5_eqns.cpp at try_get_rate_structure(), especially line 97, and review the REopt error-handling context in issue 2131. Done means kWh/kW rates no longer crash SAM and either optimize successfully or show an error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100