# Wind turbine gearbox simulator
![Static Badge](https://img.shields.io/badge/Octave-11.1.0-orange)
![Static Badge](https://img.shields.io/badge/Arch%20Linux-6.19.12-blue)
![Static Badge](https://img.shields.io/badge/Gnuplot-6.0%20patchlevel%204-yellow)
![Static Badge](https://img.shields.io/badge/Gitlab-repo-red?logo=Gitlab)


Wind turbine gearbox simulator is a matlab/octave simulator for a lumped parameters mechanical model of wind turbine gearbox. It implements varying wind profile, defects, varying gear mesh, and compute numerically the dynamical behaviour of the system using a Newmark's scheme.

## Dependencies
**Development language:** Octave 11.1.0

**Compatibility:** Matlab v2026-a (delete all `graphics_toolkit("gnuplot")` mentions in the code)

**Plot engine:** Gnuplot 6.0 patchlevel 4

## Usage
```bash
$ git clone https://gitlab.com/afoucaultc/wind_turbine_gearbox
$ cd wind_turbine_gearbox
$ octave
$ octave:1> run main.m
$ # or run any standalone (starting by a "_")
$ octave:1> >>> run _[standalone].m
```

## File tree
```bash
: '
Main process takes the main parameters and compute the
whole process of calculations. It prints every figure
into .svg files, into folder print/run_print/. The
number of periods to calculate are asked as input when
the code is started.
"class_" are static functions used to calculate and plot
see in-code comments for more informations
'
## Main process
├── main.m
├── main_parameters.m
    ├── run_main.m
    │   └── _convergence.m
    ├── run_display.m
    │   └── class_display.m
    └── run_print.m
: '
Standalone files are files that do a single specific task
that cannot be done by the main process. These starts by
a "_" and can be ran using ">>> run _file.m"
- _init_speed.m calculates the optimal initial speed to 
    avoid the transitionnal regime.
- _rms-analysis.m gives a .csv (in /data) containing the 
    RMS, STD and Kurtosis for different defects conditions
- _animation.m is showing a visual animation of the diff-
    -erent shaft rotations and vibrations
- _gear-mesh-var.m plots the difference of mesh stiffness
    between different center distance error values
- _convergence.m plots the convergence between a high
    sample rate and other sample rates to determine which
    one to choose for minimal numerical error and comput-
    -ational
    time
'
## Standalone functions
├── _init_speed.m
├── _rms-analysis.m
├── _animation.m
├── _gear-mesh-var.m
└── _convergence.m
: '
Rendering folders stores the .csv datasheet and .svg plots
'
## Rendering folders
├── data
│   └── rms.csv
└── print
    ├── _convergence
    ├── _gear-mesh-var
    └── run_print

## Others
├── octave-workspace
└── README.md
```
## Model
![Model](images/kinematicscheme.png)

As showed on the image, the model is based on 2 shaft with 4DDL each ($x$,$y$,input $\theta$ and output $\theta$), as a lumped parameters model.

The equations of movement are given by the Lagrange formulation, using the kinetic and potential energies.

$$
        \left[\frac{\partial E_p}{\partial q_i}\right] 
        + \left[\frac{d}{dt}\left(\frac{\partial E_k}{\partial\dot{q}_i}\right)\right] 
        + \frac{\partial C}{\partial\dot{q}_i} 
        = \frac{\partial W}{\partial q_i}
        \label{eq:reformlagrange}
\\
        E_k = 	\frac{1}{2}
                \left(
                        m_1{\dot{x}_1}^2+
                        m_1{\dot{y}_1}^2+
                        I_{11}{\dot{\theta}_{11}}^2+
                        I_{12}{\dot{\theta}_{12}}^2+
                        m_2{\dot{x}_2}^2+
                        m_2{\dot{y}_2}^2+
                        I_{22}{\dot{\theta}_{22}}^2+
                        I_{21}{\dot{\theta}_{21}}^2
                \right)
\\
        E_p = \frac{1}{2}
                \left( 
                        k_{x_1}{x_{1}}^2+
                        k_{y_1}{y_{1}}^2+
                        k_{\theta_1}(\theta_{11}-\theta_{12})^2+
                        k_{x_2}{x_{2}}^2+
                        k_{y_2}{y_{2}}^2+
                        k_{\theta_2}(\theta_{21}-\theta_{22})^2+
                        K_e(t){\delta}^2
                \right)
$$

The derivative of these equations is taken to directly get the movement, using:
$$
\frac{\partial E_p}{\partial q_i}+\frac{d}{dt}\left(\frac{\partial E_k}{\partial \dot{q}_i} \right) = F_i
$$

The different terms ($k$ and $m$) are regrouped in matrices, to give the following system:
$$
\left[M\right]\{\ddot{q}\} + \{\dot{q}\}+ \left(\left[K_{var}\right]+\left[K_{cst}\right]\right) \{q\} = \left\{F\right\}
$$
## Development machine specification
Hardware: Thinkpad E560, CPU Intel(R) Core(TM) i5-6200U(4)@2.8GHz, 3.70GiB RAM
OS: Arch Linux 6.19.12

