Example: Check turbine power curves

Example: Check turbine power curves#

"""Example: Check turbine power curves

For each turbine in the turbine library, make a small figure showing that its power
curve and power loss to yaw are reasonable and reasonably smooth
"""


import matplotlib.pyplot as plt
import numpy as np

from floris import FlorisModel


ws_array = np.arange(0.1, 30, 0.2)
wd_array = 270.0 * np.ones_like(ws_array)
turbulence_intensities = 0.06 * np.ones_like(ws_array)
yaw_angles = np.linspace(-30, 30, 60)
wind_speed_to_test_yaw = 11

# Grab the gch model
fmodel = FlorisModel("../inputs/gch.yaml")

# Make one turbine simulation
fmodel.set(layout_x=[0], layout_y=[0])

# Apply wind directions and wind speeds
fmodel.set(
    wind_speeds=ws_array, wind_directions=wd_array, turbulence_intensities=turbulence_intensities
)

# Get a list of available turbine models provided through FLORIS, and remove
# multi-dimensional Cp/Ct turbine definitions as they require different handling
turbines = [
    t.stem
    for t in fmodel.core.farm.internal_turbine_library.iterdir()
    if t.suffix == ".yaml" and ("multi_dim" not in t.stem)
]

# Declare a set of figures for comparing cp and ct across models
fig_pow_ct, axarr_pow_ct = plt.subplots(2, 1, sharex=True, figsize=(10, 10))

# For each turbine model available plot the basic info
for t in turbines:
    # Set t as the turbine
    fmodel.set(turbine_type=[t])
    fmodel.reset_operation() # Remove any previously applied yaw angles

    # Since we are changing the turbine type, make a matching change to the reference wind height
    fmodel.assign_hub_height_to_ref_height()

    # Plot power and ct onto the fig_pow_ct plot
    axarr_pow_ct[0].plot(
        fmodel.core.farm.turbine_map[0].power_thrust_table["wind_speed"],
        fmodel.core.farm.turbine_map[0].power_thrust_table["power"],
        label=t,
    )
    axarr_pow_ct[0].grid(True)
    axarr_pow_ct[0].legend()
    axarr_pow_ct[0].set_ylabel("Power (kW)")
    axarr_pow_ct[1].plot(
        fmodel.core.farm.turbine_map[0].power_thrust_table["wind_speed"],
        fmodel.core.farm.turbine_map[0].power_thrust_table["thrust_coefficient"],
        label=t,
    )
    axarr_pow_ct[1].grid(True)
    axarr_pow_ct[1].legend()
    axarr_pow_ct[1].set_ylabel("Ct (-)")
    axarr_pow_ct[1].set_xlabel("Wind Speed (m/s)")

    # Create a figure
    fig, axarr = plt.subplots(1, 2, figsize=(10, 5))

    # Try a few density
    for density in [1.15, 1.225, 1.3]:
        fmodel.set(air_density=density)

        # POWER CURVE
        ax = axarr[0]
        fmodel.set(
            wind_speeds=ws_array,
            wind_directions=wd_array,
            turbulence_intensities=turbulence_intensities,
        )
        fmodel.reset_operation() # Remove any previously applied yaw angles
        fmodel.run()
        turbine_powers = fmodel.get_turbine_powers().flatten() / 1e3
        if density == 1.225:
            ax.plot(ws_array, turbine_powers, label="Air Density = %.3f" % density, lw=2, color="k")
        else:
            ax.plot(ws_array, turbine_powers, label="Air Density = %.3f" % density, lw=1)
        ax.grid(True)
        ax.legend()
        ax.set_xlabel("Wind Speed (m/s)")
        ax.set_ylabel("Power (kW)")

        # Power loss to yaw, try a range of yaw angles
        ax = axarr[1]

        fmodel.set(
            wind_speeds=[wind_speed_to_test_yaw],
            wind_directions=[270.0],
            turbulence_intensities=[0.06],
        )
        yaw_result = []
        for yaw in yaw_angles:
            fmodel.set(yaw_angles=np.array([[yaw]]))
            fmodel.run()
            turbine_powers = fmodel.get_turbine_powers().flatten() / 1e3
            yaw_result.append(turbine_powers[0])
        if density == 1.225:
            ax.plot(yaw_angles, yaw_result, label="Air Density = %.3f" % density, lw=2, color="k")
        else:
            ax.plot(yaw_angles, yaw_result, label="Air Density = %.3f" % density, lw=1)
        # ax.plot(yaw_angles,yaw_result,label='Air Density = %.3f' % density)
        ax.grid(True)
        ax.legend()
        ax.set_xlabel("Yaw Error (deg)")
        ax.set_ylabel("Power (kW)")
        ax.set_title("Wind Speed = %.1f" % wind_speed_to_test_yaw)

    # Give a suptitle
    fig.suptitle(t)

plt.show()
import warnings
warnings.filterwarnings('ignore')
floris.floris_model.FlorisModel WARNING turbine_type has been changed without specifying a new reference_wind_height. reference_wind_height remains 90.00 m. Consider calling `FlorisModel.assign_hub_height_to_ref_height` to update the reference wind height to the turbine hub height.
floris.floris_model.FlorisModel WARNING turbine_type has been changed without specifying a new reference_wind_height. reference_wind_height remains 119.00 m. Consider calling `FlorisModel.assign_hub_height_to_ref_height` to update the reference wind height to the turbine hub height.
floris.floris_model.FlorisModel WARNING turbine_type has been changed without specifying a new reference_wind_height. reference_wind_height remains 150.00 m. Consider calling `FlorisModel.assign_hub_height_to_ref_height` to update the reference wind height to the turbine hub height.
../../_images/56b7bcdbb3ba2721f926acfe352185957867eb58609fee28221c5241db1e5e75.png ../../_images/8f1266b67212917045c70836f6bbb820b009f485a570257b75d593d05e9c744b.png ../../_images/54ca10647f14ef63b47e4a822229204fa623bd7eed2df988851844cf73900b34.png ../../_images/72a20c1139a00f62ab378f91e8f221bbc7ed2eef52a5eca17f1b597a0fca1b96.png