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
3188ee93
Commit
3188ee93
authored
7 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
updates in htc file
parent
f2c487fa
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
wetb/hawc2/htc_contents.py
+30
-5
30 additions, 5 deletions
wetb/hawc2/htc_contents.py
wetb/hawc2/htc_file.py
+19
-1
19 additions, 1 deletion
wetb/hawc2/htc_file.py
wetb/hawc2/tests/test_htc_file.py
+19
-0
19 additions, 0 deletions
wetb/hawc2/tests/test_htc_file.py
with
68 additions
and
6 deletions
wetb/hawc2/htc_contents.py
+
30
−
5
View file @
3188ee93
...
...
@@ -14,6 +14,7 @@ from builtins import zip
from
builtins
import
int
from
builtins
import
str
from
future
import
standard_library
import
os
standard_library
.
install_aliases
()
from
collections
import
OrderedDict
import
collections
...
...
@@ -119,8 +120,8 @@ class HTCContents(object):
ending
=
"
__%d
"
%
(
1
+
float
(
"
0%s
"
%
ending
.
replace
(
"
__
"
,
""
)))
self
[
contents
.
name_
+
ending
]
=
contents
def
add_section
(
self
,
name
,
allow_duplicate
_section
=
False
):
if
name
in
self
and
allow_duplicate
_section
is
False
:
def
add_section
(
self
,
name
,
allow_duplicate
=
False
):
if
name
in
self
and
allow_duplicate
is
False
:
return
self
[
name
]
section
=
HTCSection
(
name
)
self
.
_add_contents
(
section
)
...
...
@@ -363,8 +364,9 @@ class HTCDefaults(object):
def
add_mann_turbulence
(
self
,
L
=
29.4
,
ae23
=
1
,
Gamma
=
3.9
,
seed
=
1001
,
high_frq_compensation
=
True
,
filenames
=
None
,
no_grid_points
=
(
4096
,
32
,
32
),
box_dimension
=
(
6000
,
100
,
100
),
std_scaling
=
(
1
,
.
8
,
.
5
)):
no_grid_points
=
(
16384
,
32
,
32
),
box_dimension
=
(
6000
,
100
,
100
),
dont_scale
=
False
,
std_scaling
=
None
):
wind
=
self
.
add_section
(
'
wind
'
)
wind
.
turb_format
=
1
mann
=
wind
.
add_section
(
'
mann
'
)
...
...
@@ -383,15 +385,38 @@ class HTCDefaults(object):
setattr
(
mann
,
'
filename_%s
'
%
c
,
filename
)
for
c
,
n
,
dim
in
zip
([
'
u
'
,
'
v
'
,
'
w
'
],
no_grid_points
,
box_dimension
):
setattr
(
mann
,
'
box_dim_%s
'
%
c
,
"
%d %.4f
"
%
(
n
,
dim
/
(
n
-
1
)))
if
std
_scal
ing
is
Non
e
:
if
dont
_scale
:
mann
.
dont_scale
=
1
else
:
try
:
del
mann
.
dont_scale
except
KeyError
:
pass
if
std_scaling
is
not
None
:
mann
.
std_scaling
=
"
%f %f %f
"
%
std_scaling
else
:
try
:
del
mann
.
std_scaling
except
KeyError
:
pass
def
add_turb_export
(
self
,
filename
=
"
export_%s.turb
"
,
samplefrq
=
None
):
exp
=
self
.
wind
.
add_section
(
'
turb_export
'
,
allow_duplicate
=
True
)
for
uvw
in
'
uvw
'
:
exp
.
add_line
(
'
filename_%s
'
%
uvw
,
[
filename
%
uvw
])
sf
=
samplefrq
or
max
(
1
,
int
(
self
.
wind
.
mann
.
box_dim_u
[
1
]
/
(
self
.
wind
.
wsp
[
0
]
*
self
.
deltat
())))
exp
.
samplefrq
=
sf
if
"
time
"
in
self
.
output
:
exp
.
time_start
=
self
.
output
.
time
[
0
]
else
:
exp
.
time_start
=
0
exp
.
nsteps
=
(
self
.
simulation
.
time_stop
[
0
]
-
exp
.
time_start
[
0
])
/
self
.
deltat
()
for
vw
in
'
vw
'
:
exp
.
add_line
(
'
box_dim_%s
'
%
vw
,
self
.
wind
.
mann
[
'
box_dim_%s
'
%
vw
].
values
)
def
import_dtu_we_controller_input
(
self
,
filename
):
dtu_we_controller
=
[
dll
for
dll
in
self
.
dll
if
dll
.
name
[
0
]
==
'
dtu_we_controller
'
][
0
]
...
...
This diff is collapsed.
Click to expand it.
wetb/hawc2/htc_file.py
+
19
−
1
View file @
3188ee93
...
...
@@ -197,7 +197,7 @@ class HTCFile(HTCContents, HTCDefaults):
with
open
(
filename
,
'
w
'
,
encoding
=
'
cp1252
'
)
as
fid
:
fid
.
write
(
str
(
self
))
def
set_name
(
self
,
name
,
htc_folder
=
"
htc
"
,
log_folder
=
"
log
"
,
res_folder
=
"
res
"
):
def
set_name
(
self
,
name
,
htc_folder
=
"
htc
"
,
log_folder
=
"
log
"
,
res_folder
=
"
res
"
,
animation_folder
=
'
animation
'
,
visualization_folder
=
"
visualization
"
):
#if os.path.isabs(folder) is False and os.path.relpath(folder).startswith("htc" + os.path.sep):
self
.
contents
#load if not loaded
fmt_folder
=
lambda
folder
:
"
./
"
+
os
.
path
.
relpath
(
folder
).
replace
(
"
\\
"
,
"
/
"
)
...
...
@@ -207,6 +207,10 @@ class HTCFile(HTCContents, HTCDefaults):
self
.
simulation
.
logfile
=
os
.
path
.
join
(
fmt_folder
(
log_folder
),
"
%s.log
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
elif
'
test_structure
'
in
self
and
'
logfile
'
in
self
.
test_structure
:
# hawc2aero
self
.
test_structure
.
logfile
=
os
.
path
.
join
(
fmt_folder
(
log_folder
),
"
%s.log
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
if
'
simulation
'
in
self
and
'
animation
'
in
self
.
simulation
:
self
.
simulation
.
animation
=
os
.
path
.
join
(
fmt_folder
(
animation_folder
),
"
%s.dat
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
if
'
simulation
'
in
self
and
'
visualization
'
in
self
.
simulation
:
self
.
simulation
.
visualization
=
os
.
path
.
join
(
fmt_folder
(
visualization_folder
),
"
%s.hdf5
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
self
.
output
.
filename
=
os
.
path
.
join
(
fmt_folder
(
res_folder
),
"
%s
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
def
set_time
(
self
,
start
=
None
,
stop
=
None
,
step
=
None
):
...
...
@@ -354,6 +358,20 @@ class HTCFile(HTCContents, HTCDefaults):
if
errorcode
or
'
Elapsed time
'
not
in
log
:
raise
Exception
(
str
(
stdout
)
+
str
(
stderr
))
def
deltat
(
self
):
return
self
.
simulation
.
newmark
.
deltat
[
0
]
def
get_body
(
self
,
name
):
lst
=
[
b
for
b
in
self
.
new_htc_structure
if
b
.
name_
==
"
main_body
"
and
b
.
name
[
0
]
==
name
]
if
len
(
lst
)
==
1
:
return
lst
[
0
]
else
:
if
len
(
lst
)
==
0
:
raise
ValueError
(
"
Body
'
%s
'
not found
"
%
name
)
else
:
raise
NotImplementedError
()
class
H2aeroHTCFile
(
HTCFile
):
def
__init__
(
self
,
filename
=
None
,
modelpath
=
None
):
...
...
This diff is collapsed.
Click to expand it.
wetb/hawc2/tests/test_htc_file.py
+
19
−
0
View file @
3188ee93
...
...
@@ -159,6 +159,25 @@ class TestHtcFile(unittest.TestCase):
self
.
assertEqual
(
a
.
strip
(),
b
.
strip
())
self
.
assertEqual
(
htcfile
.
wind
.
turb_format
[
0
],
1
)
self
.
assertEqual
(
htcfile
.
wind
.
turb_format
.
comments
,
""
)
def
test_add_turb_export
(
self
):
htc
=
HTCFile
()
htc
.
add_mann_turbulence
(
30.1
,
1.1
,
3.3
,
102
,
False
)
htc
.
set_time
(
100
,
700
,
0.02
)
htc
.
add_turb_export
()
s
=
"""
begin turb_export;
filename_u
\t
export_u.turb;
filename_v
\t
export_v.turb;
filename_w
\t
export_w.turb;
samplefrq
\t
7;
time_start
\t
100;
nsteps
\t
30000.0;
box_dim_v
\t
32 3.2258;
box_dim_w
\t
32 3.2258;
end turb_export;
"""
for
a
,
b
in
zip
(
s
.
split
(
"
\n
"
),
str
(
htc
.
wind
.
turb_export
).
split
(
"
\n
"
)):
self
.
assertEqual
(
a
.
strip
(),
b
.
strip
())
def
test_sensors
(
self
):
...
...
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