{
"cells": [
{
"cell_type": "markdown",
"id": "4b1d072d",
"metadata": {},
"source": [
"# Example 4: Set"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79262f6c",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Example 4: Set\n",
"\n",
"This example illustrates the use of the set method. The set method is used to\n",
"change the wind conditions, the wind farm layout, the turbine type,\n",
"and the controls settings.\n",
"\n",
"This example demonstrates setting each of the following:\n",
" 1) Wind conditions\n",
" 2) Wind farm layout\n",
" 3) Controls settings\n",
"\n",
"\"\"\"\n",
"\n",
"\n",
"import numpy as np\n",
"\n",
"from floris import (\n",
" FlorisModel,\n",
" TimeSeries,\n",
" WindRose,\n",
")\n",
"\n",
"\n",
"fmodel = FlorisModel(\"inputs/gch.yaml\")\n",
"\n",
"######################################################\n",
"# Atmospheric Conditions\n",
"######################################################\n",
"\n",
"\n",
"# Change the wind directions, wind speeds, and turbulence intensities using numpy arrays\n",
"fmodel.set(\n",
" wind_directions=np.array([270.0, 270.0, 270.0]),\n",
" wind_speeds=[8.0, 9.0, 10.0],\n",
" turbulence_intensities=np.array([0.06, 0.06, 0.06]),\n",
")\n",
"\n",
"# Set the wind conditions as above using the TimeSeries object\n",
"fmodel.set(\n",
" wind_data=TimeSeries(\n",
" wind_directions=270.0, wind_speeds=np.array([8.0, 9.0, 10.0]), turbulence_intensities=0.06\n",
" )\n",
")\n",
"\n",
"# Set the wind conditions as above using the WindRose object\n",
"fmodel.set(\n",
" wind_data=WindRose(\n",
" wind_directions=np.array([270.0]),\n",
" wind_speeds=np.array([8.0, 9.0, 10.0]),\n",
" ti_table=0.06,\n",
" )\n",
")\n",
"\n",
"# Set the wind shear\n",
"fmodel.set(wind_shear=0.2)\n",
"\n",
"\n",
"# Set the air density\n",
"fmodel.set(air_density=1.1)\n",
"\n",
"# Set the reference wind height (which is the height at which the wind speed is given)\n",
"fmodel.set(reference_wind_height=92.0)\n",
"\n",
"\n",
"######################################################\n",
"# Array Settings\n",
"######################################################\n",
"\n",
"# Changing the wind farm layout uses FLORIS' set method to a two-turbine layout\n",
"fmodel.set(layout_x=[0, 500.0], layout_y=[0.0, 0.0])\n",
"\n",
"######################################################\n",
"# Controls Settings\n",
"######################################################\n",
"\n",
"# Changes to controls settings can be made using the set method\n",
"# Note the dimension must match (n_findex, n_turbines) or (number of conditions, number of turbines)\n",
"# Above we n_findex = 3 and n_turbines = 2 so the matrix of yaw angles must be 3x2\n",
"yaw_angles = np.array([[0.0, 0.0], [25.0, 0.0], [0.0, 0.0]])\n",
"fmodel.set(yaw_angles=yaw_angles)\n",
"\n",
"# By default for the turbines in the turbine_library, the power\n",
"# thrust model is set to \"cosine-loss\" which adjusts\n",
"# power and thrust according to cos^cosine_loss_exponent(yaw | tilt)\n",
"# where the default exponent is 1.88. For other\n",
"# control capabilities, the power thrust model can be set to \"mixed\"\n",
"# which provides the same cosine loss model, and\n",
"# additionally methods for specifying derating levels for power and disabling turbines.\n",
"\n",
"# Use the reset operation method to clear out control signals\n",
"fmodel.reset_operation()\n",
"\n",
"# Change to the mixed model turbine\n",
"fmodel.set_operation_model(\"mixed\")\n",
"\n",
"# Shut down the front turbine for the first two findex\n",
"disable_turbines = np.array([[True, False], [True, False], [False, False]])\n",
"fmodel.set(disable_turbines=disable_turbines)\n",
"\n",
"# Derate the front turbine for the first two findex\n",
"RATED_POWER = 5e6 # 5MW (Anything above true rated power will still result in rated power)\n",
"power_setpoints = np.array(\n",
" [[RATED_POWER * 0.3, RATED_POWER], [RATED_POWER * 0.3, RATED_POWER], [RATED_POWER, RATED_POWER]]\n",
")\n",
"fmodel.set(power_setpoints=power_setpoints)\n",
"import warnings\n",
"warnings.filterwarnings('ignore')"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}