-
Notifications
You must be signed in to change notification settings - Fork 4
Floris Support #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lejeunemax
wants to merge
8
commits into
EUFLOW:main
Choose a base branch
from
lejeunemax:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Floris Support #36
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1885a20
Adding a coupling with Floris
lejeunemax 12ff8a8
Merge branch 'main' of https://github.com/EUFLOW/WIFA
lejeunemax 2aa1f9d
Add Flois coupling
lejeunemax d498b97
removing local path
lejeunemax 9a044ba
Make DTU10MW def consistent accros files
lejeunemax 9650923
printing output files
lejeunemax 98f521c
Improved testing
lejeunemax 6791523
precommit check
lejeunemax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| from windIO import __path__ as wiop | ||
| from windIO import validate as validate_yaml | ||
| from windIO import load_yaml | ||
|
|
||
| from wifa.floris_api import run_floris | ||
|
|
||
| test_path = Path(os.path.dirname(__file__)) | ||
| windIO_path = Path(wiop[0]) | ||
|
|
||
|
|
||
| def _run_floris(wes_dir, expected_error=None): | ||
| """ | ||
| Helper function to run FLORIS on all system.yaml files in a directory. | ||
|
|
||
| Args: | ||
| wes_dir: Path to wind energy system directory containing system.yaml files | ||
| expected_error: If provided, the test expects this error type/message | ||
| """ | ||
| assert wes_dir.is_dir(), f"{wes_dir} is not a directory" | ||
|
|
||
| for yaml_path in wes_dir.glob("system.yaml"): | ||
| print("\nRUNNING FLORIS ON", yaml_path, "\n") | ||
|
|
||
| # Validate the YAML file against windIO schema | ||
| validate_yaml(yaml_path, Path("plant/wind_energy_system")) | ||
|
|
||
| # Load the YAML file as a dictionary | ||
| yaml_input = load_yaml(yaml_path) | ||
| yaml_input['attributes']['flow_model']['name'] = 'floris' | ||
|
|
||
| # Create output directory | ||
| output_dir_name = Path("output_test_floris") | ||
| output_dir_name.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Run FLORIS | ||
| result = run_floris(yaml_input) | ||
|
|
||
|
|
||
| def test_floris_4wts(): | ||
| """Test FLORIS with 4 turbines configuration""" | ||
| wes_dir = test_path / "../examples/cases/windio_4turbines/wind_energy_system/" | ||
| _run_floris(wes_dir) | ||
|
|
||
|
|
||
| def test_floris_simple_wind_rose(): | ||
| """Test FLORIS with simple wind rose configuration""" | ||
| wes_dir = test_path / "../examples/cases/simple_wind_rose/wind_energy_system/" | ||
| _run_floris(wes_dir) | ||
|
|
||
|
|
||
| def test_floris_timeseries(): | ||
| """Test FLORIS with timeseries and operating flag""" | ||
| wes_dir = test_path / "../examples/cases/timeseries_with_operating_flag/wind_energy_system/" | ||
| _run_floris(wes_dir) | ||
|
|
||
|
|
||
| def test_floris_heterogeneous_wind_rose(): | ||
| """Test FLORIS with heterogeneous wind rose map""" | ||
| wes_dir = test_path / "../examples/cases/heterogeneous_wind_rose_map/wind_energy_system/" | ||
| _run_floris(wes_dir) | ||
|
|
||
|
|
||
| def test_floris_heterogeneous_at_turbines(): | ||
| """Test FLORIS with heterogeneous wind rose at turbines""" | ||
| wes_dir = test_path / "../examples/cases/heterogeneous_wind_rose_at_turbines/wind_energy_system/" | ||
| _run_floris(wes_dir) | ||
|
|
||
|
|
||
| def test_floris_multiple_turbines(): | ||
| """Test FLORIS with multiple turbine types""" | ||
| wes_dir = test_path / "../examples/cases/windio_4turbines_multipleTurbines/wind_energy_system/" | ||
| _run_floris(wes_dir) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| """Run tests when executed directly""" | ||
| import sys | ||
| import traceback | ||
|
|
||
| print("=" * 80) | ||
| print("Running FLORIS tests...") | ||
| print("=" * 80) | ||
|
|
||
| tests = [ | ||
| ("4 Turbines", test_floris_4wts), | ||
| ("Simple Wind Rose", test_floris_simple_wind_rose), | ||
| ("Timeseries", test_floris_timeseries), | ||
| ("Multiple Turbine Types", test_floris_multiple_turbines), | ||
| ] | ||
|
|
||
| failed = [] | ||
| passed = [] | ||
| known_issues = [] | ||
|
|
||
| for test_name, test_func in tests: | ||
| print(f"\n{'='*80}") | ||
| print(f"Testing: {test_name}") | ||
| print(f"{'='*80}") | ||
| try: | ||
| test_func() | ||
| passed.append((test_name, "")) | ||
| print(f"✓ {test_name} PASSED") | ||
| except Exception as e: | ||
| failed.append((test_name, str(e))) | ||
| print(f"✗ {test_name} FAILED: {e}") | ||
| if "--verbose" in sys.argv or "-v" in sys.argv: | ||
| traceback.print_exc() | ||
|
|
||
| # Summary | ||
| print(f"\n{'='*80}") | ||
| print("Test Summary") | ||
| print(f"{'='*80}") | ||
| print(f"Passed: {len(passed)}/{len(tests)}") | ||
| print(f"Known Issues: {len(known_issues)}/{len(tests)}") | ||
| print(f"Failed: {len(failed)}/{len(tests)}") | ||
|
|
||
| if known_issues: | ||
| print("\nKnown issues (NotImplementedError):") | ||
| for name, error in known_issues: | ||
| print(f" WARNING: {name}: {error}") | ||
|
|
||
| if failed: | ||
| print("\nFailed tests:") | ||
| for name, error in failed: | ||
| print(f" ✗ {name}: {error}") | ||
| sys.exit(1) | ||
| else: | ||
| print("\n✓ All tests passed!") | ||
| sys.exit(0) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be ideal to manually run floris to confirm that each test creates the expected output, like we do in pywake tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been addressed by the latest commit.