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
6e9d7855
Commit
6e9d7855
authored
9 years ago
by
mads
Browse files
Options
Downloads
Patches
Plain Diff
New log_shear fit method not relying on optimization
parent
f79f159e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/wind/shear.py
+16
-13
16 additions, 13 deletions
wetb/wind/shear.py
wetb/wind/tests/test_Shear.py
+4
-1
4 additions, 1 deletion
wetb/wind/tests/test_Shear.py
with
20 additions
and
14 deletions
wetb/wind/shear.py
+
16
−
13
View file @
6e9d7855
...
...
@@ -41,7 +41,7 @@ def power_shear(alpha, z_ref, u_ref, z):
def
fit_power_shear
(
z_u_lst
):
"""
Estimate power shear parameter, alpha, from
a
mean wind
of two
height
s
"""
Estimate power shear parameter, alpha, from
the
mean wind
at hub height and one additional
height
Parameters
----------
...
...
@@ -67,17 +67,17 @@ def fit_power_shear(z_u_lst):
return
alpha
def
fit_power_shear_ref
(
z_u_lst
,
z_ref
):
"""
Estimate power shear parameter, alpha, f
o
r specifi
ed
reference height
"""
Estimate power shear parameter, alpha, fr
om two or morea
specifi
c
reference height
using polynomial fit.
Parameters
----------
z_u_lst : [(z1, u_z1), (z2, u_z2),...]
- z1: Some height
- z1
_ref
: Wind speeds or mean wind speed at z1
-
u_
z1: Wind speeds or mean wind speed at z1
- z2: another height
- u_z2: Wind speeds or mean wind speeds at z
1
- u_z2: Wind speeds or mean wind speeds at z
2
z_ref : float or int
Reference height
Reference height
(hub height)
Returns
-------
...
...
@@ -94,7 +94,7 @@ def fit_power_shear_ref(z_u_lst, z_ref):
def
shear_error
(
x
,
z_u_lst
,
z_ref
):
alpha
,
u_ref
=
x
return
np
.
sum
([(
np
.
mean
(
u
)
-
u_ref
*
(
z
/
z_ref
)
**
alpha
)
**
2
for
z
,
u
in
z_u_lst
])
return
fmin
(
shear_error
,
(.
5
,
10
),
(
z_u_lst
,
z_ref
),
disp
=
False
)
return
fmin
(
shear_error
,
(.
1
,
10
),
(
z_u_lst
,
z_ref
),
disp
=
False
)
...
...
@@ -150,9 +150,9 @@ def fit_log_shear(z_u_lst):
----------
z_u_lst : [(z1, u_z1), (z2, u_z2),...]
- z1: Some height
- z1
_ref
: Wind speeds or mean wind speed at z1
-
u_
z1: Wind speeds or mean wind speed at z1
- z2: another height
- u_z2: Wind speeds or mean wind speeds at z
1
- u_z2: Wind speeds or mean wind speeds at z
2
Returns
-------
...
...
@@ -166,9 +166,12 @@ def fit_log_shear(z_u_lst):
>>>
fit_log_shear
([(
85
,
8.88131
),
(
21
,
4.41832
)],
87.13333
)
[
0.49938238
8.99192568
]
"""
def
shear_error
(
x
,
z_u_lst
):
u_star
,
z0
=
x
return
np
.
sum
([(
np
.
mean
(
u
)
-
log_shear
(
u_star
,
z0
,
z
))
**
2
for
z
,
u
in
z_u_lst
])
return
fmin
(
shear_error
,
(
1
,
1
),
(
z_u_lst
,),
disp
=
False
)
# def shear_error(x, z_u_lst):
# u_star, z0 = x
# return np.sum([(np.mean(u) - log_shear(u_star, z0, z)) ** 2 for z, u in z_u_lst])
# return fmin(shear_error, (1, 1), (z_u_lst,), disp=False)
z
,
U
=
_z_u
(
z_u_lst
)
a
,
b
=
np
.
polyfit
(
np
.
log
(
z
),
U
,
1
)
kappa
=
0.4
return
a
*
kappa
,
np
.
exp
(
-
b
/
a
)
#, sum((U - (a * np.log(z) + b)) ** 2)
This diff is collapsed.
Click to expand it.
wetb/wind/tests/test_Shear.py
+
4
−
1
View file @
6e9d7855
...
...
@@ -143,7 +143,10 @@ class TestMannTurbulence(unittest.TestCase):
if
0
:
for
z
,
u
in
zu
:
plt
.
plot
(
u
,
z
,
'
r.
'
)
z
=
np
.
arange
(
10
,
100
)
z
=
np
.
arange
(
10
,
100
)
plt
.
plot
(
log_shear
(
u_star
,
z0
,
z
),
z
)
show
()
for
_zu
,
b
in
zip
(
zu
,
log_shear
(
u_star
,
z0
,
[
85
,
21
])):
self
.
assertAlmostEqual
(
_zu
[
1
],
b
,
4
)
...
...
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