Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
PyWake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
The Gitlab server is succesfully updated to version 17.9.2
Show more breadcrumbs
TOPFARM
PyWake
Commits
6c6a361f
Commit
6c6a361f
authored
3 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
test gradients of WS_eff, TI_eff, power, ct
parent
8360f0ed
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py_wake/tests/test_utils/test_gradients.py
+41
-22
41 additions, 22 deletions
py_wake/tests/test_utils/test_gradients.py
with
41 additions
and
22 deletions
py_wake/tests/test_utils/test_gradients.py
+
41
−
22
View file @
6c6a361f
...
...
@@ -423,7 +423,8 @@ def test_multiple_inputs():
[[
4
,
5
],
[
2
,
3
]],
8
)
def
check_gradients
(
wfm
,
name
,
wt_x
=
[
-
1300
,
-
650
,
0
],
wt_y
=
[
0
,
0
,
0
],
wt_h
=
[
110
,
110
,
110
],
fd_step
=
1e-6
,
fd_decimal
=
6
):
def
check_gradients
(
wfm
,
name
,
wt_x
=
[
-
1300
,
-
650
,
0
],
wt_y
=
[
0
,
0
,
0
],
wt_h
=
[
110
,
110
,
110
],
fd_step
=
1e-6
,
fd_decimal
=
6
,
output
=
(
lambda
wfm
:
wfm
.
aep
,
'
AEP [GWh]
'
)):
if
wfm
is
None
:
return
site
=
IEA37Site
(
16
)
...
...
@@ -440,18 +441,20 @@ def check_gradients(wfm, name, wt_x=[-1300, -650, 0], wt_y=[0, 0, 0], wt_h=[110,
def
fdstep
(
*
args
,
**
kwargs
):
return
fd
(
*
args
,
**
kwargs
,
step
=
fd_step
)
output_func
,
output_label
=
output
output_func
=
output_func
(
wfm
)
d
AEP
dx_lst
=
[
grad
(
wfm
.
aep
,
True
,
0
)(
xp
,
wt_y
,
**
kwargs
)[
2
]
for
grad
in
[
fdstep
,
cs
,
autograd
]]
npt
.
assert_almost_equal
(
d
AEP
dx_lst
[
0
],
d
AEP
dx_lst
[
1
],
fd_decimal
)
npt
.
assert_almost_equal
(
d
AEP
dx_lst
[
1
],
d
AEP
dx_lst
[
2
],
10
)
d
Output
dx_lst
=
[
grad
(
output_func
,
True
,
0
)(
xp
,
wt_y
,
**
kwargs
)[
2
]
for
grad
in
[
fdstep
,
cs
,
autograd
]]
npt
.
assert_almost_equal
(
d
Output
dx_lst
[
0
],
d
Output
dx_lst
[
1
],
fd_decimal
)
npt
.
assert_almost_equal
(
d
Output
dx_lst
[
1
],
d
Output
dx_lst
[
2
],
10
)
d
AEP
dy_lst
=
[
grad
(
wfm
.
aep
,
True
,
1
)(
wt_x
,
yp
,
**
kwargs
)[
2
]
for
grad
in
[
fdstep
,
cs
,
autograd
]]
npt
.
assert_almost_equal
(
d
AEP
dy_lst
[
0
],
d
AEP
dy_lst
[
1
],
fd_decimal
)
npt
.
assert_almost_equal
(
d
AEP
dy_lst
[
1
],
d
AEP
dy_lst
[
2
],
10
)
d
Output
dy_lst
=
[
grad
(
output_func
,
True
,
1
)(
wt_x
,
yp
,
**
kwargs
)[
2
]
for
grad
in
[
fdstep
,
cs
,
autograd
]]
npt
.
assert_almost_equal
(
d
Output
dy_lst
[
0
],
d
Output
dy_lst
[
1
],
fd_decimal
)
npt
.
assert_almost_equal
(
d
Output
dy_lst
[
1
],
d
Output
dy_lst
[
2
],
10
)
d
AEP
dh_lst
=
[
grad
(
wfm
.
aep
,
True
,
2
)(
wt_x
,
wt_y
,
hp
,
**
kwargs
)[
2
]
for
grad
in
[
fdstep
,
cs
,
autograd
]]
npt
.
assert_almost_equal
(
d
AEP
dh_lst
[
0
],
d
AEP
dh_lst
[
1
],
fd_decimal
)
npt
.
assert_almost_equal
(
d
AEP
dh_lst
[
1
],
d
AEP
dh_lst
[
2
],
10
)
d
Output
dh_lst
=
[
grad
(
output_func
,
True
,
2
)(
wt_x
,
wt_y
,
hp
,
**
kwargs
)[
2
]
for
grad
in
[
fdstep
,
cs
,
autograd
]]
npt
.
assert_almost_equal
(
d
Output
dh_lst
[
0
],
d
Output
dh_lst
[
1
],
fd_decimal
)
npt
.
assert_almost_equal
(
d
Output
dh_lst
[
1
],
d
Output
dh_lst
[
2
],
10
)
if
0
:
wfm
(
wt_x
,
wt_y
,
**
kwargs
).
flow_map
().
plot_wake_map
()
...
...
@@ -459,29 +462,29 @@ def check_gradients(wfm, name, wt_x=[-1300, -650, 0], wt_y=[0, 0, 0], wt_h=[110,
_
,
(
ax1
,
ax2
,
ax3
)
=
plt
.
subplots
(
1
,
3
,
sharey
=
False
)
ax1
.
set_title
(
"
Center line
"
)
ax1
.
set_xlabel
(
'
Downwind distance [m]
'
)
ax1
.
set_ylabel
(
'
AEP [GWh]
'
)
ax1
.
set_ylabel
(
output_label
)
ax1
.
plot
(
x_lst
[:,
2
],
[
wfm
.
aep
(
xp
,
wt_y
,
**
kwargs
)
for
xp
in
x_lst
])
ax1
.
plot
(
x_lst
[:,
2
],
[
output_func
(
xp
,
wt_y
,
**
kwargs
)
for
xp
in
x_lst
])
ax1
.
axvline
(
wt_x
[
1
],
color
=
'
k
'
)
for
grad
,
d
AEP
dx
in
zip
([
fd
,
cs
,
autograd
],
d
AEP
dx_lst
):
plot_gradients
(
wfm
.
aep
(
xp
,
wt_y
,
**
kwargs
),
d
AEP
dx
,
xp
[
2
],
grad
.
__name__
,
step
=
100
,
ax
=
ax1
)
for
grad
,
d
Output
dx
in
zip
([
fd
,
cs
,
autograd
],
d
Output
dx_lst
):
plot_gradients
(
output_func
(
xp
,
wt_y
,
**
kwargs
),
d
Output
dx
,
xp
[
2
],
grad
.
__name__
,
step
=
100
,
ax
=
ax1
)
ax2
.
set_xlabel
(
'
Crosswind distance [m]
'
)
ax2
.
set_ylabel
(
'
AEP [GWh]
'
)
ax2
.
set_ylabel
(
output_label
)
ax2
.
set_title
(
"
%d m downstream
"
%
wt_x
[
1
])
ax2
.
plot
(
y_lst
[:,
2
],
[
wfm
.
aep
(
wt_x
,
yp
,
**
kwargs
)
for
yp
in
y_lst
])
ax2
.
plot
(
y_lst
[:,
2
],
[
output_func
(
wt_x
,
yp
,
**
kwargs
)
for
yp
in
y_lst
])
gradients
.
color_dict
=
{}
for
grad
,
d
AEP
dy
in
zip
([
fd
,
cs
,
autograd
],
d
AEP
dy_lst
):
plot_gradients
(
wfm
.
aep
(
wt_x
,
yp
,
**
kwargs
),
d
AEP
dy
,
yp
[
2
],
grad
.
__name__
,
step
=
50
,
ax
=
ax2
)
for
grad
,
d
Output
dy
in
zip
([
fd
,
cs
,
autograd
],
d
Output
dy_lst
):
plot_gradients
(
output_func
(
wt_x
,
yp
,
**
kwargs
),
d
Output
dy
,
yp
[
2
],
grad
.
__name__
,
step
=
50
,
ax
=
ax2
)
ax3
.
set_xlabel
(
'
hubheight [m]
'
)
ax3
.
set_ylabel
(
'
AEP [GWh]
'
)
ax3
.
set_ylabel
(
output_label
)
ax3
.
plot
(
h_lst
[:,
2
],
[
wfm
.
aep
(
wt_x
,
wt_y
,
hp
,
**
kwargs
)
for
hp
in
h_lst
])
ax3
.
plot
(
h_lst
[:,
2
],
[
output_func
(
wt_x
,
wt_y
,
hp
,
**
kwargs
)
for
hp
in
h_lst
])
gradients
.
color_dict
=
{}
for
grad
,
d
AEP
dh
in
zip
([
fd
,
cs
,
autograd
],
d
AEP
dh_lst
):
plot_gradients
(
wfm
.
aep
(
wt_x
,
wt_y
,
hp
,
**
kwargs
),
d
AEP
dh
,
hp
[
2
],
grad
.
__name__
,
step
=
10
,
ax
=
ax3
)
for
grad
,
d
Output
dh
in
zip
([
fd
,
cs
,
autograd
],
d
Output
dh_lst
):
plot_gradients
(
output_func
(
wt_x
,
wt_y
,
hp
,
**
kwargs
),
d
Output
dh
,
hp
[
2
],
grad
.
__name__
,
step
=
10
,
ax
=
ax3
)
plt
.
suptitle
(
name
)
plt
.
show
()
...
...
@@ -616,3 +619,19 @@ def test_windturbines(wt):
turbulenceModel
=
STF2017TurbulenceModel
())
iea34
=
wt
.
name
()
==
'
IEA 3.4MW
'
check_gradients
(
get_wfm
,
wt
.
__class__
.
__name__
,
fd_step
=
(
1e-6
,
1e-3
)[
iea34
],
fd_decimal
=
(
6
,
2
)[
iea34
])
output_lst
=
[
'
WS_eff
'
,
'
TI_eff
'
,
'
power
'
,
'
ct
'
]
@pytest.mark.parametrize
(
'
output
'
,
output_lst
)
def
test_output
(
output
):
argnum
=
output_lst
.
index
(
output
)
# WS_eff_ilk, TI_eff_ilk, power_ilk, ct_ilk, localWind, wt_inputs = calc_wt_interaction
def
output_func
(
wfm
):
return
lambda
*
args
,
argnum
=
argnum
,
**
kwargs
:
wfm
.
calc_wt_interaction
(
*
args
,
**
kwargs
)[
argnum
].
mean
()
wake_deficitModel
=
BastankhahGaussianDeficit
check_gradients
(
lambda
site
,
wt
:
PropagateDownwind
(
site
,
V80
(),
wake_deficitModel
(),
turbulenceModel
=
STF2005TurbulenceModel
()),
name
=
output
,
output
=
(
output_func
,
output
),
fd_decimal
=
[
6
,
2
][
output
==
'
power
'
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment