0

I have solved a $2D$ PDE for $u(x,z,t)$ using both COMSOL and Matlab. I want to check the convergence of these two methods and try to compare them to each other.

To do this, I ran my Matlab script for various discretization grids: $$ N=64,M=32 \qquad N=128,M=32 \qquad N=256,M=32 $$ $$ N=64,M=64 \qquad N=128,M=128 \qquad N=256,M=256 $$ and saved the results at each $0.1$ seconds of time leaving me with $3D$ arrays in Matlab which I called $mov1, ..., mov6$. For example, in Matlab syntax, $mov1(:,:,1)$ is the $2D$ solution at time $t=0$ and $mov1(M/4+1,:,1)$ is the $1D$ solution at $z=0.25,t=0$.

My thought was to use these to examine the norm of the solution at the cutline $z=0.25$ for both the Comsol solution and for all Matlab solutions $mov1,...,mov6$. What I did was simply take the cutline solution I desired and then used the Matlab $norm$ function. However, what I noticed is that in all cases they seemed to be straight lines with very similar slopes but different $y-intercepts$.

I can't quite explain why but I was able to get them all to match up if I simply standardized a size (say $N=256$; note the size of $M$ doesn't matter because I'm essentially taking this out by only looking at the solution on the specific cutline) and then multiplied all other norm values by $\sqrt(256)/\sqrt(X)$ where $X$ is the size of the $x$-direction in the other solution.

I am wondering if this is a reasonable thing to do. If so, why is this the case? If not, what would be the alternative thing to do?

For reference the graphs I created are below:

Normalization No Normalization

Also, as a final comment, the COMSOL solution uses a triangular mesh with a somewhat arbitrary number of discretization points $1609$ in the $x$-direction. So there isn't a simple way to just get the points to line up without using an interpolation method which I would like to avoid doing for the moment.

Mjoseph
  • 989
  • 1
  • 9
  • 22
  • 1
    It is not clear to me what a cutline is, but I am not sure that it is critical either. From you choice of words and your proposed solution I think that you are using the default norm in MATLAB, i.e., the 2-norm. This norm is affected by the length of the vectors and we certainly need to compensate before we can compare results on different grids. However, before doing this, check if your issues do not vanish when you use the infinity norm instead, i.e. norm(x,'inf') instead of just norm(x). – Carl Christian May 11 '22 at 15:10
  • The domain I am solving on is $D=[-L,L]\times [0,1]$. What I mean by a cutline at $z=0.25$ is to just examine the solution $u(x,0.25,t)$ through time. As for the norm calculation, yes I'm simply using the $2$-norm right now; investigating the $\infty$-norm will be interesting. Thanks for the idea and thoughts! – Mjoseph May 11 '22 at 21:14
  • Thinking about this a second longer, the infinity norm isn't interesting to look at as the solution for all time and for all discretization parameters contains a decent portion of values that are simply $-1$. The solution I am dealing with is bounded within $[-1,1]$ so this will simply return straight lines of magnitude $1$ for all numerical solutions. Should I instead look at the infinity norm of the differences? i.e. take the $N=M=256$ solution to be the "exact" solution and then check the infinity norm of the difference between that solution and any other? – Mjoseph May 11 '22 at 21:21
  • 1
    Yes, the difference is interesting and it can be analyzed. The key term is Richardson extrapolation. It is late in my time zone ... – Carl Christian May 11 '22 at 22:39
  • Thank you so much! Have a great night – Mjoseph May 11 '22 at 22:52
  • Previously, I have write answers on the topic of Richardson extrapolation and a little bit about its limitations. There is a chance, that these two links may be useful to you: https://math.stackexchange.com/a/4355465/307944 and https://math.stackexchange.com/a/1780654/307944 – Carl Christian May 12 '22 at 14:18

0 Answers0