# José Abell's research blog

## NTS-02. On Rayleigh damping coefficients for FE analysis

Note to self. How to compute Rayleigh damping coefficients for given damping ratios $\xi_1$ and $\xi_2$ at frequencies $f_1$ and $f_2$.

This is textbook content, I just need to remind myself too often how this is done and end up re-deriving the equations.

Given the second-order system of differential equations representing the FE model

$$M \ddot{u} + C \dot{u} + K u = F(t)$$

The damping matrix $C$ can be written as a Rayleigh damping matrix:

$$C = a_0 M + a_1 K$$

$a_0$ and $a_1$ are Rayleigh damping coefficients found by solving

$$\left[ \begin{array}{cc} \dfrac{1}{2\pi f_1} & 2 \pi f_1 \ \dfrac{1}{2\pi f_2} & 2 \pi f_2 \end{array} \right] \left[ \begin{array}{c} a_0 \ a_1 \end{array} \right] = \left[ \begin{array}{c} \xi_1 \ \xi_2 \end{array} \right]$$

Which I do in the following code:

## NTS (Note-To-Self): Creating dynamically linked libraries

A nice extensive tutorial can be found here.

In a nutshell:

:::shell.BashLexer
gcc -Wall -fPIC -c \*.c
gcc -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 \*.o
mv libctest.so.1.0 /opt/lib
ln -sf /opt/lib/libctest.so.1.0 /opt/lib/libctest.so.1
ln -sf /opt/lib/libctest.so.1.0 /opt/lib/libctest.so

• -Wall: include warnings. See man page for warnings specified.
• -fPIC: Compiler directive to output position independent code, a characteristic required by shared libraries. Also see “-fpic”.
• -shared: Produce a shared object which can then be linked with …