Analysis of MLSM performance

From Medusa: Coordinate Free Mehless Method implementation
Revision as of 16:40, 20 October 2016 by Anja (talk | contribs)

Jump to: navigation, search

For starters, we can solve simple Diffusion equation $ \nabla^2 u = \frac{\partial u}{\partial t} $.

We solved the equation on a square $\Omega = [0, a] \times [0, a]$ with Dirichlet boundary conditions $ \left. u\right|_{\partial \Omega} = 0 $ and initial state $ u(t = 0) = 1$.

An analytical solution for this domain is known, and we use it to evaluate or own solution. \begin{equation} u(\vec{p}, t) = \sum_{\substack{n=1 \\ n \text{ odd}}}^\infty\sum_{\substack{m=1 \\ m \text{ odd}}}^\infty \frac{1}{\pi^2} \frac{16 a^2}{nm} \sin\left(\frac{\pi n}{a}p_x\right) \sin\left(\frac{\pi m}{a}p_y\right) e^{-\frac{\pi^2 (n^2+m^2)}{a^2}t} \end{equation} Because the solution is given in the series form, we only compare to the finite approximation, summing to $N = 100$ instead of infinity.Picture reference Figure 1

A square of nodes coloured according to the solution(with smaller and larger node density)
Figure 1: A picture of our solution (with smaller and larger node density)

Analysis of our method

Convergence with respect to number of nodes

Graph of errors with respect to number of nodes
Figure 2: Convergence with respect to number of nodes

We tested the method with a fixed time step of $ \Delta t = 1\cdot 10^{-5}$ on a unit square ($a = 1$). Results are on figure Figure 2. Monomial basis of $6$ monomials was used and $12$ closest nodes counted as support for each node. After more than $250$ nodes of discretization in each dimension the method diverges, which is expected. The stability criterion for diffusion equation in two dimensions is $\Delta t \leq \frac{1}{4} \Delta x^2$, where $\Delta x$ is the spatial discretization step in one dimension. In our case, at $250$ nodes per side, the right hand side yields $\frac{1}{4}\cdot\frac{1}{250}\cdot\frac{1}{250} = 4\times 10^{-6}$, so our method is stable within the expected region.

Figure 3: Convergence with respect to number of nodes for Gaussian and Monomial basis

On figure Figure 3 is another image of convergence, this time using monomial basis $\{1, x, y, x^2, y^2\}$ and Gaussian basis with discretization step $ \Delta t = 5 \cdot 10^{-6}$ and 5 support nodes. Total node count was $N = 2500$. Error was calculated after $0.01$ time units have elapsed.

Convergence with respect to number of time steps

Figure 4: Convergence with respect to different timesteps

We tested the method on a fixed node count with different time steps on the same domain as above. Results are on figure Figure 4. For large time steps the method diverges, but once it starts converging the precision increases steadily as the time step decreases, until it hits its lower limit. This behaviour is expected. The error was calculated against the analytical solution above after $0.005$ units of time have passed. A monomial basis up to order $2$ inclusive ($m = 6$) was used and the support size was $n = 12$.

Using Gaussian basis

Figure 5: Graph of error with respect to Gaussian basis $\sigma$

We tested the method on a fixed node count of $N = 2500$ with spatial step discretization of $\Delta x = \frac{1}{50}$. We used the Gaussian basis of $m = 5$ functions with support size $n = 13$. Error was calculated against analytical solution above after $0.01$ time units. A time step of $\Delta t = 10^{-5}$ was used. Results are on figure Figure 5

As we can see from the graph, there exists an interval where the choice of $\sigma$ does not matter much, but outside of this interval, the method diverges rapidly. Care from the user side must be taken, to choose $\sigma$ appropriately, with respect to plot above.

Solving in 3D

Figure 6: A $-dimensional spulution with an explicit Euler method

A $3$-dimensional case on domain $[0, 1]^3$ was tested on $N = 20^3$ nodes, making the discretization step $\Delta x = 0.05$. Support size of $n=10$ with $m=10$ Gaussian basis functions was used. Their normalization parameter was $\sigma = 60\Delta x$. A time step of $\Delta t = 10^{-5}$ and an explicit Euler method was used to calculate the solution of to $0.01$ time units. Resulting function is on figure Figure 6.

Solving Dirichlet with EngineMLS

Example code using explicit stepping to reproduce the thermal images from the beginning: example code

Solving Dirichlet with MLSM operators

Example code using explicit stepping and MLSM operators to reproduce the thermal images from the beginning: example code

Solving mixed boundary conditions with MLSM operators

By using MLSM operators and utilizing its `MLSM::neumann` method we can also solve partial diffusion equations. Solution is on figure Figure 7.

Figure 7: Example of solving using Neumann boundary conditions

Example code showing the use of Neumann boundary conditions: example code

We also support more -- interesting -- domains :)

Mikimouse heat.png

Convergence analysis for one dimensional diffusion equation

We now tried to solve the diffusion equation in one dimension $u_t = u_{xx}$ on the interval $[0,1]$ with Dirichlet boundary conditions $u(0, t) = u(1,t) = 0 $ and an initial state $u(x,0) = \sin(\pi x).$

An analytical solution for this domain is given in closed form \begin{equation} u(x,t) = \sin(\pi x) \exp(-\pi^2 t), \end{equation} so we can use it to evaluate our approximation.

We tested the method with a fixed time step of $\Delta t = 1\cdot 10^{-8}$ on a unit interval, that was discretized into $ N $ nodes. Monomial basis of $m$ monomials was used and $n$ closest nodes counted as support for each node.

Convergence with respect to number of nodes and support size

Convergence of the method was tested on different number of nodes $N = 15, 20, 25, \ldots, 200$. First we tested the method, when support size is equal to number of monomials in the basis ($n =m$), which we call local interpolation, for different values of $n = 3, 5, 7$. We then compared that to local approximation, where we take $n = 12$ supporting nodes and we only change number of monomials. We used gaussian weight function with $\sigma = 1\cdot \Delta x$. Error was calculated after $0.001$ time units have elapsed.

Larger is the support size, faster is convergence. This rule applies for local interpolation as well as approximation. But when number of nodes is too large, the method diverges faster for larger support sizes. Error for approximation is bigger than for interpolation (if we compare it for same basis size), but the method diverges with interpolation for smaller number of nodes.

Convergence with respect to weight function

We also checked the convergence for different weight functions. We tested it on number of nodes $N = 15, 20, 25, \ldots, 200$, with monomial basis with $m = 5$, support size $n = 12$ and gaussian weight function with $\sigma = w\cdot \Delta x$ for $w = 0.1$. Error was calculated after $0.001$ time units have elapsed with $\Delta t = 10^{-8}$.

When the $\sigma$ is too small, other nodes on the support domain are not taken into consideration, so taking $n = 12$ or $n = 3$ would give the same results. However when $\sigma$ is too large, all the nodes on the support domain are contributing and there is no significant difference between different weight functions.