NatLabRockies / NatLabRockies/SAM

SAM crashes when REopt optimization energy rates include kWh/kW units

Open
#2,178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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.

Image
To Reproduce

Steps to reproduce the behavior:

  1. Open example file kwh-kw-max-usage-units.zip
  2. Note kWh/kW units in energy rate table on Electricity Rates page.
  3. On Battery Cell and System page, click Get size and dispatch.
  4. 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:

Image

But perhaps this REopt error handling issue is preventing the error from being displayed correctly: https://github.com/NatLabRockies/SAM/issues/2131.

See also:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.