Notations:
Weighting function \(w_i\)
Basis function \(\varphi_i(x)\)
Residual \(R(x)\)
Useful links:
1,
2,
3
Consider the damped wave equation
\[\frac{\partial^2{u}}{\partial{t^2}} = v^2 \frac{\partial^2{u}}{\partial{x^2}}
+ \gamma \frac{\partial}{\partial{t}}\frac{\partial^2{u}}{\partial{x^2}}
\]
Take the solution domain to be the interval [0,1].
(a) Use the Galerkin method to find an approximating system of differential equations.
Defined in the interval [0,1], and the residual \(R(x) = \dfrac{\partial^2{u}}{\partial{t^2}} - v^2 \dfrac{\partial^2{u}}{\partial{x^2}} - \gamma \dfrac{\partial}{\partial{t}}\dfrac{\partial^2{u}}{\partial{x^2}} \), the Galerkin expansion is \[\sum_i\int_{0}^{1}(\dfrac{d^2a_i}{dt^2}\varphi_i\varphi_j -v^2a_i\varphi_j\dfrac{d^2\varphi_i}{dx^2} -\gamma\varphi_j\dfrac{da_i}{dt}\dfrac{d^2\varphi_i}{dx^2})dx = 0\] The second term can be integrated by parts: \[ \sum_i a_i\left[v^2\varphi_j\dfrac{d\varphi_i}{dx}\Bigg|_{0}^{1} -\int_{0}^{1}v^2\dfrac{d\varphi_i}{dx}\dfrac{d\varphi_j}{dx}dx\right] \] The third term can also be integrated by parts: \[ \sum_i \left[\gamma\varphi_j\dfrac{da_i}{dt}\dfrac{d\varphi_i}{dx}\Bigg|_0^1 - \dfrac{da_i}{dt}\int_{0}^{1}\gamma\dfrac{d\varphi_j}{dx}\dfrac{d\varphi_i}{dx}dx \right] \] Therefore, the Galerkin expansion can be rewritten as \[\mathbf{A}\cdot\dfrac{d^2\vec{a}}{dt^2}+\mathbf{B}\cdot\dfrac{d\vec{a}}{dt}+\mathbf{C}\cdot\vec{a} = 0,\] where \[\begin{align*} \mathbf{A}_{ij} & = \int_0^1\varphi_i\varphi_j dx \\ \mathbf{B}_{ij} & = \int_{0}^{1}v^2\dfrac{d\varphi_i}{dx}\dfrac{d\varphi_j}{dx}dx - v^2\varphi_j\dfrac{d\varphi_i}{dx}\Bigg|_{0}^{1} \\ \mathbf{C}_{ij} & = \int_0^1\gamma\dfrac{d\varphi_i}{dx}\dfrac{d\varphi_j}{dx} - \gamma\varphi_j\dfrac{d\varphi_i}{dx}\Bigg|_0^1 \\ \end{align*} \]
(b) Evaluate the matrix coefficients for linear hat basis functions, using elements with a fixed size of \(h\).
Hat function with the fixed size of \(h\):
\[\begin{split}
{\varphi}_i(x) =
\left\lbrace\begin{array}{ll}
\dfrac{x-x_{i-1}}{h} & x_{i-1} \leq x < x_i\\
\dfrac{x_{i+1}-x}{h} & x_i \leq x < x_{i+1}\\
0 & x < x_{i-1} \quad or \quad x \geq x_{i+1}
\end{array}\right.\end{split}\]
When \(|i-j| \geq 2, \quad \varphi_i \varphi_j = 0,\quad\) which makes \(\mathbf{A}\) a tridiagonal matrix.
\[\begin{align*}
i = j \quad \Rightarrow \quad \mathbf{A}_{ij} &= \int_{x_{i-1}}^{x_i}(\dfrac{x-x_{i-1}}{h})^2 dx + \int_{x_{i}}^{x_{i+1}}(\dfrac{x_{i+1}-x}{h})^2 dx\\
&= \dfrac{2h}{3}\\
j = i+1 \quad \Rightarrow \quad \mathbf{A}_{ij} &= \int_{x_{i}}^{x_{i+1}}\dfrac{(x_{i+1}-x)(x-x_i)}{h^2}dx\\
&= \dfrac{h}{6}\\
j = i-1 \quad \Rightarrow \quad \mathbf{A}_{ij} &= \int_{x_{i-1}}^{x_i}\dfrac{(x_{i}-x)(x-x_{i-1})}{h^2}dx\\
&= \dfrac{h}{6}\\
\end{align*}\]
download
Let's move on to \(\mathbf{B}\) and \(\mathbf{C}\).
The derivative of \(\varphi_i\):
\[\begin{split}
\dfrac{{d\varphi}_i}{dx} =
\left\lbrace\begin{array}{ll}
\dfrac{1}{h} & x_{i-1} \leq x < x_i\\
-\dfrac{1}{h} & x_i \leq x < x_{i+1}\\
0 & x < x_{i-1} \quad or \quad x \geq x_{i+1}
\end{array}\right.\end{split}\]
\[\begin{align*}
i = j \quad \Rightarrow \quad \mathbf{B}_{ij} & = \int_{x_{i-1}}^{x_i}\dfrac{v^2}{h^2} dx + \int_{x_{i}}^{x_{i+1}}\dfrac{v^2}{h^2} dx \\
& = \dfrac{v^2}{h^2}(2x_i-x_{i-1}-x_{i+1}) = 0\\
\mathbf{C}_{ij} &= \dfrac{\gamma}{h^2}(2x_i-x_{i-1}-x_{i+1}) = 0\\
j = i+1 \quad \Rightarrow \quad \mathbf{B}_{ij} & = \dfrac{v^2}{h^2}(x_{i+1}-x_i)
= \dfrac{v^2}{h}\\
\mathbf{C}_{ij} &= \dfrac{\gamma}{h^2}(x_{i+1}-x_i)
= \dfrac{\gamma}{h}\\
j = i-1 \quad \Rightarrow \quad \mathbf{B}_{ij} & = \dfrac{v^2}{h^2}(x_{i}-x_{i-1})
= \dfrac{v^2}{h}\\
\mathbf{C}_{ij} &= \dfrac{\gamma}{h^2}(x_{i+1}-x_i)
= \dfrac{\gamma}{h}
\end{align*}\]
(c) Now find the matrix coefficients for Hermite polynomial interpolation basis functions, once again using elements with a fixed size of \(h\). A symbolic math environment is useful for this problem.
Lagrange polynomial with the fixed size of \(h\): \[\begin{align*} L_{k} & = \dfrac{(x-x_0)\dotsm(x-x_{k-1})(x-x_{k+1})\dotsm(x-x_n)} {(x_0-x_k)\dotsm(x_{k-1}-x_k)(x_{k+1}-x_k)\dotsm(x_n-x_k)}\\ & = \dfrac{x(x-h)\dotsm(x-(k-1)h)(x-(k+1)h)\dotsm(x-nh)} {h^n(n-k)!k!(-1)^{k}} \end{align*}\] Hermite polynomial interpolation: \[H_{j}(x) = \{1-2(x-x_j)L^\prime_{j}(x_j)\}L^2_{j}(x)\] sympy combinatorial
Model the bending of a beam under an applied load. Use Hermite polynomial interpolation, and boundary conditions fixing the displacement and slope at one end.
\[V = \int_{0}^L\left(\dfrac{1}{2}EI(\dfrac{d^2u}{dx^2})^2-u(x)f(x)\right)dx\]