-
Notifications
You must be signed in to change notification settings - Fork 170
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
Convert turbulence intensity from single value to n_findex length array #782
Merged
Merged
Changes from all commits
Commits
Show all changes
106 commits
Select commit
Hold shift + click to select a range
5b6abad
move files around to get started
paulf81 b515274
move files around to get started
paulf81 f595720
ignore unused in __init__ files
paulf81 2096d9c
Consolidate wind rose and time series into one module
paulf81 9f94b01
Update init
paulf81 a9bb92c
Update tests
paulf81 f70c411
Add unpack functions
paulf81 1fbb6b5
Add grid and unpack tests
paulf81 1c54853
Small refactor
paulf81 96b477b
Add resample function
paulf81 d9be4ac
Test resample
paulf81 bd0e7f3
Add plot wind rose function
paulf81 c76f479
Add new wind rose usage example
paulf81 18a4884
Delete old code
paulf81 cb3a7e1
add super class to import
paulf81 8685b5f
Add a super class and inheritance
paulf81 d087abd
Add wind_data to reinitialize (also ruffing)
paulf81 c75c23c
Show example of reinit off wind_data objects
paulf81 d419e0d
Update how compute 0 freq works
paulf81 f6df165
Test computing all cases
paulf81 c819fe4
add n_findex calculation and test
paulf81 09bf38c
Add unpack_freq function
paulf81 feb0163
Get aep using wind data
paulf81 dc8bc80
Move unpack_for functions to super class
paulf81 48730a9
simplify get_farm_AEP_with_wind_data
paulf81 4bcea14
Add docstrings
paulf81 793d50a
bugfix
paulf81 b56a096
Finalize example
paulf81 6f236f4
Merge branch 'v4' into wind_rose_refactor
paulf81 81e00ee
Rename module file and base class
paulf81 6469362
Add description to example explaining plan for updates.
misi9170 ccdf2c5
providing unpack() on base class; renaming example.
misi9170 df86945
Inheritance clarified; some cleanup.
misi9170 2f2b15d
Remove copy()s (can point to same memory).
misi9170 19b647e
Small fixes throughout.
misi9170 efd3a95
Python back compatibility type-hinting issue.
misi9170 0445472
Maintain consistent formatting
rafmudaf bb83ead
update ti to array
paulf81 4fbbced
ti to array and ruff formatting
paulf81 84ae797
ti to array
paulf81 0f011d8
ti to array and ruff format
paulf81 390e583
ti to array and ruff format
paulf81 9bb615a
add ti test
paulf81 8493b59
Spell check
rafmudaf 27a131c
Remove outdated comments
rafmudaf a6dc079
Expand docs for wind data unit tests
rafmudaf 2e765b1
Add dimensions to doc string
paulf81 41af717
Add context to to_wind_rose test comments
paulf81 1d07c57
Add error to reinitialize
paulf81 689d6b0
Merge branch 'wind_rose_refactor' into wind_rose_ti_vary
paulf81 9573040
pluralize ti
paulf81 9be01c2
pluraralize ti
paulf81 f93ae9f
pluralize ti
paulf81 1fca2df
plluralize ti
paulf81 d81f427
pluralize ti
paulf81 36f6e28
pluralize ti
paulf81 f6a5483
Add new test of turbulence intensity
paulf81 2b64318
Update example 34
paulf81 f997f12
Update to ti array
paulf81 b4df579
Add example of sweeping ti
paulf81 3fbc294
Add tools for generating TI to windrose and timeseries
paulf81 594f6ab
Add example for generating TI
paulf81 2053c63
Explain what happens in default cases for WindRose
paulf81 126f4ad
Rename price to value
paulf81 4dba98d
Add check on ti and value
paulf81 6049894
Fix bin minimum
paulf81 6dda5e8
Merge branch 'wind_rose_refactor' into wind_rose_ti_vary
paulf81 cdb9875
Revert changes not connected to ti
paulf81 cbfb48d
Remove pure format changes
paulf81 20aebb9
Remove pure formatting changes
paulf81 557565b
Remove pure format changes
paulf81 853537c
Remove pure format changes
paulf81 404084d
dont import base
paulf81 ec3e8f1
Remove pure format
paulf81 e95b6e5
Remove pure formatting changes
paulf81 77328da
Remove pure formatting changes
paulf81 3edcfc5
Remove pure format changes
paulf81 3711c86
Import WindDataBase correctly
paulf81 69b33ff
Merge branch 'v4' into pr/paulf81/782
rafmudaf b313777
Add doc to examples
paulf81 c37d7ee
Update IEC function to include offset and default values
paulf81 3d08991
Update defaults
paulf81 3fef551
Move type error with raise output
paulf81 ab32696
Back to v3 style
paulf81 9627db1
Use None instead of np.newaxis
paulf81 9bae38a
Merge branch 'v4' into wind_rose_ti_vary
paulf81 e8eeb20
remove _v3 from input_full.yaml
paulf81 c2ebe42
set ti to array type input
paulf81 1a142a3
Add check on iter data
paulf81 39938ff
Set turbulence_intensities type hint to NDArrayFloat
paulf81 598aa81
Add a converter which can handle either scalar float or floris_array
paulf81 ab406b0
Add test of single ti values
paulf81 5316d5f
Replace newaxis with None for empty dimensions
rafmudaf ba9da1d
Simplify syntax
rafmudaf c32c097
remove unnecsarry try/catch
paulf81 f59ab87
minor typo fixes
ejsimley f1bae5d
adding more details on IEC TI method
ejsimley 9c8c007
Change default to 0.07 for Iref
paulf81 0a4116f
fix trailing whitespace
paulf81 f2f4b1b
updating docstrings for new default Iref
ejsimley 0bea0d5
Correct TI units in plot.
misi9170 68d3864
Clean up eg 35 plot.
misi9170 077a951
Revert legacy code
paulf81 2f84b5c
Simplify gate
rafmudaf 9957892
Consolidate and test type conversion functions
rafmudaf 5faeb1e
Add detail in comments
rafmudaf 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 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
This file contains 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
This file contains 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
This file contains 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,62 @@ | ||
# Copyright 2024 NREL | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
# See https://floris.readthedocs.io for documentation | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from floris.tools import ( | ||
FlorisInterface, | ||
TimeSeries, | ||
WindRose, | ||
) | ||
from floris.utilities import wrap_360 | ||
|
||
|
||
""" | ||
Demonstrate the new behavior in V4 where TI is an array rather than a float. | ||
Set up an array of two turbines and sweep TI while holding wd/ws constant. | ||
Use the TimeSeries object to drive the FLORIS calculations. | ||
""" | ||
|
||
|
||
# Generate a random time series of wind speeds, wind directions and turbulence intensities | ||
N = 50 | ||
wd_array = 270.0 * np.ones(N) | ||
ws_array = 8.0 * np.ones(N) | ||
ti_array = np.linspace(0.03, 0.2, N) | ||
|
||
|
||
# Build the time series | ||
time_series = TimeSeries(wd_array, ws_array, turbulence_intensities=ti_array) | ||
|
||
|
||
# Now set up a FLORIS model and initialize it using the time | ||
fi = FlorisInterface("inputs/gch.yaml") | ||
fi.reinitialize(layout_x=[0, 500.0], layout_y=[0.0, 0.0], wind_data=time_series) | ||
fi.calculate_wake() | ||
turbine_power = fi.get_turbine_powers() | ||
|
||
fig, axarr = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) | ||
ax = axarr[0] | ||
ax.plot(ti_array*100, turbine_power[:, 0]/1000, color="k") | ||
ax.set_ylabel("Front turbine power [kW]") | ||
ax = axarr[1] | ||
ax.plot(ti_array*100, turbine_power[:, 1]/1000, color="k") | ||
ax.set_ylabel("Rear turbine power [kW]") | ||
ax.set_xlabel("Turbulence intensity [%]") | ||
|
||
for ax in axarr: | ||
ax.grid(True) | ||
|
||
plt.show() |
This file contains 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,82 @@ | ||
# Copyright 2024 NREL | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
# See https://floris.readthedocs.io for documentation | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from floris.tools import ( | ||
FlorisInterface, | ||
TimeSeries, | ||
WindRose, | ||
) | ||
from floris.utilities import wrap_360 | ||
|
||
|
||
""" | ||
Demonstrate usage of TI generating and plotting functionality in the WindRose | ||
and TimeSeries classes | ||
""" | ||
|
||
|
||
# Generate a random time series of wind speeds, wind directions and turbulence intensities | ||
wind_directions = np.array([250, 260, 270]) | ||
wind_speeds = np.array([5, 6, 7, 8, 9, 10]) | ||
|
||
# Declare a WindRose object | ||
wind_rose = WindRose(wind_directions=wind_directions, wind_speeds=wind_speeds) | ||
|
||
|
||
# Define a custom function where TI = 1 / wind_speed | ||
def custom_ti_func(wind_directions, wind_speeds): | ||
return 1 / wind_speeds | ||
|
||
|
||
wind_rose.assign_ti_using_wd_ws_function(custom_ti_func) | ||
|
||
fig, ax = plt.subplots() | ||
wind_rose.plot_ti_over_ws(ax) | ||
ax.set_title("Turbulence Intensity defined by custom function") | ||
|
||
# Now use the normal turbulence model approach from the IEC 61400-1 standard, | ||
# wherein TI is defined as a function of wind speed: | ||
# Iref is defined as the TI value at 15 m/s. Note that Iref = 0.07 is lower | ||
# than the values of Iref used in the IEC standard, but produces TI values more | ||
# in line with those typically used in FLORIS (TI=8.6% at 8 m/s). | ||
Iref = 0.07 | ||
wind_rose.assign_ti_using_IEC_method(Iref) | ||
fig, ax = plt.subplots() | ||
wind_rose.plot_ti_over_ws(ax) | ||
ax.set_title(f"Turbulence Intensity defined by Iref = {Iref:0.2}") | ||
|
||
|
||
# Demonstrate equivalent usage in time series | ||
N = 100 | ||
wind_directions = 270 * np.ones(N) | ||
wind_speeds = np.linspace(5, 15, N) | ||
time_series = TimeSeries(wind_directions=wind_directions, wind_speeds=wind_speeds) | ||
time_series.assign_ti_using_IEC_method(Iref=Iref) | ||
|
||
fig, axarr = plt.subplots(2, 1, sharex=True, figsize=(7, 8)) | ||
ax = axarr[0] | ||
ax.plot(wind_speeds) | ||
ax.set_ylabel("Wind Speeds (m/s)") | ||
ax.grid(True) | ||
ax = axarr[1] | ||
ax.plot(time_series.turbulence_intensities) | ||
ax.set_ylabel("Turbulence Intensity (-)") | ||
ax.grid(True) | ||
fig.suptitle("Generating TI in TimeSeries") | ||
|
||
|
||
plt.show() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
This is the only change so far to the floris input files from v3 to v4 (that
turbulence_intensity
, a scalar, changes toturbulence_intensities
, a list). When running the new code with an v3 input file, the generic error gets raised:AttributeError: The initialization for FlowField was given extraneous inputs: ['turbulence_intensity']
Is that OK, or do we need either a converter to convert v3 models to v4 (similar to what we now have for v3-style turbine models) or a more explicit explanation of the change in the error raised?
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.
Both sound good to me, we could add a specific error for when turbulence_intensity is provided, and maybe (with a seperate issue) prepare a converter?