LagSolver

LagSolver

class onwards.lagSolver.LagSolver(farm: Farm, model_args: dict, grid_args: dict = {})

Bases: object

Inits a LagSolver object.

LagSolver object allows to compute the estimated flow state from the local, estimated Turbine states.

\[\mathbf{\hat{s}}_{wt} \rightarrow \mathbf{\hat{s}}_{flow}\]

It interfaces the c Lagrangian flow model using ctypes.

Parameters
  • farm (Farm) – Parent Farm object.

  • model_args (dict) –

    Dictionary containing the parameters used for the Lagrangian flow model’s initialization.

    Available fields:

    n_substeps

    (int , optional) - Number of Farm timesteps between two successive Lagrangian flow model updates, by default 1.

    n_fm

    (int , optional) - Maximum number of ambient flow particles used for each turbine, by default 60

    n_shed_fm

    (int , optional) - Number of Lagrangian flow model timesteps between the shedding of two successive ambient flow particles by default 2

    c0

    (float, optional) - Convective ambient particles tuning constant , by default 0.30

    n_wm

    (int , optional) - Maximum number of wake particles used for each turbine, by default 60.

    n_shed_wm

    (int , optional) - Number of Lagrangian flow model timesteps between the shedding of two successive wake particles, by default 2.

    cw_xi

    (float, optional) - Convective wake particles tuning constant, by default 0.50

    cw_r

    (float, optional) - Convective wake particles tuning constant, by default 0.30

    sigma_xi_f

    (float, optional) - Streamwise ambient filtering constant, by default 10.0

    sigma_r_f

    (float, optional) - Spanwise/transverse ambient filtering constant, by default 5.0

    sigma_t_f

    (float, optional) - Streamwise ambient filtering constant, by default 2.0

    sigma_xi_r

    (float, optional) - Streamwise ambient filtering constant, by default 1.0

    sigma_r_r

    (float, optional) - Spanwise/transverse ambient filtering constant, by default 0.5

    sigma_t_r

    (float, optional) - Streamwise ambient filtering constant, by default 2.0

    tau_r

    (float, optional) - Rotor time filtering constant in [s], by default 32

    sd_type

    (float, optional) - Type of speed deficit used ( 0 : Gaussian speed deficit 1 / only option currently available), by default 0

    ak

    (float, optional) - Wake expansion tuning constant (TI scaling), by default 0.018

    bk

    (float, optional) - Wake expansion tuning constant (TI scaling), by default 0.060

    ceps

    (float, optional) - Initial wake width tuning constant, by default 0.2

  • grid_args (dict, optional) – Dictionary containing the parameters used for the Grid’s initialization (refer to Grid).

References

1
  1. Bastankhah and F. Porte-Agel. A new analytical model for wind-turbine wakes. Renewable Energy, 70:116–123, 2014.

data_p: dict(str, Union[py_comm.c_FlowModel_p, py_comm.c_WakeModel_p])
free()

Free the underlying c model.

get(model: str, field: str, comp: Optional[int] = None, i_wt: Optional[int] = None, i0_offset: bool = True, split: bool = False) numpy.array

Extract the model data from the c LagSolver object

