Gradient of AEP with respect to yaw
Hi @mmpe, I'm trying to compute the gradient of the AEP with respect to the yaw angle. The code below works with finite differences, but fails with autograd and complex step. Maybe I'm doing something wrong, but I would appreciate if you could take a look.
Thanks a lot
One more question, where do I set the wind speed and direction?
# %% Import.
import numpy as np
from py_wake.examples.data.dtu10mw import DTU10MW
from py_wake.examples.data.hornsrev1 import Hornsrev1Site
from py_wake.literature.gaussian_models import Zong_PorteAgel_2020
from py_wake.deflection_models import JimenezWakeDeflection
from py_wake.utils.gradients import fd, cs, autograd
# %% Make wind farm model.
# Turbine.
dtu10mw = DTU10MW()
# Site.
site = Hornsrev1Site()
# Wind farm.
farm = Zong_PorteAgel_2020(site=site, windTurbines=dtu10mw, deflectionModel=JimenezWakeDeflection())
# Turbines position.
x = np.array([0.0, 4.0, 9.0]) * dtu10mw.diameter()
y = np.zeros(x.shape)
# Set yaw angle for each turbine.
applied_yaw = np.array([10.0, -10.0, 0.0])
# Simulate the wind farm.
sim_res = farm(x=x, y=y, yaw=applied_yaw, tilt=0.0)
# %% Compute gradient.
daep_fd = farm.aep_gradients(fd, wrt_arg="yaw", x=x, y=y, yaw=applied_yaw, tilt=0.0)
daep_auto = farm.aep_gradients(autograd, wrt_arg="yaw", x=x, y=y, yaw=applied_yaw, tilt=0.0)
daep_cs = farm.aep_gradients(cs, wrt_arg="yaw", x=x, y=y, yaw=applied_yaw, tilt=0.0)