{
"cells": [
{
"cell_type": "markdown",
"id": "aa14f44d",
"metadata": {},
"source": [
"# Example: Multi-dimensional Cp/Ct data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fd7d83e0",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"Example: Multi-dimensional Cp/Ct data\n",
"This example creates a FLORIS instance and:\n",
"1) Makes a two-turbine layout\n",
"2) Demonstrates single ws/wd simulations\n",
"3) Demonstrates multiple ws/wd simulations\n",
"\n",
"with the modification of using a turbine definition that has a multi-dimensional Cp/Ct table.\n",
"\n",
"In the input file `gch_multi_dim_cp_ct.yaml`, the turbine_type points to a turbine definition,\n",
"iea_15MW_floating_multi_dim_cp_ct.yaml located in the turbine_library,\n",
"that supplies a multi-dimensional Cp/Ct data file in the form of a .csv file. This .csv file\n",
"contains two additional conditions to define Cp/Ct values for: Tp for wave period, and Hs for wave\n",
"height. For every combination of Tp and Hs defined, a Cp/Ct/Wind speed table of values is also\n",
"defined. It is required for this .csv file to have the last 3 columns be ws, Cp, and Ct. In order\n",
"for this table to be used, the flag 'multi_dimensional_cp_ct' must be present and set to true in\n",
"the turbine definition. With this flag enabled, the solver will down-select to use the\n",
"interpolant defined at the closest conditions. The user must supply these conditions in the\n",
"main input file under the 'flow_field' section, e.g.:\n",
"\n",
"NOTE: The multi-dimensional Cp/Ct data used in this example is fictional for the purposes of\n",
"facilitating this example. The Cp/Ct values for the different wave conditions are scaled\n",
"values of the original Cp/Ct data for the IEA 15MW turbine.\n",
"\n",
"flow_field:\n",
" multidim_conditions:\n",
" Tp: 2.5\n",
" Hs: 3.01\n",
"\n",
"The solver will then use the nearest-neighbor interpolant. These conditions are currently global\n",
"and used to select the interpolant at each turbine.\n",
"\n",
"Also note in the example below that there is a specific method for computing powers when\n",
"using turbines with multi-dimensional Cp/Ct data under FlorisModel, called\n",
"'get_turbine_powers_multidim'. The normal 'get_turbine_powers' method will not work.\n",
"\"\"\"\n",
"\n",
"import numpy as np\n",
"\n",
"from floris import FlorisModel\n",
"\n",
"\n",
"# Initialize FLORIS with the given input file.\n",
"fmodel = FlorisModel(\"../inputs/gch_multi_dim_cp_ct.yaml\")\n",
"\n",
"# Convert to a simple two turbine layout\n",
"fmodel.set(layout_x=[0.0, 500.0], layout_y=[0.0, 0.0])\n",
"\n",
"# Single wind speed and wind direction\n",
"print(\"\\n========================= Single Wind Direction and Wind Speed =========================\")\n",
"\n",
"# Get the turbine powers assuming 1 wind speed and 1 wind direction\n",
"fmodel.set(wind_directions=[270.0], wind_speeds=[8.0], turbulence_intensities=[0.06])\n",
"\n",
"# Set the yaw angles to 0\n",
"yaw_angles = np.zeros([1, 2]) # 1 wind direction and wind speed, 2 turbines\n",
"fmodel.set(yaw_angles=yaw_angles)\n",
"\n",
"# Calculate\n",
"fmodel.run()\n",
"\n",
"# Get the turbine powers\n",
"turbine_powers = fmodel.get_turbine_powers() / 1000.0\n",
"print(\"The turbine power matrix should be of dimensions 1 findex X 2 Turbines\")\n",
"print(turbine_powers)\n",
"print(\"Shape: \", turbine_powers.shape)\n",
"\n",
"# Single wind speed and multiple wind directions\n",
"print(\"\\n========================= Single Wind Direction and Multiple Wind Speeds ===============\")\n",
"\n",
"wind_speeds = np.array([8.0, 9.0, 10.0])\n",
"wind_directions = np.array([270.0, 270.0, 270.0])\n",
"turbulence_intensities = np.array([0.06, 0.06, 0.06])\n",
"\n",
"yaw_angles = np.zeros([3, 2]) # 3 wind directions/ speeds, 2 turbines\n",
"fmodel.set(\n",
" wind_speeds=wind_speeds,\n",
" wind_directions=wind_directions,\n",
" turbulence_intensities=turbulence_intensities,\n",
" yaw_angles=yaw_angles,\n",
")\n",
"fmodel.run()\n",
"turbine_powers = fmodel.get_turbine_powers() / 1000.0\n",
"print(\"The turbine power matrix should be of dimensions 3 findex X 2 Turbines\")\n",
"print(turbine_powers)\n",
"print(\"Shape: \", turbine_powers.shape)\n",
"\n",
"# Multiple wind speeds and multiple wind directions\n",
"print(\"\\n========================= Multiple Wind Directions and Multiple Wind Speeds ============\")\n",
"\n",
"wind_speeds = np.tile([8.0, 9.0, 10.0], 3)\n",
"wind_directions = np.repeat([260.0, 270.0, 280.0], 3)\n",
"turbulence_intensities = 0.06 * np.ones_like(wind_speeds)\n",
"\n",
"yaw_angles = np.zeros([9, 2]) # 9 wind directions/ speeds, 2 turbines\n",
"fmodel.set(\n",
" wind_directions=wind_directions,\n",
" wind_speeds=wind_speeds,\n",
" turbulence_intensities=turbulence_intensities,\n",
" yaw_angles=yaw_angles,\n",
")\n",
"fmodel.run()\n",
"turbine_powers = fmodel.get_turbine_powers() / 1000.0\n",
"print(\"The turbine power matrix should be of dimensions 9 WD/WS X 2 Turbines\")\n",
"print(turbine_powers)\n",
"print(\"Shape: \", turbine_powers.shape)\n",
"import warnings\n",
"warnings.filterwarnings('ignore')"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}