Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TopFarm2
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
TopFarm2
Commits
3ee7f5bf
Commit
3ee7f5bf
authored
3 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
add dAEP_dxy as cost_gradient_function in PyWakeAEPCostModelComponent
parent
dcc9204b
No related branches found
No related tags found
1 merge request
!175
add dAEP_dxy as cost_gradient_function in PyWakeAEPCostModelComponent
Pipeline
#29593
passed
3 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/docs/example_2_wake_comparison.py
+2
-1
2 additions, 1 deletion
examples/docs/example_2_wake_comparison.py
topfarm/cost_models/py_wake_wrapper.py
+23
-7
23 additions, 7 deletions
topfarm/cost_models/py_wake_wrapper.py
with
25 additions
and
8 deletions
examples/docs/example_2_wake_comparison.py
+
2
−
1
View file @
3ee7f5bf
...
@@ -58,7 +58,8 @@ def main():
...
@@ -58,7 +58,8 @@ def main():
def
get_tf
(
windFarmModel
):
def
get_tf
(
windFarmModel
):
return
TopFarmProblem
(
return
TopFarmProblem
(
design_vars
=
dict
(
zip
(
'
xy
'
,
init_pos
.
T
)),
design_vars
=
dict
(
zip
(
'
xy
'
,
init_pos
.
T
)),
cost_comp
=
PyWakeAEPCostModelComponent
(
windFarmModel
,
n_wt
=
3
,
ws
=
10
,
wd
=
np
.
arange
(
0
,
360
,
12
)),
cost_comp
=
PyWakeAEPCostModelComponent
(
windFarmModel
,
n_wt
=
3
,
ws
=
10
,
wd
=
np
.
arange
(
0
,
360
,
12
),
grad_method
=
None
),
constraints
=
[
SpacingConstraint
(
min_spacing
),
constraints
=
[
SpacingConstraint
(
min_spacing
),
XYBoundaryConstraint
(
boundary
)],
XYBoundaryConstraint
(
boundary
)],
driver
=
EasyScipyOptimizeDriver
(),
driver
=
EasyScipyOptimizeDriver
(),
...
...
This diff is collapsed.
Click to expand it.
topfarm/cost_models/py_wake_wrapper.py
+
23
−
7
View file @
3ee7f5bf
...
@@ -13,6 +13,7 @@ from scipy.interpolate.interpolate import RegularGridInterpolator
...
@@ -13,6 +13,7 @@ from scipy.interpolate.interpolate import RegularGridInterpolator
import
warnings
import
warnings
from
py_wake.flow_map
import
HorizontalGrid
from
py_wake.flow_map
import
HorizontalGrid
import
xarray
as
xr
import
xarray
as
xr
from
py_wake.utils.gradients
import
autograd
class
PyWakeAEP
(
AEPCalculator
):
class
PyWakeAEP
(
AEPCalculator
):
...
@@ -55,17 +56,32 @@ class PyWakeAEP(AEPCalculator):
...
@@ -55,17 +56,32 @@ class PyWakeAEP(AEPCalculator):
class
PyWakeAEPCostModelComponent
(
AEPCostModelComponent
):
class
PyWakeAEPCostModelComponent
(
AEPCostModelComponent
):
def
__init__
(
self
,
windFarmModel
,
n_wt
,
wd
=
None
,
ws
=
None
,
max_eval
=
None
,
**
kwargs
):
def
__init__
(
self
,
windFarmModel
,
n_wt
,
wd
=
None
,
ws
=
None
,
max_eval
=
None
,
grad_method
=
autograd
,
**
kwargs
):
self
.
windFarmModel
=
windFarmModel
self
.
windFarmModel
=
windFarmModel
def
aep
(
**
kwargs
):
return
self
.
windFarmModel
.
aep
(
x
=
kwargs
[
topfarm
.
x_key
],
y
=
kwargs
[
topfarm
.
y_key
],
h
=
kwargs
.
get
(
topfarm
.
z_key
,
None
),
type
=
kwargs
.
get
(
topfarm
.
type_key
,
0
),
wd
=
wd
,
ws
=
ws
)
if
grad_method
:
dAEPdxy
=
self
.
windFarmModel
.
dAEPdxy
(
grad_method
)
def
daep
(
**
kwargs
):
return
dAEPdxy
(
x
=
kwargs
[
topfarm
.
x_key
],
y
=
kwargs
[
topfarm
.
y_key
],
h
=
kwargs
.
get
(
topfarm
.
z_key
,
None
),
type
=
kwargs
.
get
(
topfarm
.
type_key
,
0
),
wd
=
wd
,
ws
=
ws
)
else
:
daep
=
None
AEPCostModelComponent
.
__init__
(
self
,
AEPCostModelComponent
.
__init__
(
self
,
input_keys
=
[
topfarm
.
x_key
,
topfarm
.
y_key
],
input_keys
=
[
topfarm
.
x_key
,
topfarm
.
y_key
],
n_wt
=
n_wt
,
n_wt
=
n_wt
,
cost_function
=
lambda
**
kwargs
:
self
.
windFarmModel
.
aep
(
cost_function
=
aep
,
x
=
kwargs
[
topfarm
.
x_key
],
cost_gradient_function
=
daep
,
y
=
kwargs
[
topfarm
.
y_key
],
h
=
kwargs
.
get
(
topfarm
.
z_key
,
None
),
type
=
kwargs
.
get
(
topfarm
.
type_key
,
0
),
wd
=
wd
,
ws
=
ws
),
output_unit
=
'
GWh
'
,
output_unit
=
'
GWh
'
,
max_eval
=
max_eval
,
**
kwargs
)
max_eval
=
max_eval
,
**
kwargs
)
...
...
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