Skip to content

Fix CSP adjustment factor indexing bug#1369

Open
taylorbrown75 wants to merge 3 commits intodevelopfrom
csp_adjustment_bug
Open

Fix CSP adjustment factor indexing bug#1369
taylorbrown75 wants to merge 3 commits intodevelopfrom
csp_adjustment_bug

Conversation

@taylorbrown75
Copy link
Collaborator

Pull Request Template

Description

The CSP cmods call the adjustment_factors object starting at index=1, but it is zero indexed. This causes the final hour of the year to be zero, because the index is past the array size.

Changed to follow pattern in other cmods, using the index of n_steps rather than the hour of the year.

Corresponding branches and PRs:

SAM, LK, WEX: develop

Unit Test Impact:

Expect minor change in test results because the final hour of the year produces energy (represented in gen - System net electrical power w/ avail. derate variable).

Checklist

  • I've tagged this PR to a milestone

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 pull request fixes a critical indexing bug in CSP (Concentrated Solar Power) compute modules where the adjustment factor array was being accessed using a calculated hour value instead of the timestep index. The bug caused the final hour of the year to have zero generation because ceil(p_time_final_hr[i]) would exceed the array bounds, resulting in a return value of 0.0 from the adjustment_factors operator.

Changes:

  • Replaced hour-based indexing (haf(hour) where hour = ceil(p_time_final_hr[i])) with step-based indexing (haf(i)) across all affected CSP modules
  • This ensures proper array bounds and correct adjustment factor application for all timesteps, including the final hour
  • The fix follows the established pattern used in other cmods like biomass, wind, and generic systems

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ssc/cmod_trough_physical_iph.cpp Fixed adjustment factor indexing for trough physical IPH model (2 occurrences)
ssc/cmod_trough_physical.cpp Fixed adjustment factor indexing for trough physical model (1 occurrence)
ssc/cmod_tcsmolten_salt.cpp Fixed adjustment factor indexing for molten salt tower model (1 occurrence)
ssc/cmod_mspt_iph.cpp Fixed adjustment factor indexing for MSPT IPH model (2 occurrences)
ssc/cmod_linear_fresnel_dsg_iph.cpp Fixed adjustment factor indexing for linear Fresnel DSG IPH model (2 occurrences)
ssc/cmod_fresnel_physical_iph.cpp Fixed adjustment factor indexing for Fresnel physical IPH model (2 occurrences)
ssc/cmod_fresnel_physical.cpp Fixed adjustment factor indexing for Fresnel physical model (1 occurrence)
ssc/cmod_etes_ptes.cpp Fixed adjustment factor indexing for ETES PTES model (1 occurrence)
ssc/cmod_etes_electric_resistance.cpp Fixed adjustment factor indexing for ETES electric resistance model (1 occurrence)

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

@coveralls
Copy link

Pull Request Test Coverage Report for Build 22496035412

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 44 unchanged lines in 9 files lost coverage.
  • Overall coverage decreased (-0.002%) to 57.734%

Files with Coverage Reduction New Missed Lines %
ssc/ssc/cmod_etes_electric_resistance.cpp 1 87.96%
ssc/ssc/cmod_fresnel_physical.cpp 1 88.71%
ssc/ssc/cmod_fresnel_physical_iph.cpp 1 80.56%
ssc/ssc/common.cpp 1 76.1%
ssc/ssc/cmod_tcsmolten_salt.cpp 2 72.54%
ssc/ssc/cmod_trough_physical.cpp 2 75.94%
ssc/ssc/cmod_trough_physical_iph.cpp 2 75.58%
ssc/ssc/cmod_linear_fresnel_dsg_iph.cpp 8 0.0%
ssc/ssc/cmod_mspt_iph.cpp 26 0.0%
Totals Coverage Status
Change from base Build 22075876497: -0.002%
Covered Lines: 69203
Relevant Lines: 119866

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants