Skip to content

Enforce saving lifetime variables in PV-Battery simulations#1334

Merged
brtietz merged 4 commits into
patchfrom
SAM_2008
Jul 8, 2025
Merged

Enforce saving lifetime variables in PV-Battery simulations#1334
brtietz merged 4 commits into
patchfrom
SAM_2008

Conversation

@berg-michael

@berg-michael berg-michael commented Jun 30, 2025

Copy link
Copy Markdown
Collaborator

Description

SAM#2008 describes a bug in which deselecting the option to save lifetime variables in a PV-Battery simulation leads SAM to crash. The underlying cause of the crash is described more thoroughly in the SAM issue, but briefly, it is a heap corruption bug caused by the smaller, non-lifetime allocations being too small to compute figures for the battery in cmod_pvsamv1.cpp.

This PR partially resolves this issue by disallowing the option to not save lifetime variables in cases where more than one year is simulated for a PV-Battery system.

A separate PR in the SAM repository disables the corresponding checkbox in the UI for this option and additionally adds a warning message explaining why this option is disabled.

To review, see @brtietz's instructions in the SAM issue:

To Reproduce

Steps to reproduce the behavior:

Set up a behind the meter, detailed PV + battery simulation (tested with host developer)
On the "DC degradation" page, uncheck the "save all output variables over analysis period" box
Set up a grid outage (tested with 100% crit load and an outage in every timestep
Run the simulation
SAM crashes

Fixes NatLabRockies/SAM#2008

Corresponding branches and PRs:

NatLabRockies/SAM#2087

Unit Test Impact:

No changes expected for tests.

Checklist

  • requires help revision and I added that label
  • adds, removes, modifies, or deletes variables in existing compute modules
  • adds a new compute module
  • changes defaults
  • I've tagged this PR to a milestone

@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 15984767644

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 147 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 54.736%

Files with Coverage Reduction New Missed Lines %
ssc/ssc/cmod_pvsamv1.cpp 147 87.34%
Totals Coverage Status
Change from base Build 15459518762: 0.0%
Covered Lines: 64376
Relevant Lines: 117611

💛 - Coveralls

@brtietz brtietz requested review from brtietz and cpaulgilman July 1, 2025 14:48
@brtietz brtietz merged commit d116ea7 into patch Jul 8, 2025
10 checks passed
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.

SAM crashes if "save all output variables over analysis period" is unchecked and a grid outage is specified

4 participants