[BUG] Passing TI into wind farm model call and setting wd_chunks to not None results in error
If one passes TI to the wind farm model call instead of setting it as a parameter in the site definition, and wishes to use more than one wd
chunk PyWake errors out. Below an example to reproduce the issue. Actually, even setting wd_chunks=1
causes the same behavior. Passing TI to the site instance works properly, as a workaround. But this seems peculiar, probably not intended.
from py_wake.wind_farm_models import PropagateDownwind
from py_wake.deficit_models import NiayifarGaussianDeficit
from py_wake.turbulence_models import CrespoHernandez
from py_wake.superposition_models import LinearSum
from py_wake.wind_turbines.generic_wind_turbines import GenericTIRhoWindTurbine
from py_wake.site import UniformWeibullSite
wt_x = [0, 500, 1000]
wt_y = [0, 0, 0]
ti, rho = 0.1, 1.225
d = 100
wt = GenericTIRhoWindTurbine(
name="myawesometurbine",
diameter=d,
hub_height=1.2 * d,
power_norm=2500, # [kW]
)
site = UniformWeibullSite(p_wd=[1] * 12, a=[8] * 12, k=[2] * 12, ti=None)
wfm = PropagateDownwind(
site,
wt,
wake_deficitModel=NiayifarGaussianDeficit(
a=[0.38, 4e-3],
use_effective_ws=True,
use_effective_ti=True,
),
superpositionModel=LinearSum(),
turbulenceModel=CrespoHernandez(),
)
# runs OK
simulationResult = wfm(wt_x, wt_y, TI=ti, Air_density=rho, wd_chunks=None)
# ValueError: 'TI' needed by CrespoHernandez is missing
simulationResult = wfm( # or any N of chunks
wt_x, wt_y, TI=ti, Air_density=rho, wd_chunks=2
)
Traceback:
Traceback (most recent call last):
File "/home/ernie/playground/bug.py", line 38, in <module>
simulationResult = wfm( # or any N of chunks
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/py_wake/wind_farm_models/wind_farm_model.py", line 132, in __call__
res = self._run(x, y, h=h, type=type, wd=wd, ws=ws, time=time, verbose=verbose,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/py_wake/wind_farm_models/wind_farm_model.py", line 70, in _run
return self.calc_wt_interaction(h_i=h, type_i=type,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/py_wake/wind_farm_models/engineering_models.py", line 214, in calc_wt_interaction
zip(*map_func(self._calc_wt_interaction_args, arg_lst)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/tqdm/std.py", line 1169, in __iter__
for obj in iterable:
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/py_wake/wind_farm_models/engineering_models.py", line 167, in _calc_wt_interaction_args
return self.calc_wt_interaction(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/py_wake/wind_farm_models/engineering_models.py", line 240, in calc_wt_interaction
self._check_input(kwargs)
File "/home/ernie/.miniconda/envs/pywake/lib/python3.12/site-packages/py_wake/wind_farm_models/engineering_models.py", line 422, in _check_input
raise ValueError(f"'{n}' needed by {needed_by} is missing")
ValueError: 'TI' needed by CrespoHernandez is missing