Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • toolbox/WindEnergyToolbox
  • tlbl/WindEnergyToolbox
  • cpav/WindEnergyToolbox
  • frza/WindEnergyToolbox
  • borg/WindEnergyToolbox
  • mmpe/WindEnergyToolbox
  • ozgo/WindEnergyToolbox
  • dave/WindEnergyToolbox
  • mmir/WindEnergyToolbox
  • wluo/WindEnergyToolbox
  • welad/WindEnergyToolbox
  • chpav/WindEnergyToolbox
  • rink/WindEnergyToolbox
  • shfe/WindEnergyToolbox
  • shfe1/WindEnergyToolbox
  • acdi/WindEnergyToolbox
  • angl/WindEnergyToolbox
  • wliang/WindEnergyToolbox
  • mimc/WindEnergyToolbox
  • wtlib/WindEnergyToolbox
  • cmos/WindEnergyToolbox
  • fabpi/WindEnergyToolbox
22 results
Show changes
Commits on Source (894)
Showing with 522 additions and 211 deletions
*.bin filter=lfs diff=lfs merge=lfs -text
......@@ -18,4 +18,15 @@ wetb/hawc2/tests/test_files/htcfiles/tmp.htc
wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.sel
wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.dat
wetb/prepost/tests/data/demo_dlc/remote*
wetb/*/*/*.c
.cache/
tests/temp.htc
**/tmp/*
/wetb/fatigue_tools/rainflowcounting/compile.py
/docs/api
/htmlcov
/docs/build
/docs/source_old
.ipynb_checkpoints
/.pytest_cache/
before_script:
- apt-get update
image: dtuwindenergy/wetb
test-3.4:
image: mmpe/wetb
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- when: always
test:
image: continuumio/anaconda3:latest
stage:
test
# except:
# - test_pypi
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
#- git submodule sync --recursive
#- git submodule update --init --recursive
- python -m pip install .[all]
script:
- python3 -m pytest --cov-report term-missing:skip-covered --cov-report xml:coverage.xml --cov=wetb
tags:
- docker, linux, shared
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
# ===== build documentation =====
pages: # "pages" is a job specifically for GitLab pages [1]
stage: # build, test, deploy defined by default [2]
deploy
image: registry.windenergy.dtu.dk/hawc2/hawc2-binary/dockerimages/ubuntu_conda
script: # use sphinx to build docs, move to public page
- pip install --upgrade pip
- pip install sphinx --upgrade
- pip install sphinx sphinx_rtd_theme
- pip install nbsphinx==0.3.5
- pip install git+https://github.com/vidartf/nbsphinx-link.git
- pip install -e .
- cd docs; make html
- cd ../; mv docs/build/html public/
artifacts: # required for GitLab pages [1]
paths:
- public
only: # only run for these branches
- master
- /^test_doc.*/
tags: # only runners with this tag can do the job [3]
- python
allow_failure: true
# Deploy package to local repository
upload_package_local:
image: continuumio/anaconda3:latest
tags:
- docker, linux, shared
stage: deploy
needs:
- job: build_wheel
artifacts: true
- job: test
artifacts: false
script:
- pip install --upgrade twine packaging
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
rules:
- if: $CI_COMMIT_TAG != null
when: always
- if: $CI_COMMIT_BRANCH == "master"
when: always
- if: $CI_COMMIT_BRANCH != "master"
when: manual
allow_failure: true
# ===== BUILD WHEELS AND UPLOAD TO PYPI =====
upload_package_pypi:
image: continuumio/anaconda3:latest
tags:
- docker, linux, shared
stage: deploy
needs:
- job: build_wheel
artifacts: true
- job: test
artifacts: false
script:
- pip install --upgrade twine packaging
- twine upload dist/* -u $TWINE_USERNAME -p $TWINE_PASSWORD
only:
- tags
- test_pypi
build_wheel:
stage: build
tags:
- linux, docker, shared
image: registry.windenergy.dtu.dk/hawc2/hawc2-binary/dockerimages/ubuntu_conda
before_script:
- git config --global --add safe.directory ${CI_PROJECT_DIR}
script:
- python3 setup.py test
\ No newline at end of file
- pip wheel . --wheel-dir=dist
artifacts:
paths:
- dist/wetb*.whl
expire_in: "1d"
[submodule "TestFiles"]
path = TestFiles
url = https://gitlab.windenergy.dtu.dk/toolbox/TestFiles.git
[distutils]
index-servers=
pypi
#testpypi # include this line for testing
[testpypi]
#repository: https://test.pypi.org/legacy/ # use this line when testing
repository: https://upload.pypi.org/legacy/
username: DTUWindEnergy
Contributions
-------------
If you make a change in the toolbox, that others can benefit from please make a merge request.
If you can, please submit a merge request with the fix or improvements including tests.
The workflow to make a merge request is as follows:
-Create a feature branch, branch away from master
-Write tests and code
-Push the commit(s) to your fork
-Submit a merge request (MR) to the master branch of
-Link any relevant issues in the merge request description and leave a comment on them with a link back to the MR
-Your tests should run as fast as possible, and if it uses test files, these files should be as small as possible.
-Please keep the change in a single MR as small as possible. Split the functionality if you can
\ No newline at end of file
|build status| |coverage report|
Introduction
============
......@@ -11,106 +13,13 @@ example, some of the functions in the `prepost <#prepost>`__ module have
a similar functions in `Hawc2io <wetb/hawc2/Hawc2io.py>`__. These
different implementations will be merged in due time.
How to create HAWC2 DLB's and run them on a cluster
===================================================
The process of how to generated, run and post-process a design load
basis (DLB) of HAWC2 simulations on a DTU Wind Energy cluster is
outlined in more detail in the documentation:
- `Auto-generation of Design Load Cases <docs/howto-make-dlcs.md>`__
- `House rules mimer/hawc2sim and HAWC2 folder
structure <docs/houserules-mimerhawc2sim.md>`__
- `Generate DLB spreadsheets <docs/generate-spreadsheet.md>`__
- `How to use the Statistics DataFrame <docs/using-statistics-df.md>`__
You can also use the Pdap for post-processing, which includes a MS Word
report generator based on a full DLB, a GUI for easy plotting of HAWC2
result files, and a Python scripting interface:
- `Pdap <http://www.hawc2.dk/Download/Post-processing-tools/Pdap>`__
- `Pdap
report/docs <http://orbit.dtu.dk/en/publications/post-processing-of-design-load-cases-using-pdap%28827c432b-cf7d-44eb-899b-93e9c0648ca5%29.html>`__
Works with Python 2 and Python 3
================================
This module is tested for Python 2 and 3 compatibility, and works on
both Windows and Linux. Testing for Mac is on the way, but in theory it
should work. Python 2 and 3 compatibility is achieved with a single code
base with the help of the Python module
`future <http://python-future.org/index.html>`__.
Switching to Python 3 is in general a very good idea especially since
Python 3.5 was released. Some even dare to say it `is like eating your
vegetables <http://nothingbutsnark.svbtle.com/porting-to-python-3-is-like-eating-your-vegetables>`__.
So if you are still on Python 2, we would recommend you to give Python 3
a try!
You can automatically convert your code from Python 2 to 3 using the
`2to3 <https://docs.python.org/2/library/2to3.html>`__ utility which is
included in Python 2.7 by default. You can also write code that is
compatible with both 2 and 3 at the same time (you can find additional
resources in `issue
1 <https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/issues/1>`__).
Dependencies
============
- `numpy <http://www.numpy.org/>`__
- `cython <http://cython.org/>`__
- `scipy <http://scipy.org/scipylib/>`__
- `pandas <http://pandas.pydata.org/>`__
- xlrd and xlwt from `python-excel <http://www.python-excel.org/>`__
- `openpyxl <http://openpyxl.readthedocs.org/en/default/>`__
- h5py
- `matplotlib <http://matplotlib.org/>`__
- `pytables <http://www.pytables.org/>`__
- `pyscaffold <http://pyscaffold.readthedocs.org/en/>`__
- pytest, pytest-cov
- six, `future <http://python-future.org/index.html>`__
Both Python2 and Python3 are supported.
Installation
============
Detailed installation instructions, including how to install Python from
scratch, are described in the `detailed installation
manual <docs/install-manual-detailed.md>`__.
If you know what you are doing, you can install as a package as follows:
::
python setup.py install
Or in development mode, install from your working directory
::
pip install -e ./
Or create a binary wheel distribution package with:
::
python setup.py bdist_wheel -d dist
Tests
=====
Only a small part of the code is covered by unittests currently. More
tests are forthcoming.
- `Simple user <docs/install.md>`__
- `Developer/contributor <docs/developer-guide.md>`__
Contents of WindEnergyToolbox, `wetb <wetb>`__
==============================================
......@@ -140,6 +49,8 @@ Overview
layout) files
- `pc\_file <wetb/hawc2/pc_file.py>`__: Read PC (profile coefficient)
files
- `st\_file <wetb/hawc2/st_file.py>`__: Read ST (structural properties)
files
- `shear\_file <wetb/hawc2/shear_file.py>`__: Create user defined shear
file
- `at\_time\_file <wetb/hawc2/at_time_file.py>`__: Read at
......@@ -188,9 +99,14 @@ and create load envelopes.
Additional documentation can be found here:
- `Auto-generation of Design Load Cases <docs/howto-make-dlcs.md>`__
- `Getting started with DLBs <docs/getting-started-with-dlbs.md>`__
- `How to use the Statistics DataFrame <docs/using-statistics-df.md>`__
- `Generate DLB spreadsheets <docs/generate-spreadsheet.md>`__
- `Auto-generation of Design Load Cases <docs/howto-make-dlcs.md>`__
- `House rules for storing results on
``mimer/hawc2sim`` <docs/houserules-mimerhawc2sim.md>`__
- `How to use the Statistics
DataFrame <docs/using-statistics-df.md>`__
`fast <wetb/fast>`__
~~~~~~~~~~~~~~~~~~~~
......@@ -210,8 +126,7 @@ evaluating execution time of functions -
`caching <wetb/utils/caching.py>`__: Decorators to create cached
(calculate once) functions and properties
Note
====
This project has been set up using PyScaffold 2.5. For details and usage
information on PyScaffold see http://pyscaffold.readthedocs.org/.
.. |build status| image:: https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/badges/master/build.svg
:target: https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/commits/master
.. |coverage report| image:: https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/badges/master/coverage.svg
:target: https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/commits/master
[![build status](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/badges/master/build.svg)](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/commits/master)
[![coverage report](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/badges/master/coverage.svg)](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/commits/master)
[![pypi status](https://img.shields.io/pypi/v/wetb.png)](https://pypi.python.org/pypi/wetb)
# Introduction
The Wind Energy Toolbox (or ```wetb```, pronounce as wee-tee-bee) is a collection
......@@ -10,102 +14,15 @@ some of the functions in the [prepost](#prepost) module have a similar functions
in [Hawc2io](wetb/hawc2/Hawc2io.py). These different implementations will be
merged in due time.
# How to create HAWC2 DLB's and run them on a cluster
The process of how to generated, run and post-process a design load basis (DLB)
of HAWC2 simulations on a DTU Wind Energy cluster is outlined in more detail
in the documentation:
* [Auto-generation of Design Load Cases](docs/howto-make-dlcs.md)
* [House rules mimer/hawc2sim and HAWC2 folder structure](docs/houserules-mimerhawc2sim.md)
* [Generate DLB spreadsheets](docs/generate-spreadsheet.md)
* [How to use the Statistics DataFrame](docs/using-statistics-df.md)
You can also use the Pdap for post-processing, which includes a MS Word report
generator based on a full DLB, a GUI for easy plotting of HAWC2 result files,
and a Python scripting interface:
* [Pdap](http://www.hawc2.dk/Download/Post-processing-tools/Pdap)
* [Pdap report/docs](http://orbit.dtu.dk/en/publications/post-processing-of-design-load-cases-using-pdap%28827c432b-cf7d-44eb-899b-93e9c0648ca5%29.html)
# Works with Python 2 and Python 3
This module is tested for Python 2 and 3 compatibility, and works on both
Windows and Linux. Testing for Mac is on the way, but in theory it should work.
Python 2 and 3 compatibility is achieved with a single code base with the help
of the Python module [future](http://python-future.org/index.html).
Switching to Python 3 is in general a very good idea especially since Python 3.5
was released. Some even dare to say it
[is like eating your vegetables](http://nothingbutsnark.svbtle.com/porting-to-python-3-is-like-eating-your-vegetables).
So if you are still on Python 2, we would recommend you to give Python 3 a try!
You can automatically convert your code from Python 2 to 3 using the
[2to3](https://docs.python.org/2/library/2to3.html) utility which is included
in Python 2.7 by default. You can also write code that is compatible with both
2 and 3 at the same time (you can find additional resources in
[issue 1](https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/issues/1)).
# Dependencies
* [numpy](http://www.numpy.org/)
* [cython](http://cython.org/)
* [scipy](http://scipy.org/scipylib/)
* [pandas](http://pandas.pydata.org/)
* xlrd and xlwt from [python-excel](http://www.python-excel.org/)
* [openpyxl](http://openpyxl.readthedocs.org/en/default/)
* h5py
* [matplotlib](http://matplotlib.org/)
* [pytables](http://www.pytables.org/)
* [pyscaffold](http://pyscaffold.readthedocs.org/en/)
* pytest, pytest-cov
* six, [future](http://python-future.org/index.html)
Both Python2 and Python3 are supported.
# Installation
Detailed installation instructions, including how to install Python from scratch,
are described in the [detailed installation manual](docs/install-manual-detailed.md).
If you know what you are doing, you can install as a package as follows:
```
python setup.py install
```
Or in development mode, install from your working directory
See documentation.
```
pip install -e ./
```
# Documentation
Or create a binary wheel distribution package with:
```
python setup.py bdist_wheel -d dist
```
# Tests
Only a small part of the code is covered by unittests currently. More tests are
forthcoming.
[https://toolbox.pages.windenergy.dtu.dk/WindEnergyToolbox/](https://toolbox.pages.windenergy.dtu.dk/WindEnergyToolbox/)
# Contents of WindEnergyToolbox, [wetb](wetb)
......@@ -125,8 +42,9 @@ forthcoming.
- [Hawc2io](wetb/hawc2/Hawc2io.py): Read binary, ascii and flex result files
- [sel_file](wetb/hawc2/sel_file.py): Read/write *.sel (sensor list) files
- [htc_file](wetb/hawc2/htc_file.py): Read/write/manipulate htc files
- [ae_file](wetb/hawc2/ae_file.py): Read AE (aerodynamic blade layout) files
- [pc_file](wetb/hawc2/pc_file.py): Read PC (profile coefficient) files
- [ae_file](wetb/hawc2/ae_file.py): Read/write/manipulate AE (aerodynamic blade layout) files
- [pc_file](wetb/hawc2/pc_file.py): Read/write/manipulate PC (profile coefficient) files
- [st_file](wetb/hawc2/st_file.py): Read/write/manipulate ST (structural properties) files
- [shear_file](wetb/hawc2/shear_file.py): Create user defined shear file
- [at_time_file](wetb/hawc2/at_time_file.py): Read at output_at_time files
- [log_file](wetb/hawc2/log_file.py): Read and interpret log files
......@@ -157,10 +75,11 @@ load calculations, and create load envelopes.
Additional documentation can be found here:
* [Auto-generation of Design Load Cases](docs/howto-make-dlcs.md)
* [How to use the Statistics DataFrame](docs/using-statistics-df.md)
- [Getting started with DLBs](docs/getting-started-with-dlbs.md)
- [Generate DLB spreadsheets](docs/generate-spreadsheet.md)
- [Auto-generation of Design Load Cases](docs/howto-make-dlcs.md)
- [House rules for storing results on ```mimer/hawc2sim```](docs/houserules-mimerhawc2sim.md)
- [How to use the Statistics DataFrame](docs/using-statistics-df.md)
### [fast](wetb/fast)
Tools for working with NREL's FAST code (An aeroelastic computer-aided engineering (CAE) tool for horizontal axis wind turbines)
......@@ -173,9 +92,3 @@ Other functions
- [timing](wetb/utils/timing.py): Decorators for evaluating execution time of functions
- [caching](wetb/utils/caching.py): Decorators to create cached (calculate once) functions and properties
# Note
This project has been set up using PyScaffold 2.5. For details and usage
information on PyScaffold see http://pyscaffold.readthedocs.org/.
Subproject commit 167b16d8f1a26161ebc5a258c62389777d133489
FROM continuumio/anaconda3:latest
MAINTAINER Mikkel Friis-Møller <mikf@dtu.dk>
RUN apt-get update && \
apt-get install make && \
apt-get install libgl1-mesa-glx -y && \
apt-get install gcc gfortran -y
RUN conda update -y conda && \
conda install -y sphinx_rtd_theme && \
conda install setuptools_scm mock h5py pytables pytest pytest-cov nose sphinx blosc pbr paramiko && \
conda install scipy pandas matplotlib cython xlrd coverage xlwt openpyxl psutil pandoc twine pypandoc && \
conda install -c conda-forge pyscaffold sshtunnel --no-deps && \
conda clean -y --all
RUN pip install --upgrade pip && \
pip install --no-cache-dir git+https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox.git
# build image
docker build -t dtuwindenergy/wetb ./
# or pull from docker hub
# create container
docker create -it --name wetb dtuwindenergy/wetb
# start container
docker start wetb
# enter container with bash prompt
docker exec -it wetb bash
# push
docker push dtuwindenergy/wetb
#checkout single branch for testing:
git clone --single-branch --branch test_pypi https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox.git
#Copy local folder into docker container:
docker cp "C:\Sandbox\Git\WindEnergyToolbox\." wetb:/WETB/
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = TOPFARM
SOURCEDIR = .
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
docs/bladed/Bladed_airfoil.png

46.8 KiB

docs/bladed/Bladed_st_centers.png

43.6 KiB

docs/bladed/Bladed_turbine_coord.png

123 KiB

docs/bladed/HAWC2_c2_def_ccord.png

38.3 KiB

docs/bladed/HAWC2_st_centers.png

15.1 KiB

docs/bladed/HAWC2_turbine_coord.png

121 KiB

%% Cell type:markdown id: tags:
# Bladed to HAWC2 model conversion formulation
%% Cell type:markdown id: tags:
# Coordinate transformation: <br>
The parameters belonging to HAWC2 are showed by $*^H$ and the parameters belonging to Bladed are showed by $*^B$.
$ ----------------------------------$<br>
The blade root coordinate systems of the codes can be transfromed as:
\begin{equation}
\begin{bmatrix} x^H \\ y^H \\ z^H \end{bmatrix} = \begin{bmatrix} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x^B \\ y^B \\ z^B \end{bmatrix}
\end{equation}
The transformation matrix is called $R^{H2B}$.
$ ----------------------------------$<br>
The total rotation angle is expressed by $\theta_{CS}^{B}$ which is comupted as:<br>
$\theta_{CS}^{B}$ = -$\theta_p^B$ - $\beta_{\alpha}^B$ <br>
**BE CAREFUL !!!** -> Bladed positive pitch/twist definition are in negative z direction. <br>
Transformation matrix $R^{B2CS}$ from Bladed local cross-section coordinates to the rotor coordinate system. <br>
\begin{equation}
\begin{bmatrix} x^B \\ y^B \\ z^B \end{bmatrix} = \begin{bmatrix} cos(\theta_{CS}^{B}) & sin(\theta_{CS}^{B}) & 0 \\ -sin(\theta_{CS}^{B}) & cos(\theta_{CS}^{B}) & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x^B_{CS} \\ y^B_{CS} \\ z^B_{CS} \end{bmatrix}
\end{equation}
$ ----------------------------------$<br>
Total transformation from Bladed local coordinates to HAWC2 can be written as: <br>
\begin{equation}
\begin{bmatrix} x^H \\ y^H \\ z^H \end{bmatrix} = R^{H2B} R^{B2CS} \begin{bmatrix} x^B_{CS} \\ y^B_{CS} \\ z^B_{CS} \end{bmatrix}
\end{equation}
$ ----------------------------------$
%% Cell type:markdown id: tags:
## Center positions <br>
HAWC2 defines elastic, shear and mass center according to the half chord (*c2_def*) location in its st files
whereas Bladed measures center positions from leading edge position. The center positions ($x_{LE}^B$ and $y_{LE}^B$) can be defined with respect to the half chord ($x_{c2}^B$ and $y_{c2}^B$) in Bladed coordinate system as: <br>
$x_{c2}^B$ = $x_{LE}^B$ <br>
$y_{c2}^B$ = $y_{LE}^B$ - c/2 <br>
where *c* is the chord length. <br>
These coordinates can be transformed to HAWC2 coordinate system by multiplying them with $R^{H2B}$.
%% Cell type:markdown id: tags:
## Inertia conversion <br>
Bladed has total inertia value *Ip* and radius of gyration ratio *RGRATIO* in its input file. <br>
\begin{equation}
RGRATIO = \dfrac{RG_y}{RG_x}
\end{equation}
\begin{equation}
RG_x^2 = \dfrac{I_x}{m} \; , \; RG_y^2 = \dfrac{I_y}{m}
\end{equation}
where m is mass and $I_x$ is the mass moment of inertia with respect to x axis.
\begin{equation}
Ip = I_x + RGRATIO^2 \times I_x
\end{equation}
The *Ip* is defined with respec to mass center in Bladed whereas it is defined at elastic center in HAWC2. <br>
\begin{equation}
Ip^{ea} = Ip^{cg} + m \times (xyz^{cg} - xyz^{ea})^2
\end{equation}
**BE CAREFUL !!!** -> do not forget to transform inertia results from Bladed coordinate system to HAWC2 coordinate system.
********************************
BLADED to HAWC2 model conversion
********************************
**BLADED** is a tool developed by DNV, and ``wetb`` contains a basic reader that
can interpret a BLADED project file (.prj) and convert the data structures into
an equivalent set of **HAWC2** input files (htc, st, ae, pc).
================================
API and workflow
================================
---------------------------------
Read BLADED project file
---------------------------------
The input from a Bladed model is given in a project file (*prj*) and is formatted
in the XML definition. Within this file the core BLADED inputs are given in the
CDATA field and which according to the XML standards refer to Character Data,
see also `here <https://www.w3resource.com/xml/CDATA-sections.php>`_ and `here
<https://en.wikipedia.org/wiki/CDATA>`_ for a more detailed technical description.
Within the CDATA field a custom BLADED type markup definition is used. The ``wetb``
reader includes an interpreter for this custom BLADED markup and outputs this
data structure to the user as a nested dictionary, and which allows easy access
to all the different key/value pairs defined in the BLADED CDATA field. This
nested dictionary structure is accessible via the variable
``wetb.bladed.readprj.ReadBladedProject.bd``.
Outside the CDATA field the XML data is parsed via the ``lxml`` Python package,
and the entire XML object ``lxml.objectify.fromstring(str)`` is exposed to the user
via the ``wetb.bladed.readprj.ReadBladedProject.xmlroot`` variable.
In ``wetb` the
project file can be read using the following::
from wetb.bladed.readprj import ReadBladedProject
prj = ReadBladedProject('my_bladed_project_file.prj')
# XML object tree (and lxml data object)
prj.xmlroot
# CDATA field as nested dictionary
prj.bd
A convenience function ``wetb.bladed.readprj.ReadBladedProject.get_key`` is also
available to extract a ``numpy`` array, for example as follows::
from wetb.bladed.readprj import ReadBladedProject
prj = ReadBladedProject('my_bladed_project_file.prj')
# the following keys contain a data array
data_arr = prj.get_key('BSTIFFMB', 'EIFLAP')
# which is the similar calling (but excludes data conversion to int/float)
prj.bd['BSTIFFMB']['EIFLAP']
# if a key contains a section with sub-keys, a dictionary is returned:
data_dict = prj.get_key('BSTIFFMB')
# and is similar to
prj.bd['BSTIFFMB']
------------------------------------
Convert BLADED project file to HAWC2
------------------------------------
The class ``wetb.bladed.prj2hawc.Convert2Hawc`` will convert a Bladed project
file into a set of HAWC2 input files. This process assumes that a standard
3 bladed upwind turbine configuration is used, and a generic HAWC2 `htc template
file <https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/-/blob/master/wetb/bladed/template.htc>`_
serves as the starting point for the conversion process. Note that the converter
class ``wetb.bladed.prj2hawc.Convert2Hawc`` inherits from
``wetb.bladed.readprj.ReadBladedProject``, and hence will first read the Bladed
project file::
import os
import urllib.request
import shutil
from wetb.bladed.prj2hawc import Convert2Hawc
# download the htc template file,
url = 'https://gitlab.windenergy.dtu.dk/toolbox/WindEnergyToolbox/-/'
url += 'raw/master/wetb/bladed/template.htc'
fname_tmpl = '/path/to/my/template.htc'
with urllib.request.urlopen(url) as response, open(fname_tmpl, 'wb') as fout:
shutil.copyfileobj(response, fout)
# file name of the Bladed project file
fprj = '/path/to/my/bladed.prj'
# initiate the project converter object, will first read the prj file (see above)
prj = Convert2Hawc(fprj)
# convert to the HAWC2 formats: htc, ae, pc and st files
fname_htc = fname_tmpl.replace('template.htc', 'bladed-to-hawc2.htc')
prj.convert(fname_htc)
# note that the ae, pc and st files will be saved in the same directory as
# fname_htc, with .htc replaced by .ae, .pc, .st etc.
================================
Theoretical background
================================
---------------------------------
Coordinate systems
---------------------------------
The coordinate systems used in both codes are different. Note that in HAWC2
coordinate systems of general bodies are defined by the users. However,
the HAWC2 global and blade cross-section coordinate systems are predetermined,
and they differ from Bladed in the following manner:
* Global Bladed *X* axis is positive pointing downwind whereas in HAWC2 the
global *Y* direction is positive in the downwind direction.
* The HAWC2 global *Z* direction is in the same direction as the gravity vector
(positive down), while it is the opposite in Bladed (positive up).
* The Bladed cross-section coordinate system is rotated 90 degrees around *Z* wrt HAWC2.
The figures below illustrate clearly the HAWC2 and Bladed coordinate systems.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bladed coordinate systems
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. figure:: Bladed_turbine_coord.png
:width: 200
:alt: bladed_turbine_coord
Bladed coordinate system, rotor rotation and radius definition.
.. figure:: Bladed_st_centers.png
:width: 400
:alt: bladed_st_coord
Bladed cross-section structural centers, half chord location and structural pitch definition.
.. figure:: Bladed_airfoil.png
:width: 400
:alt: bladed_airfoil_coord
Bladed airfoil geometric positioning along the blade.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
HAWC2 coordinate systems
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. figure:: HAWC2_turbine_coord.png
:width: 200
:alt: hawc2_turbine_coord
HAWC2 global, tower, shaft, hub, blade-i and meteorological coordinate systems.
.. figure:: HAWC2_st_centers.png
:width: 400
:alt: hawc2_st_ccord
HAWC2 cross-section structural centers, half chord location and structural pitch definition.
.. figure:: HAWC2_c2_def_ccord.png
:width: 400
:alt: hawc2_airfoil_coord
HAWC2 airfoil positioning in blade body coordinates and aerodynamic pitch given as in the *htc* file *c2_def* section.
---------------------------------
Cross-sectional parameters
---------------------------------
Bladed uses isotropic material definitions for all bodies and for the HAWC2
conversion the same isotropic assumption is used. Since the HAWC2 *st* file definition
splits the Young's (*E*) and shear modulus (*G*) from the actual stiffness terms, and Bladed
defines the actual stiffness values (meaning the product of *EI* etc), the
corresponding HAWC2 *st* input simply assumes a value for *E* and *G*, and
specifies the inertia such that the product (i.e. stiffness) is correct.
Bladed defines a mass polar moment of inertia in combination with the ratio
between the mass radii of gyration around the airfoil's center of mass, while
in HAWC2 the radii of gyration in *X* and *Y* direction are given wrt the elastic
center.
---------------------------------
References
---------------------------------
[1] `HAWC2 User Manual v12.8 <http://tools.windenergy.dtu.dk/HAWC2/manual/>`_
[2] Bladed 4.6 Manual