In [1]:
%matplotlib inline
%load_ext autoreload
%autoreload
import numpy as np
import scipy as sp
import pandas as pd
from scipy import interpolate
import matplotlib.pyplot as plt
import os,sys,inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(os.path.dirname(currentdir))
#sys.path.insert(0,parentdir)
#sys.path.append(parentdir+'/gclarsen/src/gclarsen')
import fusedwake.WindTurbine as wt
import fusedwake.WindFarm as wf
#import fusedwake.fused as fused_gcl
from fusedwake.gcl import *
In [2]:
#from gclarsen.fusedwasp import PlantFromWWH
#wwh = PlantFromWWH(filename = parentdir+'/wind-farm-wake-model/gclarsen/src/gclarsen/test/wind_farms/horns_rev/hornsrev1_turbine_nodescription.wwh')
#wwh = PlantFromWWH(filename = 'hornsrev1_turbine_nodescription.wwh')
common inputs
In [9]:
wf.WindFarm?
In [11]:
v80 = wt.WindTurbine('Vestas v80 2MW offshore','V80_2MW_offshore.dat',70,40)
HR1 = wf.WindFarm(name='Horns Rev 1',yml='hornsrev.yml')#,v80)
WD = range(0,360,1)
FUSED-Wind implementation
In [12]:
"""
##Fused inputs
inputs = dict(
wind_speed=8.0,
roughness=0.0001,
TI=0.05,
NG=4,
sup='lin',
wt_layout = fused_gcl.generate_GenericWindFarmTurbineLayout(HR1))
fgcl = fused_gcl.FGCLarsen()
# Setting the inputs
for k,v in inputs.iteritems():
setattr(fgcl, k, v)
fP_WF = np.zeros([len(WD)])
for iwd, wd in enumerate(WD):
fgcl.wind_direction = wd
fgcl.run()
fP_WF[iwd] = fgcl.power
"""
Out[12]:
pure python implementation
In [13]:
P_WF = np.zeros([len(WD)])
P_WF_v0 = np.zeros([len(WD)])
for iwd, wd in enumerate(WD):
P_WT,U_WT,CT_WT = GCLarsen(WS=8.0,z0=0.0001,TI=0.05,WD=wd,WF=HR1,NG=4,sup='lin')
P_WF[iwd] = P_WT.sum()
P_WT,U_WT,CT_WT = GCLarsen_v0(WS=8.0,z0=0.0001,TI=0.05,WD=wd,WF=HR1,NG=4,sup='lin')
P_WF_v0[iwd] = P_WT.sum()
In [6]:
fig, ax = plt.subplots()
ax.plot(WD,P_WF/(HR1.WT[0].get_P(8.0)*HR1.nWT),'-o', label='python')
ax.plot(WD,P_WF_v0/(HR1.WT[0].get_P(8.0)*HR1.nWT),'-d', label='python v0')
ax.set_xlabel('wd [deg]')
ax.set_ylabel('Wind farm efficiency [-]')
ax.set_title(HR1.name)
ax.legend(loc=3)
plt.savefig(HR1.name+'_Power_wd_360.pdf')
In [7]:
WD = 261.05
P_WT,U_WT,CT_WT = GCLarsen_v0(WS=10.,z0=0.0001,TI=0.1,WD=WD,WF=HR1, NG=5, sup='quad')
P_WT_2,U_WT_2,CT_WT_2 = GCLarsen(WS=10.,z0=0.0001,TI=0.1,WD=WD,WF=HR1, NG=5, sup='quad')
In [8]:
np.testing.assert_array_almost_equal(U_WT,U_WT_2)
np.testing.assert_array_almost_equal(P_WT,P_WT_2)
There was a bug corrected in the new implementation of the GCL model
New implementation is wrapped inside fusedwind
In [9]:
WD = range(0,360,1)
In [10]:
%%timeit
fP_WF = np.zeros([len(WD)])
for iwd, wd in enumerate(WD):
fgcl.wind_direction = wd
fgcl.run()
fP_WF[iwd] = fgcl.power
In [11]:
%%timeit
#%%prun -s cumulative #profiling
P_WF = np.zeros([len(WD)])
for iwd, wd in enumerate(WD):
P_WT,U_WT,CT_WT = GCLarsen(WS=8.0,z0=0.0001,TI=0.05,WD=wd,WF=HR1,NG=4,sup='lin')
P_WF[iwd] = P_WT.sum()
In [12]:
df=pd.DataFrame(data=P_WF, index=WD, columns=['P_WF'])
In [13]:
df.plot()
Out[13]:
Normally distributed wind direction uncertainty (reference wind direction, not for individual turbines).
In [14]:
P_WF_GAv8 = np.zeros([len(WD)])
P_WF_GAv16 = np.zeros([len(WD)])
for iwd, wd in enumerate(WD):
P_WT_GAv,U_WT,CT_WT = GCL_P_GaussQ_Norm_U_WD(meanWD=wd,stdWD=2.5,NG_P=8, WS=8.0,z0=0.0001,TI=0.05,WF=HR1,NG=4,sup='lin')
P_WF_GAv8[iwd] = P_WT_GAv.sum()
P_WT_GAv,U_WT,CT_WT = GCL_P_GaussQ_Norm_U_WD(meanWD=wd,stdWD=2.5,NG_P=16, WS=8.0,z0=0.0001,TI=0.05,WF=HR1,NG=4,sup='lin')
P_WF_GAv16[iwd] = P_WT_GAv.sum()
In [ ]:
fig, ax = plt.subplots()
fig.set_size_inches([12,6])
ax.plot(WD,P_WF/(HR1.WT.get_P(8.0)*HR1.nWT),'-o', label='Pure python')
ax.plot(WD,fP_WF/(HR1.WT.get_P(8.0)*HR1.nWT),'-d', label='FUSED wrapper')
ax.plot(WD,P_WF_GAv16/(HR1.WT.get_P(8.0)*HR1.nWT),'-', label='Gauss Avg. FUSED wrapper, NG_P = 16')
ax.plot(WD,P_WF_GAv8/(HR1.WT.get_P(8.0)*HR1.nWT),'-', label='Gauss Avg. FUSED wrapper, NG_P = 8')
ax.set_xlabel('wd [deg]')
ax.set_ylabel('Wind farm efficiency [-]')
ax.set_title(HR1.name)
ax.legend(loc=3)
plt.savefig(HR1.name+'_Power_wd_360.pdf')
Uniformly distributed wind direction uncertainty (bin/sectors definition)
In [ ]:
P_WF_GA_u8 = np.zeros([len(WD)])
for iwd, wd in enumerate(WD):
P_WT_GAv,U_WT,CT_WT = GCL_P_GaussQ_Uni_U_WD(meanWD=wd,U_WD=2.5,NG_P=8, WS=8.0,z0=0.0001,TI=0.05,WF=HR1,NG=4,sup='lin')
P_WF_GA_u8[iwd] = P_WT_GAv.sum()
In [ ]:
fig, ax = plt.subplots()
fig.set_size_inches([12,6])
ax.plot(WD,fP_WF/(HR1.WT.get_P(8.0)*HR1.nWT),'-d', label='FUSED wrapper')
ax.plot(WD,P_WF_GAv8/(HR1.WT.get_P(8.0)*HR1.nWT),'-', label='Gauss Quad. Normal, NG_P = 8')
ax.plot(WD,P_WF_GA_u8/(HR1.WT.get_P(8.0)*HR1.nWT),'-', label='Gauss Quad. Uniform, NG_P = 8')
ax.set_xlabel('wd [deg]')
ax.set_ylabel('Wind farm efficiency [-]')
ax.set_title(HR1.name)
ax.legend(loc=3)
plt.savefig(HR1.name+'_Power_wd_360.pdf')
In [ ]:
In [ ]:
In [ ]:
In [ ]: