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
Show more breadcrumbs
TOPFARM
PyWake
Commits
c6e13bed
Commit
c6e13bed
authored
4 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
use faster method as long as only one wt type is used (even if type!=0)
parent
806bfcd3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py_wake/tests/test_deficit_models/test_noj.py
+1
-5
1 addition, 5 deletions
py_wake/tests/test_deficit_models/test_noj.py
py_wake/wind_turbines.py
+5
-10
5 additions, 10 deletions
py_wake/wind_turbines.py
with
6 additions
and
15 deletions
py_wake/tests/test_deficit_models/test_noj.py
+
1
−
5
View file @
c6e13bed
import
pytest
import
pytest
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
from
py_wake
import
NOJ
from
py_wake
import
NOJ
from
py_wake.examples.data.iea37
import
iea37_path
from
py_wake.examples.data.iea37._iea37
import
IEA37_WindTurbines
,
IEA37Site
from
py_wake.site._site
import
UniformSite
from
py_wake.site._site
import
UniformSite
from
py_wake.tests
import
npt
from
py_wake.tests
import
npt
from
py_wake.flow_map
import
HorizontalGrid
from
py_wake.flow_map
import
HorizontalGrid
...
@@ -72,7 +68,7 @@ def test_NOJ_6_turbines_in_row():
...
@@ -72,7 +68,7 @@ def test_NOJ_6_turbines_in_row():
site
=
UniformSite
([
1
],
0.1
)
site
=
UniformSite
([
1
],
0.1
)
wake_model
=
NOJ
(
site
,
NibeA0
)
wake_model
=
NOJ
(
site
,
NibeA0
)
WS_eff_ilk
=
wake_model
.
calc_wt_interaction
(
x
,
y
,
[
50
]
*
n_wt
,
[
0
.0
]
*
n_wt
,
0.0
,
11.0
)[
0
]
WS_eff_ilk
=
wake_model
.
calc_wt_interaction
(
x
,
y
,
[
50
]
*
n_wt
,
[
0
]
*
n_wt
,
0.0
,
11.0
)[
0
]
np
.
testing
.
assert_array_almost_equal
(
np
.
testing
.
assert_array_almost_equal
(
WS_eff_ilk
[
1
:,
0
,
0
],
11
-
np
.
sqrt
(
np
.
cumsum
(((
11
*
2
/
3
*
20
**
2
)
**
2
)
/
(
20
+
8
*
np
.
arange
(
1
,
6
))
**
4
)))
WS_eff_ilk
[
1
:,
0
,
0
],
11
-
np
.
sqrt
(
np
.
cumsum
(((
11
*
2
/
3
*
20
**
2
)
**
2
)
/
(
20
+
8
*
np
.
arange
(
1
,
6
))
**
4
)))
...
...
This diff is collapsed.
Click to expand it.
py_wake/wind_turbines.py
+
5
−
10
View file @
c6e13bed
...
@@ -118,20 +118,15 @@ class WindTurbines():
...
@@ -118,20 +118,15 @@ class WindTurbines():
def
_ct_power
(
self
,
ws_i
,
type_i
=
0
):
def
_ct_power
(
self
,
ws_i
,
type_i
=
0
):
ws_i
=
np
.
asarray
(
ws_i
)
ws_i
=
np
.
asarray
(
ws_i
)
if
np
.
any
(
type_i
!=
0
):
t
=
np
.
unique
(
type_i
)
# .astype(int)
CT
=
np
.
zeros_like
(
ws_i
,
dtype
=
np
.
float
)
if
len
(
t
)
>
1
:
P
=
np
.
zeros_like
(
ws_i
,
dtype
=
np
.
float
)
if
type_i
.
shape
!=
ws_i
.
shape
:
type_i
=
(
np
.
zeros
(
ws_i
.
shape
[
0
])
+
type_i
).
astype
(
int
)
type_i
=
(
np
.
zeros
(
ws_i
.
shape
[
0
])
+
type_i
).
astype
(
int
)
# TODO: check if faster to calculate both in same line
CT
=
np
.
array
([
self
.
ct_funcs
[
t
](
ws
)
for
t
,
ws
in
zip
(
type_i
,
ws_i
)])
CT
=
np
.
array
([
self
.
ct_funcs
[
t
](
ws
)
for
t
,
ws
in
zip
(
type_i
,
ws_i
)])
P
=
np
.
array
([
self
.
power_funcs
[
t
](
ws
)
for
t
,
ws
in
zip
(
type_i
,
ws_i
)])
P
=
np
.
array
([
self
.
power_funcs
[
t
](
ws
)
for
t
,
ws
in
zip
(
type_i
,
ws_i
)])
# for t in np.unique(type_i).astype(int):
# m = type_i == t
# CT[m] = self.ct_funcs[t](ws_i[m])
# P[m] = self.power_funcs[t](ws_i[m])
return
CT
,
P
return
CT
,
P
else
:
else
:
return
self
.
ct_funcs
[
0
](
ws_i
),
self
.
power_funcs
[
0
](
ws_i
)
return
self
.
ct_funcs
[
t
[
0
]
](
ws_i
),
self
.
power_funcs
[
t
[
0
]
](
ws_i
)
def
set_gradient_funcs
(
self
,
power_grad_funcs
,
ct_grad_funcs
):
def
set_gradient_funcs
(
self
,
power_grad_funcs
,
ct_grad_funcs
):
def
add_grad
(
f_lst
,
df_lst
):
def
add_grad
(
f_lst
,
df_lst
):
...
...
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