Flux calculation in Simple diffusion does not work!

Numerical methods and mathematical models of Elmer
jfaraudo
Posts: 17
Joined: 11 May 2018, 11:50
Antispam: Yes

Re: Flux calculation in Simple diffusion does not work!

Post by jfaraudo »

Thank you very much again Matthias,

You are right, the only real issue still remaining is the convective flux.

The value of the convective flux looks like the program is computing the surface area (0.005 m x 1 m) by the concentration (0.1 Kg/m3) and a velocity of 1 m/s instead of 0 (this gives the 5e-4 reported by Elmer). For some reason the program does not use the zero velocity.

I'll wait for Peter to report on that, but if I have the time, I'll look at the fortran program.

thanks again!


jordi
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Flux calculation in Simple diffusion does not work!

Post by raback »

Hi Jordi

I'm a little offended that you decleare that I didn't look close enough at the case. In fact I even fetched in from git and run the case through and compared the results plotting them in octave. Everything was fine. I can accept that I didn't carefully enough report the findings. Devil lies in the detail.

What I tried to say about convective flux is that it does not make any sense in this context. It computes \int c \vec{v} \cdot \vec{n} dA where v is the given variable. In this case it was concentration. So what is obviously sloppy with the code is that it does not require v to be a vector quantity. It takes then just the 1st term of the dot product (the reason for sloppiness in cylindrical symmetry where dimension of space and v differ). The "convective flux" to make more sense should involve a solved vector field as the variable. For example, variable "velocity" and coefficient "density" may be used to compute mass fluxes. Now you didn't even solver for velocity.

As Matthias correctly pointed out FEM does not ensure conservation (as does FVM). There are conservative formulations also in FEM but typically for Poisson equation standard Galerkin method is used. In fact you can find FEM codes giving same results with same elements almost to number precision. Note that Comsol by default may use quadratic elements guaranteeing a much better flux conservation than linear elements.

-Peter
jfaraudo
Posts: 17
Joined: 11 May 2018, 11:50
Antispam: Yes

Re: Flux calculation in Simple diffusion does not work!

Post by jfaraudo »

Dear Peter,

I disagree. The convective flux makes sense , and it has to be zero because velocity is zero. In this very same example in ghithub, when we solve for the velocity using NS we get a zero velocity field in all the system and the same convective flux that we reported there. You can check it by yourself.

The problem is that the things that you explain (that make sense) do not correspond with the things that we found in Elmer manual.

We computed the convective flux guided by the Manual and previous posts in the forum
(see viewtopic.php?f=3&t=4269&hilit=convecti ... ble#p15172 )

According to the Manual, the calculation of the convective flux Fcon is (I do not see how to insert images here so I will use LateX notation):

Fcon = \int_{Gamma} c \vec{v} \vec{n} d\Gamma

Here I understood that "c" is the concentration and "v" the velocity. Anyway, since the velocity field "v" is undefined (so it is zero), the integral has to be zero (or report a warning or error) but Elmer reports a large and different from zero value.

Of course, we repeated the simulation solving NS equations and we still get the same values of the convective flux.

Now, we have changed our .sif trying to interpret what you said.
It seems that now the convective flow is zero, as it should be, so the answer was simply to modify the .sif to ask Elmer to calculate correctly the physical magnitudes. It is very difficult to interpret from Elmer manual what to do exactly , some definitions are rather counterintuitive (for example "c" in the integral of Fcon is not the concentration as it seems at a first look but a coefficient which could be the concentration. I would rather said that concentration is a scalar field, not a coefficient, but anyway...)

After finishing our tests (4 cases of increasing complexity from pure diffusion to electrochemistry) we will post the results in githib and we will try to build up a tutorial with these. I think it is always useful to have tutorials to start running simple cases and then it is easier to go to the real stuff.

thanks to everytbody that answered all our posts

Jordi


-
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Flux calculation in Simple diffusion does not work!

Post by raback »

Hi All,

What you write makes sense but it is not what the code did. It assumed that you really give "v". The coefficient "c" was material property (defaulted to unity if not given). So as example "v" could have been velocity and "c" density. If "v" was scalar it just computed the line integral.

I just worked a little with the code and now really the flux of type c*f*v is possible. If the given "variable" is scalar it is taken as "f" and the code tries to find the "v" computed by N-S equation. Most importantly, I added "Warn" if the variable is scalar and velocity does not exist. So as in your case there was now velocity field the right thing to do is to complain about it and refuse to compute the flux.

There is a test case "AdvDiffFluxes" that demonstrate these.

-Peter
Post Reply