forked from NREL/floris
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert turbulence intensity from single value to n_findex length arr…
…ay (NREL#782) * Convert turbulence_intensity to tubulence_intensities throughout the code and refactor all code to expect turbulence_intensities to be an array and not a float * Add additional tests of turbulence intensity to confirm correct behavior of new features * Complete WindRose and TimeSeries handling of turbulence intensities * Add helper functions to WindRose and TimeSeries which allow turbulence intensities to be generated, rather than provided, as a function of wind directions and wind speeds * Add additional examples of usage --------- Co-authored-by: misi9170 <[email protected]> Co-authored-by: Rafael M Mudafort <[email protected]> Co-authored-by: Eric Simley <[email protected]>
- Loading branch information
1 parent
1eb76b1
commit 61e1f13
Showing
36 changed files
with
584 additions
and
105 deletions.
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.