Commit b8824696 authored by Matias Sessarego's avatar Matias Sessarego
Browse files

fix spelling, complexsite

parent 11cc9a7f
......@@ -215,6 +215,75 @@ class UniformSite(Site):
return np.zeros_like(x_i)
class ComplexSite(Site):
def __init__(self, p_wd, ti, interp_method='piecewise', alpha=0.143, h_ref=None):
self.ti = ti
self.alpha = alpha
self.h_ref = h_ref
super().__init__()
p_wd = Sector2Subsector(p_wd, interp_method=interp_method)
self.p_wd = p_wd / p_wd.sum()
def probability(self, wd, ws, wd_bin_size, ws_bin_size):
P = self.p_wd[np.round(wd).astype(np.int) % 360] * wd_bin_size
return P / P.sum()
def local_wind(self, x_i, y_i, h_i=None, wd=None, ws=None, h_ref=None, wd_bin_size=None, ws_bin_size=None):
if wd is None:
wd = self.default_wd
if ws is None:
ws = self.default_ws
def get_default(w_bin_size, w):
if w_bin_size is None:
if hasattr(w, '__len__') and len(w) > 1:
return w[1] - w[0]
else:
return 1
else:
return w_bin_size
ws_bin_size = get_default(ws_bin_size, ws)
wd_bin_size = get_default(wd_bin_size, wd)
WD_ilk, WS_ilk = [np.tile(W, (len(x_i), 1, 1)).astype(np.float)
for W in np.meshgrid(wd, ws, indexing='ij')]
# accouting wind shear when required
h_ref = h_ref or self.h_ref
if h_i is not None and h_ref is not None:
h_i = np.array(h_i)
if not np.all(h_i == h_ref):
wind_shear_ratio = (h_i / h_ref) ** self.alpha
WS_ilk = WS_ilk * wind_shear_ratio[:, na, na]
TI_ilk = np.zeros_like(WD_ilk) + self.ti
P_lk = self.probability(WD_ilk[0], WS_ilk[0], wd_bin_size, ws_bin_size)
return WD_ilk, WS_ilk, TI_ilk, P_lk
def distances(self, src_x_i, src_y_i, src_h_i, dst_x_j, dst_y_j, dst_h_j, wd_il):
wd_l = np.mean(wd_il, 0)
dx_ij, dy_ij, dh_ij = [np.subtract(*np.meshgrid(dst_j, src_i, indexing='ij')).T
for src_i, dst_j in [(src_x_i, dst_x_j),
(src_y_i, dst_y_j),
(src_h_i, dst_h_j)]]
src_x_i, src_y_i = map(np.asarray, [src_x_i, src_y_i])
theta_l = np.deg2rad(90 - wd_l)
cos_l = np.cos(theta_l)
sin_l = np.sin(theta_l)
dw_il = (cos_l[na, :] * src_x_i[:, na] + sin_l[na] * src_y_i[:, na])
dw_ijl = (-cos_l[na, na, :] * dx_ij[:, :, na] - sin_l[na, na, :] * dy_ij[:, :, na])
cw_ijl = np.abs(sin_l[na, na, :] * dx_ij[:, :, na] +
-cos_l[na, na, :] * dy_ij[:, :, na])
dh_ijl = np.zeros_like(dw_ijl)
dh_ijl[:, :, :] = dh_ij[:, :, na]
dw_order_indices_l = np.argsort(-dw_il, 0).astype(np.int).T
return dw_ijl, cw_ijl, dh_ijl, dw_order_indices_l
def elevation(self, x_i, y_i):
return np.zeros_like(x_i)
class UniformWeibullSite(UniformSite):
def __init__(self, p_wd, a, k, ti, interp_method='piecewise', alpha=0.143, h_ref=None):
super().__init__(p_wd, ti, interp_method=interp_method, alpha=alpha, h_ref=h_ref)
......
......@@ -38,7 +38,7 @@ class NOJ(WakeModel, SquaredSum):
The calculation formula can be found in Eq. (A1) of :
[Ref] Feng J, Shen WZ, Solving the wind farm layout optimization
problem using Random search algorithm, Reneable Energy 78 (2015)
problem using Random search algorithm, Renewable Energy 78 (2015)
182-192
Note that however there are typos in Equation (A1), '2' before alpha
and beta should be 1.
......
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