Skip to content
Snippets Groups Projects
Commit 5edf73cd authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

pyfuga stuff

parent 672ebc6b
No related branches found
No related tags found
No related merge requests found
FROM continuumio/anaconda:latest
FROM continuumio/anaconda3:latest
MAINTAINER Pierre-Elouan Rethore <pe@retho.re>
RUN apt-get update \
......
Subproject commit 5e567f7f2f4a28ed43da99052b43474eadaefd81
Subproject commit 5f695353b799e0e49ad78c9ba40e09e84b3c762d
......@@ -75,7 +75,7 @@ class PyFuga(object):
def get_no_tubines(self):
no_turbines_p = c_int_p(c_int(0))
self.lib.getNoTurbines(no_turbines_p)
self.lib.GetNoTurbines(no_turbines_p)
return no_turbines_p.contents.value
def move_turbines(self, tb_x, tb_y):
......@@ -91,7 +91,7 @@ class PyFuga(object):
AEPNet_p = c_double_p(c_double(0))
AEPGros_p = c_double_p(c_double(0))
capacity_p = c_double_p(c_double(0))
self.lib.getAEP(AEPNet_p, AEPGros_p, capacity_p)
self.lib.GetAEP(AEPNet_p, AEPGros_p, capacity_p)
#print(tb_x, tb_y, AEPNet_p.contents.value, (15.850434458235156 - AEPNet_p.contents.value) / .000001)
net, gros, cap = [p.contents.value for p in [AEPNet_p, AEPGros_p, capacity_p]]
return (net, gros, cap, net / gros)
......@@ -101,7 +101,7 @@ class PyFuga(object):
dAEPdxyz = np.zeros(len(tb_x)), np.zeros(len(tb_x)), np.zeros(len(tb_x))
dAEPdxyz_ctype = [dAEP.ctypes for dAEP in dAEPdxyz]
self.lib.getAEPGradients(*[dAEP_ctype.data_as(c_double_p) for dAEP_ctype in dAEPdxyz_ctype])
self.lib.GetAEPGradients(*[dAEP_ctype.data_as(c_double_p) for dAEP_ctype in dAEPdxyz_ctype])
#print(tb_x, tb_y, dAEPdxyz)
return np.array(dAEPdxyz)
......
......@@ -38,10 +38,10 @@ class Test(unittest.TestCase):
turbine_model_path=fuga_path + 'LUT/', turbine_model_name='Vestas_V80_(2_MW_offshore)[h=67.00]',
tb_x=[423974, 424033], tb_y=[6151447, 6150889],
mast_position=(0, 0, 70), z0=0.0001, zi=400, zeta0=0,
farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1\hornsrev_north_only.lib')
farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1/hornsrev_north_only.lib')
def testCheckVersion(self):
lib = PascalDLL(fuga_path + "FugaLib/FugaLib.dll")
lib = PascalDLL(fuga_path + "FugaLib/FugaLib.%s"%('so','dll')[os.name=='nt'])
self.assertRaisesRegex(Exception, "This version of FugaLib supports interface version ", lib.CheckInterfaceVersion, 1)
# PyFuga(fuga_path + "FugaLib/FugaLib.dll", fuga_path + "LUT/Farms/", "Horns Rev 1", fuga_path + "LUT/",
# (0, 0, 70), 0.0001, 400, 0, 'Horns Rev 1\hornsrev0.lib')
......
......@@ -4,18 +4,17 @@ Created on 19/04/2018
@author: Mads
'''
import numpy as np
class AEPCalculator(object):
def __init__(self, wdir=np.arange(360),wsp=np.arange(3,25), wind_resource, wake_model):
def __init__(self, wdir=np.arange(360), wsp=np.arange(3, 25), wind_resource, wake_model):
self.wdir = wdir
self.wsp = wsp
self.wind_resource = wind_resource
self.wake_model = wake_model
def calculate_aep(self, turbine_positions):
no_wake_wsp, no_wake_ti, weight = self.wind_resource(turbine_positions, self.wdir, self.wsp)
wake_wsp, power, ct = self.wake_model(turbine_positions, no_wake_wsp, no_wake_ti)
return np.sum(power * weight)
\ No newline at end of file
return np.sum(power * weight) * 24 * 365
......@@ -4,22 +4,22 @@ Created on 19/04/2018
@author: Mads
'''
import numpy as np
class WindResource(object):
def __init__(self,f,a,k,ti):
def __init__(self, f, a, k, ti):
self.f = f
self.a = a
self.k = k
self.ti = ti
def weibull_weight(self, ws):
cdf = lambda ws, A=self.A,k=self.k : 1 - np.exp(-(ws / A) ** k)
dws = np.diff(ws,0)
return cdf(ws+dws) - cdf(ws-dws)
cdf = lambda ws, A=self.A, k=self.k: 1 - np.exp(-(ws / A) ** k)
dws = np.diff(ws, 0) / 2
return cdf(ws + dws) - cdf(ws - dws)
def __call__(self, turbine_positions, wdir, wsp):
WS = np.broadcast_to(wsp, (len(turbine_positions), len(wdir),len(wsp)))
weight = self.weibull_weight(self.a, self.k, WS)
#TODO: add weight from wdir dist
return WS, np.zeros_like(WS)+self.ti, weight
WS = np.broadcast_to(wsp, (len(turbine_positions), len(wdir), len(wsp)))
weight = self.weibull_weight(self.a, self.k, WS) * self.f
return WS, np.zeros_like(WS) + self.ti, weight
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment