py-wake
Advanced tools
| import os | ||
| import numpy | ||
| import pytest | ||
| from py_wake import np | ||
| from py_wake.deficit_models import BastankhahGaussianDeficit | ||
| from py_wake.examples.data.hornsrev1 import V80, Hornsrev1Site | ||
| from py_wake.tests import npt | ||
| from py_wake.utils import gpu_utils | ||
| from py_wake.utils.layouts import rectangle | ||
| from py_wake.wind_farm_models import All2AllIterative, PropagateDownwind | ||
| if gpu_utils.cupy_found: | ||
| import cupy as cp | ||
| def test_gpu_name(): | ||
| import socket | ||
| if socket.gethostname() == 'DTU-MM156971': | ||
| assert gpu_utils.gpu_name == 'NVIDIA GeForce RTX 5070' | ||
| def test_print_gpu_mem(): | ||
| gpu_utils.print_gpu_mem() | ||
| def test_free_gpu_mem(): | ||
| initial = gpu_utils.mempool.total_bytes() | ||
| cp.zeros(128 * 1024) | ||
| before = gpu_utils.mempool.total_bytes() | ||
| gpu_utils.free_gpu_mem(verbose=False) | ||
| after = gpu_utils.mempool.total_bytes() | ||
| assert after < before | ||
| @pytest.mark.parametrize('wfm_cls', [PropagateDownwind, All2AllIterative]) | ||
| def test_cupy(wfm_cls): | ||
| kwargs = dict(site=Hornsrev1Site(), windTurbines=V80(), | ||
| wake_deficitModel=BastankhahGaussianDeficit(use_effective_ws=True)) | ||
| def get_aep(np_backend): | ||
| np.set_backend(np_backend) | ||
| wfm = wfm_cls(**kwargs) | ||
| x, y = rectangle(16, 4, 80 * 5) | ||
| n_cpu = 1 # n_cpu = (1, 2)[np_backend == numpy] | ||
| wfm.aep([0], [0], n_cpu=n_cpu) # setup multiprocessing pool | ||
| P = wfm(x, y, n_cpu=n_cpu).Power | ||
| aep = wfm.aep(x, y, n_cpu=n_cpu) | ||
| np.set_backend(numpy) | ||
| return aep | ||
| aep_cpu = get_aep(numpy) | ||
| aep_gpu = get_aep(cp) | ||
| with pytest.raises(AssertionError): | ||
| npt.assert_array_equal(aep_cpu, aep_gpu.get()) | ||
| npt.assert_array_almost_equal(aep_cpu, aep_gpu.get(), 10) | ||
| assert aep_gpu.__class__ == cp.ndarray |
| import time | ||
| import numpy as np | ||
| from py_wake.examples.data.hornsrev1 import V80, Hornsrev1Site | ||
| from py_wake.flow_map import XYGrid | ||
| from py_wake.literature.gaussian_models import Bastankhah_PorteAgel_2014 | ||
| try: | ||
| from mpi4py import MPI | ||
| except ImportError: | ||
| MPI = None | ||
| if MPI: | ||
| TOLS = {"rtol": 1e-6, "atol": 1e-6} | ||
| def test_mpi_wind_farm_model(): | ||
| comm = MPI.COMM_WORLD | ||
| rank = comm.Get_rank() | ||
| site = Hornsrev1Site() | ||
| x, y = site.initial_position.T | ||
| windTurbines = V80() | ||
| wf_model = Bastankhah_PorteAgel_2014(site, windTurbines, k=0.0324555) | ||
| np.random.seed(0) | ||
| n = 2000 | ||
| use_time = False | ||
| wss = np.random.uniform(0, 15, n) if use_time else None | ||
| wds = np.random.uniform(0, 360, n) if use_time else None | ||
| if rank == 0: | ||
| start = time.time() | ||
| aep = wf_model(x=x, y=y, ws=wss, wd=wds, time=use_time, n_cpu=4).aep() | ||
| jac_full = ( | ||
| wf_model.aep_gradients(x=x, y=y, ws=wss, wd=wds, time=use_time, n_cpu=4) * 1e6 | ||
| ) # fmt: skip | ||
| if rank == 0: | ||
| elapsed = time.time() - start | ||
| print(f"WFM AEP+Grad runtime: {elapsed:.4f} seconds") | ||
| # serial run | ||
| aep_reff = wf_model(x=x, y=y, ws=wss, wd=wds, time=use_time, n_cpu=1).aep() | ||
| jac_reff = ( | ||
| wf_model.aep_gradients(x=x, y=y, ws=wss, wd=wds, time=use_time, n_cpu=1) * 1e6 | ||
| ) # fmt: skip | ||
| np.testing.assert_allclose(aep.sum().values, aep_reff.sum().values, **TOLS) | ||
| np.testing.assert_allclose(jac_full, jac_reff, **TOLS) | ||
| def test_mpi_flow_map(): | ||
| comm = MPI.COMM_WORLD | ||
| rank = comm.Get_rank() | ||
| site = Hornsrev1Site() | ||
| x, y = site.initial_position.T | ||
| windTurbines = V80() | ||
| wf_model = Bastankhah_PorteAgel_2014(site, windTurbines, k=0.0324555) | ||
| sim_res = wf_model(x=x, y=y, wd=np.arange(0, 360, 30), ws=[9, 10, 11]) | ||
| grid = XYGrid( | ||
| x=np.linspace(x.min() - 500, x.max() + 500, 100), | ||
| y=np.linspace(y.min() - 500, y.max() + 500, 100), | ||
| ) | ||
| if rank == 0: | ||
| start = time.time() | ||
| # MPI parallel flow map (n_cpu > 1 enables MPI when running with mpirun) | ||
| flow_map_mpi = sim_res.flow_map(grid=grid, n_cpu=4) | ||
| if rank == 0: | ||
| elapsed = time.time() - start | ||
| print(f"WFM flow_map runtime: {elapsed:.4f} seconds") | ||
| flow_map_serial = sim_res.flow_map(grid=grid, n_cpu=1) | ||
| np.testing.assert_allclose( | ||
| flow_map_mpi.WS_eff.values, flow_map_serial.WS_eff.values, **TOLS | ||
| ) | ||
| np.testing.assert_allclose( | ||
| flow_map_mpi.TI_eff.values, flow_map_serial.TI_eff.values, **TOLS | ||
| ) | ||
| if __name__ == "__main__": | ||
| test_mpi_wind_farm_model() | ||
| test_mpi_flow_map() |
+1
-1
@@ -118,3 +118,3 @@ # -*- coding: utf-8 -*- | ||
| # Controls when a cell will time out (defaults to 30; use -1 for no timeout): | ||
| nbsphinx_timeout = 180 | ||
| nbsphinx_timeout = 600 | ||
@@ -121,0 +121,0 @@ # Default Pygments lexer for syntax highlighting in code cells: |
+5
-3
| Metadata-Version: 2.4 | ||
| Name: py_wake | ||
| Version: 2.6.15 | ||
| Version: 2.6.16 | ||
| Summary: Open source static wake modeling framework from DTU | ||
@@ -30,4 +30,2 @@ Author: DTU Wind Energy | ||
| Requires-Dist: pooch | ||
| Requires-Dist: windkit | ||
| Requires-Dist: geopandas | ||
| Provides-Extra: test | ||
@@ -43,2 +41,4 @@ Requires-Dist: pytest; extra == "test" | ||
| Requires-Dist: ipywidgets; extra == "test" | ||
| Requires-Dist: windkit; extra == "test" | ||
| Requires-Dist: geopandas; extra == "test" | ||
| Provides-Extra: docs | ||
@@ -56,2 +56,4 @@ Requires-Dist: sphinx; extra == "docs" | ||
| Requires-Dist: topfarm; extra == "docs" | ||
| Requires-Dist: windkit; extra == "docs" | ||
| Requires-Dist: geopandas; extra == "docs" | ||
| Dynamic: license-file | ||
@@ -58,0 +60,0 @@ |
+13
-8
@@ -6,19 +6,24 @@ """PyWake | ||
| """ | ||
| import netCDF4 | ||
| import numpy | ||
| import numpy | ||
| from py_wake.utils.numpy_utils import NumpyWrapper | ||
| np = numpy | ||
| locals()['np'] = NumpyWrapper() | ||
| from py_wake.deficit_models.noj import NOJLocal, NOJ # nopep8 | ||
| from py_wake.deficit_models.gaussian import BastankhahGaussian, NiayifarGaussian, ZongGaussian # nopep8 | ||
| from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussian # nopep8 | ||
| from py_wake.literature.turbopark import Nygaard_2022 # nopep8 | ||
| from py_wake.deficit_models.deficit_model import DeficitModel # nopep8 | ||
| from py_wake.deficit_models.fuga import Fuga, FugaBlockage # nopep8 | ||
| from py_wake.deficit_models.gaussian import ( # nopep8 | ||
| BastankhahGaussian, | ||
| IEA37SimpleBastankhahGaussian, # nopep8 | ||
| NiayifarGaussian, | ||
| ZongGaussian, | ||
| ) | ||
| from py_wake.deficit_models.gcl import GCL, GCLLocal # nopep8 | ||
| from py_wake.flow_map import HorizontalGrid, XYGrid, YZGrid, XZGrid # nopep8 | ||
| from py_wake.deficit_models.noj import NOJ, NOJLocal # nopep8 | ||
| from py_wake.flow_map import HorizontalGrid, XYGrid, XZGrid, YZGrid # nopep8 | ||
| from py_wake.literature.turbopark import Nygaard_2022 # nopep8 | ||
| from py_wake.wind_farm_models.wind_farm_model import WindFarmModel # nopep8 | ||
| from py_wake.deficit_models.deficit_model import DeficitModel # nopep8 | ||
| try: # pragma: no cover | ||
@@ -25,0 +30,0 @@ # version.py created when installing py_wake |
@@ -130,3 +130,3 @@ from numpy import newaxis as na | ||
| method = [['linear', 'nearest'][d in ['d_h', 'variable']] for d in da.dims] | ||
| method = [['linear', 'nearest'][d in ['d_h', 'variables']] for d in da.dims] | ||
| XRLUTDeficitModel.__init__(self, da, get_input=self.get_input, method=method, bounds=bounds, | ||
@@ -145,3 +145,4 @@ rotorAvgModel=rotorAvgModel, groundModel=groundModel, | ||
| def get_mdu(hcw_ijlk, dw_ijlk=dw_ijlk): | ||
| hcw_ijlk = np.nan_to_num(np.clip(hcw_ijlk, -lim, lim), nan=lim) | ||
| hcw_ijlk = np.clip(hcw_ijlk, -lim, lim) | ||
| hcw_ijlk = np.where(np.isnan(hcw_ijlk), lim, hcw_ijlk) | ||
| return self._calc_mdu(D_src_il=D_src_il, dw_ijlk=dw_ijlk, | ||
@@ -148,0 +149,0 @@ hcw_ijlk=hcw_ijlk, h_ilk=h_ilk, z_ijlk=z_ijlk, TI_ilk=TI_ilk, **kwargs) |
@@ -0,2 +1,7 @@ | ||
| import warnings | ||
| from numpy import newaxis as na | ||
| from numpy.exceptions import ComplexWarning | ||
| from scipy.interpolate import RegularGridInterpolator as RGI | ||
| from py_wake import np | ||
@@ -7,3 +12,2 @@ from py_wake.deflection_models.deflection_model import DeflectionModel | ||
| from py_wake.utils.grid_interpolator import GridInterpolator | ||
| from scipy.interpolate import RegularGridInterpolator | ||
@@ -22,3 +26,3 @@ | ||
| zlevels = [jh, jh + 1] | ||
| tabs = self.load_luts(['VL', 'VT'], zlevels).reshape(2, 2, -1, len(self.x)) | ||
| tabs = self.load_luts(['VL', 'VT'], zlevels).reshape(2, 2, len(self.y), len(self.x)) | ||
| t = np.modf(np.log(self.zHub / self.z0) / self.ds)[0] | ||
@@ -43,3 +47,4 @@ tabs = tabs[:, 0] * (1 - t) + t * tabs[:, 1] | ||
| self.fTtab = fT = np.concatenate([fT[::-1], fT[1:]], 0) | ||
| self.fLT = GridInterpolator([self.x, self.mirror(self.y, anti_symmetric=True)], np.array([fL, fT]).T) | ||
| self.fLT = GridInterpolator([self.x, self.mirror(self.y, anti_symmetric=True)], | ||
| np.array([fL, fT]).T, bounds='limit') | ||
@@ -68,54 +73,36 @@ def calc_deflection(self, dw_ijlk, hcw_ijlk, dh_ijlk, WS_ilk, WS_eff_ilk, yaw_ilk, ct_ilk, D_src_il, **_): | ||
| if 0: # J < 1000: | ||
| # To find lut_y we calculate y for a range of lut_y grid points around y and interpolate | ||
| lut_y_ijlx = (np.round(hcw_ijlk / self.dy) + np.arange(-X // 2, X // 2)[na, na, na]) * self.dy | ||
| dw_ijlx = np.repeat(dw_ijlk, X, 3) | ||
| # calculate deflection, lambda(lut_y) = # F * (cos(yaw) * fT(lut_y) + sin(yaw) * fL(lut_y) | ||
| fL, fT = self.fLT(np.array([dw_ijlx.flatten(), lut_y_ijlx.flatten()]).T).T | ||
| if J < 1000: | ||
| lambda_ijlkx = F_ilk[:, na, :, :, na] * (fL.reshape(I, J, L, 1, X) * cos_ilk[:, na, :, :, na] + | ||
| fT.reshape(I, J, L, 1, X) * sin_ilk[:, na, :, :, na]) | ||
| # Calcuate deflected y | ||
| y_ijlkx = lut_y_ijlx[:, :, :, na] + lambda_ijlkx | ||
| def get_err(deflected_hcw_ijlk, dw_ijlk): | ||
| dw_ijlk = np.broadcast_to(dw_ijlk, deflected_hcw_ijlk.shape) | ||
| fL, fT = self.fLT(np.array([dw_ijlk.flatten(), deflected_hcw_ijlk.flatten()]).T).T | ||
| lambda_ijlk = F_ilk[:, na, :, :] * (fL.reshape(dw_ijlk.shape) * cos_ilk[:, na, :, :] + | ||
| fT.reshape(dw_ijlk.shape) * sin_ilk[:, na, :, :]) | ||
| hcw_ijlk = np.array([[[[np.interp(hcw_ijlk[i, j, l, k], y_ijlkx[i, j, l, k], lut_y_ijlx[i, j, l]) | ||
| for k in range(K)] | ||
| for l in range(L)] | ||
| for j in range(J)] | ||
| for i in range(I)]) | ||
| else: | ||
| x, y = self.fLT.x | ||
| return deflected_hcw_ijlk + lambda_ijlk - hcw_ijlk | ||
| # def get_hcw_jk(i, l): | ||
| # x_idx = (np.searchsorted(x, [dw_ijl.min(), dw_ijl.max()]) + np.array([-1, 1])) | ||
| # m_x = len(x) - 1 | ||
| # x_slice = slice(*np.minimum([m_x, m_x], np.maximum([0, 0], x_idx))) | ||
| # | ||
| # y_idx = (np.searchsorted(y, [hcw_ijl.min(), hcw_ijl.max()]) + np.array([-20, 20])) | ||
| # m_y = len(y) - 1 | ||
| # y_slice = slice(*np.minimum([m_y, m_y], np.maximum([0, 0], y_idx))) | ||
| # | ||
| # x_ = x[x_slice] | ||
| # y_ = y[y_slice] | ||
| # VLT = self.fLT.V[x_slice, y_slice] | ||
| # | ||
| # def get_hcw_j(i, l, k): | ||
| # lambda2p = F_ilk[i, l, k] * \ | ||
| # np.sum(VLT * [np.cos(theta_ilk[i, l, k]), np.sin(theta_ilk[i, l, k])], -1) | ||
| # lambda2 = RegularGridInterpolator( | ||
| # (x_, y_), [np.interp(y_, y_ + l2p_x, l2p_x) for l2p_x in lambda2p]) | ||
| # | ||
| # hcw_j = hcw_ijl[i, :, l].copy() | ||
| # m = (hcw_ijl[i, :, l] > y_[0]) & (hcw_ijl[i, :, l] < y_[-1]) | ||
| # hcw_j[m] -= lambda2((dw_ijl[i, :, l][m], hcw_ijl[i, :, l][m])) | ||
| # return hcw_j | ||
| # return [get_hcw_j(i, l, k) for k in range(K)] | ||
| # | ||
| # hcw_ijlk_old = np.moveaxis([[get_hcw_jk(i, l) | ||
| # for l in range(L)] | ||
| # for i in range(I)], 3, 1) | ||
| deflected_hcw_ijlk = hcw_ijlk | ||
| D = D_src_il.max() | ||
| # Newton Raphson | ||
| complex = np.iscomplexobj(hcw_ijlk) or np.iscomplexobj(dw_ijlk) | ||
| for i in range(8): | ||
| if complex: | ||
| err = get_err(deflected_hcw_ijlk, dw_ijlk) | ||
| derr = (get_err(deflected_hcw_ijlk + .1) - err) / .1 | ||
| else: | ||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", ComplexWarning) | ||
| cs_err = get_err(deflected_hcw_ijlk + 1e-20j, dw_ijlk) | ||
| err, derr = np.real(cs_err), np.imag(cs_err) / 1e-20 | ||
| step = -np.clip(err / derr, -D, D) # limit step to 100m | ||
| if np.allclose(step, 0, atol=1e-6): | ||
| break | ||
| deflected_hcw_ijlk = deflected_hcw_ijlk + step | ||
| hcw_ijlk = deflected_hcw_ijlk | ||
| else: | ||
| x, y = self.fLT.grid | ||
| hcw_ijlk = np.array([self.get_hcw_jlk(i, K, L, x, y, dw_ijlk, hcw_ijlk, F_ilk, theta_ilk) | ||
| for i in range(I)]) | ||
| # npt.assert_array_almost_equal(hcw_ijlk_old, hcw_ijlk, 4) | ||
@@ -125,14 +112,5 @@ return dw_ijlk, hcw_ijlk, dh_ijlk | ||
| def get_hcw_jlk(self, i, K, L, x, y, dw_ijlk, hcw_ijlk, F_ilk, theta_ilk): | ||
| if (K == 1 and L > 1 and np.all(dw_ijlk == dw_ijlk[:1, :, :1]) and np.all(hcw_ijlk == hcw_ijlk[:1, :, :1]) and | ||
| len(np.unique(theta_ilk[i, :, 0])) < L): | ||
| hcw_jlk = np.zeros((dw_ijlk.shape[1], L, K)) | ||
| for theta, l in zip(*np.unique(theta_ilk[i], return_index=True)): | ||
| hcw_jlk[:, theta_ilk[i, :, 0] == theta] = np.array(self.get_hcw_jk( | ||
| i, l, K, x, y, dw_ijlk, hcw_ijlk, F_ilk, theta_ilk)).T[:, na] | ||
| return hcw_jlk | ||
| return np.moveaxis([self.get_hcw_jk(i, l, K, x, y, dw_ijlk, hcw_ijlk, F_ilk, theta_ilk) | ||
| for l in range(L)], 2, 0) | ||
| else: | ||
| return np.moveaxis([self.get_hcw_jk(i, l, K, x, y, dw_ijlk, hcw_ijlk, F_ilk, theta_ilk) | ||
| for l in range(L)], 2, 0) | ||
| def get_hcw_jk(self, i, l, K, x, y, dw_ijlk, hcw_ijlk, F_ilk, theta_ilk): | ||
@@ -149,3 +127,3 @@ x_idx = (np.searchsorted(x, [dw_ijlk.min(), dw_ijlk.max()]) + np.array([-1, 1], dtype=int)) | ||
| y_ = y[y_slice] | ||
| VLT = self.fLT.V[x_slice, y_slice] | ||
| VLT = self.fLT.values[x_slice, y_slice] | ||
| return [self.get_hcw_j(i, l, k, F_ilk, VLT, theta_ilk, x_, y_, hcw_ijlk, dw_ijlk) for k in range(K)] | ||
@@ -156,3 +134,3 @@ | ||
| np.sum(VLT * [np.cos(theta_ilk[i, l, k]), np.sin(theta_ilk[i, l, k])], -1) | ||
| lambda2 = RegularGridInterpolator( | ||
| lambda2 = RGI( | ||
| (x_, y_), np.array([np.interp(y_, y_ + l2p_x, l2p_x) for l2p_x in lambda2p], dtype=float)) | ||
@@ -171,6 +149,7 @@ hcw_l = min(l, hcw_ijlk.shape[2] - 1) | ||
| if __name__ == '__main__': | ||
| from py_wake import Fuga | ||
| from py_wake.examples.data.iea37._iea37 import IEA37Site, IEA37_WindTurbines | ||
| import matplotlib.pyplot as plt | ||
| from py_wake import Fuga | ||
| from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines, IEA37Site | ||
| site = IEA37Site(16) | ||
@@ -177,0 +156,0 @@ x, y = [0, 600, 1200], [0, 0, 0] # site.initial_position[:2].T |
@@ -1,6 +0,8 @@ | ||
| from py_wake.wind_farm_models.engineering_models import PropagateDownwind, All2AllIterative | ||
| from py_wake.deficit_models.fuga import FugaDeficit | ||
| from py_wake.superposition_models import LinearSum | ||
| from py_wake.deficit_models.fuga import FugaDeficit | ||
| from py_wake.examples.data.hornsrev1 import Hornsrev1Site, V80 | ||
| from py_wake.tests.test_files import tfp | ||
| from py_wake.wind_farm_models.engineering_models import ( | ||
| All2AllIterative, | ||
| PropagateDownwind, | ||
| ) | ||
@@ -88,3 +90,3 @@ | ||
| if __name__ == '__main__': | ||
| from py_wake.examples.data.hornsrev1 import V80, Hornsrev1Site, wt16_x, wt16_y | ||
| path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00.nc' | ||
@@ -94,3 +96,3 @@ | ||
| windTurbines = V80() | ||
| x, y = site.initial_position.T | ||
| x, y = wt16_x, wt16_y | ||
@@ -97,0 +99,0 @@ for wf_model in [Ott_Nielsen_2014(path, site, windTurbines), |
| import numpy as np | ||
| from py_wake.wind_farm_models.engineering_models import PropagateDownwind | ||
| from py_wake.deficit_models.gaussian import ( | ||
| BastankhahGaussianDeficit, | ||
| BlondelSuperGaussianDeficit2020, | ||
| CarbajofuertesGaussianDeficit, | ||
| NiayifarGaussianDeficit, | ||
| ZongGaussianDeficit, | ||
| ) | ||
| from py_wake.deficit_models.utils import ct2a_mom1d | ||
| from py_wake.superposition_models import LinearSum, WeightedSum | ||
| from py_wake.deficit_models.gaussian import BastankhahGaussianDeficit, NiayifarGaussianDeficit, ZongGaussianDeficit, \ | ||
| BlondelSuperGaussianDeficit2020, CarbajofuertesGaussianDeficit | ||
| from py_wake.rotor_avg_models.gaussian_overlap_model import GaussianOverlapAvgModel | ||
| from py_wake.superposition_models import LinearSum, SqrMaxSum, WeightedSum | ||
| from py_wake.turbulence_models.crespo import CrespoHernandez | ||
| from py_wake.superposition_models import SqrMaxSum | ||
| from py_wake.rotor_avg_models.gaussian_overlap_model import GaussianOverlapAvgModel | ||
| from py_wake.examples.data.hornsrev1 import Hornsrev1Site, V80 | ||
| from py_wake.wind_farm_models.engineering_models import PropagateDownwind | ||
@@ -283,6 +287,7 @@ | ||
| if __name__ == '__main__': | ||
| from py_wake.examples.data.hornsrev1 import V80, Hornsrev1Site, wt16_x, wt16_y | ||
| site = Hornsrev1Site() | ||
| windTurbines = V80() | ||
| x, y = site.initial_position.T | ||
| x, y = wt16_x, wt16_y | ||
@@ -289,0 +294,0 @@ for wf_model in [Bastankhah_PorteAgel_2014(site, windTurbines, k=0.0324555), |
+16
-14
@@ -0,11 +1,12 @@ | ||
| from abc import ABC, abstractmethod | ||
| import matplotlib.pyplot as plt | ||
| import xarray as xr | ||
| from numpy import newaxis as na | ||
| import py_wake.utils.xarray_utils # register ilk function @UnusedImport | ||
| from py_wake import np | ||
| from py_wake.site.shear import PowerShear | ||
| import py_wake.utils.xarray_utils # register ilk function @UnusedImport | ||
| import xarray as xr | ||
| from abc import ABC, abstractmethod | ||
| from py_wake.utils.functions import arg2ilk | ||
| from py_wake.utils.xarray_utils import ilk2da | ||
| from numpy import newaxis as na | ||
| from py_wake.utils.functions import arg2ilk | ||
| from collections.abc import Iterable | ||
@@ -41,8 +42,2 @@ """ | ||
| time = np.arange(len(wd)) | ||
| elif isinstance(time, Iterable) and ( | ||
| len(ws) != len(time) or len(wd) != len(time) | ||
| ): # avoid redundant passing wd & ws for time series sites | ||
| wd = np.zeros(len(time)) | ||
| ws = np.zeros(len(time)) | ||
| assert len(wd) == len(ws) | ||
| coords = {'time': np.atleast_1d(time), 'wd': np.atleast_1d(wd), 'ws': np.atleast_1d(ws)} | ||
@@ -139,3 +134,9 @@ else: | ||
| def get_defaults(self, wd=None, ws=None): | ||
| def get_defaults(self, wd=None, ws=None, time=False): | ||
| if time is not False: | ||
| if wd is None or ws is None: | ||
| raise ValueError('wd and ws must be specified for time series') | ||
| else: | ||
| wd, ws = np.atleast_1d(wd), np.atleast_1d(ws) | ||
| assert len(wd) == len(ws) | ||
| if wd is None: | ||
@@ -187,3 +188,3 @@ wd = self.default_wd | ||
| """ | ||
| wd, ws = self.get_defaults(wd, ws) | ||
| wd, ws = self.get_defaults(wd, ws, time) | ||
| wd_bin_size = self.wd_bin_size(wd, wd_bin_size) | ||
@@ -403,2 +404,3 @@ lw = LocalWind(x, y, h, wd, ws, time, wd_bin_size) | ||
| from py_wake.site import xrsite # @NoMove # nopep8 | ||
| UniformSite = xrsite.UniformSite | ||
@@ -405,0 +407,0 @@ UniformWeibullSite = xrsite.UniformWeibullSite |
@@ -36,3 +36,3 @@ from py_wake import np | ||
| alpha = self.alpha.interp_ilk(localWind.coords, interp_method=self.interp_method) | ||
| return (h / self.h_ref)[:, na, na] ** alpha * WS_ilk | ||
| return (h / self.h_ref).reshape((h.shape + (1, 1))[:3]) ** alpha * WS_ilk | ||
@@ -54,3 +54,4 @@ | ||
| L_inv = self.h_zeta / self.h_ref # 1 / Obukhov length | ||
| return (np.log(h[:, na, na] / z0) - psi(h[:, na, na] * L_inv, Cm1=self.Cm1, Cm2=self.Cm2)) / (np.log(self.h_ref / z0) - psi(self.h_zeta, Cm1=self.Cm1, Cm2=self.Cm2)) * WS_ilk | ||
| return (np.log(h[:, na, na] / z0) - psi(h[:, na, na] * L_inv, Cm1=self.Cm1, Cm2=self.Cm2)) / \ | ||
| (np.log(self.h_ref / z0) - psi(self.h_zeta, Cm1=self.Cm1, Cm2=self.Cm2)) * WS_ilk | ||
@@ -57,0 +58,0 @@ |
@@ -1,6 +0,7 @@ | ||
| from py_wake.utils.streamline import VectorField3D | ||
| import numpy as np | ||
| from scipy.interpolate._rgi import RegularGridInterpolator as RGI | ||
| from py_wake.site.streamline_distance import StreamlineDistance | ||
| from py_wake.site.xrsite import XRSite | ||
| from py_wake.site.streamline_distance import StreamlineDistance | ||
| from py_wake.utils.streamline import VectorField3D | ||
@@ -7,0 +8,0 @@ |
@@ -641,3 +641,3 @@ import pytest | ||
| fm = sim_res.flow_map(Points(x=[200, 200, 200], y=[0, 200, 400], h=[110, 110, 110]), wd=sim_res.wd, ws=sim_res.ws) | ||
| npt.assert_allclose(fm.WS_eff[:, 1], [3.4, 6.1, 7.5], atol=.1) | ||
| npt.assert_allclose(fm.WS_eff[:, 0], [3.4, 6.1, 7.5], atol=.1) | ||
| if 0: | ||
@@ -644,0 +644,0 @@ axes = plt.subplots(2, 1)[1] |
@@ -16,2 +16,4 @@ from pathlib import Path | ||
| from py_wake.utils import fuga_utils | ||
| from py_wake.utils.gradients import fd, autograd | ||
| from py_wake.examples.data.hornsrev1 import V80 | ||
@@ -37,6 +39,6 @@ | ||
| plt.plot(x, notebook_deflection, label='Notebook deflection') | ||
| plt.plot(x, fuga_deflection) | ||
| plt.plot(x, fuga_deflection, '.-') | ||
| plt.show() | ||
| plt.close('all') | ||
| npt.assert_allclose(fuga_deflection, notebook_deflection, atol=1e-5) | ||
| npt.assert_allclose(fuga_deflection, notebook_deflection, atol=1e-3) | ||
@@ -90,20 +92,22 @@ | ||
| powerCtFunction = PowerCtTabular([0, 100], [0, 0], 'w', [0.850877, 0.850877]) | ||
| wt = WindTurbine(name='', diameter=80, hub_height=70, powerCtFunction=powerCtFunction) | ||
| wt = V80() | ||
| path = tfp + 'fuga/2MW/Z0=0.00001000Zi=00400Zeta0=0.00E+00.nc' | ||
| site = UniformSite([1, 0, 0, 0], ti=0.075) | ||
| wfm = PropagateDownwind( | ||
| site, | ||
| wt, | ||
| wake_deficitModel=FugaYawDeficit(path), | ||
| deflectionModel=FugaDeflection(path, 'input_par') | ||
| ) | ||
| wfm = PropagateDownwind(site, wt, wake_deficitModel=FugaYawDeficit(path), | ||
| deflectionModel=FugaDeflection(path, 'input_par')) | ||
| WS = 10 | ||
| yaw_ref = np.full((10, 1), 17) | ||
| yaw_step = np.eye(10, 10) * 1e-6 + yaw_ref | ||
| yaw = np.concatenate([yaw_step, yaw_ref], axis=1) | ||
| sim_res = wfm(np.arange(10) * wt.diameter() * 4, [0] * 10, yaw=yaw, wd=[270] * 11, ws=[WS] * 11, time=True) | ||
| yaw = np.arange(12).reshape((3, 4)) + 10 | ||
| x = np.arange(3) * wt.diameter() * 4 | ||
| kwargs = dict(x=x, y=x * 0, wd=np.arange(270, 274), ws=np.full(4, WS), time=True) | ||
| def dPdyaw(yaw): | ||
| return wfm(**kwargs, yaw=yaw, return_simulationResult=False)[2].sum() | ||
| if 0: | ||
| wfm(**kwargs, yaw=yaw).flow_map(XYGrid(resolution=100), time=0).plot_wake_map() | ||
| plt.show() | ||
| daep_autograd = autograd(dPdyaw)(yaw) | ||
| daep_fd = fd(dPdyaw)(yaw) | ||
| npt.assert_allclose(daep_autograd, daep_fd, atol=0.002) |
@@ -1,22 +0,28 @@ | ||
| from py_wake.flow_map import HorizontalGrid, YZGrid, Points, XYGrid, XZGrid | ||
| from py_wake.tests import npt | ||
| import warnings | ||
| import matplotlib.pyplot as plt | ||
| import pytest | ||
| from py_wake import np | ||
| from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussianDeficit | ||
| from py_wake.deficit_models.no_wake import NoWakeDeficit | ||
| from py_wake.deflection_models.jimenez import JimenezWakeDeflection | ||
| from py_wake.examples.data import hornsrev1, wtg_path | ||
| from py_wake.examples.data.hornsrev1 import V80 | ||
| from py_wake.examples.data.iea37 import IEA37_WindTurbines, IEA37Site | ||
| from py_wake.examples.data.ParqueFicticio._parque_ficticio import ParqueFicticioSite | ||
| from py_wake.flow_map import HorizontalGrid, Points, XYGrid, XZGrid, YZGrid | ||
| from py_wake.literature.iea37_case_study1 import IEA37CaseStudy1 | ||
| from py_wake.site._site import UniformSite | ||
| from py_wake.site.distance import StraightDistance | ||
| from py_wake.examples.data.iea37 import IEA37Site, IEA37_WindTurbines | ||
| import pytest | ||
| from py_wake.deflection_models.jimenez import JimenezWakeDeflection | ||
| from py_wake.wind_turbines._wind_turbines import WindTurbines, WindTurbine | ||
| from py_wake.examples.data import wtg_path, hornsrev1 | ||
| from py_wake.superposition_models import SquaredSum | ||
| from py_wake.tests import npt | ||
| from py_wake.utils.profiling import timeit | ||
| from py_wake.wind_farm_models.engineering_models import ( | ||
| All2AllIterative, | ||
| PropagateDownwind, | ||
| ) | ||
| from py_wake.wind_turbines._wind_turbines import WindTurbine, WindTurbines | ||
| from py_wake.wind_turbines.power_ct_functions import PowerCtTabular | ||
| from py_wake.examples.data.hornsrev1 import V80 | ||
| from py_wake.literature.iea37_case_study1 import IEA37CaseStudy1 | ||
| from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussianDeficit | ||
| from py_wake.wind_farm_models.engineering_models import PropagateDownwind, All2AllIterative | ||
| from py_wake.superposition_models import SquaredSum | ||
| import warnings | ||
| from py_wake.deficit_models.no_wake import NoWakeDeficit | ||
| from py_wake.site._site import UniformSite | ||
| from py_wake.site.shear import PowerShear | ||
@@ -503,2 +509,3 @@ | ||
| wfm = IEA37CaseStudy1(16) | ||
| wfm.site.shear = PowerShear() | ||
| x, y = wfm.site.initial_position.T | ||
@@ -513,4 +520,4 @@ sim_res = wfm(x, y, wd=np.arange(360), ws=np.arange(3, 25)) | ||
| wf_y = 0 | ||
| from numpy import newaxis as na | ||
| from tqdm import tqdm | ||
| from numpy import newaxis as na | ||
@@ -523,6 +530,8 @@ def run_loop(): | ||
| y_jl = si[na] * dw[:, na] + hcw[:, na] * co[na] + wf_y | ||
| h_j = dh + wf_h | ||
| h_j = np.linspace(-1, 1, 100) + wf_h | ||
| WS_eff_jlk_lst = [] | ||
| for wd, x_j, y_j in zip(wd_lst, x_jl.T, y_jl.T): | ||
| lw_j, WS_eff_jlk, TI_eff_jlk = wfm._flow_map(x_j[:, na], y_j[:, na], h_j[:, na], sim_res.localWind, | ||
| wd, sim_res.ws, sim_res) | ||
| WS_eff_jlk_lst.append(WS_eff_jlk[:, 0]) | ||
| if 0: | ||
@@ -534,4 +543,5 @@ plt.contourf(x_j.reshape(X.shape), y_j.reshape(X.shape), | ||
| plt.show() | ||
| return np.moveaxis(WS_eff_jlk_lst, 0, 1) | ||
| timeit(run_loop, verbose=1, line_profile=0)() | ||
| res_ref, _ = timeit(run_loop, verbose=1, line_profile=0)() | ||
@@ -544,3 +554,3 @@ def run_vec(): | ||
| y_jl = si[na] * dw[:, na] + hcw[:, na] * co[na] + wf_y | ||
| h_jl = dh[:, na] + wf_h | ||
| h_jl = np.linspace(-1, 1, 100)[:, na] + wf_h | ||
@@ -556,3 +566,5 @@ lw_j, WS_eff_jlk, TI_eff_jlk = wfm._flow_map(x_jl, y_jl, h_jl, sim_res.localWind, | ||
| plt.show() | ||
| return WS_eff_jlk | ||
| timeit(run_vec, verbose=1, line_profile=0)() | ||
| res, _ = timeit(run_vec, verbose=1, line_profile=0)() | ||
| npt.assert_array_equal(res_ref, res) |
@@ -0,15 +1,20 @@ | ||
| from pathlib import Path | ||
| import matplotlib.pyplot as plt | ||
| import pandas as pd | ||
| import pytest | ||
| from surrogates_interface.surrogates import TensorFlowModel | ||
| from py_wake import np | ||
| import pandas as pd | ||
| import matplotlib.pyplot as plt | ||
| from py_wake.examples.data.iea34_130rwt._iea34_130rwt import IEA34_130_1WT_Surrogate, IEA34_130_2WT_Surrogate | ||
| from py_wake.tests import npt | ||
| from py_wake.deficit_models.noj import NOJ | ||
| from py_wake.examples.data import example_data_path | ||
| from py_wake.examples.data.iea34_130rwt._iea34_130rwt import ( | ||
| IEA34_130_1WT_Surrogate, | ||
| IEA34_130_2WT_Surrogate, | ||
| ) | ||
| from py_wake.site.xrsite import UniformSite | ||
| from py_wake.tests import npt | ||
| from py_wake.turbulence_models.stf import STF2017TurbulenceModel | ||
| from pathlib import Path | ||
| from py_wake.utils.gradients import autograd, cs, fd, plot_gradients | ||
| from py_wake.wind_turbines.wind_turbine_functions import FunctionSurrogates | ||
| from py_wake.examples.data import example_data_path | ||
| from py_wake.utils.gradients import plot_gradients, fd, autograd, cs | ||
| import pytest | ||
| from surrogates_interface.surrogates import TensorFlowModel | ||
@@ -139,3 +144,3 @@ | ||
| wfm = NOJ(site, wt, turbulenceModel=STF2017TurbulenceModel()) | ||
| sim_res = wfm([0, 0], [0, dist * 130], wd=wdir, time=True, Alpha=shear) | ||
| sim_res = wfm([0, 0], [0, dist * 130], ws=ws, wd=wdir, time=True, Alpha=shear) | ||
@@ -142,0 +147,0 @@ npt.assert_allclose(ws, ws_ref, rtol=.006) |
| import os | ||
| import warnings | ||
| from pathlib import Path | ||
| import pytest | ||
| import xarray | ||
| from py_wake.tests.notebook import Notebook | ||
| import py_wake | ||
| from py_wake.flow_map import Grid | ||
| from pathlib import Path | ||
| import xarray | ||
| import warnings | ||
| from py_wake.tests.notebook import Notebook | ||
@@ -39,2 +39,10 @@ | ||
| plt.rcParams.update({'figure.max_open_warning': 0}) | ||
| from py_wake.utils import profiling | ||
| def dummy_profileit(f, *args, **kwargs): | ||
| def wrapper(*args, **kwargs): | ||
| return f(*args, **kwargs), 0, 0 | ||
| return wrapper | ||
| profiling.profileit = dummy_profileit | ||
| with warnings.catch_warnings(): | ||
@@ -41,0 +49,0 @@ warnings.filterwarnings('ignore', 'The .* model is not representative of the setup used in the literature') |
@@ -337,3 +337,3 @@ import warnings | ||
| dw_stop=np.full(x.shape, 2000)) | ||
| if 1: | ||
| if 0: | ||
| fm.plot_wake_map() | ||
@@ -340,0 +340,0 @@ for sl in stream_lines: |
@@ -1,20 +0,21 @@ | ||
| from py_wake import np | ||
| import contextlib | ||
| import io | ||
| import math | ||
| import os | ||
| import shutil | ||
| import time | ||
| import matplotlib.pyplot as plt | ||
| import pytest | ||
| from numpy import newaxis as na | ||
| from py_wake.tests import npt | ||
| import pytest | ||
| from py_wake import NOJ, np | ||
| from py_wake.examples.data.ParqueFicticio import ParqueFicticio_path, ParqueFicticioSite | ||
| from py_wake.site.distance import StraightDistance, TerrainFollowingDistance | ||
| from py_wake.site.wasp_grid_site import WaspGridSite | ||
| import os | ||
| import time | ||
| from py_wake.site.xrsite import XRSite | ||
| from py_wake.tests import npt | ||
| from py_wake.tests.test_files.wasp_grid_site import one_layer | ||
| from py_wake.site.distance import TerrainFollowingDistance, StraightDistance | ||
| import math | ||
| from py_wake import NOJ | ||
| import matplotlib.pyplot as plt | ||
| from py_wake.site.xrsite import XRSite | ||
| import shutil | ||
| from py_wake.wind_turbines._wind_turbines import WindTurbine | ||
| from py_wake.wind_turbines.power_ct_functions import PowerCtTabular | ||
| import contextlib | ||
| import io | ||
@@ -225,3 +226,3 @@ | ||
| time_w_pkl = time.time() - start | ||
| npt.assert_array_less(time_w_pkl * 10, time_wo_pkl) | ||
| npt.assert_array_less(time_w_pkl * 8, time_wo_pkl) | ||
@@ -228,0 +229,0 @@ |
@@ -9,2 +9,3 @@ from py_wake.examples.data.hornsrev1 import Hornsrev1WRFSite, V80 | ||
| from py_wake.flow_map import XYGrid | ||
| from py_wake.site.wrf import WRFSite | ||
@@ -25,2 +26,3 @@ | ||
| dw, cw = [v[0, 1, 0, 0] for v in site.distance(x[:2], y[:2], x[:2] * 0 + h, wd_l=[0], time=[t])[:2]] | ||
| if 0: | ||
@@ -54,1 +56,23 @@ X, Y = np.meshgrid(site.ds.x.values, site.ds.y.values) | ||
| npt.assert_array_equal(fm.wd, [10]) | ||
| @pytest.mark.parametrize('wt_idx,wd,t,ref_shape', [ | ||
| (0, 0, 9, (1, 12, 3)), # 1 wt, 1 wd, 1 time | ||
| ([0], 0, 9, (1, 12, 3)), # 1 wt, 1 wd, 1 time | ||
| ([0, 1], [0, 0], [9, 9], (2, 12, 3)), # 2 wt, same wd and time | ||
| ([0, 1], 0, 9, (2, 12, 3)), # 2 wt, same wd and time | ||
| ([0, 0], [0, 10], [9, 10], (2, 12, 3)), # 1 wt, two wd and time | ||
| ([0, 0], [0, 10], 0, (2, 21, 3)), # 1 wt, two wd and time=0 | ||
| ([0, 0], [0, 10], False, (2, 21, 3)), # 1 wt, two wd and time=False (uses time=0) | ||
| ]) | ||
| def test_streamlines(wt_idx, wd, t, ref_shape): | ||
| site = Hornsrev1WRFSite(time_slice=slice(f"2020-04-27 12:00", f"2020-04-27"), streamlines=True) | ||
| x, y = site.initial_position[wt_idx].T | ||
| h = x * 0 + 70 | ||
| streamlines = site.distance.vectorField.stream_lines(wd, time=t, | ||
| start_points=np.array([x, y, h]).T, | ||
| dw_stop=200) | ||
| npt.assert_array_equal(streamlines.shape, ref_shape) |
@@ -25,2 +25,3 @@ from py_wake import np | ||
| from py_wake.utils.gradients import fd, autograd, cs | ||
| from py_wake.utils.functions import mean_deg | ||
@@ -239,2 +240,4 @@ | ||
| wsp_lst = [9, 10, 9, 10, 11] | ||
| with pytest.raises(ValueError, match='wd and ws must be specified for time series'): | ||
| site.local_wind(x=[2.5, 7.5], y=[2.5, 2.5], h=100, ws=wsp_lst, time=True) | ||
| lw = site.local_wind(x=[2.5, 7.5], y=[2.5, 2.5], h=100, wd=wdir_lst, ws=wsp_lst, time=True) | ||
@@ -782,9 +785,4 @@ assert lw.WS_ilk.shape == (2, 5, 1) | ||
| ) | ||
| # test local wind compute without ref ws and wd inputs | ||
| ws0 = non_uniform_ts_site.local_wind( | ||
| site_x[1], | ||
| site_y[2], | ||
| time=[3], | ||
| )["WS_ilk"] | ||
| ws0 = non_uniform_ts_site.local_wind(site_x[1], site_y[2], time=[3], wd=[0], ws=[0])["WS_ilk"] | ||
| assert ws0 == site_ws[1, 2, 3] | ||
@@ -800,8 +798,4 @@ | ||
| ) | ||
| aep = ( | ||
| wf_model([site_x[1], site_x[2]], [site_y[1], site_y[2]], time=site_time) | ||
| .aep() | ||
| .sum() | ||
| .values | ||
| ) | ||
| ws, wd = site_ws.mean((0, 1)), mean_deg(site_wd, (0, 1)) | ||
| aep = (wf_model(site_x[1:3], site_y[1:3], time=site_time, ws=ws, wd=wd).aep().sum().values) | ||
| assert aep > 0.0 |
@@ -171,2 +171,4 @@ import pytest | ||
| wfm_pdw = PropagateDownwind(**kwargs) | ||
| wfm_rc = PropagateDownwind(**{**kwargs, 'wake_deficitModel': NiayifarGaussianDeficit()}) | ||
| operating = [1] * 8 + [0] | ||
@@ -176,2 +178,4 @@ sim_res_a2a = wfm_a2a(wt9_x, wt9_y, operating=operating) | ||
| npt.assert_array_almost_equal(sim_res_a2a.WS_eff.sel(wt=8), sim_res_pdw.WS_eff.sel(wt=8)) | ||
| sim_res_rc = wfm_rc(wt9_x, wt9_y, operating=operating) | ||
| npt.assert_array_less(sim_res_rc.WS_eff.sel(wd=270)[3:], sim_res_pdw.WS_eff.sel(wd=270)[3:]) | ||
@@ -178,0 +182,0 @@ |
@@ -63,3 +63,3 @@ import warnings | ||
| if 'yaw_ilk' in wfm.args4all: | ||
| kwargs.update({'yaw': 0, 'tilt': 0, **kwargs}) | ||
| kwargs.update({'yaw': 10, 'tilt': 5, **kwargs}) | ||
@@ -66,0 +66,0 @@ xp, yp, hp = x_lst[20], y_lst[25], h_lst[2] |
| import os | ||
| import warnings | ||
| import matplotlib.pyplot as plt | ||
| import pytest | ||
| from autograd.numpy.numpy_boxes import ArrayBox | ||
| from numpy import newaxis as na | ||
| import pytest | ||
| import matplotlib.pyplot as plt | ||
| from py_wake import np | ||
| from py_wake.deficit_models.deficit_model import WakeDeficitModel, BlockageDeficitModel | ||
| from py_wake.deficit_models.deficit_model import BlockageDeficitModel, WakeDeficitModel | ||
| from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussianDeficit | ||
| from py_wake.deficit_models.noj import NOJDeficit | ||
| from py_wake.deflection_models.deflection_model import DeflectionModel | ||
| from py_wake.examples.data.hornsrev1 import V80, Hornsrev1Site | ||
| from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines, IEA37Site | ||
| from py_wake.examples.data.ParqueFicticio._parque_ficticio import ParqueFicticioSite | ||
| from py_wake.examples.data.hornsrev1 import Hornsrev1Site, V80 | ||
| from py_wake.examples.data.iea37._iea37 import IEA37Site, IEA37_WindTurbines | ||
| from py_wake.flow_map import XYGrid | ||
@@ -25,3 +25,6 @@ from py_wake.ground_models.ground_models import GroundModel | ||
| from py_wake.site.shear import Shear | ||
| from py_wake.superposition_models import SuperpositionModel, AddedTurbulenceSuperpositionModel | ||
| from py_wake.superposition_models import ( | ||
| AddedTurbulenceSuperpositionModel, | ||
| SuperpositionModel, | ||
| ) | ||
| from py_wake.tests import npt | ||
@@ -34,3 +37,7 @@ from py_wake.turbulence_models.stf import STF2005TurbulenceModel, STF2017TurbulenceModel | ||
| from py_wake.utils.profiling import profileit | ||
| from py_wake.wind_farm_models.engineering_models import PropagateDownwind, All2AllIterative, EngineeringWindFarmModel | ||
| from py_wake.wind_farm_models.engineering_models import ( | ||
| All2AllIterative, | ||
| EngineeringWindFarmModel, | ||
| PropagateDownwind, | ||
| ) | ||
@@ -192,7 +199,7 @@ | ||
| for kwargs in [{}, dict(wd_chunks=12, ws_chunks=9), dict(n_cpu=2, wd_chunks=12, ws_chunks=9)]: | ||
| for kwargs in [{}, dict(wd_chunks=12, ws_chunks=9)]: | ||
| simulationResult = wf_model(x=np.array([0.0, 0.0]), y=np.array([1000.0, 0.0]), **kwargs) | ||
| fm = simulationResult.flow_map(XYGrid(resolution=50)) | ||
| fm.plot_wake_map() | ||
| if 0: | ||
| fm.plot_wake_map() | ||
| plt.show() | ||
@@ -199,0 +206,0 @@ |
@@ -0,15 +1,50 @@ | ||
| import time | ||
| import numpy as np | ||
| from memory_profiler import _get_memory | ||
| from py_wake.utils.profiling import get_memory_usage | ||
| from py_wake.utils.parallelization import gc_func | ||
| from py_wake.utils.parallelization import get_map_func, get_pool_map | ||
| from py_wake.utils.profiling import get_memory_usage, timeit | ||
| def test_gc_function(): | ||
| def f(): | ||
| np.full((1, 1024**2, 128), 1.) # allocate 1gb | ||
| mem_before = get_memory_usage() | ||
| gc_func(f)() | ||
| # def test_gc_function(): | ||
| # outcommented as the gcfunc seems to have no effect | ||
| # from py_wake.utils.parallelization import gc_func | ||
| # | ||
| # def f(): | ||
| # np.full((1, 1024**2, 128), 1.) # allocate 1gb | ||
| # | ||
| # mem_before = get_memory_usage() | ||
| # gc_func(f)() | ||
| # | ||
| # # assert memory increase is less than 5mb (on linux an increase occurs) | ||
| # assert get_memory_usage() - mem_before < 5 | ||
| # | ||
| # mem_before = get_memory_usage() | ||
| # f() | ||
| # | ||
| # # assert memory increase is less than 5mb (on linux an increase occurs) | ||
| # assert get_memory_usage() - mem_before < 5 | ||
| # assert memory increase is less than 5mb (on linux an increase occurs) | ||
| assert get_memory_usage() - mem_before < 5 | ||
| def f(x): | ||
| time.sleep(0.1) | ||
| return x * 2 | ||
| def test_get_map_func(): | ||
| map_func = get_map_func(n_cpu=1, starmap=True, verbose=False) | ||
| r = list(map_func(lambda x, y: x + y, [(1, 2), (3, 4), (5, 6)])) | ||
| assert r == [3, 7, 11] | ||
| map_func = get_map_func(n_cpu=1, starmap=False, verbose=False) | ||
| r = list(map_func(lambda x: x[0] + x[1], [(1, 2), (3, 4), (5, 6)])) | ||
| assert r == [3, 7, 11] | ||
| map_func = get_map_func(n_cpu=1, starmap=False, verbose=False) | ||
| t = timeit(lambda x: list(map_func(f, x)))(np.arange(6))[1] | ||
| assert np.min(t) > 0.6 | ||
| map_func = get_map_func(n_cpu=2, starmap=False, verbose=False) | ||
| t = timeit(lambda x: list(map_func(f, x)), min_runs=3)(np.arange(6))[1] | ||
| assert np.min(t) < 0.5 |
| import os | ||
| import struct | ||
| from py_wake import np | ||
| import warnings | ||
| from pathlib import Path | ||
| import xarray as xr | ||
| from pathlib import Path | ||
| import warnings | ||
| from numpy import newaxis as na | ||
| from scipy.optimize import fsolve | ||
| from scipy.special import lambertw | ||
| from py_wake import np | ||
| from py_wake.utils import gradients | ||
| from py_wake.utils.most import phi, psi | ||
| from scipy.special import lambertw | ||
| from scipy.optimize import fsolve | ||
@@ -124,5 +126,10 @@ | ||
| if hasattr(self, 'dataset_path'): | ||
| dataset = xr.load_dataset(self.dataset_path) | ||
| dataset = xr.open_dataset(self.dataset_path) | ||
| self.diameter = dataset.diameter.item() | ||
| return np.array([dataset[k].load().transpose('z', 'y', 'x').values for k in UVLT]) | ||
| if zlevels is None: | ||
| return np.array([dataset[k].load().transpose('z', 'y', 'x').values for k in UVLT]) | ||
| else: | ||
| z = np.exp(np.array(zlevels) * self.ds) * self.z0 | ||
| return np.array([dataset[k].load().interp(z=z, method='nearest').transpose('z', 'y', 'x').values | ||
| for k in UVLT]) | ||
| else: | ||
@@ -129,0 +136,0 @@ luts = np.array([[np.fromfile(str(self.path / (self.prefix + '%04d%s.dat' % (j, uvlt))), np.dtype('<f'), -1) |
@@ -1,27 +0,27 @@ | ||
| from py_wake import np | ||
| from numpy import asarray as np_asarray | ||
| # from numpy import asanyarray as np_asanyarray | ||
| import numpy | ||
| import autograd.numpy as anp | ||
| from autograd.numpy.numpy_boxes import ArrayBox | ||
| import inspect | ||
| from autograd.core import defvjp, primitive | ||
| from autograd.differential_operators import jacobian, elementwise_grad | ||
| from functools import wraps | ||
| from inspect import signature | ||
| from functools import wraps | ||
| from xarray.core.dataarray import DataArray | ||
| from xarray.core import variable | ||
| from py_wake.utils import gradients | ||
| from scipy.interpolate._cubic import PchipInterpolator as scipy_PchipInterpolator | ||
| from itertools import count | ||
| from scipy.interpolate import UnivariateSpline as scipy_UnivariateSpline | ||
| import autograd.numpy as anp | ||
| from py_wake.utils.numpy_utils import AutogradNumpy | ||
| # from numpy import asanyarray as np_asanyarray | ||
| import numpy | ||
| from autograd.core import defvjp, primitive | ||
| from autograd.differential_operators import elementwise_grad, jacobian | ||
| from autograd.numpy.numpy_boxes import ArrayBox | ||
| from autograd.numpy.numpy_vjps import unbroadcast_f | ||
| from autograd.scipy.special import gamma as agamma | ||
| from numpy import asarray as np_asarray | ||
| from scipy.interpolate import UnivariateSpline as scipy_UnivariateSpline | ||
| from scipy.interpolate._cubic import PchipInterpolator as scipy_PchipInterpolator | ||
| from scipy.special import gamma as sgamma | ||
| from autograd.scipy.special import gamma as agamma | ||
| from xarray.core import variable | ||
| from xarray.core.dataarray import DataArray | ||
| from py_wake import np | ||
| from py_wake.utils import gradients | ||
| from py_wake.utils.numpy_utils import AutogradNumpy | ||
| def asarray(x, dtype=None, order=None, **kwargs): | ||
@@ -74,6 +74,8 @@ # kwargs: copy, like, etc introduced in numpy >=2 | ||
| def minimum(x1, x2, out=None, where=True, **kwargs): | ||
| if isinstance(x1, ArrayBox) or isinstance(x2, ArrayBox): | ||
| return anp.where((x2 < x1) & where, x2, x1) # @UndefinedVariable | ||
| else: | ||
| return numpy.minimum(x1, x2, out=out, where=where, **kwargs) | ||
| try: | ||
| if np.backend.minimum == minimum: | ||
| raise TypeError | ||
| return np.backend.minimum(x1, x2, out=out, where=where, **kwargs) | ||
| except TypeError: | ||
| return np.backend.where((x2 < x1) & where, x2, x1) | ||
@@ -80,0 +82,0 @@ |
@@ -26,4 +26,4 @@ from py_wake import np | ||
| """ | ||
| self.x = x.copy() | ||
| self.V = V | ||
| self.x = self.grid = x.copy() | ||
| self.bounds = bounds | ||
@@ -39,3 +39,3 @@ self.method = method | ||
| self.x[i] = np.r_[self.x[i], self.x[i][-1] + 1] | ||
| self.V = np.asarray(V) | ||
| self.V = self.values = np.asarray(V) | ||
| if not np.all(np.asarray(self.V.shape[:len(self.n)]) == self.n): | ||
@@ -42,0 +42,0 @@ raise ValueError("Lengths of x does not match shape of V") |
| import inspect | ||
| import os | ||
| import pkgutil | ||
| import warnings | ||
| from numpy import newaxis as na | ||
| import py_wake | ||
| from py_wake import np | ||
| from numpy import newaxis as na | ||
| from py_wake.site._site import Site | ||
| import warnings | ||
| from py_wake.utils.grid_interpolator import GridInterpolator | ||
| import py_wake | ||
@@ -163,16 +165,24 @@ | ||
| def get_exclude_dict(): | ||
| from py_wake.deficit_models.deficit_model import ConvectionDeficitModel, WakeDeficitModel, \ | ||
| BlockageDeficitModel | ||
| from py_wake.deficit_models.deficit_model import XRLUTDeficitModel | ||
| from py_wake.deficit_models.deficit_model import ( | ||
| BlockageDeficitModel, | ||
| ConvectionDeficitModel, | ||
| WakeDeficitModel, | ||
| XRLUTDeficitModel, | ||
| ) | ||
| from py_wake.deficit_models.noj import NOJDeficit | ||
| from py_wake.deficit_models.rans_lut import RANSLUTDeficit | ||
| from py_wake.rotor_avg_models.rotor_avg_model import RotorAvgModel, NodeRotorAvgModel | ||
| from py_wake.wind_farm_models.engineering_models import EngineeringWindFarmModel, PropagateDownwind | ||
| from py_wake.deflection_models.deflection_model import DeflectionIntegrator | ||
| from py_wake.ground_models.ground_models import NoGround | ||
| from py_wake.rotor_avg_models.rotor_avg_model import ( | ||
| NodeRotorAvgModel, | ||
| RotorAvgModel, | ||
| ) | ||
| from py_wake.site.streamline_distance import StreamlineDistance | ||
| from py_wake.superposition_models import LinearSum | ||
| from py_wake.deficit_models.noj import NOJDeficit | ||
| from py_wake.turbulence_models.rans_lut_turb import RANSLUTTurbulence | ||
| from py_wake.turbulence_models.turbulence_model import XRLUTTurbulenceModel | ||
| from py_wake.turbulence_models.rans_lut_turb import RANSLUTTurbulence | ||
| from py_wake.ground_models.ground_models import NoGround | ||
| from py_wake.site.streamline_distance import StreamlineDistance | ||
| from py_wake.wind_farm_models.engineering_models import ( | ||
| EngineeringWindFarmModel, | ||
| PropagateDownwind, | ||
| ) | ||
| return { | ||
@@ -204,5 +214,7 @@ "WindFarmModel": ([EngineeringWindFarmModel], [], PropagateDownwind), | ||
| if base_class is Site: | ||
| from py_wake.examples.data.hornsrev1 import Hornsrev1Site | ||
| from py_wake.examples.data.iea37._iea37 import IEA37Site | ||
| from py_wake.examples.data.hornsrev1 import Hornsrev1Site | ||
| from py_wake.examples.data.ParqueFicticio._parque_ficticio import ParqueFicticioSite | ||
| from py_wake.examples.data.ParqueFicticio._parque_ficticio import ( | ||
| ParqueFicticioSite, | ||
| ) | ||
| return [IEA37Site, Hornsrev1Site, ParqueFicticioSite] | ||
@@ -224,3 +236,5 @@ exclude_cls_lst, exclude_subcls_lst, default = get_exclude_dict()[base_class.__name__] | ||
| try: | ||
| _module = importlib.import_module(module_name) | ||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", DeprecationWarning) | ||
| _module = importlib.import_module(module_name) | ||
| for n in dir(_module): | ||
@@ -227,0 +241,0 @@ v = _module.__dict__[n] |
@@ -0,7 +1,14 @@ | ||
| import atexit | ||
| import gc | ||
| import multiprocessing | ||
| import atexit | ||
| import platform | ||
| import gc | ||
| from itertools import starmap | ||
| try: # pragma: no cover | ||
| from mpi4py import MPI | ||
| comm = MPI.COMM_WORLD | ||
| assert comm.Get_size() > 1 | ||
| except (ImportError, AssertionError): | ||
| MPI = None | ||
| pool_dict = {} | ||
@@ -24,28 +31,29 @@ | ||
| class gc_func(): | ||
| def __init__(self, func): | ||
| self.func = func | ||
| # class gc_func(): | ||
| # seems to have no effect | ||
| # def __init__(self, func): | ||
| # self.func = func | ||
| # | ||
| # def __call__(self, *args, **kwargs): | ||
| # import time | ||
| # t = time.perf_counter() | ||
| # r = self.func(*args, **kwargs) | ||
| # print('f', time.perf_counter() - t) | ||
| # gc.collect() | ||
| # print('gc', time.perf_counter() - t) | ||
| # return r | ||
| def __call__(self, *args, **kwargs): | ||
| r = self.func(*args, **kwargs) | ||
| gc.collect() | ||
| return r | ||
| def get_pool_map(n_cpu=multiprocessing.cpu_count(), starmap=False, verbose=True): | ||
| pool = get_pool(n_cpu) | ||
| def get_pool_map(processes=multiprocessing.cpu_count()): | ||
| pool = get_pool(processes) | ||
| def pool_map(func, iterable, chunksize=None): | ||
| iterable = get_tqdm_iterable(iterable, verbose=verbose) | ||
| if starmap: | ||
| return pool.starmap(func, iterable, chunksize) | ||
| else: | ||
| return pool.map(func, iterable, chunksize) | ||
| return pool_map | ||
| def gc_map(func, iterable, chunksize=None): | ||
| return pool.map(gc_func(func), iterable, chunksize) | ||
| return gc_map | ||
| def get_pool_starmap(processes=multiprocessing.cpu_count()): | ||
| pool = get_pool(processes) | ||
| def gc_map(func, iterable, chunksize=None): | ||
| return pool.starmap(gc_func(func), iterable, chunksize) | ||
| return gc_map | ||
| def close_pools(): # pragma: no cover | ||
@@ -56,26 +64,63 @@ for k, pool in pool_dict.items(): | ||
| # def get_map_func(n_cpu, verbose, desc='', unit='it'): | ||
| # n_cpu = n_cpu or multiprocessing.cpu_count() | ||
| # if n_cpu > 1: | ||
| # map_func = get_pool_map(n_cpu) | ||
| # else: | ||
| # from tqdm import tqdm | ||
| # | ||
| # def map_func(f, iter): | ||
| # return tqdm(map(f, iter), desc=desc, unit=unit, total=len(iter), disable=not verbose) | ||
| # return map_func | ||
| def get_n_cpu(n_cpu): | ||
| if MPI is None: | ||
| n_cpu = n_cpu or multiprocessing.cpu_count() | ||
| else: # pragma: no cover | ||
| comm = MPI.COMM_WORLD | ||
| n_cpu = min(n_cpu or comm.Get_size(), comm.Get_size()) | ||
| return n_cpu | ||
| def get_starmap_func(n_cpu, verbose, desc='', unit='it', leave=True): | ||
| n_cpu = n_cpu or multiprocessing.cpu_count() | ||
| def get_map_func(n_cpu, starmap=False, verbose=True, desc='', unit='it', leave=True): | ||
| n_cpu = get_n_cpu(n_cpu) | ||
| if n_cpu > 1: | ||
| map_func = get_pool_starmap(n_cpu) | ||
| if MPI and n_cpu > 1: # pragma: no cover | ||
| map_func = get_mpi_map_func(n_cpu, starmap=starmap) | ||
| else: | ||
| map_func = get_pool_map(n_cpu, starmap=starmap, verbose=verbose) | ||
| else: | ||
| from tqdm import tqdm | ||
| if starmap: | ||
| from itertools import starmap | ||
| mapf = starmap | ||
| else: | ||
| mapf = map | ||
| def map_func(f, iter): | ||
| return starmap(f, tqdm(iter, desc=desc, unit=unit, total=len(iter), disable=not verbose, leave=leave)) | ||
| return mapf(f, get_tqdm_iterable(iter, desc=desc, unit=unit, verbose=verbose, leave=leave)) | ||
| return map_func | ||
| def get_tqdm_iterable(iterable, desc='', unit='it', total=None, verbose=True, leave=True): | ||
| from tqdm import tqdm | ||
| total = getattr(iterable, '__len__', lambda: total)() | ||
| return tqdm(iterable, desc=desc, unit=unit, total=total, disable=not verbose, leave=leave) | ||
| atexit.register(close_pools) | ||
| def get_mpi_map_func(n_cpu, starmap=False): # pragma: no cover | ||
| assert MPI is not None, "mpi4py is not installed" | ||
| comm = MPI.COMM_WORLD | ||
| rank = comm.Get_rank() | ||
| def mpi_map_func(f, iter_args): | ||
| iter_args = list(iter_args) | ||
| # Distribute work across MPI ranks | ||
| local_args = [iter_args[i] for i in range(rank, len(iter_args), n_cpu)] | ||
| local_results = ( | ||
| [f(arg) for arg in local_args] | ||
| if not starmap | ||
| else [f(*arg) for arg in local_args] | ||
| ) | ||
| # Gather results from all ranks | ||
| all_results = comm.allgather(local_results) | ||
| # Reconstruct results in original order | ||
| results = [None] * len(iter_args) | ||
| for r, res_list in enumerate(all_results): | ||
| for idx, res in enumerate(res_list): | ||
| results[r + idx * n_cpu] = res | ||
| return results | ||
| return mpi_map_func |
@@ -37,4 +37,9 @@ import xarray as xr | ||
| def stream_lines(self, wd, start_points, dw_stop, time=False, step_size=20): | ||
| # print(np.shape(wd), np.shape(start_points), time) | ||
| start_points = np.atleast_2d(start_points) | ||
| stream_lines = [start_points] | ||
| dw_stop = np.zeros(len(start_points)) + dw_stop | ||
| wd = np.zeros(len(start_points)) + wd | ||
| if time is not False: | ||
| time = np.zeros(len(start_points)) + time | ||
| m = np.arange(len(wd)) | ||
@@ -41,0 +46,0 @@ co, si = np.cos(np.deg2rad(270 - wd)), np.sin(np.deg2rad(270 - wd)) |
@@ -0,5 +1,6 @@ | ||
| import xarray as xr | ||
| from numpy import newaxis as na | ||
| from py_wake import np | ||
| import xarray as xr | ||
| try: # pragma: no cover | ||
@@ -11,2 +12,3 @@ from xarray.plot.plot import _PlotMethods as DataArrayPlotAccessor | ||
| import warnings | ||
| from py_wake.utils.grid_interpolator import GridInterpolator | ||
@@ -33,3 +35,3 @@ | ||
| v = v[:, :, na] | ||
| dtype = (np.float, np.complex)[np.iscomplexobj(v)] | ||
| dtype = (getattr(np, 'float', np.float64), np.complex)[np.iscomplexobj(v)] | ||
| v = v.astype(dtype) | ||
@@ -36,0 +38,0 @@ if shape is None: |
@@ -31,5 +31,5 @@ # file generated by setuptools-scm | ||
| __version__ = version = '2.6.15' | ||
| __version_tuple__ = version_tuple = (2, 6, 15) | ||
| __version__ = version = '2.6.16' | ||
| __version_tuple__ = version_tuple = (2, 6, 16) | ||
| __commit_id__ = commit_id = None |
@@ -0,21 +1,36 @@ | ||
| import warnings | ||
| from abc import abstractmethod | ||
| from numpy import newaxis as na | ||
| from tqdm import tqdm | ||
| from py_wake import np | ||
| from py_wake.superposition_models import SuperpositionModel, LinearSum, WeightedSum, CumulativeWakeSum, SquaredSum | ||
| from py_wake.wind_farm_models.wind_farm_model import WindFarmModel | ||
| from py_wake.deficit_models.deficit_model import ( | ||
| BlockageDeficitModel, | ||
| ConvectionDeficitModel, | ||
| WakeDeficitModel, | ||
| ) | ||
| from py_wake.deficit_models.no_wake import NoWakeDeficit | ||
| from py_wake.deflection_models.deflection_model import DeflectionModel | ||
| from py_wake.input_modifier_models.input_modifier_model import InputModifierModel | ||
| from py_wake.rotor_avg_models.rotor_avg_model import ( | ||
| NodeRotorAvgModel, | ||
| RotorAvgModel, | ||
| WSPowerRotorAvg, | ||
| ) | ||
| from py_wake.superposition_models import ( | ||
| CumulativeWakeSum, | ||
| LinearSum, | ||
| SquaredSum, | ||
| SuperpositionModel, | ||
| WeightedSum, | ||
| ) | ||
| from py_wake.turbulence_models.turbulence_model import TurbulenceModel | ||
| from py_wake.utils import gradients | ||
| from py_wake.utils.gradients import cabs, item_assign | ||
| from py_wake.rotor_avg_models.rotor_avg_model import RotorAvgModel, NodeRotorAvgModel, WSPowerRotorAvg | ||
| from py_wake.turbulence_models.turbulence_model import TurbulenceModel | ||
| from py_wake.deficit_models.deficit_model import ConvectionDeficitModel, BlockageDeficitModel, WakeDeficitModel | ||
| from tqdm import tqdm | ||
| from py_wake.wind_turbines._wind_turbines import WindTurbines | ||
| from py_wake.utils.model_utils import check_model, fix_shape | ||
| from py_wake.utils import gradients | ||
| import warnings | ||
| from py_wake.input_modifier_models.input_modifier_model import InputModifierModel | ||
| from py_wake.deficit_models.no_wake import NoWakeDeficit | ||
| from py_wake.utils.parallelization import get_starmap_func | ||
| import multiprocessing | ||
| from py_wake.utils.parallelization import get_map_func | ||
| from py_wake.wind_farm_models.external_wind_farm_models import ExternalWindFarm | ||
| from py_wake.wind_farm_models.wind_farm_model import WindFarmModel | ||
| from py_wake.wind_turbines._wind_turbines import WindTurbines | ||
@@ -212,3 +227,3 @@ | ||
| h_i, D_i = self.windTurbines.get_defaults(len(x_ilk), type_i, h_i) | ||
| wd, ws = self.site.get_defaults(wd, ws) | ||
| wd, ws = self.site.get_defaults(wd, ws, time) | ||
| I, L, K, = len(x_ilk), len(wd), (1, len(ws))[time is False] | ||
@@ -224,2 +239,6 @@ kwargs.update(dict(x_ilk=x_ilk, y_ilk=y_ilk, h_ilk=h_i[:, na, na], wd=wd, ws=ws, time=time, | ||
| wd=kwargs['wd'], ws=kwargs['ws'], time=kwargs['time']) | ||
| if time is False: | ||
| assert lw['WS_ilk'].shape[2] == len(ws), \ | ||
| "Conflicting sizes. Number of ws must match wind speed dimension of local wind, WS" | ||
| for k in ['WS_ilk', 'WD_ilk', 'TI_ilk']: | ||
@@ -414,3 +433,3 @@ if k in kwargs: | ||
| def _flow_map(self, x_jl, y_jl, h_jl, lw, wd, ws, sim_res_data, D_dst=0, memory_GB=1, n_cpu=1): | ||
| def _flow_map(self, x_jl, y_jl, h_jl, lw, wd, ws, sim_res_data, D_dst=0, memory_GB=1, n_cpu=1, verbose=None): | ||
| """call this function via SimulationResult.flow_map""" | ||
@@ -424,3 +443,2 @@ wd, ws = np.atleast_1d(wd), np.atleast_1d(ws) | ||
| np.broadcast_to(lw_j.TI_ilk, (len(x_jl), L, K)).astype(float)) | ||
| n_cpu = n_cpu or multiprocessing.cpu_count() | ||
| # *6=dx_ijlk, dy_ijlk, dz_ijlk, dh_ijlk, deficit, blockage | ||
@@ -433,4 +451,5 @@ size_GB = I * J * L * K * np.array([]).itemsize * 6 * n_cpu / 1024**3 | ||
| map_func = get_starmap_func(n_cpu=n_cpu, verbose=wd_chunks + j_chunks > 2 and self.verbose, desc='Calculate flow map', | ||
| unit='wd', leave=0) | ||
| verbose = verbose or self.verbose | ||
| map_func = get_map_func(n_cpu=n_cpu, starmap=True, verbose=wd_chunks + j_chunks > 2 and verbose, | ||
| desc='Calculate flow map', unit='chunk', leave=0) | ||
| wt_x_ilk, wt_y_ilk, wt_h_ilk = [sim_res_data[k].ilk() for k in ['x', 'y', 'h']] | ||
@@ -802,10 +821,5 @@ | ||
| # print(i) | ||
| deficit = ewf(i=0, l=i_wt_l == i, | ||
| deficit_jlk=deficit[0], | ||
| deficit = ewf(i=0, l=i_wt_l == i, deficit_jlk=deficit[0], | ||
| **model_kwargs, dst_xyh_jlk=dst_xyh_jlk)[na] | ||
| **model_kwargs, | ||
| # **{**model_kwargs, 'dw_ijlk': sdw_ijlk, 'hcw_ijlk': shcw_ijlk, 'dh_ijlk': sdh_ijlk} | ||
| dst_xyh_jlk=dst_xyh_jlk | ||
| )[na] | ||
| if self.blockage_deficitModel: | ||
@@ -1165,8 +1179,9 @@ blockage_nk.append(blockage[0]) | ||
| if __name__ == '__main__': | ||
| from py_wake.examples.data.iea37 import IEA37Site, IEA37_WindTurbines | ||
| import matplotlib.pyplot as plt | ||
| from py_wake.deficit_models.gaussian import ZongGaussianDeficit | ||
| from py_wake.deficit_models.selfsimilarity import SelfSimilarityDeficit | ||
| from py_wake.deficit_models.gaussian import ZongGaussianDeficit | ||
| from py_wake.examples.data.iea37 import IEA37_WindTurbines, IEA37Site | ||
| from py_wake.flow_map import XYGrid | ||
| from py_wake.turbulence_models.stf import STF2017TurbulenceModel | ||
| from py_wake.flow_map import XYGrid | ||
| import matplotlib.pyplot as plt | ||
@@ -1173,0 +1188,0 @@ site = IEA37Site(16) |
@@ -1,4 +0,2 @@ | ||
| import multiprocessing | ||
| from abc import ABC, abstractmethod | ||
| from collections.abc import Iterable | ||
@@ -17,3 +15,3 @@ import xarray as xr | ||
| from py_wake.utils.model_utils import check_model, fix_shape | ||
| from py_wake.utils.parallelization import get_pool_map, get_pool_starmap | ||
| from py_wake.utils.parallelization import get_map_func, get_n_cpu | ||
| from py_wake.wind_turbines import WindTurbines | ||
@@ -62,4 +60,3 @@ | ||
| n_cpu=1, wd_chunks=None, ws_chunks=1, **kwargs): | ||
| if time is False and np.ndim(wd): | ||
| wd = np.sort(np.array(wd)) | ||
| assert len(x) == len(y) | ||
@@ -77,3 +74,3 @@ self.verbose = verbose | ||
| for wf in self.externalWindFarms]] | ||
| wd, ws = self.site.get_defaults(wd, ws) | ||
| wd, ws = self.site.get_defaults(wd, ws, time) | ||
| I, L, K, = len(x), len(np.atleast_1d(wd)), (1, len(np.atleast_1d(ws)))[time is False] | ||
@@ -147,8 +144,2 @@ if len([k for k in kwargs if 'yaw' in k.lower() and k != 'yaw' and not k.startswith('yawc_')]): | ||
| """ | ||
| if isinstance(time, Iterable) and (len(ws if ws is not None else []) != len(time) or | ||
| len(wd if wd is not None else []) != len(time) | ||
| ): # avoid redundant passing wd & ws for time series sites | ||
| wd = np.zeros(len(time)) | ||
| ws = np.zeros(len(time)) | ||
| res = self._run(x, y, h=h, type=type, wd=wd, ws=ws, time=time, verbose=verbose, | ||
@@ -165,3 +156,3 @@ n_cpu=n_cpu, wd_chunks=wd_chunks, ws_chunks=ws_chunks, **kwargs) | ||
| def aep(self, x, y, h=None, type=0, wd=None, ws=None, # @ReservedAssignment | ||
| def aep(self, x, y, h=None, type=0, wd=None, ws=None, time=False, # @ReservedAssignment | ||
| normalize_probabilities=False, with_wake_loss=True, | ||
@@ -176,3 +167,3 @@ n_cpu=1, wd_chunks=None, ws_chunks=1, **kwargs): | ||
| This function bypasses the simulation result and returns only the total AEP, | ||
| which makes it slightly faster for small problems. | ||
| which makes it slightly faster for small problems and avoids the intermediate xarray SimulationResult. | ||
| >> windFarmModel.aep(x,y,...) | ||
@@ -194,2 +185,6 @@ | ||
| Wind speed(s) | ||
| time : boolean or array_like | ||
| If False (default), the simulation will be computed for the full wd x ws matrix | ||
| If True, the wd and ws will be considered as a time series of flow conditions with time stamp 0,1,..,n | ||
| If array_like: same as True, but the time array is used as flow case time stamp | ||
| yaw : int, float, array_like or None, optional | ||
@@ -226,3 +221,3 @@ Yaw misalignement, Positive is counter-clockwise when seen from above. | ||
| """ | ||
| res = self._run(x, y, h=h, type=type, wd=wd, ws=ws, | ||
| res = self._run(x, y, h=h, type=type, wd=wd, ws=ws, time=time, | ||
| n_cpu=n_cpu, wd_chunks=wd_chunks, ws_chunks=ws_chunks, **kwargs) | ||
@@ -237,3 +232,3 @@ _, _, power_ilk, _, localWind, kwargs_ilk = res | ||
| if with_wake_loss is False: | ||
| wd, ws = self.site.get_defaults(wd, ws) | ||
| wd, ws = self.site.get_defaults(wd, ws, time) | ||
| I, L, K, = len(x), len(np.atleast_1d(wd)), len(np.atleast_1d(ws)) | ||
@@ -299,5 +294,4 @@ power_ilk = np.broadcast_to(self.windTurbines.power(ws=localWind.WS_ilk, | ||
| def _multiprocessing_chunks(self, wd, ws, time, | ||
| n_cpu, wd_chunks, ws_chunks, **kwargs): | ||
| n_cpu = n_cpu or multiprocessing.cpu_count() | ||
| def _multiprocessing_chunks(self, wd, ws, time, n_cpu, wd_chunks, ws_chunks, **kwargs): | ||
| n_cpu = get_n_cpu(n_cpu) | ||
| wd_chunks = int(np.minimum(wd_chunks or n_cpu, len(wd))) | ||
@@ -311,10 +305,3 @@ ws_chunks = int(np.minimum(ws_chunks or 1, len(ws))) | ||
| ws_i = np.linspace(0, len(ws) + 1, ws_chunks + 1).astype(int) | ||
| if n_cpu > 1: | ||
| map_func = get_pool_map(n_cpu) | ||
| else: | ||
| from tqdm import tqdm | ||
| def map_func(f, iter): | ||
| return tqdm(map(f, iter), total=len(iter), disable=not self.verbose) | ||
| if time is False: | ||
@@ -352,5 +339,8 @@ # (wd x ws) matrix | ||
| arg_lst = [{'wd': wd[wd_slice], 'ws': ws[ws_slice], 'time': get_subtask_arg('time', time, wd_slice, ws_slice), | ||
| ** {k: get_subtask_arg(k, v, wd_slice, ws_slice) for k, v in kwargs.items()}} for wd_slice, ws_slice in slice_lst] | ||
| arg_lst = [{'wd': wd[wd_slice], 'ws': ws[ws_slice], | ||
| 'time': get_subtask_arg('time', time, wd_slice, ws_slice), | ||
| **{k: get_subtask_arg(k, v, wd_slice, ws_slice) for k, v in kwargs.items()}} for wd_slice, ws_slice in slice_lst] | ||
| map_func = get_map_func(n_cpu, verbose=self.verbose) | ||
| return map_func, arg_lst, wd_chunks, ws_chunks | ||
@@ -362,3 +352,3 @@ | ||
| n_cpu=1, wd_chunks=None, ws_chunks=None, time=False, **kwargs): | ||
| wd, ws = self.site.get_defaults(wd, ws) | ||
| wd, ws = self.site.get_defaults(wd, ws, time) | ||
| wd_bin_size = self.site.wd_bin_size(wd) | ||
@@ -448,3 +438,3 @@ | ||
| coords = {k: (dep, v, {'Description': d}) for k, dep, v, d in [ | ||
| ('wt', 'wt', np.arange(n_wt), 'Wind turbine number'), | ||
| ('wt', 'wt', np.arange(n_wt, dtype=int), 'Wind turbine number'), | ||
| ('wd', ('wd', 'time')['time' in lw], lw.wd, 'Ambient reference wind direction [deg]'), | ||
@@ -759,3 +749,3 @@ ('ws', ('ws', 'time')['time' in lw], lw.ws, 'Ambient reference wind speed [m/s]'), | ||
| def flow_map(self, grid=None, wd=None, ws=None, time=None, D_dst=0, memory_GB=1, n_cpu=1): | ||
| def flow_map(self, grid=None, wd=None, ws=None, time=None, D_dst=0, memory_GB=.1, n_cpu=1, verbose=None): | ||
| """Return a FlowMap object with WS_eff and TI_eff of all grid points | ||
@@ -797,3 +787,3 @@ | ||
| x_j[:, na], y_j[:, na], h_j[:, na], self.localWind, wd, ws, sim_res, D_dst=D_dst, | ||
| memory_GB=memory_GB, n_cpu=n_cpu) | ||
| memory_GB=memory_GB, n_cpu=n_cpu, verbose=verbose) | ||
| return FlowMap(sim_res, X, Y, lw_j, WS_eff_jlk, TI_eff_jlk, plane=plane) | ||
@@ -800,0 +790,0 @@ |
+39
-38
| docs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
| docs/conf.py,sha256=ng5Ion73YHT7C3_VVXJ-DVV6g06hMuwbumLBNrtf0I4,8805 | ||
| docs/conf.py,sha256=jdyg6gyca0HdaDpADVKCxLo8JGWpOnlPGfi6mMzex38,8805 | ||
| docs/make_pdf.py,sha256=ypKM0-mmOSBJ7RydLvxulAn3PGGywMtn15W_ckQkHNQ,852 | ||
| docs/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
| docs/validation_report/generate_validation_figures.py,sha256=LG3foYpvdfXhAoN88ejpTwLNqkAb12IgVoD-V2E7kp4,27790 | ||
| py_wake/__init__.py,sha256=-0bNwPpZWQXG-_zE_7hFRoJeG0SRBuDeGM9n5aFWgS0,1188 | ||
| py_wake/__init__.py,sha256=plc0Tgq4NHJw8YvzBvdgI50r5tWRznHaMzZgvrJSXqc,1181 | ||
| py_wake/flow_map.py,sha256=pZCV-mbPDtVLuvdGejKJhUnR52VorJ7fobP10Oj7ZL4,22441 | ||
| py_wake/superposition_models.py,sha256=mlZSy-T6YiAhdSgAu-reP1YECRsPpgHh8GDCfPAsZ6w,10124 | ||
| py_wake/version.py,sha256=Y_kUiwIfdfJcl4d1EVlpBvcQ85D9f1ATuvVihYhIFyg,706 | ||
| py_wake/version.py,sha256=w6Wi-Vv2osckU1Br_lqmghSD8v0m4QyQ_pMHdGIEQi4,706 | ||
| py_wake/deficit_models/__init__.py,sha256=w1S4F3FmAgtwqGO90fASYoqxOb6SsgjbasiD3V8_1uk,709 | ||
| py_wake/deficit_models/deficit_model.py,sha256=iLb9wUO8wDeYAEBAoAlS2W4Q4B16ZSO0L4DhVq3NxYQ,10280 | ||
| py_wake/deficit_models/fuga.py,sha256=Jhi52MpvF7-KTk62dZfdLLUf4piCslwIBJTr7N17Hng,13863 | ||
| py_wake/deficit_models/fuga.py,sha256=pZ9wUI5VBPcJM-2FWGUVYwQIQ6oWKFlOw0qSyu6V4hI,13907 | ||
| py_wake/deficit_models/gaussian.py,sha256=_ntryBrucuo9EMSLnyJH3dt9mM9SnB0DxP9wzH_w7Zo,36119 | ||
@@ -27,3 +27,3 @@ py_wake/deficit_models/gcl.py,sha256=o4b9NRe9rSUJ8PmD3OOD5gOpYY6LBY2OXQfrhh7EBns,8988 | ||
| py_wake/deflection_models/deflection_model.py,sha256=NRDbCrLxAB65Wd_1GrOWP6dJKYf-XJ9Qjl9HZ_VqEZw,3285 | ||
| py_wake/deflection_models/fuga_deflection.py,sha256=w-jym62eQcNxjZy0xh27Lmq4AbKEb-mbGp6ahkZZB44,8418 | ||
| py_wake/deflection_models/fuga_deflection.py,sha256=_DX4VNYjJGX7C7H44z4foCfcgiYhFWyIJAzd6NC_mnI,6817 | ||
| py_wake/deflection_models/gcl_hill_vortex.py,sha256=RVzjomvLIU9Pjkyo4I7UFNgWmoL87PY5SQQbyr90SXE,4484 | ||
@@ -272,4 +272,4 @@ py_wake/deflection_models/jimenez.py,sha256=i48tR__COvfllN_5oagnPwvjBA6Axp09s7Ydv2yNGhU,2765 | ||
| py_wake/literature/cumulative_sum.py,sha256=xEvkOPnwlUmv8xlp658G7UlATmtsnNAxFC0-ZHnVcbo,3708 | ||
| py_wake/literature/fuga.py,sha256=j8nTeyl-SsdUPPNqPxyW-8WDLlLyWH-FF-JrT1E3h1I,4764 | ||
| py_wake/literature/gaussian_models.py,sha256=Pb2wq2x2tiODSeDT-aH1hPko1A5xkWAt4uFoxHqk79Y,16695 | ||
| py_wake/literature/fuga.py,sha256=PH8dThOIZfSl8nnli5IiGrmBsKalQ7A2F933Cl6asQI,4791 | ||
| py_wake/literature/gaussian_models.py,sha256=yoaovf5bcMzPYV1B4jOppqPj2nVBS8M1vTTtgqFvXrU,16728 | ||
| py_wake/literature/iea37_case_study1.py,sha256=deRn2CLDE6OzUL5xfN2S87-m4mJ0X5bOwCCB89o4lno,1471 | ||
@@ -286,9 +286,9 @@ py_wake/literature/noj.py,sha256=pXbHINVCi9KqPWYznatHqZE9c42bKdHxFReTfFidrt4,2554 | ||
| py_wake/site/__init__.py,sha256=YeIRWHuiIo0cRD3NIcaqgoWL6u-NfQkDo3uQsgAxjj4,161 | ||
| py_wake/site/_site.py,sha256=zvIXS6oPbUffMTXAIq1TXXKhYqePqEFNGAejPtPRxyQ,16256 | ||
| py_wake/site/_site.py,sha256=DfGxjqTwiOm_XSTBYRV3LAwBVghknNbOFWsBUOH5Rg4,16210 | ||
| py_wake/site/distance.py,sha256=61kvn9ye6ld_vn7rTdJ0GgLjA41uB4e_esnoXDWumzw,8947 | ||
| py_wake/site/jit_streamline_distance.py,sha256=GJo2mn_bTjuGX3-gSGkv1dkRfo7hGDVKDmefRWYk5o8,159 | ||
| py_wake/site/shear.py,sha256=OGU2eQCuZ7H3hAjAbATK9ZXqIWBFjDazp9dmKumDnSw,4213 | ||
| py_wake/site/shear.py,sha256=HVrUmwzUiTAEKGP6eVJQKOODv1FCbI30CJaPSMj4H0s,4248 | ||
| py_wake/site/streamline_distance.py,sha256=01NdwM__ITY0w4kWavUx1arKxCvtc42cEteugQhN7mo,4518 | ||
| py_wake/site/wasp_grid_site.py,sha256=d-vonrkXMuVVgbq9OG0ri3XHYekdDfvfjdndkigCOrQ,10227 | ||
| py_wake/site/wrf.py,sha256=l2ziX34vcdxf2xgH3GiGxCdslgJldR8ZUd7BoZqxxEY,1653 | ||
| py_wake/site/wrf.py,sha256=lgqcF5TPtucaKAry9A0MopJHAXWcER-35wioRWxKZFE,1654 | ||
| py_wake/site/xrsite.py,sha256=-Kr2LMx0dpKI-ke4z3hbRyv-GWulLntjkSU-nY1LWIA,19887 | ||
@@ -298,6 +298,6 @@ py_wake/tests/__init__.py,sha256=-YOzxrKhc4yGKHFLkjCX7YHO-8Km_E65UCtlKNs3Z1Y,1001 | ||
| py_wake/tests/notebook.py,sha256=21RVNXcqRCy6b3GoRcKxR5E0IGV2d9U6BaqqOKZ8f8Y,6804 | ||
| py_wake/tests/test_flow_map.py,sha256=V_dZu9y1K4QaAM7whhKyvTG2O57LmLk5o6y08mbSauw,22448 | ||
| py_wake/tests/test_flow_map.py,sha256=eJOyk5Jtku0dewznV0owGucDGSRpfyDaZZrxVZVqWxI,22799 | ||
| py_wake/tests/test_main.py,sha256=pc01ZUXMnFDHZwNh7ulqP5FWZDt9I7-gp0D_TN2-9Bs,1914 | ||
| py_wake/tests/test_notebooks.py,sha256=j2mlOAzwMwe6PfEFS2sEl4aQJDxfDQHR8DM6gZq9B-Q,1958 | ||
| py_wake/tests/test_superposition_models.py,sha256=dxcgeB_LXn1USv_4QNRuyjL83Cy0qhV1yPdJN6enRj4,8759 | ||
| py_wake/tests/test_notebooks.py,sha256=eB95mMOWg-FRHqpbuEIdcNEO2E7mc_nwAVD2yxpxl5E,2216 | ||
| py_wake/tests/test_superposition_models.py,sha256=-PQ3qnJf9d1p9XvgSG6X02FNYUHQo35HyU_Pmg-e2uo,9009 | ||
| py_wake/tests/test_deficit_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
@@ -307,3 +307,3 @@ py_wake/tests/test_deficit_models/test_BastankhahGaussian.py,sha256=rXMkNTHirHBAKWhRtWCOpZqzX0KX5d2w1ACwAHlEXKo,1069 | ||
| py_wake/tests/test_deficit_models/test_blockage_models.py,sha256=guS3PX7YdNfI1Po4JzEhGu6BT6ODSxEBR6fBIMUorko,11856 | ||
| py_wake/tests/test_deficit_models/test_deficit_models.py,sha256=vIe5H_cX0rZ-V1bD3I4FWgnaeR1qy6NGc-uCefA9qhI,34083 | ||
| py_wake/tests/test_deficit_models/test_deficit_models.py,sha256=VN3E4vInJ2-_2t1S5k5IViK-bRtBsB79z2M6qwkyUNc,34083 | ||
| py_wake/tests/test_deficit_models/test_fuga.py,sha256=kFa_D4mt5P7NpESPOAE8f3KBaWq8zFFTyQfqqmhZNiA,24824 | ||
@@ -316,3 +316,3 @@ py_wake/tests/test_deficit_models/test_gcl.py,sha256=i2mIAoNUnGswJ8xXVjjHVw9Imgzhs6thfI8zkgLCt04,1189 | ||
| py_wake/tests/test_deflection_models/test_deflection_models.py,sha256=AeooRiOoM7la1vZ3w1YadqgoGFtmpzdtbk4-KxOHXfg,8422 | ||
| py_wake/tests/test_deflection_models/test_fuga_deflection.py,sha256=irdF7LNnZv-H4dIQwYGUdBf4rcZNiI8nDMxAtHdyngk,4578 | ||
| py_wake/tests/test_deflection_models/test_fuga_deflection.py,sha256=GQss-YTdsVvct3ypBpT96X0QkmrMqg3Ed7Xw4dpxF4s,4785 | ||
| py_wake/tests/test_deflection_models/test_hillvortex.py,sha256=RfQi0eJDgYkyUKLuxfrge-qyV9tNNv0xZ0tLl5k-IKw,4887 | ||
@@ -334,3 +334,3 @@ py_wake/tests/test_deflection_models/test_jimenez.py,sha256=td9Pp-d8rSE94pMNsBvYxsojcPky_wJZ0szSjAsOZWk,4131 | ||
| py_wake/tests/test_load_surrogates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
| py_wake/tests/test_load_surrogates/test_iea34_surrogates.py,sha256=wshSTEBnwttaLHdSm1UEzWPj-Sr6aBz0Wachcc5w0RQ,10906 | ||
| py_wake/tests/test_load_surrogates/test_iea34_surrogates.py,sha256=JD0cKjc4IEPobGugqe8esF2E0KC6028ulNy_PWeFtH8,10928 | ||
| py_wake/tests/test_load_surrogates/test_tensorflow_surrogate_utils.py,sha256=9kZB5ngi2wdFIq5eAoJdMY34bjjDeqxlZzA09hdLNsg,1642 | ||
@@ -343,9 +343,9 @@ py_wake/tests/test_noise_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
| py_wake/tests/test_sites/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
| py_wake/tests/test_sites/test_distances.py,sha256=fsDoPw7gFBu4w7Rze0wvO15XwWsb0ylm0uyoRyrseGY,16420 | ||
| py_wake/tests/test_sites/test_distances.py,sha256=NO-BaFsuv6jItb3sCXGjvt8ylEYoGNlQPtc63DvT73M,16420 | ||
| py_wake/tests/test_sites/test_iea37_readers.py,sha256=nEoXISd3M7USxJe4PFBI2wUlLTjiL6NEnXMvFWHzwxo,1427 | ||
| py_wake/tests/test_sites/test_shear_models.py,sha256=g4zg1QCvl2WQY6f10BiRlBAnyJyaaQRVpeiLnkNT4SU,4053 | ||
| py_wake/tests/test_sites/test_site.py,sha256=NpE0hX1l17fZmzmrBR5x8w12Hc8Bu5w3NzGG9W60URk,11205 | ||
| py_wake/tests/test_sites/test_wasp_grid_site.py,sha256=miNHoOVFt31YqM0Auo97GkAfQ86eyUvc_xkoVO86xEA,15662 | ||
| py_wake/tests/test_sites/test_wrf.py,sha256=5tKl0MCaaAqkinj5Cw06d45NZ9kLJPbMzMbGVU9jb74,2460 | ||
| py_wake/tests/test_sites/test_xrsite.py,sha256=3lASkg3Cdv-MQwrXZRuGqQDGONy6pzRdLOurQTneKGI,31239 | ||
| py_wake/tests/test_sites/test_wasp_grid_site.py,sha256=lU3N1uVmEyL7rqrb9Upmm3YJtvHj8gsGy8c-a4zLAMk,15644 | ||
| py_wake/tests/test_sites/test_wrf.py,sha256=MKTJG7YNHOYES69m8vIzrQzXL6xyubXK90zTDF6aXbQ,3504 | ||
| py_wake/tests/test_sites/test_xrsite.py,sha256=lvfjrm0rVDvLfJ9O0vKzj1yVecxBWlrMK-Rt1RmVg2M,31451 | ||
| py_wake/tests/test_turbulence_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
@@ -358,3 +358,3 @@ py_wake/tests/test_turbulence_models/test_rans_lut_turb.py,sha256=koOW0RJ3lXQDUplY-0Sj4r-6mq1FvLJUH4z3EqETHYc,2696 | ||
| py_wake/tests/test_utils/test_fuga_utils.py,sha256=6YYCrngD4bA9XJdIQqMxMTQ-GmwOybrKSll1IANLB6A,2260 | ||
| py_wake/tests/test_utils/test_gpu_utils.py,sha256=vTVMTLrb9KKr7bHr-AbZZwytV9fhqABq0cn9K4-pt1I,1292 | ||
| py_wake/tests/test_utils/test_gpu_cupy.py,sha256=tqj2MvNyt0S0FGtkx_Hj3tfLMpNWIj3QGPPbBTxg3OY,1907 | ||
| py_wake/tests/test_utils/test_gradient_utils.py,sha256=vyacCD9xviDv1YUBmgRoQbG4E1ZiMpSg27anfunw3Kw,16514 | ||
@@ -364,7 +364,8 @@ py_wake/tests/test_utils/test_grid_interpolator.py,sha256=XWXlIhCpxoRxlSBM6RUeEmEVfYOe3c2wlhjo9hibyWA,7876 | ||
| py_wake/tests/test_utils/test_maps.py,sha256=GPmATBxFtH-y6u6uZNFNbrrXNobKLz4tsiACly7hO8c,486 | ||
| py_wake/tests/test_utils/test_model_gradients.py,sha256=JHZ-uZfNDW-O8sNTssBmE-EJR_XDSAan1OmCtaSROhE,12638 | ||
| py_wake/tests/test_utils/test_model_gradients.py,sha256=JRXj5xv4AAMTqz8hubk63wqqJ5BoF9gTq0YC0MiPGH8,12639 | ||
| py_wake/tests/test_utils/test_model_utils.py,sha256=219lb_0_74xshlw2lKdEgTyPGSRXe8F-uplifqpRdnM,3847 | ||
| py_wake/tests/test_utils/test_most.py,sha256=WG2Ng8T1mcmIAsP23OnQeGCoVQ9D8NEX-2fmhH4tMd8,1311 | ||
| py_wake/tests/test_utils/test_numpy.py,sha256=zcjmLyL19eQEW0uxRz81LueCceGm8zG0-wH6VxEIj5c,7544 | ||
| py_wake/tests/test_utils/test_parallelization.py,sha256=VxxcU58DrwxNyXkl2R00ipf0TUwVJg4Qj7rz8JjEjFo,434 | ||
| py_wake/tests/test_utils/test_mpi.py,sha256=nOM6VzeUHSxlg0n1nEt3g8S5KaN8BpJpASpqADANSCc,2875 | ||
| py_wake/tests/test_utils/test_numpy.py,sha256=-1w5XJjZQDbRjLt9sRbico_ziNK3_4VsrYkY1czNlpg,7536 | ||
| py_wake/tests/test_utils/test_parallelization.py,sha256=JZM9iYxmiY8KnDw0ZqKfDWIOhU-LeVDuXYmXxnd34x0,1520 | ||
| py_wake/tests/test_utils/test_plotting.py,sha256=tCmEUdvZinzcFMiBGRth8MbFKuVSxQFDuPNh762GBps,286 | ||
@@ -403,23 +404,23 @@ py_wake/tests/test_utils/test_profiling.py,sha256=jwanMam7pqEVzlKdsjKqDzWJN1Y7PqY0RN6FqYggNIk,1558 | ||
| py_wake/utils/floris_wrapper.py,sha256=aEaDMo9kLtYyPGKkpwVjAV10iSC3GvhSkbr2rM7ndvE,1401 | ||
| py_wake/utils/fuga_utils.py,sha256=2V49V9jjm0H7JC0ph1-0sgVcvCBiLGNjpZPxyRIkWfg,14955 | ||
| py_wake/utils/fuga_utils.py,sha256=hxHJZkc29oI_zNhytFCCGg04THGkPfJsCUDqta7lFJU,15238 | ||
| py_wake/utils/functions.py,sha256=YiQTF-JBX00Oi8kvbYMeP8zGiCi90qbz8Zhc-N6lrEs,1966 | ||
| py_wake/utils/generic_power_ct_curves.py,sha256=kY8z7a4qZ8fBxYBYS5ULC8j0wlE_LHxPxLPH5LDQO_Y,3957 | ||
| py_wake/utils/gpu_utils.py,sha256=qun-tz8HuwLForxFk7H8DlkdPNmjeRiqMew7f6LOc1c,1618 | ||
| py_wake/utils/gradients.py,sha256=uuhBCbpb7y9K02qbW0m6Ryr-QI7HCbsQzD3Q2uFwbLw,15207 | ||
| py_wake/utils/grid_interpolator.py,sha256=Yq6VFkEMkxJkALC74ATvvHYpTlRMsinkG6VTe_c49Pg,8231 | ||
| py_wake/utils/gradients.py,sha256=AvwWkzBfDc0NDKo6_qMUQp4ExaPnx99jWnzpN3BsLSE,15227 | ||
| py_wake/utils/grid_interpolator.py,sha256=6dL9tL9E6wo_k5NPxX7fBXkgc7_UlPUPnGK-9TQhwQE,8239 | ||
| py_wake/utils/ieawind37_utils.py,sha256=t32eUKrPP6oH2G7Lc53l03TZOe7cj4XhBt_FlNZB5kQ,305 | ||
| py_wake/utils/layouts.py,sha256=YHV1FwZJECBjTqqYIi8ipVIOefXYoWS7AarK7ND048M,998 | ||
| py_wake/utils/maps.py,sha256=cvz1j14Is_EdsXX4wkautCXm_OcDaSwDk4a6JJdhGs4,593 | ||
| py_wake/utils/model_utils.py,sha256=CkdZ38hwCkmyfTO5x6iwAgrVi3o0hOohDVZ213ti_Uw,15350 | ||
| py_wake/utils/model_utils.py,sha256=UP3H4XlAQsE45zl3QFje1zroF7OaqCUDEm6TZ81OrEc,15521 | ||
| py_wake/utils/most.py,sha256=9DEZ5C06qdttfGdfUCyaFCGt-YT8xPnQ3URIuHpbcdE,1208 | ||
| py_wake/utils/notebook_extensions.py,sha256=E0UOiQ1AAMaIbnnzsyj-gGv8oRWD8wAvHsj2BN10LXU,704 | ||
| py_wake/utils/numpy_utils.py,sha256=I9URsvF0ALXOFwdlkTK-mQLul0d-5wLjSWuEeAmE5ZU,3192 | ||
| py_wake/utils/parallelization.py,sha256=k_w4AQMndE4acS0vwBMlZx4AgT_Oi7N7OK3OqVJzc5I,2101 | ||
| py_wake/utils/parallelization.py,sha256=aHT3B1pIC6YYWZqUAclW1VzMCroblqnwwoebsImFaB8,3693 | ||
| py_wake/utils/plotting.py,sha256=zXharIIWIwl-E0Xh2JP3qAnYEEAKGJidQcldhRd0dRo,568 | ||
| py_wake/utils/profiling.py,sha256=g6aDNtZg_7lcxUg4WdAawGMysaoZW87iPyTWwiPvWdA,4668 | ||
| py_wake/utils/rans_lut_utils.py,sha256=-zs25tCdg2heaoCjyEDdk0vSDTImdhjtTpbDH_YEClI,12423 | ||
| py_wake/utils/streamline.py,sha256=VjpEESETjxvYQwv11--FtL0Z9oX4EG87qyLYpss3Krc,2657 | ||
| py_wake/utils/streamline.py,sha256=QSfp_kLVxihTlWq3P0AHvpf_OS-QUIj17xoNhhI8QXk,2835 | ||
| py_wake/utils/tensorflow_surrogate_utils.py,sha256=QdIPqxoYiuXFvieHQyP-TE6gS8syXbxoUZ1liCBFil0,7198 | ||
| py_wake/utils/weibull.py,sha256=cD1SIyXHEn17IQueZnsy9-upo2oZivVCpYOWka-_DsE,1262 | ||
| py_wake/utils/xarray_utils.py,sha256=pXIlFSyL54K19II6Edlt5wd_Hoh15FGNBVRrjfRTYX0,7791 | ||
| py_wake/utils/xarray_utils.py,sha256=l4EmohWhs7n35F7Ik0wyIXbInvzxSMMrfFeW5FqluS0,7817 | ||
| py_wake/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 | ||
@@ -431,6 +432,6 @@ py_wake/validation/ecn_wieringermeer.py,sha256=1PexliJn_LHkeLRM8r6-iMEk72jtIUUBH3kWI0nV4P4,2930 | ||
| py_wake/wind_farm_models/__init__.py,sha256=cl0nC9vqhXgpRuaCFkQpDET2Yyzbwnd5Kv2wgZHUI6E,137 | ||
| py_wake/wind_farm_models/engineering_models.py,sha256=6Ab-eDX3_ZIeHAmJ_qD8OtlWVWo5V75tvp6rPKu6O7I,63786 | ||
| py_wake/wind_farm_models/engineering_models.py,sha256=Mq3kh5aFfO4YSrBHzg3ukPN-RBZb8XKBMT9vJESptp4,63776 | ||
| py_wake/wind_farm_models/external_wind_farm_models.py,sha256=QRSwdq45J4hwmYANBCv87HFGAho04_gkTWY9rUUUazM,12587 | ||
| py_wake/wind_farm_models/minimalistic_wind_farm_model.py,sha256=9BepPjAo_WDMcG4feUQo7YDY2WSFJOpNMmzgT0yNBn4,11160 | ||
| py_wake/wind_farm_models/wind_farm_model.py,sha256=QvYmeqAVz2QyrjH21VEt1T52lJS2NQcTq3cW-W1qUFQ,42814 | ||
| py_wake/wind_farm_models/wind_farm_model.py,sha256=8rQ0tbfZDMs8_9Ag_c1UQz28O7xF7tEBS43wey_BWfs,42573 | ||
| py_wake/wind_turbines/__init__.py,sha256=w1D9rLfxk7m_UdrqbVVokWwAikxIzeRh6Wb9zVT2Mhs,145 | ||
@@ -442,6 +443,6 @@ py_wake/wind_turbines/_wind_turbines.py,sha256=ukh8Kw4tUHH5vkXiVC8JaI-5xuIjCRVUROWInnJQJcw,18915 | ||
| py_wake/wind_turbines/wind_turbines_deprecated.py,sha256=HpNmBR8CJL4-8JBaygDI0t086qfw5bR2DOQI8Ox4AZ4,6250 | ||
| py_wake-2.6.15.dist-info/licenses/LICENSE,sha256=XE2CGPqQgzSXqIajXpAVYJ5SRNmaWOIeMePK6MocsuY,1084 | ||
| py_wake-2.6.15.dist-info/METADATA,sha256=SSQCWVa8eKVPv3uF5TFb3P6jgVBLU_g6yIjM3bgWEoA,3644 | ||
| py_wake-2.6.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91 | ||
| py_wake-2.6.15.dist-info/top_level.txt,sha256=GsaXU4YwyMkZZ6dkb4h0FMc5RaLIT2Qns_YoScKoXdk,20 | ||
| py_wake-2.6.15.dist-info/RECORD,, | ||
| py_wake-2.6.16.dist-info/licenses/LICENSE,sha256=XE2CGPqQgzSXqIajXpAVYJ5SRNmaWOIeMePK6MocsuY,1084 | ||
| py_wake-2.6.16.dist-info/METADATA,sha256=gVr6wRfNyRfmVfe0Mbzgi9H8-1EDANsVPMZO5O-SI5Q,3760 | ||
| py_wake-2.6.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91 | ||
| py_wake-2.6.16.dist-info/top_level.txt,sha256=GsaXU4YwyMkZZ6dkb4h0FMc5RaLIT2Qns_YoScKoXdk,20 | ||
| py_wake-2.6.16.dist-info/RECORD,, |
| from py_wake.utils import gpu_utils | ||
| import pytest | ||
| import os | ||
| from py_wake.deficit_models.gaussian import BastankhahGaussian | ||
| from py_wake.examples.data.hornsrev1 import Hornsrev1Site, V80 | ||
| from py_wake import np | ||
| from py_wake.utils.layouts import rectangle | ||
| from py_wake.utils.profiling import timeit | ||
| from py_wake.tests import npt | ||
| if gpu_utils.cupy_found: | ||
| import cupy as cp | ||
| def test_gpu_name(): | ||
| if os.environ.get('SLURM_JOB_PARTITION', '') == 'gpuq': | ||
| assert gpu_utils.gpu_name == 'Quadro P4000' | ||
| def test_print_gpu_mem(): | ||
| gpu_utils.print_gpu_mem() | ||
| def test_free_gpu_mem(): | ||
| initial = gpu_utils.mempool.total_bytes() | ||
| cp.zeros(128 * 1024) | ||
| before = gpu_utils.mempool.total_bytes() | ||
| gpu_utils.free_gpu_mem(verbose=False) | ||
| after = gpu_utils.mempool.total_bytes() | ||
| assert after < before | ||
| def test_pywake_gpu(): | ||
| import numpy | ||
| np.set_backend(numpy) | ||
| wfm = BastankhahGaussian(site=Hornsrev1Site(), windTurbines=V80()) | ||
| x, y = rectangle(100, 50, 5 * 80) | ||
| aep_cpu, t_cpu = timeit(wfm.aep)(x, y) | ||
| np.set_backend(cp) | ||
| wfm.aep([0], [0]) | ||
| aep_gpu, t_gpu = timeit(wfm.aep)(x, y) | ||
| npt.assert_almost_equal(aep_cpu, aep_gpu) | ||
| assert t_gpu < t_cpu |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.