Parameters
  • model (str) – Sub-model from which data should be extracted W for wake or F for ambient flow field.

  • field (str) – Name of the field to be extracted.

  • comp (int, optional) – Flow component to be extracted (0: x or 1: z), by default None.

  • i_wt (int, optional) – Index of the Turbine data should be extracted from if None (by default data is extracted from all turbines.

  • i0_offset (bool, optional) – If True (by default), the i0 offset is removed and data is shifted accordingly.

  • i0_offset – If True the output array is splitted into a len(i_wt) list, by default False.

Returns

Array containing the field requested.

Return type

np.array

Raises
  • ValueError – If model is not W or F.

  • ValueError – If no field component, comp, is provided for a vector field.

  • ValueError – If a field component, comp, is specified for a scalar field.

  • ValueError – If the wind turbine index request, i_wt, is not valid.

get_FlowModel(*args, **kwargs) numpy.array

Proxy for :meth:`.LagSolver.get`( ‘F’, … )

get_WakeModel(*args, **kwargs) numpy.array

Proxy for :meth:`.LagSolver.get`( ‘W’, … )

get_bounds(model: str, i_wt: int, i_sigma: int = 0) List[List[float]]

Returns the bounds of the subdomain

Parameters
  • model (str) – Sub-model from which the bounds of the subdomain are extracted W for wake or F for ambient flow field.

  • i_wt (int, optional) – Index of the Turbine.

  • i_sigma (int) – Index of the subdomain (0 -> sigma_f_* and 1 -> sigma_r_*), by default 0.

Returns

List of the coordinates of the vertices of the subdomain.

Return type

List[List[float]]

Raises

ValueError – If model is not W or F.

get_part_iwt(model: str) numpy.array

Computes the mapping between the LagSolver.get() outputs for i_wt=None and the Turbines.

Parameters

model (str) – Sub-model from which data should be extracted W for wake or F for ambient flow field.

Returns

Mapping between the array index and the turbine index.

Return type

np.array

Raises

ValueError – If model is not W or F.

See also

get

get_restart(rst: dict = {}) None
get_time()

Returns the current Lagrangian model time

init_from_restart(rst: dict, i_wt: List[int] = None) None
interp_FlowModel(xv: numpy.array, zv: numpy.array, filt: str = 'flow', buffer: Optional[onwards.lagSolver.libc.pyCommunicator.Vec] = None, i_wt_exclude: int = - 1) numpy.array

Interpolates the ambient flow field at [ xv, zv ]

Parameters
  • xv (np.array) – array containing the x locations where the field should be evaluated.

  • zv (np.array) – array containing the z locations where the field should be evaluated.

  • filt (str, optional) – flow or rotor depending on the width of the filter used for the ambient velocity field computation, by default flow.

  • buffer (py_comm.Vec, optional) – Vec object allocating the output memory location (allows not to reallocate the wind farm global grid at every time step), buffer shape should be consistent with xv and zv if None (by default) a new output vector is allocated.

  • i_wt_exclude (int, optional) – Ignores the selected wind turbine for the ambient velocity computations, by default -1 (ie: all turbines are used).

Returns

Estimated ambient flow field [u, w]

Return type

np.array

Raises
  • ValueError – If the buffer shape provided is not consistent with the shape of xv, zv.

  • Exception – If filt is not rotor or flow.

interp_WakeModel(xv: numpy.array, zv: numpy.array, buffer: Optional[onwards.lagSolver.libc.pyCommunicator.Vec] = None)

Interpolates the wake flow field at [ xv, zv ]

Parameters
  • xv (np.array) – array containing the x locations where the field should be evaluated.

  • zv (np.array) – array containing the z locations where the field should be evaluated.

  • buffer (py_comm.Vec, optional) – Vec object allocating the output memory location (allows not to reallocate the wind farm global grid at every time step), buffer shape should be consistent with xv and zv if None (by default) a new output vector is allocated.

Returns

Estimated ambient flow field [u, w]

Return type

np.array

Raises

ValueError – If the buffer shape provided is not consistent with the shape of xv, zv.

reset(model_args_new: dict, rst: dict = {})

Resets the flow states to the initial configuration and updates the Lagrangian flow model parameters.

Parameters

model_args (dict) – Dictionary containing the parameters of the Lagrangian flow model to be updated.

Raises

ValueError – If one of the following model parameters is updated: n_fm, n_wm or sd_type.

rews_compute(x_rotor: List[float], r_rotor: float, comp: int = 0) float

Computes the Rotor Effective Wind Speed at x_rotor over a rotor of diameter, r_rotor and oriented along x.

Parameters
  • x_rotor (List[float]) – Fictive rotor center location [x,y,z] in [m].

  • r_rotor (float) – Fictive rotor diameter in [m].

  • comp (int) – Flow component to be evaluated (0: x or 1: z), by default None.

Returns

The Rotor Effective Wind Speed of diameter r_rotor and located at x_rotor.

Return type

float

update()

Updates the Lagrangian flow model

Raises

Exception – If a time mismatch is detected between the parent Farm object and the Lagrangian flow model.

Grid

class onwards.lagSolver.Grid(lag_solver: LagSolver, grid_args: dict)

Bases: object

Inits the Grid over which data will be interpolated.

Parameters
  • lag_solver (LagSolver) – Parent LagSolver object

  • model_args (dict) –

    Dictionary containing the parameters used for the Lagrangian flow model’s initialization.

    grid_args description

    enable

    (bool, optional) - If False, the grid is turned off, by default True.

    dx

    (float, optional) - x grid spacing in [m], by default 20.

    dx

    (float, optional) - x grid spacing in [m], by default 20.

    dz

    (float, optional) - z grid spacing in [m], by default 20.

    margin

    (List[List[float]], optional) - [[xm, xp], [ym, yp]] minimal margin of the domain around each Turbine.

du_wm_compute(subGridFlag=False) numpy.array

Interpolates the wake flow model over the Grid.

Returns

The ambient wake field interpolated at the grid locations.

Return type

np.array

u_compute() numpy.array

Interpolates the flow model over the Grid.

Returns

The ambient flow field interpolated at the grid locations.

Return type

np.array

u_fm_compute(filt: str = 'flow') numpy.array

Interpolates the ambient flow model over the Grid.

Parameters

filt (str, optional) – flow or rotor depending on the width of the filter used for the ambient velocity field computation, by default flow.

Returns

The ambient flow field interpolated at the grid locations.

Return type

np.array

Raises

ValueError – If filt is not valid (ie: rotor or flow).

update()

Updates the grid