Commit 589d5962 authored by Jenni Rinker's avatar Jenni Rinker
Browse files

adding three exercises, turbie package

parent d8f9842b
Pipeline #24948 passed with stage
in 1 minute and 44 seconds
......@@ -10,7 +10,9 @@ pages: # "pages" is a job specifically for GitLab pages [1]
- apt-get install -y pandoc
script: # use sphinx to build docs, move to public page
- pip install -r developer_requirements.txt
#- pip install -e .
- cd turbie/
- pip install -e .
- cd ..
- cd docs; make html
- cd ../; mv docs/build/html public/
artifacts: # required for GitLab pages [1]
......
......@@ -30,4 +30,5 @@ Contents:
what_is_codecamp
faq
schedule
preparation
\ No newline at end of file
preparation
turbie/index
\ No newline at end of file
{
"cells": [
{
"cell_type": "markdown",
"id": "7aa1a63b",
"metadata": {},
"source": [
"# Definition\n",
"\n",
"Turbie is a simple, two-degree-of-freedom (2DOF) system based of the DTU 10 MW Reference Wind Turbine. She is equivalent to the forced 2DOF mass-spring-damper system shown below, which is defined by a mass matrix, stiffness matrix, and damping matrix.\n",
"\n",
"<img src=\"figures/1-diagram.png\" alt=\"Diagram of Turbie\" style=\"width: 600px;\"/>"
]
},
{
"cell_type": "raw",
"id": "6aa637f1",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"Here are two files that you can download with parameters for Turbie: :download:`download turbie_parameters.txt <turbie_parameters.txt>` and :download:`download CT.txt <CT.txt>`"
]
},
{
"cell_type": "markdown",
"id": "da4474f2",
"metadata": {},
"source": [
"## Mass, stiffness and damping matrices\n",
"\n",
"To derive Turbie's mass, stiffness and damping matrices, we make a few assumptions about our dynamical system: \n",
"* The turbine can only move in the fore-aft direction; \n",
"* The 3 blade deflections in the fore-aft direction are syncronized, i.e., only collective flapwise deflections. \n",
"\n",
"With these assumptions, we have reduced Turbie to two degrees of freedom: the deflection of the blades in the fore-aft direction and the deflection of the nacelle in the fore-aft direction. The 2 DOFs of the system are therefore defined as \n",
"* $x_1(t)$: the deflection of the blades from their undeflected position in the global coordinate system; \n",
"* $x_2(t)$: the deflection of the nacelle from its undeflected position in the global coordinate system.\n",
"\n",
"With these DOFs, Turbie is equivalent to a 2DOF mass-spring-damper system, as shown above, where Mass 1 represents the 3 blades and Mass 2 represents the combined effects of the nacelle, hub and tower.\n",
"\n",
"**Exercise for the reader!** Given the diagram of the 2DOF mass, spring and damper system, derive the equations of motion and give the mass, stiffness and damping matrices.\n",
"\n",
"**Answer**.\n",
"The 2DOF mass-spring-damper system has the following system matrices:\n",
"\\begin{equation}\n",
"[M] = \\left[\\begin{array}{cc}m_1 & 0\\\\0 & m_2\\end{array} \\right] \n",
"\\end{equation}\n",
"\\begin{equation}\n",
"[C] = \\left[\\begin{array}{cc}c_1 & -c_1\\\\-c_1 & c_1+c_2\\end{array} \\right]\n",
"\\end{equation}\n",
"\\begin{equation}\n",
"[K] = \\left[\\begin{array}{cc}k_1 & -k_1\\\\-k_1 & k_1+k_2\\end{array} \\right]\n",
"\\end{equation}\n",
"\n",
"Here is a table of relevant parameter values for Turbie,\n",
"\n",
"Symbol |Decription |Value\n",
"-----|-----|----- \n",
"$m_b$|Mass of a single blade|41 metric tons\n",
"$m_n$|Mass of the nacelle|446 metric tons\n",
"$m_t$|Mass of the tower|628 metric tons\n",
"$m_h$|Mass of the hub|105 metric tons \n",
"$c_1$|Equivalent damping of the blades|4208 N/(m/s)\n",
"$c_2$|Equivalent damping of the nacelle, hub and tower|12730 N/(m/s)\n",
"$k_1$|Equivalent stiffness of the blades|1711000 N/m\n",
"$k_2$|Equivalent stiffness of the nacelle, hub and tower|3278000 N/m\n",
"$D_{rotor}$|Rotor diameter|180 m\n",
"$\\rho$|Air density|1.22 kg/m^3\n",
"\n",
"and here is the thrust-coefficient look-up table:\n",
"\n",
"Wind speed (m/s) | CT (-)\n",
"------|-----\n",
"4.0 | 0.923\n",
"5.0 | 0.919\n",
"6.0 | 0.904\n",
"7.0 | 0.858\n",
"8.0 | 0.814\n",
"9.0 | 0.814\n",
"10.0 | 0.814\n",
"11.0 | 0.814\n",
"12.0 | 0.577\n",
"13.0 | 0.419\n",
"14.0 | 0.323\n",
"15.0 | 0.259\n",
"16.0 | 0.211\n",
"17.0 | 0.175\n",
"18.0 | 0.148\n",
"19.0 | 0.126\n",
"20.0 | 0.109\n",
"21.0 | 0.095\n",
"22.0 | 0.084\n",
"23.0 | 0.074\n",
"24.0 | 0.066\n",
"25.0 | 0.059"
]
},
{
"cell_type": "markdown",
"id": "69d87383",
"metadata": {},
"source": [
"## Dynamical equations\n",
"\n",
"A wind turbine is, as you might expect, forced by the wind. To accurately model aerodynamics, you should include extra time-dependent variables to include phenomena such as dynamic stall, tower shadow, variable turbine speed, etc. For simplicity, we make the following assumptions: \n",
"* No dynamic inflow, dynamic stall, or tower shadow; \n",
"* Turbie's thrust coefficient can be directly calculated from the current wind speed; \n",
"* The only aerodynamic forcing is on the blades; \n",
"* No spatial variation of turbulence.\n",
"\n",
"With these assumptions, the aerodynamic forcing on the blades is given by \n",
"\\begin{equation}\n",
" f_{aero}(t) = \\frac12\\, \\rho\\, C_T(t)\\, A\\, (u(t) - \\dot{x}_1)\\,|u(t) - \\dot{x}_1|,\n",
"\\end{equation}\n",
"where $A$ is the rotor area and $u(t)$ is the wind speed at time $t$. The thrust coefficient $C_T(t)$ is determined from $u(t)$ using the look-up table defined above.\n",
"\n",
"The full dynamical equations for Turbie are then given by\n",
"\\begin{equation}\n",
"[M]\\ddot{\\overline{x}}(t) + [C]\\dot{\\overline{x}}(t) + [K]\\overline{x}(t) = \\overline{F}(t)\n",
"\\end{equation}\n",
"where $\\overline{x}(t)=[x_1(t), x_2(t)]^T$ is the state vector and the forcing vector is given by\n",
"\\begin{equation}\n",
"\\overline{F}(t) = \\left[ \\begin{array}{c} f_{aero}(t) \\\\ 0\\end{array} \\right].\n",
"\\end{equation}"
]
},
{
"cell_type": "markdown",
"id": "8232c79b",
"metadata": {},
"source": []
}
],
"metadata": {
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:7aa1a63b tags:
# Definition
Turbie is a simple, two-degree-of-freedom (2DOF) system based of the DTU 10 MW Reference Wind Turbine. She is equivalent to the forced 2DOF mass-spring-damper system shown below, which is defined by a mass matrix, stiffness matrix, and damping matrix.
<img src="figures/1-diagram.png" alt="Diagram of Turbie" style="width: 600px;"/>
%% Cell type:raw id:6aa637f1 tags:
Here are two files that you can download with parameters for Turbie: :download:`download turbie_parameters.txt <turbie_parameters.txt>` and :download:`download CT.txt <CT.txt>`
%% Cell type:markdown id:da4474f2 tags:
## Mass, stiffness and damping matrices
To derive Turbie's mass, stiffness and damping matrices, we make a few assumptions about our dynamical system:
* The turbine can only move in the fore-aft direction;
* The 3 blade deflections in the fore-aft direction are syncronized, i.e., only collective flapwise deflections.
With these assumptions, we have reduced Turbie to two degrees of freedom: the deflection of the blades in the fore-aft direction and the deflection of the nacelle in the fore-aft direction. The 2 DOFs of the system are therefore defined as
* $x_1(t)$: the deflection of the blades from their undeflected position in the global coordinate system;
* $x_2(t)$: the deflection of the nacelle from its undeflected position in the global coordinate system.
With these DOFs, Turbie is equivalent to a 2DOF mass-spring-damper system, as shown above, where Mass 1 represents the 3 blades and Mass 2 represents the combined effects of the nacelle, hub and tower.
**Exercise for the reader!** Given the diagram of the 2DOF mass, spring and damper system, derive the equations of motion and give the mass, stiffness and damping matrices.
**Answer**.
The 2DOF mass-spring-damper system has the following system matrices:
\begin{equation}
[M] = \left[\begin{array}{cc}m_1 & 0\\0 & m_2\end{array} \right]
\end{equation}
\begin{equation}
[C] = \left[\begin{array}{cc}c_1 & -c_1\\-c_1 & c_1+c_2\end{array} \right]
\end{equation}
\begin{equation}
[K] = \left[\begin{array}{cc}k_1 & -k_1\\-k_1 & k_1+k_2\end{array} \right]
\end{equation}
Here is a table of relevant parameter values for Turbie,
Symbol |Decription |Value
-----|-----|-----
$m_b$|Mass of a single blade|41 metric tons
$m_n$|Mass of the nacelle|446 metric tons
$m_t$|Mass of the tower|628 metric tons
$m_h$|Mass of the hub|105 metric tons
$c_1$|Equivalent damping of the blades|4208 N/(m/s)
$c_2$|Equivalent damping of the nacelle, hub and tower|12730 N/(m/s)
$k_1$|Equivalent stiffness of the blades|1711000 N/m
$k_2$|Equivalent stiffness of the nacelle, hub and tower|3278000 N/m
$D_{rotor}$|Rotor diameter|180 m
$\rho$|Air density|1.22 kg/m^3
and here is the thrust-coefficient look-up table:
Wind speed (m/s) | CT (-)
------|-----
4.0 | 0.923
5.0 | 0.919
6.0 | 0.904
7.0 | 0.858
8.0 | 0.814
9.0 | 0.814
10.0 | 0.814
11.0 | 0.814
12.0 | 0.577
13.0 | 0.419
14.0 | 0.323
15.0 | 0.259
16.0 | 0.211
17.0 | 0.175
18.0 | 0.148
19.0 | 0.126
20.0 | 0.109
21.0 | 0.095
22.0 | 0.084
23.0 | 0.074
24.0 | 0.066
25.0 | 0.059
%% Cell type:markdown id:69d87383 tags:
## Dynamical equations
A wind turbine is, as you might expect, forced by the wind. To accurately model aerodynamics, you should include extra time-dependent variables to include phenomena such as dynamic stall, tower shadow, variable turbine speed, etc. For simplicity, we make the following assumptions:
* No dynamic inflow, dynamic stall, or tower shadow;
* Turbie's thrust coefficient can be directly calculated from the current wind speed;
* The only aerodynamic forcing is on the blades;
* No spatial variation of turbulence.
With these assumptions, the aerodynamic forcing on the blades is given by
\begin{equation}
f_{aero}(t) = \frac12\, \rho\, C_T(t)\, A\, (u(t) - \dot{x}_1)\,|u(t) - \dot{x}_1|,
\end{equation}
where $A$ is the rotor area and $u(t)$ is the wind speed at time $t$. The thrust coefficient $C_T(t)$ is determined from $u(t)$ using the look-up table defined above.
The full dynamical equations for Turbie are then given by
\begin{equation}
[M]\ddot{\overline{x}}(t) + [C]\dot{\overline{x}}(t) + [K]\overline{x}(t) = \overline{F}(t)
\end{equation}
where $\overline{x}(t)=[x_1(t), x_2(t)]^T$ is the state vector and the forcing vector is given by
\begin{equation}
\overline{F}(t) = \left[ \begin{array}{c} f_{aero}(t) \\ 0\end{array} \right].
\end{equation}
%% Cell type:markdown id:8232c79b tags:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
V(m/s) CT
4.0 0.923
5.0 0.919
6.0 0.904
7.0 0.858
8.0 0.814
9.0 0.814
10.0 0.814
11.0 0.814
12.0 0.577
13.0 0.419
14.0 0.323
15.0 0.259
16.0 0.211
17.0 0.175
18.0 0.148
19.0 0.126
20.0 0.109
21.0 0.095
22.0 0.084
23.0 0.074
24.0 0.066
25.0 0.059
\ No newline at end of file
.. turbie
Turbie
=========
We would like to introduce you to your new best
friend: Turbie. Turbie is a simple model of
a wind turbine, with just two degrees of freedom,
but we will use her in CodeCamp to buff up our
coding skills via eigenanalyses, PSD plots,
and analyses of time-marching responses.
Contents:
.. toctree::
:maxdepth: 2
1-definition
2-loading-plotting
3-psd
\ No newline at end of file
This diff is collapsed.
% Turbie parameters
41e3 % mb [kg]
446e3 % mn [kg]
105e3 % mh [kg]
628e3 % mt [kg]
4.208e3 % c1 [N/(m/s)]
1.273e4 % c2 [N/(m/s)]
1.711e6 % k1 [N/(m/s)]
3.278e6 % k2 [N/(m/s)]
0.63 % fb [Hz]
0.25 % ft [Hz]
0.004933803235848756 % drb [-]
0.0030239439187460114 % drt [-]
178 % Dr [m]
1.22 % rho [kg/m3]
# -*- coding: utf-8 -*-
"""Setup file for turbie
"""
from setuptools import setup
setup(name='turbie',
version='0.0.1',
description='Just a simple wind turbine',
url='https://gitlab.windenergy.dtu.dk/python-at-risoe/codecamp',
author='Jenni Rinker',
author_email='rink@dtu.dk',
license='MIT',
packages=['turbie', # top-level package
],
install_requires=['matplotlib', # plotting turbie results
'numpy', # numeric arrays
'scipy', # solve ivp
],
zip_safe=False)
# -*- coding: utf-8 -*-
"""Functions for Turbie
"""
import matplotlib.pyplot as plt
import numpy as np
def load_results(path):
"""Load turbie results from text file.
Returns 4 [nt] arrays: t, u, x1 and x2.
"""
res_arr = np.loadtxt(path, skiprows=1)
t, u, x1, x2 = res_arr.T
return t, u, x1, x2
def plot_results(t, u, x1, x2, tspan=None):
"""Make a plot of the Turbie results array.
Returns the figure and axes handles.
"""
if tspan is None: # if tspan not given, take whole range
tspan = [t[0], t[-1]]
# mask the data so it falls within tspan
mask = (t >= tspan[0]) & (t <= tspan[1])
t = t[mask]
u = u[mask]
x1 = x1[mask]
x2 = x2[mask]
fig, axs = plt.subplots(2, 1, clear=True, figsize=(10, 4))
ax = axs[0] # subplot 1: wind speed
ax.plot(t, u)
ax.set_ylabel('Wind speed [m/s]')
ax.set_xlim(tspan)
ax = axs[1] # subplot 2: blade and tower deflection
ax.plot(t, x1, label='Blades')
ax.plot(t, x2, label='Tower')
ax.set_ylabel('Deflection [m]')
ax.set_xlabel('Time [s]')
ax.set_xlim(tspan)
ax.legend()
plt.tight_layout() # make sure the axes fit the figure
return fig, axs
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment