Skip to content

Update Hercules solar model to accept pysam_options dictionary#250

Merged
genevievestarke merged 6 commits intoNatLabRockies:developfrom
genevievestarke:update_solar_model
Apr 20, 2026
Merged

Update Hercules solar model to accept pysam_options dictionary#250
genevievestarke merged 6 commits intoNatLabRockies:developfrom
genevievestarke:update_solar_model

Conversation

@genevievestarke
Copy link
Copy Markdown
Collaborator

@genevievestarke genevievestarke commented Apr 14, 2026

This PR allows the pysam PVWatts model in Hercules to accept a dictionary that can define the parameters in the SystemDesign portion of the model. A good reference for what you can set using this dictionary can be found here: https://h2integrate.readthedocs.io/en/stable/technology_models/pvwattsv8_solar_pv.html

This is fully back compatible with current configurations, but it now allows the solar farm parameters to be set with more precision if needed.

To Do:

  • Update Hercules docs
  • Add a test for this

Tests to add:

  • That an error is thrown if losses, tilt, or system capacity are provided
  • That the solar plant uses the defaults if pysam_options is not provided
  • That the defaults are updated if pysam_options is provided

Comment on lines +47 to +54
print(
"PySAM model options provided in input are being used to define the PVWatts system."
)
if "losses" in h_dict[self.component_name] or "tilt" in h_dict[self.component_name]:
print(
"Warning: 'losses' and 'tilt' parameters in the input will be ignored "
"since PySAM model options are provided."
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For consistency should use self.logger.info in place of print

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And on the warning statement self.logger.warning()

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.

Done! One is updated for a logger.info and the other was changed to a ValueError

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks great, thanks!

sys_design = {
"ModelParams": {"SystemDesign": h_dict[self.component_name]["pysam_options"]},
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need a check that sys_design contains some minimum number of defined parameters? We could also supply defaults through an |

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.

Done! Let me know what you think!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes, that looks really good! I had a few more very small comments but all in all great!

log_channels:
- power

# solar_farm: # The name of component object 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's remove commented code before final merge

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.

Done!

}

# Ensure system capacity is set from upper level of input
# TODO: Should losses and tilt also be forced to be set from
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What if we say, everything that is in effect implemented through sys_design must come in through pysam_options to make things less confusing

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.

Hmm, I was trying to differentiate between the pysam_options definition and the Hercules defaults. We could have defaults for some parameters in pysam_options and not others, but that might obscure what you can actually set. Alternatively, we could require the users to set all of the necessary parameters every time. Thoughts?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My idea was if a parameter is only used by Hercules as a pass-through to pvwatts, it goes into the pysam_options sub_dict, otherwise if it's used at least one other place within Hercules can be higher level and copied in

@paulf81
Copy link
Copy Markdown
Collaborator

paulf81 commented Apr 15, 2026

Thank you @genevievestarke so much for jumping on this!! Had a few comments for your consideration and happy to help with any pieces like logging etc.,

Comment thread hercules/plant_components/solar_pysam_pvwatts.py Outdated
Comment thread hercules/plant_components/solar_pysam_pvwatts.py Outdated
@genevievestarke genevievestarke requested a review from paulf81 April 17, 2026 15:39
Copy link
Copy Markdown
Collaborator

@paulf81 paulf81 left a comment

Choose a reason for hiding this comment

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

Looks great to me!

@genevievestarke genevievestarke merged commit eb5c871 into NatLabRockies:develop Apr 20, 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.

2 participants