In [1]:
%load_ext autoreload
%autoreload 2
import numpy as np
from IPython.display import HTML, Latex, Markdown, Pretty

from windIO.Plant import WTLayout
from fusedwake.WindFarm import WindFarm
from fusedwake.Plotting import circles

from fusedwake.gcl import GCL
import fusedwake.gcl.fortran as fgcl

%matplotlib inline
import matplotlib.pyplot as plt

In [2]:
#filename = 'middelgrunden.yml'
#filename = 'lillgrund.yml'
#filename = 'hornsrev.yml'
#filename = 'test_WF.yml'
filename = 'test_WF_2Turbines.yml'

#wtl = WTLayout(filename)
wf = WindFarm(yml=filename)

In [7]:
gcl = GCL(WF=wf)

In [10]:
# Inputs
WS=10.0*np.ones([wf.nWT])
WD=270*np.ones([wf.nWT])
TI=0.1*np.ones([wf.nWT])
version = 'fort_gclm' # 

# Run the models
out=gcl(WS=WS, WD=WD, TI=TI, version='fort_gclm')
out.p_wt.sum()


Out[10]:
2233421.0030666208

In [11]:
# Inputs
WS=10.0+np.random.normal(loc=0.0, scale=0.25, size=[wf.nWT])#np.ones([wf.nWT])
WD=270+np.random.normal(loc=0.0, scale=5, size=[wf.nWT])#np.ones([wf.nWT])
TI=0.1+np.random.normal(loc=0.0, scale=0.01, size=[wf.nWT])#*np.ones([wf.nWT])
version = 'fort_gclm' # 

# Run the models
fort_gclm_s = gcl(WS=WS, WD=WD, TI=TI, version='fort_gclm')
fort_gclm_s.p_wt.sum()


Out[11]:
2214424.4701494453

In [13]:
fig = plt.figure(figsize=[6,5])
ax = fig.add_subplot(111)
circles(x=wf.xyz[0,:],
        y=wf.xyz[1,:],
        s=np.array(wf.R),
        c=WS, 
        cmap=plt.cm.viridis,lw=0,
        )
plt.colorbar()
for i in range(wf.nWT):
    ax.annotate(str(wf.__getattr__('name')[i][-2:]).zfill(2),wf.xyz[[0,1],i]+0.7*np.array([wf.R[i],wf.R[i]]))
    ax.arrow(x=wf.xyz[0,i],
          y=wf.xyz[1,i],
          dx=wf.R[1]*WS[i]*np.cos(np.deg2rad(270-WD[i])),
          dy=wf.R[1]*WS[i]*np.sin(np.deg2rad(270-WD[i])),
          head_length=3*wf.R[1],head_width=wf.R[1],
          length_includes_head=True,
          fc='k',ec='k',
         )
ax.set_xlim([-40, 960])
ax.set_ylim([-500, 500])


Out[13]:
(-500, 500)

In [14]:
fig = plt.figure(figsize=[6,5])
ax = fig.add_subplot(111)
circles(x=wf.xyz[0,:],
        y=wf.xyz[1,:],
        s=np.array(wf.R),
        c=fort_gclm_s.p_wt/1e6,
        cmap=plt.cm.viridis,lw=0,
        )
plt.colorbar()
for i in range(wf.nWT):
    ax.annotate(str(wf.__getattr__('name')[i][-2:]).zfill(2),wf.xyz[[0,1],i]+0.7*np.array([wf.R[i],wf.R[i]]))
ax.set_xlim([-40, 960])
ax.set_ylim([-500, 500])


Out[14]:
(-500, 500)

In [15]:
fig = plt.figure(figsize=[6,5])
ax = fig.add_subplot(111)
circles(x=wf.xyz[0,:],
        y=wf.xyz[1,:],
        s=np.array(wf.R),
        c=TI,
        cmap=plt.cm.viridis,lw=0,
        )
plt.colorbar()
for i in range(wf.nWT):
    ax.annotate(str(wf.__getattr__('name')[i][-2:]).zfill(2),wf.xyz[[0,1],i]+0.7*np.array([wf.R[i],wf.R[i]]))
ax.set_xlim([-40, 960])
ax.set_ylim([-500, 500])


Out[15]:
(-500, 500)

In [16]:
WD = np.linspace(-30,30,100)+270.
WS = 8.

In [18]:
P_rat_py_v0 = []
P_rat_py_v1 = []
P_rat_fgcl = []
P_rat_fgclm = []
P_rat_fgclm_rdn = []
for wd in WD:
    out = gcl(WS=WS*np.ones([wf.nWT]), WD=wd*np.ones([wf.nWT]), TI=0.1*np.ones([wf.nWT]), version='py_gcl_v0')
    P_rat_py_v0 = np.append(P_rat_py_v0,out.p_wt[1]/out.p_wt[0])
    
    out = gcl(WS=WS*np.ones([wf.nWT]), WD=wd*np.ones([wf.nWT]), TI=0.1*np.ones([wf.nWT]), version='py_gcl_v1')
    P_rat_py_v1 = np.append(P_rat_py_v1,out.p_wt[1]/out.p_wt[0])
    
    out = gcl(WS=WS, WD=wd, TI=0.1, version='fort_gcl')
    P_rat_fgcl = np.append(P_rat_fgcl,out.p_wt[1]/out.p_wt[0])
    
    out = gcl(WS=WS*np.ones([wf.nWT]), WD=wd*np.ones([wf.nWT]), TI=0.1**np.ones([wf.nWT]), version='fort_gclm')
    P_rat_fgclm = np.append(P_rat_fgclm,out.p_wt[1]/out.p_wt[0])
    
    out = gcl(WS=WS*np.ones([wf.nWT]), WD=wd+np.random.normal(loc=0.0, scale=2, size=[wf.nWT]), 
              TI=0.1**np.ones([wf.nWT]), version='fort_gclm')
    P_rat_fgclm_rdn = np.append(P_rat_fgclm_rdn,out.p_wt[1]/out.p_wt[0])

In [23]:
fig = plt.figure(figsize=[10,10])
ax = fig.add_subplot(111)

plt.plot(WD,P_rat_py_v1,'sk',ms=10,mfc='w',label ='py_gcl_v1')
#plt.plot(-WD,P_rat_py_v1,'x--',label ='py_gcl_v1_inv')

plt.plot(WD,P_rat_py_v0,'<b',ms=9,mfc='w',label ='py_gcl_v0')
#plt.plot(-WD,P_rat_py_v0,'-',label ='py_gcl_v0_inv')

plt.plot(WD,P_rat_fgcl,'-ok',ms=8,mec='k',mfc='w',label ='fort_gcl')
#plt.plot(-WD,P_rat_fgcl,'+--',label ='fort_gcl')

plt.plot(WD,P_rat_fgclm,'--+r',label ='fort_gclm')
#plt.plot(-WD,P_rat_fgclm_s,'.-',label ='fort_gclm')

#plt.plot(WD,P_rat_fgclm_rdn,'o',label ='fort_gclm_s_rdn')

plt.legend(loc=4)


Out[23]:
<matplotlib.legend.Legend at 0x11bf992d0>

In [ ]: