"In this exercisw we will use the wind2loads artificial neural networks code to predict the turbine loads of the DTU 10MW reference turbine."
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -62,9 +62,18 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\base.py:253: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.21.3 when using version 0.20.3. This might lead to breaking code or invalid results. Use at your own risk.\n",
" UserWarning)\n"
]
}
],
"source": [
"import workshop\n",
"import os\n",
...
...
@@ -76,13 +85,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Set up the problem\n",
"## Set up the problem\n",
"In this example we will import most of the code for setting up the workflow."
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -108,13 +117,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Run the optimization\n",
"## Run the optimization\n",
"In this example there is the option to change the maximum number of iterations, the tolerance of the optimization as well as the maximum allowable load. The maximum allowable load is set as a percentage of the loads calculated for the initial layout, meaning e.g. that allowable_load=1.0 is 100% of the initial loads. We will optimize on AEP of the wind farm."
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"outputs": [
{
...
...
@@ -141,7 +150,7 @@
"Optimization FAILED.\n",
"Iteration limit exceeded\n",
"-----------------------------------\n",
"Optimized in\t174.461s\n"
"Optimized in\t130.683s\n"
]
},
{
...
...
@@ -166,7 +175,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Post Process\n",
"## Post Process\n",
"During the optimization all variable are recorded. After it is finished one can see all the recorded variables by typing `recorder.keys()` and plot them by writing `plt.plot([your variable],'.')`. We can use this procedure to examine how the load constraint has developed during the optimization:"
]
},
...
...
@@ -179,7 +188,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 6,
"metadata": {},
"outputs": [
{
...
...
@@ -217,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 7,
"metadata": {},
"outputs": [
{
...
...
%% Cell type:markdown id: tags:
# Loads
Topfarm supports load constraints by evaluating a trained surrogate model at each iteration. There are currently two different high-level load workflows implemented, namely the Dynamic Wake Meandering (DWM) and the Frandsen approach.
### DWM
In DWM the loads are calculated for all turbines for all flowcases and for all turbine interactions. This means that for each turbine it will look at the wakes coming from all other turbines (individually). The results are subsequently reduced to only one load per turbine by applying a soft max. This is done to create a differentiable expression for the max load instead of just taking the max load, which would not work well in a gradient-based optimization.
### Frandsen
In the Frandsen implementation, the turbulence is aggregated from different sectors with the Wöhler exponent as described in the IEC. Loads are then calculated based on the effective turbulence. Alternatively, if one would like to improve the fidelity by trading off some memory consumption the loads could be calculated based on the all wind direction sectors and subsequently aggregated with the Wöhler exponent.
## Load Surrogates
Topfarm can utilize surrogates trained with a range of different algorithms and softwares, namely scikit-learn, OpenTURNS, TensorFlow and the artificial neural networks code (wind2loads ANN) developed at DTU.
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\base.py:253: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.21.3 when using version 0.20.3. This might lead to breaking code or invalid results. Use at your own risk.
UserWarning)
%% Cell type:markdown id: tags:
# Set up the problem
## Set up the problem
In this example we will import most of the code for setting up the workflow.
In this example there is the option to change the maximum number of iterations, the tolerance of the optimization as well as the maximum allowable load. The maximum allowable load is set as a percentage of the loads calculated for the initial layout, meaning e.g. that allowable_load=1.0 is 100% of the initial loads. We will optimize on AEP of the wind farm.
%% Cell type:code id: tags:
``` python
problem=get_problem(5,1.0)
cost,state,recorder=problem.optimize(disp=True)
```
%% Output
Iteration limit exceeded (Exit mode 9)
Current function value: -1285467307.7406654
Iterations: 6
Function evaluations: 6
Gradient evaluations: 6
Optimization FAILED.
Iteration limit exceeded
-----------------------------------
Optimized in 174.461s
Optimized in 130.683s
%% Cell type:markdown id: tags:
# Post Process
## Post Process
During the optimization all variable are recorded. After it is finished one can see all the recorded variables by typing `recorder.keys()` and plot them by writing `plt.plot([your variable],'.')`. We can use this procedure to examine how the load constraint has developed during the optimization:
%% Cell type:markdown id: tags:
First we show the relative loads meaning the ratio between the load at each iteration and the initial loads:
"\u001b[1;32m<ipython-input-3-50701ef3030d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 16\u001b[0m \u001b[1;31m# Convenient plot component for plotting the cables from simple_msp in jupyter notebooks\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 17\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mworkshop\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcabling\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mXYCablePlotComp\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mget_site\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'workshop.cabling'"
"In this exercisw we will use the wind2loads artificial neural networks code to predict the turbine loads of the DTU 10MW reference turbine."
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -83,9 +83,18 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\base.py:253: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.21.3 when using version 0.20.3. This might lead to breaking code or invalid results. Use at your own risk.\n",
" UserWarning)\n"
]
}
],
"source": [
"import workshop\n",
"import os\n",
...
...
@@ -97,13 +106,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Set up the problem\n",
"## Set up the problem\n",
"In this example we will import most of the code for setting up the workflow."
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
...
...
@@ -129,13 +138,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Run the optimization\n",
"## Run the optimization\n",
"In this example there is the option to change the maximum number of iterations, the tolerance of the optimization as well as the maximum allowable load. The maximum allowable load is set as a percentage of the loads calculated for the initial layout, meaning e.g. that allowable_load=1.0 is 100% of the initial loads. We will optimize on AEP of the wind farm."
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 5,
"metadata": {},
"outputs": [
{
...
...
@@ -162,7 +171,7 @@
"Optimization FAILED.\n",
"Iteration limit exceeded\n",
"-----------------------------------\n",
"Optimized in\t174.461s\n"
"Optimized in\t130.683s\n"
]
},
{
...
...
@@ -187,7 +196,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Post Process\n",
"## Post Process\n",
"During the optimization all variable are recorded. After it is finished one can see all the recorded variables by typing `recorder.keys()` and plot them by writing `plt.plot([your variable],'.')`. We can use this procedure to examine how the load constraint has developed during the optimization:"
]
},
...
...
@@ -200,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 6,
"metadata": {},
"outputs": [
{
...
...
@@ -238,7 +247,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 7,
"metadata": {},
"outputs": [
{
...
...
%% Cell type:markdown id: tags:
# Loads
Topfarm supports load constraints by evaluating a trained surrogate model at each iteration. There are currently two different high-level load workflows implemented, namely the Dynamic Wake Meandering (DWM) and the Frandsen approach.
### DWM
In DWM the loads are calculated for all turbines for all flowcases and for all turbine interactions. This means that for each turbine it will look at the wakes coming from all other turbines (individually). The results are subsequently reduced to only one load per turbine by applying a soft max. This is done to create a differentiable expression for the max load instead of just taking the max load, which would not work well in a gradient-based optimization.
### Frandsen
In the Frandsen implementation, the turbulence is aggregated from different sectors with the Wöhler exponent as described in the IEC. Loads are then calculated based on the effective turbulence. Alternatively, if one would like to improve the fidelity by trading off some memory consumption the loads could be calculated based on the all wind direction sectors and subsequently aggregated with the Wöhler exponent.
## Load Surrogates
Topfarm can utilize surrogates trained with a range of different algorithms and softwares, namely scikit-learn, OpenTURNS, TensorFlow and the artificial neural networks code (wind2loads ANN) developed at DTU.
%% Cell type:markdown id: tags:
[Try this yourself](https://colab.research.google.com/github/DTUWindEnergy/TopFarm2/blob/master/docs/notebooks/loads.ipynb)(requires google account)
C:\ProgramData\Anaconda3\lib\site-packages\sklearn\base.py:253: UserWarning: Trying to unpickle estimator MinMaxScaler from version 0.21.3 when using version 0.20.3. This might lead to breaking code or invalid results. Use at your own risk.
UserWarning)
%% Cell type:markdown id: tags:
# Set up the problem
## Set up the problem
In this example we will import most of the code for setting up the workflow.
In this example there is the option to change the maximum number of iterations, the tolerance of the optimization as well as the maximum allowable load. The maximum allowable load is set as a percentage of the loads calculated for the initial layout, meaning e.g. that allowable_load=1.0 is 100% of the initial loads. We will optimize on AEP of the wind farm.
%% Cell type:code id: tags:
``` python
problem=get_problem(5,1.0)
cost,state,recorder=problem.optimize(disp=True)
```
%% Output
Iteration limit exceeded (Exit mode 9)
Current function value: -1285467307.7406654
Iterations: 6
Function evaluations: 6
Gradient evaluations: 6
Optimization FAILED.
Iteration limit exceeded
-----------------------------------
Optimized in 174.461s
Optimized in 130.683s
%% Cell type:markdown id: tags:
# Post Process
## Post Process
During the optimization all variable are recorded. After it is finished one can see all the recorded variables by typing `recorder.keys()` and plot them by writing `plt.plot([your variable],'.')`. We can use this procedure to examine how the load constraint has developed during the optimization:
%% Cell type:markdown id: tags:
First we show the relative loads meaning the ratio between the load at each iteration and the initial loads: