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
21105c06
Commit
21105c06
authored
1 year ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
Fix failing notebook, combinemodels.ipynb
parent
3df40a91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/notebooks/exercises/CombineModels.ipynb
+2
-1
2 additions, 1 deletion
docs/notebooks/exercises/CombineModels.ipynb
with
2 additions
and
1 deletion
docs/notebooks/exercises/CombineModels.ipynb
+
2
−
1
View file @
21105c06
...
...
@@ -48,7 +48,8 @@
"from py_wake.superposition_models import *\n",
"from py_wake.deflection_models import *\n",
"from py_wake.turbulence_models import *\n",
"from py_wake.ground_models import *"
"from py_wake.ground_models import *\n",
"from py_wake.deficit_models.utils import *"
]
},
{
...
...
%% Cell type:markdown id: tags:
# Experiment: Combine Models
In this notebook, you can combine the difference models of PyWake and see the effects in terms of AEP and a flow map.
%% Cell type:markdown id: tags:
**Install PyWake if needed**
%% Cell type:code id: tags:
```
python
# Install PyWake if needed
try
:
import
py_wake
except
ModuleNotFoundError
:
!
pip
install
git
+
https
:
//
gitlab
.
windenergy
.
dtu
.
dk
/
TOPFARM
/
PyWake
.
git
```
%% Cell type:markdown id: tags:
**Now we also import all available models**
%% Cell type:code id: tags:
```
python
from
py_wake.deficit_models
import
*
from
py_wake.wind_farm_models
import
*
from
py_wake.rotor_avg_models
import
*
from
py_wake.superposition_models
import
*
from
py_wake.deflection_models
import
*
from
py_wake.turbulence_models
import
*
from
py_wake.ground_models
import
*
from
py_wake.deficit_models.utils
import
*
```
%% Cell type:markdown id: tags:
**Then, we set up the site, wind turbines as well as their initial positions**
.
%% Cell type:code id: tags:
```
python
from
py_wake.examples.data.iea37._iea37
import
IEA37Site
,
IEA37_WindTurbines
site
=
IEA37Site
(
16
)
windTurbines
=
IEA37_WindTurbines
()
x
,
y
=
site
.
initial_position
.
T
```
%% Cell type:code id: tags:
```
python
# prepare for the model combination tool
from
py_wake.utils.model_utils
import
get_models
,
get_signature
from
ipywidgets
import
interact
from
IPython.display
import
HTML
,
display
,
Javascript
import
time
import
matplotlib.pyplot
as
plt
# Fix ipywidget label width
display
(
HTML
(
'''
<style>.widget-label { min-width: 20ex !important; }</style>
'''
))
def
print_signature
(
windFarmModel
,
**
kwargs
):
s
=
"""
# windFarmModel autogenerated by dropdown boxes
t = time.time()
wfm = %s
sim_res = wfm(x,y)
plt.figure(figsize=(12,8))
sim_res.flow_map(wd=270).plot_wake_map()
print (wfm)
print (
"
Computation time (AEP + flowmap):
"
, time.time()-t)
plt.title(
'
AEP: %%.2fGWh
'
%%(sim_res.aep().sum()))
"""
%
get_signature
(
windFarmModel
,
kwargs
,
1
)
# Write windFarmModel code to cell starting "# windFarmModel autogenerated by dropdown boxes"
display
(
Javascript
(
"""
for (var cell of IPython.notebook.get_cells()) {
if (cell.get_text().startsWith(
"
# windFarmModel autogenerated by dropdown boxes
"
)){
cell.set_text(`%s`);
cell.execute();
}
}
"""
%
s
))
# setup list of models
models
=
{
n
:[(
getattr
(
m
,
'
__name__
'
,
m
),
m
)
for
m
in
get_models
(
cls
)]
for
n
,
cls
in
[(
'
windFarmModel
'
,
WindFarmModel
),
(
'
wake_deficitModel
'
,
WakeDeficitModel
),
(
'
rotorAvgModel
'
,
RotorAvgModel
),
(
'
superpositionModel
'
,
SuperpositionModel
),
(
'
blockage_deficitModel
'
,
BlockageDeficitModel
),
(
'
deflectionModel
'
,
DeflectionModel
),
(
'
turbulenceModel
'
,
TurbulenceModel
),
(
'
groundModel
'
,
GroundModel
)
]}
```
%% Output
%% Cell type:markdown id: tags:
### Combine and execute model
Combine your model via the dropdown boxes below.
Choosing a different model updates and executes the the code cell below which runs the wind farm model, prints the AEP and plots a flow map.
%% Cell type:code id: tags:
```
python
_
=
interact
(
print_signature
,
**
models
)
```
%% Output
%% Cell type:code id: tags:
```
python
# windFarmModel autogenerated by dropdown boxes
t
=
time
.
time
()
wfm
=
PropagateDownwind
(
site
,
windTurbines
,
wake_deficitModel
=
NOJDeficit
(
k
=
0.1
,
rotorAvgModel
=
AreaOverlapAvgModel
(),
groundModel
=
None
),
superpositionModel
=
LinearSum
(),
deflectionModel
=
None
,
turbulenceModel
=
None
,
rotorAvgModel
=
None
)
sim_res
=
wfm
(
x
,
y
)
plt
.
figure
(
figsize
=
(
12
,
8
))
sim_res
.
flow_map
(
wd
=
270
).
plot_wake_map
()
print
(
wfm
)
print
(
"
Computation time (AEP + flowmap):
"
,
time
.
time
()
-
t
)
plt
.
title
(
'
AEP: %.2fGWh
'
%
(
sim_res
.
aep
().
sum
()))
```
%% Output
PropagateDownwind(EngineeringWindFarmModel, NOJDeficit-wake, LinearSum-superposition)
Computation time (AEP + flowmap): 1.170867681503296
Text(0.5, 1.0, 'AEP: 355.83GWh')
...
...
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