Skip to content

Commit

Permalink
Add an interface option for turbine operation model definitions (#770)
Browse files Browse the repository at this point in the history
* add power to 5MW model, matches https://github.com/NREL/floris/blob/main/floris/turbine_library/nrel_5MW.yaml with extension for before cut in and after cut out. Rename thrust field.

* Removing Cp interp and replacing with direct power interp; updating thrust_coefficient key name.

* Convert to W for power_interp; remove ref air density from power calc (tests need updating yet).

* Minor updates for plot axes---contains temporary limitation to NREL 5MW turbine only, will remove prior to merge into v4 branch.

* Updating 15mw based on https://github.com/IEAWindTask37/IEA-15-240-RWT/blob/master/Documentation/IEA-15-240-RWT_tabular.xlsx

* 10mw updated.

* Updating turbine curve conversion utility and example.

* Utility for converting from v3 turbine models to v4.

* Ruff and isort.

* Changing names to check out v3 versions.

* Renaming again...

* Converting old models over.

* So that tests run, using v4 5MW.

* Updates to test_build_turbine_dict.

* Updating conftest, test_power() to reflect absolute power in turbine yaml.

* air density removed from power() calls in reg tests.

* Reinstating accidentally overwritten file.

* Convert from `ref_density_cp_ct` to `ref_air_density`.

* `ref_tilt` replaces `ref_tilt_cp_ct`

* Ruff, isort; remove AIR_DENSITY from turbine_unit_test.test_power().

* Clearing empty lines.

* Check for smoothness; not yet passing `smooth enough` test.

* Tests passing for smoothness.

* Converter prints warning if nonsmooth; added handling for no R4.

* Update build_turbine_dict test for clarity and simplicity. Ruff, isort.

* Bugfixes in example after semantic changes to build_turbine_dict.

* Moving turbine into its own simulation directory; updating names of interp functions.

* SimpleTurbine power module.

* Turbine submodule pieces.

* Added thrust coefficient to SimpleTurbine.

* Adding extra arguments to Ct(), power(), and axial_induction().

* Updating turbine_unit_test for new layout.

* Add handling for different model types.

* cosine loss model option, but currently matches simple.

* Moving velocities to own file (may need renaming).

* Temp; runs, still todo items for power().

* Now passing all the way through the power calculation.

* Updating thrust model to match power.

* Update imports in tests.

* Passing arguments as kwargs.

* cosine loss model; move various turbine parameters inside power_thrust_table; call power() and thrust_coefficient() with kwargs.

* Update tests calling power; turbine model structure.

* emg reg tests failing.'

* Jensen reg passes.

* TB reg tests pass.

* CC, gauss reg tests good.

* Fix bug in how tilt_angles are passed through.

* Turbine building utilities updated.

* removing unnecessary attributes from Farm class.'

* Updated axial_induction() keywords for consistency.

* Note to return to axial_induction() model.

* rename rotor_effective_velocity.py

* Move rotor velocity tests to individual module.

* tests for air density correction.

* add base class for turbine models; add tests.

* init test passes.

* test_power, test_Ct now passing.

* axial_induction passes.

* Remove ref_tilt argument from Ct()

* isort, ruff.

* Remove multidim utilities and their imports.

* working through example 30 to go through full multidim example.

* example 30 now runs. Can likely remove commented out code, but will leave for the time being and clean up later.

* 31 now runs.

* isort.

* End of file.

* Moving multidim functionality onto turbine.py

* Remove turbine_multi_dim.py

* Missed a reference...

* ruff, isort.

* removing unneeded TODOs.

* moving turbine utilities.

* Move multidim selector to utilities, model map to top of turbine.py

* Rename power_interp power_function throughout.

* comments for turbine.py

* Adding descriptions for the turbine submodels.

* fix end of file.

* Disclaimers and copyrights.

* removing sorting of uneeded properties from full_flow solvers.

* Inherit from correct base class.

* Turbine library updates for examples 17 and 18.

* Example 24.

* ex. 33.

* ruff.

* Return nrel_5MW.yaml to converted (rather than updated) version.

* Remove unused code

* Remove extra lines at end of file

* Move rotor velocity module up to floris.simulation

* Consolidate turbine models into one module

* Move turbine preprocessing to floris.turbine_library

* Fix line length linting and isort errors

* Update API for turbine previewer

* Prevent test file from being exported

* Bug fix in example

* Remove duplicate code

* Rename Farm setup function to reflect the data

* Move axial_induction functionality to submodels; propagate changes.

* add axial induction model tests.

* Rename Ct functions throughout.

* Update fi method call.

* Line length.

* Missed the constructors.

* Rename to .

* Remove unused library in dependencies

This was previously used for the multidimension turbine, but it has since been consolidated and flatten_dict isn't used

* Remove unused import

* Fix incorrect type hints

---------

Co-authored-by: Rafael M Mudafort <[email protected]>
  • Loading branch information
misi9170 and rafmudaf authored Jan 10, 2024
1 parent e877d70 commit 8e6fb6b
Show file tree
Hide file tree
Showing 56 changed files with 3,566 additions and 3,465 deletions.
72 changes: 38 additions & 34 deletions docs/turbine_interaction.ipynb

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion examples/18_check_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@

# TEMPORARY
print(turbines)
turbines = turbines[1:]
turbines = [
t for t in turbines
if "converted" not in t
if "updated" not in t
if "legacy" not in t
if t != "x_20MW"
]
print(turbines)
# END TEMPORARY

# Declare a set of figures for comparing cp and ct across models
Expand Down
8 changes: 5 additions & 3 deletions examples/24_floating_turbine_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@
power_floating_defined_floating = fi_floating_defined_floating.get_turbine_powers().flatten()/1000.

# Grab Ct
ct_fixed = fi_fixed.get_turbine_Cts().flatten()
ct_floating = fi_floating.get_turbine_Cts().flatten()
ct_floating_defined_floating = fi_floating_defined_floating.get_turbine_Cts().flatten()
ct_fixed = fi_fixed.get_turbine_thrust_coefficients().flatten()
ct_floating = fi_floating.get_turbine_thrust_coefficients().flatten()
ct_floating_defined_floating = (
fi_floating_defined_floating.get_turbine_thrust_coefficients().flatten()
)

# Grab turbine tilt angles
eff_vels = fi_fixed.turbine_average_velocities
Expand Down
6 changes: 3 additions & 3 deletions examples/30_multi_dimensional_cp_ct.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
fi.calculate_wake(yaw_angles=yaw_angles)

# Get the turbine powers
turbine_powers = fi.get_turbine_powers_multidim() / 1000.0
turbine_powers = fi.get_turbine_powers() / 1000.0
print("The turbine power matrix should be of dimensions 1 findex X 2 Turbines")
print(turbine_powers)
print("Shape: ",turbine_powers.shape)
Expand All @@ -86,7 +86,7 @@
fi.reinitialize(wind_speeds=wind_speeds, wind_directions=wind_directions)
yaw_angles = np.zeros([3, 2]) # 3 wind directions/ speeds, 2 turbines
fi.calculate_wake(yaw_angles=yaw_angles)
turbine_powers = fi.get_turbine_powers_multidim() / 1000.0
turbine_powers = fi.get_turbine_powers() / 1000.0
print("The turbine power matrix should be of dimensions 3 findex X 2 Turbines")
print(turbine_powers)
print("Shape: ",turbine_powers.shape)
Expand All @@ -100,7 +100,7 @@
fi.reinitialize(wind_directions=wind_directions, wind_speeds=wind_speeds)
yaw_angles = np.zeros([9, 2]) # 9 wind directions/ speeds, 2 turbines
fi.calculate_wake(yaw_angles=yaw_angles)
turbine_powers = fi.get_turbine_powers_multidim()/1000.
turbine_powers = fi.get_turbine_powers()/1000.
print("The turbine power matrix should be of dimensions 9 WD/WS X 2 Turbines")
print(turbine_powers)
print("Shape: ",turbine_powers.shape)
4 changes: 2 additions & 2 deletions examples/31_multi_dimensional_cp_ct_2Hs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
fi_hs_1.calculate_wake()

# Collect the turbine powers in kW
turbine_powers = fi.get_turbine_powers_multidim()/1000.
turbine_powers_hs_1 = fi_hs_1.get_turbine_powers_multidim()/1000.
turbine_powers = fi.get_turbine_powers()/1000.
turbine_powers_hs_1 = fi_hs_1.get_turbine_powers()/1000.

# Plot the power in each case and the difference in power
fig, axarr = plt.subplots(1,3,sharex=True,figsize=(12,4))
Expand Down
8 changes: 4 additions & 4 deletions examples/33_specify_turbine_power_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import matplotlib.pyplot as plt
import numpy as np

from floris.simulation import turbine
from floris.tools import build_turbine_dict, FlorisInterface
from floris.tools import FlorisInterface
from floris.turbine_library import build_cosine_loss_turbine_dict


"""
Expand All @@ -39,7 +39,7 @@
"thrust_coefficient":[0, 0.9, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.25, 0.2]
}

turbine_dict = build_turbine_dict(
turbine_dict = build_cosine_loss_turbine_dict(
turbine_data_dict,
"example_turbine",
file_name=None,
Expand Down Expand Up @@ -70,7 +70,7 @@

specified_powers = (
np.array(turbine_data_dict["power_coefficient"])
*0.5*turbine_dict["ref_air_density"]
*0.5*turbine_dict["power_thrust_table"]["ref_air_density"]
*turbine_dict["rotor_diameter"]**2*np.pi/4
*np.array(turbine_data_dict["wind_speed"])**3
)/1000
Expand Down
106 changes: 53 additions & 53 deletions examples/inputs_floating/turbine_files/nrel_5MW_fixed.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
turbine_type: 'nrel_5MW_floating'
generator_efficiency: 1.0
hub_height: 90.0
pP: 1.88
pT: 1.88
rotor_diameter: 126.0
TSR: 8.0
ref_density_cp_ct: 1.225
ref_tilt_cp_ct: 5.0
correct_cp_ct_for_tilt: True # Apply tilt correction to cp/ct
power_thrust_table:
ref_air_density: 1.225
ref_tilt: 5.0
pP: 1.88
pT: 1.88
power:
- 0.0
- 0.000000
- 0.000000
- 0.178085
- 0.289075
- 0.349022
- 0.384728
- 0.406059
- 0.420228
- 0.428823
- 0.433873
- 0.436223
- 0.436845
- 0.436575
- 0.436511
- 0.436561
- 0.436517
- 0.435903
- 0.434673
- 0.433230
- 0.430466
- 0.378869
- 0.335199
- 0.297991
- 0.266092
- 0.238588
- 0.214748
- 0.193981
- 0.175808
- 0.159835
- 0.145741
- 0.133256
- 0.122157
- 0.112257
- 0.103399
- 0.095449
- 0.088294
- 0.081836
- 0.075993
- 0.070692
- 0.065875
- 0.061484
- 0.057476
- 0.053809
- 0.050447
- 0.047358
- 0.044518
- 0.041900
- 0.039483
- 0.0
- 0.0
thrust:
- 36.722155848902254
- 94.65678115354163
- 170.596391826316
- 267.74933496419163
- 387.64681352354114
- 533.9617151673435
- 707.4062402827329
- 909.9965782677073
- 1142.7197798534328
- 1407.4994184495558
- 1707.1272243371227
- 2047.3355806543098
- 2430.5778091805637
- 2858.3081150622215
- 3329.100627354195
- 3842.9755943182267
- 4403.86140594055
- 4999.993508066915
- 4999.99850473839
- 4999.997854617397
- 5000.00304890274
- 5000.002113339491
- 4999.997282778227
- 5000.002243172759
- 5000.000360590384
- 5000.009074693787
- 4999.987262704901
- 5000.007345811091
- 5000.006875165497
- 4999.994990648268
- 4999.97705933755
- 4999.983698972648
- 4999.991318085188
- 5000.024022703328
- 5000.016589748782
- 5000.025709581146
- 4999.944891236294
- 5000.035324880168
- 4999.967955734346
- 5000.013248451465
- 5000.063199891701
- 5000.068982245371
- 4999.9325188896555
- 5000.011035557985
- 5000.012771123277
- 4717.243379938609
- 0.0
- 0.0
thrust_coefficient:
- 0.0
- 0.0
- 0.0
Expand Down
106 changes: 53 additions & 53 deletions examples/inputs_floating/turbine_files/nrel_5MW_floating.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
turbine_type: 'nrel_5MW_floating'
generator_efficiency: 1.0
hub_height: 90.0
pP: 1.88
pT: 1.88
rotor_diameter: 126.0
TSR: 8.0
ref_density_cp_ct: 1.225
ref_tilt_cp_ct: 5.0
correct_cp_ct_for_tilt: True # Apply tilt correction to cp/ct
power_thrust_table:
ref_air_density: 1.225
ref_tilt: 5.0
pP: 1.88
pT: 1.88
power:
- 0.0
- 0.000000
- 0.000000
- 0.178085
- 0.289075
- 0.349022
- 0.384728
- 0.406059
- 0.420228
- 0.428823
- 0.433873
- 0.436223
- 0.436845
- 0.436575
- 0.436511
- 0.436561
- 0.436517
- 0.435903
- 0.434673
- 0.433230
- 0.430466
- 0.378869
- 0.335199
- 0.297991
- 0.266092
- 0.238588
- 0.214748
- 0.193981
- 0.175808
- 0.159835
- 0.145741
- 0.133256
- 0.122157
- 0.112257
- 0.103399
- 0.095449
- 0.088294
- 0.081836
- 0.075993
- 0.070692
- 0.065875
- 0.061484
- 0.057476
- 0.053809
- 0.050447
- 0.047358
- 0.044518
- 0.041900
- 0.039483
- 0.0
- 0.0
thrust:
- 36.722155848902254
- 94.65678115354163
- 170.596391826316
- 267.74933496419163
- 387.64681352354114
- 533.9617151673435
- 707.4062402827329
- 909.9965782677073
- 1142.7197798534328
- 1407.4994184495558
- 1707.1272243371227
- 2047.3355806543098
- 2430.5778091805637
- 2858.3081150622215
- 3329.100627354195
- 3842.9755943182267
- 4403.86140594055
- 4999.993508066915
- 4999.99850473839
- 4999.997854617397
- 5000.00304890274
- 5000.002113339491
- 4999.997282778227
- 5000.002243172759
- 5000.000360590384
- 5000.009074693787
- 4999.987262704901
- 5000.007345811091
- 5000.006875165497
- 4999.994990648268
- 4999.97705933755
- 4999.983698972648
- 4999.991318085188
- 5000.024022703328
- 5000.016589748782
- 5000.025709581146
- 4999.944891236294
- 5000.035324880168
- 4999.967955734346
- 5000.013248451465
- 5000.063199891701
- 5000.068982245371
- 4999.9325188896555
- 5000.011035557985
- 5000.012771123277
- 4717.243379938609
- 0.0
- 0.0
thrust_coefficient:
- 0.0
- 0.0
- 0.0
Expand Down
Loading

0 comments on commit 8e6fb6b

Please sign in to comment.