Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TOPFARM
PyWake
Commits
80a3f270
Commit
80a3f270
authored
Feb 18, 2021
by
Mads M. Pedersen
Committed by
Mads M. Pedersen
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
np.int>int, np.float>float
parent
230aff5f
Pipeline
#20334
passed with stages
in 9 minutes and 6 seconds
Changes
13
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
27 additions
and
27 deletions
+27
-27
py_wake/deficit_models/fuga.py
py_wake/deficit_models/fuga.py
+1
-1
py_wake/deficit_models/gcl.py
py_wake/deficit_models/gcl.py
+1
-1
py_wake/examples/data/iea37/iea37_reader.py
py_wake/examples/data/iea37/iea37_reader.py
+1
-1
py_wake/site/distance.py
py_wake/site/distance.py
+1
-1
py_wake/site/wasp_grid_site.py
py_wake/site/wasp_grid_site.py
+1
-1
py_wake/tests/test_sites/test_wasp_grid_site.py
py_wake/tests/test_sites/test_wasp_grid_site.py
+1
-1
py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py
.../test_wind_farm_models/test_enginering_wind_farm_model.py
+1
-1
py_wake/utils/fuga_utils.py
py_wake/utils/fuga_utils.py
+1
-1
py_wake/utils/gradients.py
py_wake/utils/gradients.py
+2
-2
py_wake/utils/grid_interpolator.py
py_wake/utils/grid_interpolator.py
+2
-2
py_wake/validation/validation_lib.py
py_wake/validation/validation_lib.py
+3
-3
py_wake/wind_farm_models/engineering_models.py
py_wake/wind_farm_models/engineering_models.py
+2
-2
py_wake/wind_turbines.py
py_wake/wind_turbines.py
+10
-10
No files found.
py_wake/deficit_models/fuga.py
View file @
80a3f270
...
...
@@ -159,7 +159,7 @@ class LUTInterpolator(object):
# zp = np.maximum(np.minimum(zp, self.z[-1]), self.z[0])
def
i0f
(
_i
):
_i0
=
np
.
asarray
(
_i
).
astype
(
np
.
int
)
_i0
=
np
.
asarray
(
_i
).
astype
(
int
)
_if
=
_i
-
_i0
return
_i0
,
_if
...
...
py_wake/deficit_models/gcl.py
View file @
80a3f270
...
...
@@ -123,7 +123,7 @@ def get_dU(x, r, R, CT, TI):
Wake velocity deficit at a location
"""
CT
=
np
.
maximum
(
CT
,
np
.
finfo
(
np
.
float
).
eps
)
CT
=
np
.
maximum
(
CT
,
np
.
finfo
(
float
).
eps
)
Area
=
np
.
pi
*
R
*
R
Rw
,
xx0
,
c1
=
get_Rw
(
x
,
R
,
TI
,
CT
)
c1s
=
c1
*
c1
...
...
py_wake/examples/data/iea37/iea37_reader.py
View file @
80a3f270
...
...
@@ -31,7 +31,7 @@ def read_iea37_windturbine(filename):
def
ct
(
wsp
):
wsp
=
np
.
asarray
(
wsp
)
ct
=
np
.
zeros_like
(
wsp
,
dtype
=
np
.
float
)
ct
=
np
.
zeros_like
(
wsp
,
dtype
=
float
)
ct
[(
wsp
>=
wsp_cut_in
)
&
(
wsp
<=
wsp_cut_out
)]
=
constant_ct
return
ct
...
...
py_wake/site/distance.py
View file @
80a3f270
...
...
@@ -337,7 +337,7 @@ class TerrainFollowingDistance2():
x_rotated_il
=
x_i
[:,
na
]
*
cos_wd_il
+
y_i
[:,
na
]
*
sin_wd_il
y_rotated_il
=
y_i
[:,
na
]
*
cos_wd_il
-
x_i
[:,
na
]
*
sin_wd_il
downwind_order_il
=
np
.
argsort
(
x_rotated_il
,
0
).
astype
(
np
.
int
)
downwind_order_il
=
np
.
argsort
(
x_rotated_il
,
0
).
astype
(
int
)
dist_down_iil
=
dx_ii
[:,
:,
na
]
*
cos_wd_il
[:,
na
,
:]
+
dy_ii
[:,
:,
na
]
*
sin_wd_il
[:,
na
,
:]
dy_rotated_iil
=
dy_ii
[:,
:,
na
]
*
cos_wd_il
[:,
na
,
:]
-
dx_ii
[:,
:,
na
]
*
sin_wd_il
[:,
na
,
:]
...
...
py_wake/site/wasp_grid_site.py
View file @
80a3f270
...
...
@@ -135,7 +135,7 @@ def load_wasp_grd(path, globstr='*.grd', speedup_using_pickle=True):
yl
,
yu
=
_parse_line_floats
(
f
)
zl
,
zu
=
_parse_line_floats
(
f
)
values
=
np
.
array
([
l
.
split
()
for
l
in
f
.
readlines
()
if
l
.
strip
()
!=
b
""
],
dtype
=
np
.
float
)
# around 8 times faster
dtype
=
float
)
# around 8 times faster
xarr
=
np
.
linspace
(
xl
,
xu
,
nx
)
yarr
=
np
.
linspace
(
yl
,
yu
,
ny
)
...
...
py_wake/tests/test_sites/test_wasp_grid_site.py
View file @
80a3f270
...
...
@@ -90,7 +90,7 @@ def test_wasp_resources_grid_point(site):
# 0.7221162 4.606324 17.96417 11.45838
# 0.8088576 8.196074 16.16308 9.277925
# 0.8800673 3.932325 14.82337 5.380589
# 0.8726974 -3.199536 19.99724 -1.433086""".split("\n")], dtype=
np.
float)
# 0.8726974 -3.199536 19.99724 -1.433086""".split("\n")], dtype=float)
# for x_ in x.T:
# print(list(x_))
x
=
[
262978
]
...
...
py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py
View file @
80a3f270
...
...
@@ -179,7 +179,7 @@ def test_dAEP_2wt():
x
,
y
=
iea37_site
.
initial_position
[
np
.
array
([
0
,
2
,
5
,
8
,
14
])].
T
# plot 2 wt case
x
,
y
=
np
.
array
([[
0
,
130
*
4
],
[
0
,
0
]],
dtype
=
np
.
float
)
x
,
y
=
np
.
array
([[
0
,
130
*
4
],
[
0
,
0
]],
dtype
=
float
)
x_lst
=
np
.
array
([
0.
,
1.
])
*
np
.
arange
(
1
,
600
,
10
)[:,
na
]
kwargs
=
{
'ws'
:
[
10
],
'wd'
:
[
270
]}
...
...
py_wake/utils/fuga_utils.py
View file @
80a3f270
...
...
@@ -91,5 +91,5 @@ class FugaUtils():
def
load_luts
(
self
,
UVLT
=
[
'UL'
,
'UT'
,
'VL'
,
'VT'
],
zlevels
=
None
):
luts
=
np
.
array
([[
np
.
fromfile
(
str
(
self
.
path
/
(
self
.
prefix
+
'%04d%s.dat'
%
(
j
,
uvlt
))),
np
.
dtype
(
'<f'
),
-
1
)
for
j
in
(
zlevels
or
self
.
zlevels
)]
for
uvlt
in
UVLT
]).
astype
(
np
.
float
)
for
j
in
(
zlevels
or
self
.
zlevels
)]
for
uvlt
in
UVLT
]).
astype
(
float
)
return
luts
.
reshape
((
len
(
UVLT
),
len
(
zlevels
or
self
.
zlevels
),
self
.
ny
//
2
,
self
.
nx
))
py_wake/utils/gradients.py
View file @
80a3f270
...
...
@@ -21,7 +21,7 @@ anp.asarray = asarray
# replace dsqrt to avoid divide by zero if x=0
eps
=
2
*
np
.
finfo
(
np
.
float
).
eps
**
2
eps
=
2
*
np
.
finfo
(
float
).
eps
**
2
defvjp
(
anp
.
sqrt
,
lambda
ans
,
x
:
lambda
g
:
g
*
0.5
*
np
.
where
(
x
==
0
,
eps
,
x
)
**-
0.5
)
# @UndefinedVariable
...
...
@@ -57,7 +57,7 @@ def use_autograd_in(modules=["py_wake."]):
def
_step_grad
(
f
,
argnum
,
step_func
,
step
):
def
wrap
(
*
args
,
**
kwargs
):
x
=
np
.
atleast_1d
(
args
[
argnum
]).
astype
(
np
.
float
)
x
=
np
.
atleast_1d
(
args
[
argnum
]).
astype
(
float
)
ref
=
f
(
*
args
,
**
kwargs
)
return
np
.
array
([
step_func
(
f
(
*
(
args
[:
argnum
]
+
(
x_
,)
+
args
[
argnum
+
1
:]),
**
kwargs
),
ref
,
step
)
for
x_
in
x
+
np
.
diag
(
np
.
ones_like
(
x
)
*
step
)]).
T
...
...
py_wake/utils/grid_interpolator.py
View file @
80a3f270
...
...
@@ -119,11 +119,11 @@ class EqDistRegGrid2DInterpolator():
xp
,
yp
=
x
,
y
xi
=
(
xp
-
self
.
x0
)
/
self
.
dx
xif
,
xi0
=
np
.
modf
(
xi
)
xi0
=
xi0
.
astype
(
np
.
int
)
xi0
=
xi0
.
astype
(
int
)
yi
=
(
yp
-
self
.
y0
)
/
self
.
dy
yif
,
yi0
=
np
.
modf
(
yi
)
yi0
=
yi0
.
astype
(
np
.
int
)
yi0
=
yi0
.
astype
(
int
)
if
mode
==
'extrapolate'
:
xif
[
xi0
<
self
.
xi_valid_min
]
=
0
xif
[
xi0
>
self
.
xi_valid_max
-
2
]
=
1
...
...
py_wake/validation/validation_lib.py
View file @
80a3f270
...
...
@@ -10,7 +10,7 @@ from py_wake.deficit_models.noj import NOJDeficit
from
py_wake.deficit_models.gaussian
import
BastankhahGaussianDeficit
from
py_wake.superposition_models
import
SquaredSum
from
py_wake.rotor_avg_models
import
RotorCenter
import
xarray
as
xr
# -----------------------------------------------------
# Default values
...
...
@@ -339,7 +339,7 @@ def plot_single_wake(swc_out, lw=lw):
'''
for
case
in
swc_out
.
keys
():
jj
=
len
(
swc_out
[
case
][
'xDown'
])
color
=
cm
.
tab10
(
np
.
linspace
(
0
,
1
,
len
(
swc_out
[
case
][
'deficit_models'
])))
color
=
cm
.
tab10
(
np
.
linspace
(
0
,
1
,
len
(
swc_out
[
case
][
'deficit_models'
])))
# @UndefinedVariable
fig
,
ax
=
plt
.
subplots
(
1
,
jj
,
sharey
=
False
,
figsize
=
(
5
*
jj
,
5
))
fig
.
suptitle
(
case
)
...
...
@@ -396,7 +396,7 @@ def plotbar_single_wake(swc_out, cLES=cLES, cRANS=cRANS):
names
=
[]
subnames
=
[]
lines
=
[]
color
=
cm
.
tab10
(
np
.
linspace
(
0
,
1
,
len
(
swc_out
[
case
][
'deficit_models'
])))
color
=
cm
.
tab10
(
np
.
linspace
(
0
,
1
,
len
(
swc_out
[
case
][
'deficit_models'
])))
# @UndefinedVariable
i
=
0
ymax
=
0
for
case
in
swc_out
.
keys
():
...
...
py_wake/wind_farm_models/engineering_models.py
View file @
80a3f270
...
...
@@ -175,7 +175,7 @@ class EngineeringWindFarmModel(WindFarmModel):
# add eps to avoid non-differentiable 0
if
'autograd'
in
np
.
__name__
:
eps
=
2
*
np
.
finfo
(
np
.
float
).
eps
**
2
eps
=
2
*
np
.
finfo
(
float
).
eps
**
2
else
:
eps
=
0
cw_iil
=
np
.
sqrt
(
hcw_iil
**
2
+
dh_iil
**
2
+
eps
)
...
...
@@ -374,7 +374,7 @@ class PropagateDownwind(EngineeringWindFarmModel):
dh_nk
=
[]
def
ilk2mk
(
x_ilk
):
return
np
.
broadcast_to
(
x_ilk
.
astype
(
np
.
float
),
(
I
,
L
,
K
)).
reshape
((
I
*
L
,
K
))
return
np
.
broadcast_to
(
x_ilk
.
astype
(
float
),
(
I
,
L
,
K
)).
reshape
((
I
*
L
,
K
))
indices
=
np
.
arange
(
I
*
I
*
L
).
reshape
((
I
,
I
,
L
))
TI_mk
=
ilk2mk
(
lw
.
TI_ilk
)
...
...
py_wake/wind_turbines.py
View file @
80a3f270
...
...
@@ -366,22 +366,22 @@ class WindTurbines():
root
=
tree
.
getroot
()
# Reading data from wtg_file
name
=
root
.
attrib
[
'Description'
]
diameter
=
np
.
float
(
root
.
attrib
[
'RotorDiameter'
])
hub_height
=
np
.
float
(
root
.
find
(
'SuggestedHeights'
).
find
(
'Height'
).
text
)
diameter
=
float
(
root
.
attrib
[
'RotorDiameter'
])
hub_height
=
float
(
root
.
find
(
'SuggestedHeights'
).
find
(
'Height'
).
text
)
perftab
=
list
(
root
.
iter
(
'PerformanceTable'
))[
m
]
density
=
np
.
float
(
perftab
.
attrib
[
'AirDensity'
])
ws_cutin
=
np
.
float
(
perftab
.
find
(
'StartStopStrategy'
).
attrib
[
'LowSpeedCutIn'
])
ws_cutout
=
np
.
float
(
perftab
.
find
(
'StartStopStrategy'
).
attrib
[
'HighSpeedCutOut'
])
density
=
float
(
perftab
.
attrib
[
'AirDensity'
])
ws_cutin
=
float
(
perftab
.
find
(
'StartStopStrategy'
).
attrib
[
'LowSpeedCutIn'
])
ws_cutout
=
float
(
perftab
.
find
(
'StartStopStrategy'
).
attrib
[
'HighSpeedCutOut'
])
cut_ins
.
append
(
ws_cutin
)
cut_outs
.
append
(
ws_cutout
)
i_point
=
0
for
DataPoint
in
perftab
.
iter
(
'DataPoint'
):
i_point
=
i_point
+
1
ws
=
np
.
float
(
DataPoint
.
attrib
[
'WindSpeed'
])
Ct
=
np
.
float
(
DataPoint
.
attrib
[
'ThrustCoEfficient'
])
power
=
np
.
float
(
DataPoint
.
attrib
[
'PowerOutput'
])
ws
=
float
(
DataPoint
.
attrib
[
'WindSpeed'
])
Ct
=
float
(
DataPoint
.
attrib
[
'ThrustCoEfficient'
])
power
=
float
(
DataPoint
.
attrib
[
'PowerOutput'
])
if
i_point
==
1
:
dt
=
np
.
array
([[
ws
,
Ct
,
power
]])
else
:
...
...
@@ -498,7 +498,7 @@ class Interp(object):
def
cube_power
(
ws_cut_in
=
3
,
ws_cut_out
=
25
,
ws_rated
=
12
,
power_rated
=
5000
):
def
power_func
(
ws
):
ws
=
np
.
asarray
(
ws
)
power
=
np
.
zeros_like
(
ws
,
dtype
=
np
.
float
)
power
=
np
.
zeros_like
(
ws
,
dtype
=
float
)
m
=
(
ws
>=
ws_cut_in
)
&
(
ws
<
ws_rated
)
power
[
m
]
=
power_rated
*
((
ws
[
m
]
-
ws_cut_in
)
/
(
ws_rated
-
ws_cut_in
))
**
3
power
[(
ws
>=
ws_rated
)
&
(
ws
<=
ws_cut_out
)]
=
power_rated
...
...
@@ -510,7 +510,7 @@ def dummy_thrust(ws_cut_in=3, ws_cut_out=25, ws_rated=12, ct_rated=8 / 9):
# temporary thrust curve fix
def
ct_func
(
ws
):
ws
=
np
.
asarray
(
ws
)
ct
=
np
.
zeros_like
(
ws
,
dtype
=
np
.
float
)
ct
=
np
.
zeros_like
(
ws
,
dtype
=
float
)
if
ct_rated
>
0
:
# ct = np.ones_like(ct)*ct_rated
m
=
(
ws
>=
ws_cut_in
)
&
(
ws
<
ws_rated
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment