diff --git a/docker/Dockerfile b/docker/Dockerfile index 86c6cca886b632969b3c189c233292c797d34772..70c74e9ca7523fe39cc8441e0f8f3be0639d0cca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM continuumio/anaconda:latest +FROM continuumio/anaconda3:latest MAINTAINER Pierre-Elouan Rethore <pe@retho.re> RUN apt-get update \ diff --git a/topfarm/cost_models/fuga/Colonel b/topfarm/cost_models/fuga/Colonel index 5e567f7f2f4a28ed43da99052b43474eadaefd81..5f695353b799e0e49ad78c9ba40e09e84b3c762d 160000 --- a/topfarm/cost_models/fuga/Colonel +++ b/topfarm/cost_models/fuga/Colonel @@ -1 +1 @@ -Subproject commit 5e567f7f2f4a28ed43da99052b43474eadaefd81 +Subproject commit 5f695353b799e0e49ad78c9ba40e09e84b3c762d diff --git a/topfarm/cost_models/fuga/py_fuga.py b/topfarm/cost_models/fuga/py_fuga.py index 2c81a77e2cb7fb6993efa1984f8ac6e5f6465635..a107204eb1e30e877fa13d90274704a1875d997f 100644 --- a/topfarm/cost_models/fuga/py_fuga.py +++ b/topfarm/cost_models/fuga/py_fuga.py @@ -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) diff --git a/topfarm/cost_models/fuga/tests/test_pyfuga.py b/topfarm/cost_models/fuga/tests/test_pyfuga.py index 8c20b363f9dfaaa2dd617c51c897b6a5daf44371..c65c78c46b52d46318a3806e8f6862292b160c21 100644 --- a/topfarm/cost_models/fuga/tests/test_pyfuga.py +++ b/topfarm/cost_models/fuga/tests/test_pyfuga.py @@ -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') diff --git a/topfarm/cost_models/utils/aep_calculator.py b/topfarm/cost_models/utils/aep_calculator.py index 94d86f52d51ce4cf828a3aa54b3a3419b0fe8e1a..cd5a3e4044c6d31cae4d122ab7e88554d62a7613 100644 --- a/topfarm/cost_models/utils/aep_calculator.py +++ b/topfarm/cost_models/utils/aep_calculator.py @@ -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 diff --git a/topfarm/cost_models/utils/wind_resource.py b/topfarm/cost_models/utils/wind_resource.py index d41a14e7fdee12647315cbc8098da4191bf654e6..1b5a81bd110465e7948124dcf41df24d8a65c59d 100644 --- a/topfarm/cost_models/utils/wind_resource.py +++ b/topfarm/cost_models/utils/wind_resource.py @@ -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