Skip to content

Enable compatibility with NREL-PySAM v6 and v7#219

Merged
genevievestarke merged 2 commits intoNatLabRockies:developfrom
misi9170:reqs/pysam
Mar 4, 2026
Merged

Enable compatibility with NREL-PySAM v6 and v7#219
genevievestarke merged 2 commits intoNatLabRockies:developfrom
misi9170:reqs/pysam

Conversation

@misi9170
Copy link
Copy Markdown
Collaborator

@misi9170 misi9170 commented Mar 2, 2026

Currently, Hercules requires NREL-PySAM v6. However, v7 was released in April 2025 and the latest version is v7.1.0 (released August 2025).

Hercules, as is, is not compatible with v7 of NREL-PySAM. This "fixes" this by adding a couple of try/except clauses on a few lines that generate errors. However, I am not sure if this is a legitimate fix or if I am changing the behavior.

With the update:

  • tests pass using both v6.0.1 and v7.1.0
  • example 03_wind_and_solar runs to completion and produces visually the same result:

Using v6.0.1:
image

Using v7.1.0:
image

Assuming we no longer need to use the lines that are excepted in this change, we could simply require v7. However, this is a change that will affect users directly, as they'll need to update their local environments to keep using Hercules. The change I've implemented here allows users to stay on v6, or to move up to v7.

If a valid correction, addresses #218

@paulf81
Copy link
Copy Markdown
Collaborator

paulf81 commented Mar 2, 2026

I think that could work, I think I added those lines when tinkering with this module and not sure how critical. Maybe @brookeslawski would you mind to give this change a look over?

@paulf81 paulf81 requested a review from brookeslawski March 2, 2026 19:38

system_model.AdjustmentFactors.adjust_constant = 0
system_model.AdjustmentFactors.dc_adjust_constant = 0
try:
Copy link
Copy Markdown
Collaborator

@elenya-grant elenya-grant Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to keep backward compatibility with PySAM v6 you could do:

import PySAM

if int(PySAM.__version__.split(".")[0]) < 7:
   system_model.AdjustmentFactors.dc_adjust_constant = 0

instead of the try-except

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to see whether running with v6 with these lines just removed still passes tests

@misi9170
Copy link
Copy Markdown
Collaborator Author

misi9170 commented Mar 4, 2026

Ok, I've now simply removed the two lines that caused issues. Tests still pass, and example 03 still provides (visually) the same output, so perhaps that's good enough?

@genevievestarke genevievestarke merged commit aaa4ed8 into NatLabRockies:develop Mar 4, 2026
3 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.

4 participants