Excercises¶
Let us program some of the above MWR formulations. Here is a jupyter notebook that we can use as a starting point.
Notebook - excercises¶
Excercises:
Get the different methods to work and explore how good the MWR solutions are.
What happens if you increase the velocity and make the problem more advection dominated?
What do you think is the problem with advectino dominated problems?
Higher-order approximations¶
What we have seen is that for diffusion dominated problems, the above approximation gives reasonable results. For advection dominated problems, a simple polynomial function can no longer approximate the solution in a satisfactory way. One possible solution is to use a higher polynomial as the approximating function. Let’s try this:
The boundary conditions can now be written as:
The first and second derivatives become:
So the residual is
(88)¶\[R(x)=c\left ( a_1 + 2a_2x+3a_3x^2 \right ) - K(2a_2+6a_3x)\]
We will only use the collocation method with two collocation points to determine the two unknown coefficients. The result is a system of equations for the four coefficients \(ai\):
We can solve this system of equations with the Symbolic Math Toolbox of Matlab or again via sympy using python. Try to do that!
Notebook - derivation of higher-order constants¶
Have a close look at the above notebook and make sure you understand how symbolic systems of equations are solved using sympy! Also check if we are now able to approximate the solution for advection-dominated problems.
Outlook¶
The above considerations have shown how we can find approximate solutions to partial differential equations using MWR. If you remember the characterization above: “…finite element methods partition the problem domain into subregions and produce a simple function in each subregion that approximates the solution”, we can already see that finite elements do something very similar. In essence we will partition the domain into many elements, approximate the solution over every element using the Galerkin method and very simple basis functions, and will finally obtain the global solution by summing up the contributions of each element. That is what we will do over the next weeks!