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
a7c2afda
Commit
a7c2afda
authored
4 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
add test utilizing multiprocessing to calculate aep
parent
d05f9552
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_wind_farm_models/test_parallel_aep.py
+30
-0
30 additions, 0 deletions
py_wake/tests/test_wind_farm_models/test_parallel_aep.py
with
30 additions
and
0 deletions
py_wake/tests/test_wind_farm_models/test_parallel_aep.py
0 → 100644
+
30
−
0
View file @
a7c2afda
import
multiprocessing
from
py_wake.examples.data.hornsrev1
import
HornsrevV80
,
Hornsrev1Site
,
wt_x
,
wt_y
from
py_wake
import
IEA37SimpleBastankhahGaussian
from
py_wake.tests.check_speed
import
timeit
import
numpy
as
np
from
py_wake.tests
import
npt
wt
=
HornsrevV80
()
site
=
Hornsrev1Site
()
wf_model
=
IEA37SimpleBastankhahGaussian
(
site
,
wt
)
wd_lst
=
np
.
arange
(
0
,
360
)
def
aep_wd
(
args
):
x
,
y
,
wd
=
args
return
wf_model
(
x
,
y
,
wd
=
wd
,
ws
=
None
).
aep
()
def
aep_all_multiprocessing
(
pool
,
x
,
y
):
return
np
.
sum
(
pool
.
map
(
aep_wd
,
[(
x
,
y
,
i
)
for
i
in
wd_lst
]))
def
test_multiprocessing
():
pool
=
multiprocessing
.
Pool
()
aep1
,
t_lst1
=
timeit
(
aep_wd
,
min_runs
=
1
)((
wt_x
,
wt_y
,
wd_lst
))
aep2
,
t_lst2
=
timeit
(
aep_all_multiprocessing
,
min_runs
=
1
)(
pool
,
wt_x
,
wt_y
)
t1
,
t2
=
np
.
mean
(
t_lst1
),
np
.
mean
(
t_lst2
)
print
(
"
1 CPU: %.2fs, %d CPUs: %.2fs, speedup: %d%%
"
%
(
t1
,
pool
.
_processes
,
t2
,
(
t1
-
t2
)
/
t1
*
100
))
npt
.
assert_almost_equal
(
aep1
,
aep2
)
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