Commit 68b16ffe authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

- fix probability normalization for multiple turbines

- add test, which tests aep probability normalizing for two turbines
- remove not-needed autograd switch
parent 1d9ae356
......@@ -4,7 +4,7 @@ from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines, IEA37Site
from py_wake import NOJ, Fuga
from py_wake.site._site import UniformSite
from py_wake.tests import npt
from py_wake.examples.data.hornsrev1 import HornsrevV80
from py_wake.examples.data.hornsrev1 import HornsrevV80, Hornsrev1Site
from py_wake.tests.test_files.fuga import LUT_path_2MW_z0_0_03
from py_wake.flow_map import HorizontalGrid
from py_wake.wind_farm_models.engineering_models import All2AllIterative
......@@ -113,6 +113,19 @@ def test_aep():
npt.assert_almost_equal(sim_res.aep(normalize_probabilities=True), 3.35 * 24 * 365 / 1000)
def test_two_wt_aep():
site = Hornsrev1Site()
windTurbines = IEA37_WindTurbines()
wake_model = NOJ(site, windTurbines)
sim_res1 = wake_model([0], [0], wd=270)
sim_res2 = wake_model([0, 0], [0, 500], wd=270)
npt.assert_almost_equal(sim_res1.aep(normalize_probabilities=True), 3.35 * 5.845, 2)
npt.assert_almost_equal(sim_res1.aep() * 2, sim_res2.aep())
npt.assert_almost_equal(sim_res1.aep(normalize_probabilities=True) * 2,
sim_res2.aep(normalize_probabilities=True))
def test_All2AllIterativeDeflection():
site = IEA37Site(16)
windTurbines = IEA37_WindTurbines()
......
......@@ -134,11 +134,8 @@ class EngineeringWindFarmModel(WindFarmModel):
hcw_iil = hcw_iil / self.wec
# add eps to avoid non-differentiable 0
if 'autograd' in np.__name__:
eps = 2 * np.finfo(np.float).eps ** 2
else:
eps = 0
cw_iil = np.sqrt(hcw_iil**2 + dh_iil**2 + eps)
cw_iil = np.sqrt(hcw_iil**2 + dh_iil**2)
kwargs = {'localWind': lw,
'WS_eff_ilk': WS_eff_ilk, 'TI_eff_ilk': TI_eff_ilk,
......
......@@ -137,14 +137,15 @@ class SimulationResult():
If True, wake loss is included, i.e. power is calculated using local effective wind speed\n
If False, wake loss is neglected, i.e. power is calculated using local free flow wind speed
"""
P_ilk = self.localWind.P_ilk
if normalize_probabilities:
P_ilk /= P_ilk.sum()
norm = self.localWind.P_ilk.sum((1, 2))[:, np.newaxis, np.newaxis]
else:
norm = 1
if with_wake_loss:
return self.power_ilk * P_ilk * 24 * 365 * 1e-9
return self.power_ilk * self.localWind.P_ilk / norm * 24 * 365 * 1e-9
else:
power_ilk = self.windFarmModel.windTurbines.power(self.localWind.WS_ilk, self.type_i)
return power_ilk * P_ilk * 24 * 365 * 1e-9
return power_ilk * self.localWind.P_ilk / norm * 24 * 365 * 1e-9
def aep(self, normalize_probabilities=False, with_wake_loss=True):
"""Anual Energy Production (sum of all wind turbines, directions and speeds) in GWh.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment