from abc import abstractmethod
from foxes.utils import all_subclasses
from .model import Model
[docs]class WakeModel(Model):
"""
Abstract base class for wake models.
:group: core
"""
[docs] @abstractmethod
def init_wake_deltas(self, algo, mdata, fdata, pdata, wake_deltas):
"""
Initialize wake delta storage.
They are added on the fly to the wake_deltas dict.
Parameters
----------
algo: foxes.core.Algorithm
The calculation algorithm
mdata: foxes.core.Data
The model data
fdata: foxes.core.Data
The farm data
pdata: foxes.core.Data
The evaluation point data
wake_deltas: dict
The wake deltas storage, add wake deltas
on the fly. Keys: Variable name str, for which the
wake delta applies, values: numpy.ndarray with
shape (n_states, n_points, ...)
"""
pass
[docs] @abstractmethod
def contribute_to_wake_deltas(
self,
algo,
mdata,
fdata,
pdata,
states_source_turbine,
wake_coos,
wake_deltas,
):
"""
Calculate the contribution to the wake deltas
by this wake model.
Modifies wake_deltas on the fly.
Parameters
----------
algo: foxes.core.Algorithm
The calculation algorithm
mdata: foxes.core.Data
The model data
fdata: foxes.core.Data
The farm data
pdata: foxes.core.Data
The evaluation point data
states_source_turbine: numpy.ndarray
For each state, one turbine index for the
wake causing turbine. Shape: (n_states,)
wake_coos: numpy.ndarray
The wake frame coordinates of the evaluation
points, shape: (n_states, n_points, 3)
wake_deltas: dict
The wake deltas, are being modified ob the fly.
Key: Variable name str, for which the
wake delta applies, values: numpy.ndarray with
shape (n_states, n_points, ...)
"""
pass
[docs] def finalize_wake_deltas(
self,
algo,
mdata,
fdata,
pdata,
amb_results,
wake_deltas,
):
"""
Finalize the wake calculation.
Modifies wake_deltas on the fly.
Parameters
----------
algo: foxes.core.Algorithm
The calculation algorithm
mdata: foxes.core.Data
The model data
fdata: foxes.core.Data
The farm data
pdata: foxes.core.Data
The evaluation point data
amb_results: dict
The ambient results, key: variable name str,
values: numpy.ndarray with shape (n_states, n_points)
wake_deltas: dict
The wake deltas, are being modified ob the fly.
Key: Variable name str, for which the wake delta
applies, values: numpy.ndarray with shape
(n_states, n_points, ...) before evaluation,
numpy.ndarray with shape (n_states, n_points) afterwards
"""
pass
[docs] @classmethod
def new(cls, wmodel_type, *args, **kwargs):
"""
Run-time wake model factory.
Parameters
----------
wmodel_type: str
The selected derived class name
args: tuple, optional
Additional parameters for constructor
kwargs: dict, optional
Additional parameters for constructor
"""
if wmodel_type is None:
return None
allc = all_subclasses(cls)
found = wmodel_type in [scls.__name__ for scls in allc]
if found:
for scls in allc:
if scls.__name__ == wmodel_type:
return scls(*args, **kwargs)
else:
estr = (
"Wake model type '{}' is not defined, available types are \n {}".format(
wmodel_type, sorted([i.__name__ for i in allc])
)
)
raise KeyError(estr)