-
Notifications
You must be signed in to change notification settings - Fork 155
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
Enabling vectorized time series calculation of wind conditions #400
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d4eb506
enabling time series calculation of wind conditions
bayc 1cb6ecd
enabling time series calculation of wind conditions
bayc effa646
fixing w_initial_sorted error
bayc 2757be6
Merge branch 'feature/time_series' of https://github.com/bayc/floris …
bayc b44373a
Merge branch 'develop' into feature/time_series
rafmudaf 91694a4
Add an example using time series
paulf81 81b2ab7
updating conftest with time_series flag
bayc c8ae068
updating formatting
bayc 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright 2021 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 | ||
|
||
""" | ||
This example demonstrates running FLORIS in time series mode. | ||
|
||
Typically when an array of wind directions and wind speeds are passed in FLORIS, | ||
it is assumed these are defining a grid of wd/ws points to consider, as in a wind rose. | ||
All combinations of wind direction and wind speed are therefore computed, and resulting | ||
matrices, for example of turbine power are returned with martrices whose dimensions are | ||
wind direction, wind speed and turbine number. | ||
|
||
In time series mode, specified by setting the time_series flag of the FLORIS interface to True | ||
each wd/ws pair is assumed to constitute a single point in time and each pair is computed. | ||
Results are returned still as a 3 dimensional matrix, however the index of the (wd/ws) pair | ||
is provided in the first dimension, the second dimension is fixed at 1, and the thrid is | ||
turbine number again for consistency. | ||
|
||
Note by not specifying yaw, the assumption is that all turbines are always pointing into the | ||
current wind direction with no offset. | ||
""" | ||
|
||
# Initialize FLORIS to simple 4 turbine farm | ||
fi = FlorisInterface("inputs/gch.yaml") | ||
|
||
# Convert to a simple two turbine layout | ||
fi.reinitialize(layout=([0, 500.], [0., 0.])) | ||
|
||
# Create a fake time history where wind speed steps in the middle while wind direction | ||
# Walks randomly | ||
time = np.arange(0, 120, 10.) # Each time step represents a 10-minute average | ||
ws = np.ones_like(time) * 8. | ||
ws[int(len(ws) / 2):] = 9. | ||
wd = np.ones_like(time) * 270. | ||
|
||
for idx in range(1, len(time)): | ||
wd[idx] = wd[idx - 1] + np.random.randn() * 2. | ||
|
||
|
||
# Now intiialize FLORIS object to this history using time_series flag | ||
fi.reinitialize(wind_directions=wd, wind_speeds=ws, time_series=True) | ||
|
||
# Collect the powers | ||
fi.calculate_wake() | ||
turbine_powers = fi.get_turbine_powers() / 1000. | ||
|
||
# Show the dimensions | ||
num_turbines = len(fi.layout_x) | ||
print('There are %d time samples, and %d turbines and so the resulting turbine power matrix has the shape:' % (len(time), num_turbines), turbine_powers.shape) | ||
|
||
|
||
fig, axarr = plt.subplots(3, 1, sharex=True, figsize=(7,8)) | ||
|
||
ax = axarr[0] | ||
ax.plot(time, ws, 'o-') | ||
ax.set_ylabel('Wind Speed (m/s)') | ||
ax.grid(True) | ||
|
||
ax = axarr[1] | ||
ax.plot(time, wd, 'o-') | ||
ax.set_ylabel('Wind Direction (Deg)') | ||
ax.grid(True) | ||
|
||
ax = axarr[2] | ||
for t in range(num_turbines): | ||
ax.plot(time,turbine_powers[:, 0, t], 'o-', label='Turbine %d' % t) | ||
ax.legend() | ||
ax.set_ylabel('Turbine Power (kW)') | ||
ax.set_xlabel('Time (minutes)') | ||
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
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
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.
I'm guessing this is by mistake. I think we want to keep
reference_wind_height
a floatThere 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.
Yes good catch @Bartdoekemeijer