Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
toolbox
WindEnergyToolbox
Commits
3893e7aa
Commit
3893e7aa
authored
8 years ago
by
tlbl
Browse files
Options
Downloads
Patches
Plain Diff
controller:adding selection of regions and Komega2
parent
0e0e25d9
No related branches found
No related tags found
1 merge request
!14
Controller functions
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/control/control.py
+35
-0
35 additions, 0 deletions
wetb/control/control.py
wetb/control/tests/test_control.py
+64
-0
64 additions, 0 deletions
wetb/control/tests/test_control.py
with
99 additions
and
0 deletions
wetb/control/control.py
+
35
−
0
View file @
3893e7aa
...
...
@@ -78,6 +78,41 @@ class Control(object):
return
kp
,
ki
,
K1
,
K2
def
K_omega2
(
V
,
P
,
R
,
TSR
):
Va
=
np
.
array
(
V
)
Pa
=
np
.
array
(
P
)
Ra
=
np
.
array
(
R
)
TSRa
=
np
.
array
(
TSR
)
K
=
Ra
**
3
*
np
.
mean
(
Pa
/
(
TSRa
*
Va
)
**
3
)
return
K
def
select_regions
(
self
,
pitch
,
omega
,
power
):
i12
=
0
n
=
len
(
pitch
)
for
i
in
range
(
n
-
1
):
if
(
abs
(
power
[
i
]
/
power
[
i
+
1
]
-
1.
)
>
0.01
):
if
(
abs
(
omega
[
i
]
/
omega
[
i
+
1
]
-
1.
)
>
0.01
):
i12
=
i
break
i23
=
n
-
1
for
i
in
range
(
i12
,
n
-
1
):
if
(
abs
(
omega
[
i
]
/
omega
[
i
+
1
]
-
1.
)
<
0.01
):
i23
=
i
break
i34
=
i23
for
i
in
range
(
i23
,
n
-
1
):
if
(
abs
(
power
[
i
]
/
power
[
i
+
1
]
-
1.
)
>
0.01
):
if
(
abs
(
omega
[
i
]
/
omega
[
i
+
1
]
-
1.
)
<
0.01
):
i34
=
i
+
1
return
i12
,
i23
,
i34
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
wetb/control/tests/test_control.py
+
64
−
0
View file @
3893e7aa
...
...
@@ -66,6 +66,70 @@ class TestControl(unittest.TestCase):
self
.
assertEqual
(
K1
,
10.01111637532056
)
self
.
assertEqual
(
K2
,
599.53659803157643
)
def
test_regions
(
self
):
crt
=
control
.
Control
()
pitch
=
np
.
array
([
0.
,
-
2.
,
-
2.
,
-
2.
,
-
2.
,
-
2.
,
-
2.
,
-
1.
,
0.
,
])
omega
=
np
.
array
([
1.
,
1.
,
1.
,
2.
,
3.
,
3.
,
3.
,
3.
,
3.
,
])
power
=
np
.
array
([
1.
,
2.
,
3.
,
4.
,
5.
,
6.
,
7.
,
7.
,
7.
,
])
istart
,
iend
=
0
,
-
1
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
2
)
self
.
assertEqual
(
i2
,
4
)
self
.
assertEqual
(
i3
,
6
)
istart
,
iend
=
3
,
-
1
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
1
)
self
.
assertEqual
(
i3
,
3
)
istart
,
iend
=
5
,
-
1
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
0
)
self
.
assertEqual
(
i3
,
1
)
istart
,
iend
=
6
,
-
1
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
0
)
self
.
assertEqual
(
i3
,
0
)
istart
,
iend
=
5
,
-
2
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
0
)
self
.
assertEqual
(
i3
,
1
)
istart
,
iend
=
3
,
-
3
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
1
)
self
.
assertEqual
(
i3
,
2
)
istart
,
iend
=
2
,
-
4
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
2
)
self
.
assertEqual
(
i3
,
2
)
istart
,
iend
=
0
,
3
i1
,
i2
,
i3
=
crt
.
select_regions
(
pitch
[
istart
:
iend
],
omega
[
istart
:
iend
],
power
[
istart
:
iend
])
self
.
assertEqual
(
i1
,
0
)
self
.
assertEqual
(
i2
,
0
)
self
.
assertEqual
(
i3
,
2
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
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