Fix CSP adjustment factor indexing bug#1369
Open
taylorbrown75 wants to merge 3 commits intodevelopfrom
Open
Conversation
There was a problem hiding this comment.
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)wherehour = 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.
tyneises
approved these changes
Feb 26, 2026
Pull Request Test Coverage Report for Build 22496035412Details
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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