foxes.core.rotor_model.RotorModel¶
- class foxes.core.rotor_model.RotorModel[source]¶
Bases:
FarmDataModel
Abstract base class of rotor models.
Rotor models calculate ambient farm data from states, and provide rotor points and weights for the calculation of rotor effective quantities.
- Parameters:
calc_vars (list of str) – The variables that are calculated by the model (Their ambients are added automatically)
- calc_vars¶
The variables that are calculated by the model (Their ambients are added automatically)
Methods
__init__
(calc_vars)calculate
(algo, mdata, fdata[, rpoints, ...])Calculate ambient rotor effective results.
The rotor model design points.
eval_rpoint_results
(algo, mdata, fdata, ...)Evaluate rotor point results.
finalize
(algo[, verbosity])Finalizes the model.
get_data
(variable, data[, st_sel, upcast, ...])Getter for a data entry in either the given data source, or the model object.
get_rotor_points
(algo, mdata, fdata)Calculates rotor points from design points.
initialize
(algo[, verbosity])Initializes the model.
The number of rotor points
output_farm_vars
(algo)The variables which are being modified by the model.
The weights of the rotor points
run_calculation
(algo, *data, out_vars, ...)Starts the model calculation in parallel, via xarray's apply_ufunc.
var
(v)Creates a model specific variable name.
Attributes
Initialization flag.
Unique id based on the model type.
- calculate(algo, mdata, fdata, rpoints=None, weights=None, store_rpoints=False, store_rweights=False, store_amb_res=False, states_turbine=None)[source]¶
Calculate ambient rotor effective results.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
mdata (foxes.core.Data) – The model data
fdata (foxes.core.Data) – The farm data
rpoints (numpy.ndarray, optional) – The rotor points, or None for automatic for this rotor. Shape: (n_states, n_turbines, n_rpoints, 3)
weights (numpy.ndarray, optional) – The rotor point weights, or None for automatic for this rotor. Shape: (n_rpoints,)
store_rpoints (bool, optional) – Switch for storing rotor points to mdata
store_rweights (bool, optional) – Switch for storing rotor point weights to mdata
store_amb_res (bool, optional) – Switch for storing ambient rotor point reults as they come from the states to mdata
states_turbine (numpy.ndarray of int, optional) – The turbine indices, one per state. Shape: (n_states,)
- Returns:
results – results dict. Keys: Variable name str. Values: numpy.ndarray with results, shape: (n_states, n_turbines)
- Return type:
- abstract design_points()[source]¶
The rotor model design points.
Design points are formulated in rotor plane (x,y,z)-coordinates in rotor frame, such that - (0,0,0) is the centre point, - (1,0,0) is the point radius * n_rotor_axis - (0,1,0) is the point radius * n_rotor_side - (0,0,1) is the point radius * n_rotor_up
- Returns:
dpoints – The design points, shape: (n_points, 3)
- Return type:
- eval_rpoint_results(algo, mdata, fdata, rpoint_results, weights, states_turbine=None, copy_to_ambient=False)[source]¶
Evaluate rotor point results.
This function modifies fdata, either for all turbines or one turbine per state, depending on parameter states_turbine. In the latter case, the turbine dimension of the rpoint_results is expected to have size one.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
mdata (foxes.core.Data) – The model data
fdata (foxes.core.Data) – The farm data
rpoint_results (dict) – The results at rotor points. Keys: variable str. Values: numpy.ndarray, shape if states_turbine is None: (n_states, n_turbines, n_rpoints). Else: (n_states, 1, n_rpoints)
weights (numpy.ndarray) – The rotor point weights, shape: (n_rpoints,)
states_turbine (numpy.ndarray of int, optional) – The turbine indices, one per state. Shape: (n_states,)
copy_to_ambient (bool, optional) – If True, the fdata results are copied to ambient variables after calculation
- finalize(algo, verbosity=0)¶
Finalizes the model.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
verbosity (int) – The verbosity level, 0 = silent
- get_data(variable, data, st_sel=None, upcast=None, data_prio=False, accept_none=False)¶
Getter for a data entry in either the given data source, or the model object.
- Parameters:
variable (str) – The variable, serves as data key
data (dict) – The data source
st_sel (numpy.ndarray of bool, optional) – If given, get the specified state-turbine subset
upcast (str, optional) – Either ‘farm’ or ‘points’, broadcasts potential scalar data to numpy.ndarray with dimensions (n_states, n_turbines) or (n_states, n_points), respectively
data_prio (bool) – First search the data source, then the object
accept_none (bool) – Do not throw an error if data entry is None or np.nan
- get_rotor_points(algo, mdata, fdata)[source]¶
Calculates rotor points from design points.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
mdata (foxes.core.Data) – The model data
fdata (foxes.core.Data) – The farm data
- Returns:
points – The rotor points, shape: (n_states, n_turbines, n_rpoints, 3)
- Return type:
- initialize(algo, verbosity=0)¶
Initializes the model.
This includes loading all required data from files. The model should return all array type data as part of the idata return dictionary (and not store it under self, for memory reasons). This data will then be chunked and provided as part of the mdata object during calculations.
- Parameters:
algo (foxes.core.Algorithm) – The calculation algorithm
verbosity (int) – The verbosity level, 0 = silent
- Returns:
idata – The dict has exactly two entries: data_vars, a dict with entries name_str -> (dim_tuple, data_ndarray); and coords, a dict with entries dim_name_str -> dim_array
- Return type:
- property initialized¶
Initialization flag.
- Returns:
True if the model has been initialized.
- Return type:
- property model_id¶
Unique id based on the model type.
- Returns:
Unique id of the model object
- Return type:
- abstract n_rotor_points()[source]¶
The number of rotor points
- Returns:
n_rpoints – The number of rotor points
- Return type:
- abstract rotor_point_weights()[source]¶
The weights of the rotor points
- Returns:
weights – The weights of the rotor points, add to one, shape: (n_rpoints,)
- Return type:
- run_calculation(algo, *data, out_vars, **calc_pars)¶
Starts the model calculation in parallel, via xarray’s apply_ufunc.
Typically this function is called by algorithms.
- Parameters:
- Returns:
results – The calculation results
- Return type:
xarray.Dataset