# Layout optimization¶

This example demonstrates some basics about running wind farm optimization tasks with foxes. All optimizations use the iwopy interface in the background (also by Fraunhofer IWES, see link for details).

In the following we invoke the optimization library pymoo which contains a number of very nice genetic algorithm implementations. Within foxes we do that implicitely via the iwopy interface.

These are the required imports for this example:

In [1]:

import numpy as np
import matplotlib.pyplot as plt
from plotly.offline import iplot
from iwopy.interfaces.pymoo import Optimizer_pymoo

import foxes
import foxes.variables as FV
import foxes.utils.geom2d as gm
from foxes.opt.problems.layout import FarmLayoutOptProblem
from foxes.opt.constraints import FarmBoundaryConstraint, MinDistConstraint
from foxes.opt.objectives import MaxFarmPower


In the following we are tackling the problem of optimizing a wind farm layout for a site near Bremen, Germany. The data of a (coarse) wind rose with 216 states is provided as static data file with name "wind_rose_bremen.csv":

state,wd,ws,weight
0,0.0,3.5,0.00158
1,0.0,6.0,0.00244
2,0.0,8.5,0.00319
3,0.0,12.5,0.0036700002
4,0.0,17.5,0.00042
...


First, let’s create the states object and have a look at the wind rose:

In [2]:

states = foxes.input.states.StatesTable(
data_source="wind_rose_bremen.csv",
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
var2col={FV.WS: "ws", FV.WD: "wd", FV.WEIGHT: "weight"},
fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
)

o = foxes.output.StatesRosePlotOutput(states, point=[0., 0., 100.])
fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20])
iplot(fig)