You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.4 KiB
Python

from py_wake.wind_turbines import WindTurbine
from py_wake.wind_turbines.power_ct_functions import PowerCtTabular
from py_wake.site._site import UniformSite
from py_wake.site.xrsite import XRSite
from py_wake.wind_farm_models import PropagateDownwind
from py_wake.deficit_models.gaussian import TurboGaussianDeficit
from py_wake.flow_map import XYGrid
import numpy as np
import xarray as xr
D = 126 #Diametro del wT
h = 90 #Altura del WT
ws = 8
initial_position = np.array([[1, 1]])
def py_wake_Initial_Conf(D, name, h):
power_curve = np.array([
[ 0.1, 1.000],
[ 4.5, 267.7],
[ 5.0, 387.6],
[ 5.5, 534.0],
[ 6.0, 707.4],
[ 6.5, 910.0],
[ 7.0, 1142.7],
[ 7.5, 1407.5],
[ 8.0, 1707.1],
[ 8.5, 2047.3],
[ 9.0, 2430.6]]) * [1, 1000]
ct_curve = np.array([
[ 0.1, 0.100],
[ 4.5, 0.928],
[ 5.0, 0.892],
[ 5.5, 0.861],
[ 6.0, 0.835],
[ 6.5, 0.812],
[ 7.0, 0.792],
[ 7.5, 0.776],
[ 8.0, 0.7702530978349217],
[ 8.5, 0.762],
[ 9.0, 0.763]])
powerct = PowerCtTabular(power_curve[:, 0], power_curve[:, 1], 'w',ct_curve[:, 1], method='linear')
return WindTurbine(name=name, diameter=D, hub_height=h, powerCtFunction=powerct)
windTurbines = py_wake_Initial_Conf(D, 'NREL_5MW', h)
grid = XYGrid(x=np.arange(0, 10.01, 0.1)*D, y=np.arange(0, 10.01, 0.1)*D)
def run(direction=0, initial_position=initial_position, ws=ws):
initial_position = np.array(initial_position);
p_wd = [0] * 360
p_wd[0] = p_wd[225] = p_wd[270] = p_wd[315] = 1
site = UniformSite(p_wd=p_wd, ws=ws, initial_position=initial_position*D)
#ds = xr.Dataset(
# data_vars={'P': ('wd', [1, 1, 1, 1])},
# coords={'wd': [0, 90, 180, 270]})
#ds['TI'] = 0.1
#site = XRSite(ds, interp_method='nearest', initial_position=initial_position*D, default_ws=np.atleast_1d(ws))
wt_x, wt_y = site.initial_position.T
wfm = PropagateDownwind(site, windTurbines, wake_deficitModel=TurboGaussianDeficit())
xa = wfm(x=wt_x, y=wt_y, wd=direction, yaw=0).flow_map(grid)
ws = xa.WS_eff
aep = wfm(x=wt_x, y=wt_y).aep()
#return ws[:,:,0,0].values[:,:,0].tolist(), list(aep.values[:,direction,0])
return ws[:,:,0,0].values[:,:,0].tolist(), {dir: list(aep.values[:,dir,0]) for dir in (0, 225, 270, 315)}