Skip to content

Conversation

@elenya-grant
Copy link
Collaborator

@elenya-grant elenya-grant commented Nov 26, 2025

Preprocessing Tool for Turbine Model Files

Added pre-processing methods/tools that can be used to assist making input files (for wind performance models) for running H2I. The methods in this PR utilize some functionality in the turbine-models library package.

Note: the PySAM wind plant model does not allow for rotor diameter or hub-height to be input in the pysam_options dictionary. So - these parameters have to be removed from the pysam_options dictionary and moved to a higher level in the config. I am unsure whether the function export_turbine_to_pysam_format() should include this reformatting/reorganizing or not (it currently does not!). How to use this function with the PySAM Windpower wrapper is highlighted in the test h2integrate/preprocess/test/test_wind_turbine_file_tools.py::test_pysam_turbine_export.

If possible, this PR should include some added tests once PR #372 is merged in.

Notes for reviewers:

  • @genevievestarke, I'd be specifically interested on your thoughts about the usage of FlorisTurbineDefaults in export_turbine_to_floris_format()
  • @johnjasa: I'd like your thoughts on the new function write_yaml_readable() (and whether it should have a different name), I'd also be curious if you think that the new pre-processing functions need to be integrated into an existing or new example.

Type of Contribution

  • Feature Enhancement
    • New Technology Model
  • Bug Fix
  • Documentation Update
  • CI Changes
  • Other (please describe): new tools

General PR Checklist

  • CHANGELOG.md has been updated to describe the changes made in this PR
  • Documentation
    • Docstrings are up-to-date
    • Related docs/ files are up-to-date, or added when necessary
    • Documentation has been rebuilt successfully
    • [-] Examples have been updated (if applicable)
  • Tests pass (If not, and this is expected, please elaborate in the tests section)
  • Added tests for new functionality or bug fixes
  • PR description thoroughly describes the new feature, bug fix, etc.

New Technology Checklist

  • Performance Model: Technology performance model has been implemented and follows H2Integrate patterns (if applicable)
  • Cost Model: Technology cost model has been implemented (if applicable)
  • Tests: Unit tests have been added for the new technology
    • Performance model tests (if applicable)
    • Cost model tests (if applicable)
    • Integration tests with H2Integrate system
  • Example: A working example demonstrating the new technology has been created
    • Example has been tested and runs successfully in test_all_examples.py
    • Example is documented with clear explanations in examples/README.md
      • Input file comments
      • Run file comments
  • Documentation:
    • Technology documentation page added to docs/technology_models/
    • Technology added to the main technology models list in docs/technology_models/technology_overview.md
  • Integration: Technology has been properly integrated into H2Integrate
    • Added to supported_models.py
    • If a new commodity_type is added, update create_financial_model in h2integrate_model.py
    • Follows established naming conventions outlined in docs/developer_guide/coding_guidelines.md

Related issues

Impacted areas of the software

  • pyproject.toml: added turbine-models dependency
  • h2integrate/core/utilities.py
    • write_yaml_readable(): similar to write_yaml() but uses yaml library instead of ruamel.yaml library
  • h2integrate/preprocess/wind_turbine_file_tools.py
    • export_turbine_to_pysam_format(): method that takes in a turbine name and write a .yaml file of the turbine model parameters formatted for PySAM.Windpower
    • FlorisTurbineDefaults: config class to specify default turbine parameters that are needed for FLORIS turbine models but that don't likely exist in the turbine-models library.
    • export_turbine_to_floris_format(): method that takes in a turbine name and write a .yaml file of the turbine model parameters formatted for FLORIS
  • h2integrate/preprocess/test/test_wind_turbine_file_tools.py
    • test_turbine_export_error: test that error is thrown if turbine name is invalid
    • test_pysam_turbine_export: tests that export_turbine_to_pysam_format() writes a file and that the file can be used with the PYSAMWindPlantPerformanceModel
    • test_floris_turbine_export: tests that export_turbine_to_floris_format() writes a file. Will be tested for compatibility with FLORIS once PR Added FLORIS wind plant model #372 is merged in.
  • docs/misc_resources/turbine_models_library_preprocessing.ipynb: doc file that shows example usage of the turbine models preprocessing tools

Additional supporting information

Test results, if applicable

@elenya-grant elenya-grant marked this pull request as ready for review December 2, 2025 19:28
@elenya-grant elenya-grant added ready for review This PR is ready for input from folks and removed in progress labels Dec 2, 2025
Copy link
Collaborator

@genevievestarke genevievestarke 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! It's awesome that the floris and pysam formatting tools are in the turbine-library package!


@define
class FlorisTurbineDefaults(BaseConfig):
"""Config class to specify default turbine parameters that are required by FLORIS.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these look like good defaults. The wind_speeds and wind_directions parameters may need defaults to run, as well. These are then overwritten by the time series data, but I'm not sure if it will run without them defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the heads up, this will be easier to fix once the Floris turbine wrapper is pulled in

Copy link
Collaborator

@johnjasa johnjasa left a comment

Choose a reason for hiding this comment

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

I like this PR a lot! It's fun to give users more tools for success.

I left a quick note on the function you explicitly asked about. Everything else looks pretty nice to me. The only blocking change I'd ask for is the inclusion of a .ipynb doc file that uses and explains the preprocessing steps you've introduced here. It'd be both documentation and testing, as it would get run when the docs build. Feel free to call me if you want to talk through what I'm picturing here!

yaml.dump(instance, f)


def write_yaml_readable(instance: dict, foutput: str | Path):
Copy link
Collaborator

@johnjasa johnjasa Dec 11, 2025

Choose a reason for hiding this comment

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

Would write_readable_yaml flow better? I accept it as-is, too. I like the function and what it does! Would love to see it in a doc page.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the function name to write_readable_yaml and will include in the doc page

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@johnjasa I added a doc page to docs/misc_resources/turbine_models_library_preprocessing.ipynb that highlights specifically how to use the new functions with PySAM models.

@johnjasa johnjasa added needs modifications This PR has been reviewed, at least partially, and is ready for PR author response and removed ready for review This PR is ready for input from folks labels Dec 11, 2025
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@elenya-grant elenya-grant added ready for review This PR is ready for input from folks and removed needs modifications This PR has been reviewed, at least partially, and is ready for PR author response labels Dec 29, 2025
@genevievestarke
Copy link
Collaborator

I'm getting an error running the Jupyter notebook saying that the NREL_5MW turbine doesn't have enough information:
image

Does this look familiar to anyone?

@elenya-grant
Copy link
Collaborator Author

I'm getting an error running the Jupyter notebook saying that the NREL_5MW turbine doesn't have enough information: image

Does this look familiar to anyone?

Would you check the version of the turbine-models package you're using? The error may be because of an older version. This PR does require the most recent version of the turbine-models package (version 0.2.1)

@genevievestarke
Copy link
Collaborator

Would you check the version of the turbine-models package you're using? The error may be because of an older version. This PR does require the most recent version of the turbine-models package (version 0.2.1)

Ok, this was a local environment/kernel issue! All good now!

Copy link
Collaborator

@johnjasa johnjasa left a comment

Choose a reason for hiding this comment

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

Thanks for your changes and patience! I love this and expect it to be a useful basis for other preprocessing utilities.

@johnjasa johnjasa enabled auto-merge January 5, 2026 16:43
@johnjasa johnjasa merged commit 08f0511 into NatLabRockies:develop Jan 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review This PR is ready for input from folks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants