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
78e39b30
Commit
78e39b30
authored
6 years ago
by
Mikkel Friis-Møller
Browse files
Options
Downloads
Patches
Plain Diff
Changed 1.1 to a variable; pad with a default value of 1.1.
parent
f513e4af
No related branches found
No related tags found
1 merge request
!94
Handle disabled mpi
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
topfarm/utils.py
+11
-10
11 additions, 10 deletions
topfarm/utils.py
with
11 additions
and
10 deletions
topfarm/utils.py
+
11
−
10
View file @
78e39b30
...
...
@@ -46,29 +46,30 @@ def latest_id(case_recorder_dir):
return
latest
def
random_positions
(
boundary
,
n_wt
,
n_iter
,
step_size
,
min_space
,
plot
=
False
,
verbose
=
True
):
def
random_positions
(
boundary
,
n_wt
,
n_iter
,
step_size
,
min_space
,
pad
=
1.1
,
plot
=
False
,
verbose
=
True
):
'''
Input:
boundary: list of tuples, e.g.: [(0, 0), (6, 1), (7, -11), (-1, -10)]
n_wt: number of wind turbines
n_iter: number of iterations allowed to try and satisfy the minimum
spacing constraint
step_size: the multiplier on the gradient that the turbines
are moved
in each step
step_size: the multiplier on the
spacing
gradient that the turbines
are moved
in each step
min_space: the minimum spacing between turbines
pad: the multiplier on the boundary gradient
plot: plot the generated random layout
verbose: print helpful text to the console
Returns an array of xy coordinates of the wind turbines
'''
x
,
y
=
map
(
_random
,
np
.
array
(
boundary
).
T
)
turbines
=
_random_positions
(
x
,
y
,
boundary
,
n_wt
,
n_iter
,
step_size
,
min_space
,
plot
,
verbose
)
min_space
,
pad
,
plot
,
verbose
)
return
turbines
def
_random_positions
(
x
,
y
,
boundary
,
n_wt
,
n_iter
,
step_size
,
min_space
,
plot
,
verbose
):
pad
,
plot
,
verbose
):
boundary_comp
=
PolygonBoundaryComp
(
boundary
,
n_wt
)
spacing_comp
=
SpacingComp
(
nTurbines
=
n_wt
)
turbineX
=
copy
(
x
)
...
...
@@ -89,7 +90,7 @@ def _random_positions(x, y, boundary, n_wt, n_iter, step_size, min_space,
turbineX
+=
dx
[
index
]
*
step_size
turbineY
+=
dy
[
index
]
*
step_size
turbineX
,
turbineY
=
_contain
(
n_wt
,
turbineX
,
turbineY
,
boundary_comp
)
boundary_comp
,
pad
)
else
:
if
verbose
:
print
(
'
Obtained required spacing after {} iterations
'
.
format
(
...
...
@@ -110,7 +111,7 @@ def _random(b):
return
np
.
random
.
rand
(
n_wt
)
*
(
max
(
b
)
-
min
(
b
))
+
min
(
b
)
def
_contain
(
n_wt
,
turbineX
,
turbineY
,
boundary_comp
):
def
_contain
(
n_wt
,
turbineX
,
turbineY
,
boundary_comp
,
pad
):
for
i
in
range
(
0
,
n_wt
):
dng
=
boundary_comp
.
calc_distance_and_gradients
(
turbineX
,
turbineY
)
...
...
@@ -118,8 +119,8 @@ def _contain(n_wt, turbineX, turbineY, boundary_comp):
if
dist
<
0
:
dx
=
dng
[
1
][
i
]
dy
=
dng
[
2
][
i
]
turbineX
[
i
]
-=
dx
*
dist
*
1.1
turbineY
[
i
]
-=
dy
*
dist
*
1.1
turbineX
[
i
]
-=
dx
*
dist
*
pad
turbineY
[
i
]
-=
dy
*
dist
*
pad
return
turbineX
,
turbineY
...
...
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