Wrong L2 norm in ft01_poisson tutorial program


258
views
0
6 months ago by
I am running the first tutorial program https://fenicsproject.org/pub/tutorial/python/vol1/ft01_poisson.py
and getting strange result:

error_L2 = 0.00823509807335
error_max = 1.33226762955e-15

Here the value of the second norm looks normal, while the first norm is obvious too large.

If I calculate the L2 norm like this
error_l2_2 = np.linalg.norm(vertex_values_u_D - vertex_values_u)​
I getting the small value of error which is ok
error_L2_2 = 4.95015069149e-15
I use fenics 2017.2 from anaconda forge on mac.
Community: FEniCS Project

2 Answers


3
6 months ago by
I've encountered this before. The prescribed exact solution is quadratic in space; so the linear elements don't approximate the solution to machine precision.

If you change 
V = FunctionSpace(mesh, 'P', 1)​

to

V = FunctionSpace(mesh, 'P', 2)

then the L2 norm should report something close to machine precision.

1
6 months ago by
Yes but the question is why this:

vertex_values_u_D = u_D.compute_vertex_values(mesh)

vertex_values_u = u.compute_vertex_values(mesh)

error_max = np.max(np.abs(vertex_values_u_D - vertex_values_u))​



gives a e-15 error, while the L-2 norm:

error_L2 = errornorm(u_D, u, 'L2')​


gives so big error?

It must be that the statement:



vertex_values_u_D = u_D.compute_vertex_values(mesh)​



projects the Expression on V, in a different way the the erronorm(u_D, u, 'l2').

So if we project the u_D expression (degree=1) on V (or u_D expression (degree=2) on V(degree=2) before computing the L-2 norm we get good results:



error_L2 = 1.0876735128e-15
error_max = 1.33226762955e-15​


Maybe a Fenics developer can tell us the difference.

Alright it does sound like you're asking a different question than the one which I understood. Consider clarifying the question (by editing your original post). Also there is a feature (that I'm using now) to comment on an answer, which is a better way to discuss the answer I provided. I also don't always find AllAnswered to be entirely intuitive.

Just to continue the discussion: It seems mathematically correct to me that the vertex-wise solution may be accurate to machine precision, while the integrated L2 norm error would be substantial.
written 6 months ago by Alexander G. Zimmerman  
I agree with Alexander. I now see that L2 norm in errornorm function is actually integral over domain and L2 norm in np.linalg.norm function is just vertex wise norm.
written 6 months ago by Sergey Lebedev  
Alexander I did not post the original question. I p;osted a different answer from yours.

So after consideration,

the reason you see different values of L-2 norm error and vertex-wise error is because the Expression u_D is different order than the solution u.

It is not in general mathematically correct that if the error on the vertices is machine precision, than the L-2 norm could be substantial. This happens because L-2 norm considers ALSO the values of u_D on the faces of the elements not only on vertices, while compute_vertex_values considers values ONLY on vertices.

Since u_D is 2nd degree polynomial, there are values on the faces that do not correspond to any values of our solution u.
written 6 months ago by Minas Mattheakis  
My sincere apologies! Somehow I thought that your answer was from the OP. Thanks for clarifying.
written 6 months ago by Alexander G. Zimmerman  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »