{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Wind Farm Simulation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example, a simple wind farm case is presented where the different capabilities of PyWake such as calculating AEP, extracting power values and plotting time series are shown." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Install PyWake if needed**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Install PyWake if needed\n", "try:\n", " import py_wake\n", "except ModuleNotFoundError:\n", " !pip install git+https://gitlab.windenergy.dtu.dk/TOPFARM/PyWake.git" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**First we import some basic Python elements**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import xarray as xr" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Now we import the site, wind turbine and wake deficit model to use in the simulation**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "BastankhahGaussian(PropagateDownwind, BastankhahGaussianDeficit-wake, SquaredSum-superposition)\n" ] } ], "source": [ "# import and setup site and windTurbines\n", "%load_ext py_wake.utils.notebook_extensions\n", "\n", "from tqdm.notebook import tqdm\n", "from py_wake.utils import layouts \n", "from py_wake.utils.profiling import timeit, profileit\n", "from py_wake.examples.data.hornsrev1 import Hornsrev1Site, V80\n", "from py_wake.literature.gaussian_models import Bastankhah_PorteAgel_2014\n", "from py_wake.utils.plotting import setup_plot\n", "xr.set_options(display_expand_data=False)\n", "\n", "site = Hornsrev1Site()\n", "x, y = site.initial_position.T\n", "windTurbines = V80()\n", "\n", "wf_model = Bastankhah_PorteAgel_2014(site, windTurbines)\n", "\n", "#this allows you to see what type of engineering models you are simulating\n", "print(wf_model)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simple simulation - all wind directions and wind speeds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To run the wind farm simulation, we must call the `WindFarmModel` (wf_model) element that was previously created. As default, the model will run for all wind directions and wind speeds defined. The default properties are:\n", "\n", "- `site.default_wd`: 0-360$^\\circ$ in bins of 1$^\\circ$\n", "- `site.default_ws`: 3-25 m/s in bins of 1 m/s\n", "\n", "The default values for wind speeds and wind directions can be overwritten by either a scalar or an array." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "sim_res = wf_model(x, y, # wind turbine positions\n", " h=None, # wind turbine heights (defaults to the heights defined in windTurbines)\n", " type=0, # Wind turbine types\n", " wd=None, # Wind direction \n", " ws=None, # Wind speed \n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulation Results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `SimulationResult` object is a xarray dataset that provides information about the simulation result with some additional methods and attributes. \n", "It has the coordinates\n", "\n", "- `wt`: Wind turbine number\n", "- `wd`: Ambient reference wind direction\n", "- `ws`: Ambient reference wind speed\n", "- `x`,`y`,`h`: position and hub height of wind turbines\n", "\n", "and data variables:\n", "\n", "- `WD`: Local free-stream wind direction\n", "- `WS`: Local free-stream wind speed\n", "- `TI`: Local free-stream turbulence intensity\n", "- `P`: Probability of flow case (wind direction and wind speed)\n", "- `WS_eff`: Effetive local wind speed [m/s]\n", "- `TI_eff`: Effective local turbulence intensity\n", "- `power`: Effective power production [W]\n", "- `ct`: Thrust coefficient\n", "- `Yaw`: Yaw misalignment [deg]\n", "\n", "where \"effective\" means \"including wake effects\"\n", " " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.SimulationResult>\n", "Dimensions: (wt: 80, wd: 360, ws: 23)\n", "Coordinates:\n", " * wt (wt) int32 0 1 2 3 4 5 6 7 8 ... 72 73 74 75 76 77 78 79\n", " * wd (wd) int32 0 1 2 3 4 5 6 7 ... 353 354 355 356 357 358 359\n", " * ws (ws) int32 3 4 5 6 7 8 9 10 11 ... 18 19 20 21 22 23 24 25\n", " x (wt) float64 4.24e+05 4.24e+05 ... 4.294e+05 4.295e+05\n", " y (wt) float64 6.151e+06 6.151e+06 ... 6.148e+06 6.148e+06\n", " h (wt) float64 70.0 70.0 70.0 70.0 ... 70.0 70.0 70.0 70.0\n", " type (wt) int32 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0\n", "Data variables: (12/16)\n", " WS_eff (wt, wd, ws) float64 3.0 4.0 5.0 6.0 ... 22.87 23.88 24.89\n", " TI_eff (wt, wd, ws) float64 0.1 0.1 0.1 0.1 ... 0.1 0.1 0.1 0.1\n", " Power (wt, wd, ws) float64 0.0 6.66e+04 1.54e+05 ... 2e+06 2e+06\n", " CT (wt, wd, ws) float64 0.0 0.818 0.806 ... 0.06084 0.05377\n", " wd_bin_size int32 1\n", " WS (ws) int32 3 4 5 6 7 8 9 10 11 ... 18 19 20 21 22 23 24 25\n", " ... ...\n", " Weibull_A (wd) float64 9.177 9.177 9.177 9.177 ... 9.177 9.177 9.177\n", " Weibull_k (wd) float64 2.393 2.393 2.393 2.393 ... 2.393 2.393 2.393\n", " Sector_frequency (wd) float64 0.001199 0.001199 ... 0.001199 0.001199\n", " P (wd, ws) float64 6.147e-05 8.559e-05 ... 2.193e-08\n", " tilt int32 0\n", " yaw int32 0
<xarray.DataArray 'Power' (ws: 23)>\n", "0.0 5.52e+04 1.309e+05 2.418e+05 3.947e+05 ... 2e+06 2e+06 2e+06 2e+06 2e+06\n", "Coordinates:\n", " wt int32 3\n", " wd int32 0\n", " * ws (ws) int32 3 4 5 6 7 8 9 10 11 12 ... 16 17 18 19 20 21 22 23 24 25\n", " x float64 4.242e+05\n", " y float64 6.15e+06\n", " h float64 70.0\n", " type int32 0\n", "Attributes:\n", " Description: Power [W]