Exercises
Taken from the notes
Static, 1d
Problem: \(\partial_{xx} \psi = -S\) with \(\psi(0) = 0 = \partial_x \psi(1)\).
- Compute (analytically) \(K_{AB}\) for linear shape functions on three elements.
- Compute (analytically) \(F_B\) when \(S(x) = 1 - x\) on three elements.
- Solve (numerically) for \(\psi_A\); compare to \(\psi = x (x^2 - 3 x + 3) / 6\).
Static, 1d
- Write a numerical FE solver on an evenly spaced grid with \(N_e\) elements.
- First use simple BCs, check \(S = 1 - x\) again.
- Check \(S = (1 - x)^2\); compare to \(\psi = x (4 - 6 x + 4 x^2 - x^3) / 12\). Check convergence with \(N_e\).
- Implement non-trivial BCs. Check
\[
S = \begin{cases} 1 & |x - \tfrac{1}{2}| < \tfrac{1}{4}, \\ 0 & \text{otherwise} \end{cases}
\]
for which the solution is in the notes.
- Use the method of manufactured solutions to create additional tests with non-trivial BCs.
- Extend your solver to use an arbitrary unstructured grid.
Static, 2d
Use Neumann boundaries except where \(x=0\): there use Dirichlet. Use the grid generation code from the notes (or write similar.)
- Check \(S(x, y) = 1 \implies \psi = x (1 - x/2)\).
- Check the one-dimensional examples in 2d (where BCs allow).
- Check
\[
S = 2 x (x - 2) (3 y^2 - 3 y + \tfrac{1}{2}) + y^2 (y - 1)^2
\]
with solution
\[
\psi = x (1 - \tfrac{x}{2}) y^2 (1 - y)^2 .
\]
Time evolution, 1d
- Compute the form of the stiffness matrix and force vector for an even grid for advection.
- Re-compute for advection-diffusion.
- Starting from the static code, write a function to compute the time derivative of \(\psi\) on the grid.
- Test with simple initial data and BCs as in previous examples.