CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Convection-diffusion in 1D : wrong solution for a large Delta x (http://www.cfd-online.com/Forums/openfoam/76790-convection-diffusion-1d-wrong-solution-large-delta-x.html)

nuovodna June 4, 2010 09:09

Convection-diffusion in 1D : wrong solution for a large Delta x
 
Hi, i wrote a solver to solve a convection-diffusion equation on a 1D mesh

fvScalarMatrix noUEqn
(
fvm::div(v,noU)
== fvm::laplacian(d1,noU)
);

where v is a constant value surfaceScalarField (value is 4), d1 is a constant value surfaceScalarField (value is 0.1) and noU is a volScalarField

Mesh: 1 m x 1 m x 1m [10 x 1 x 1] -> Delta x = 0.1
Boundary condition : inlet: noU=0 outlet: noU=1

Using UPWIND scheme on div(v,noU) i obtain a wrong noU field : all values are negative (the only positive value remains at the outlet like boundary condition says)!! If i reduce Delta x to 0.01 i obtain a positive noU field according to analitical solution.
I printed noUEqn.H() and noUEqn.A() and they are like the values manually computed with a simple spreadsheet.
How can i fix it?? Why at lower resolution it gives me negative values?

Thanks in advance
Regards

Emanuele

nuovodna June 7, 2010 09:45

If i use UPWIND scheme on div, I have this noU cell values:

Code:

-3.41333e-07
 -2.38933e-06
 -1.26293e-05
 -6.38293e-05
 -0.000319829
 -0.00159983
 -0.00799983
 -0.0399998
 -0.2
 -1

These values are totally different from analytical solution: they should be positive

nuovodna June 18, 2010 05:47

I invert the matrix manually and it returns the same negative value. Perhaps, the effect of boundary is dominant

santiagomarquezd July 1, 2010 13:25

Emanuele: are you inverting the noUEqn matrix

Code:

fvScalarMatrix noUEqn
        (                   
            fvm::div(v,noU)           
            == fvm::laplacian(d1,noU)
        );

inmediately after it is assembled or once solve is called?. Before calling solve noUEqn doesn't include the BC contribution.

Regards.

nuovodna July 2, 2010 05:45

I printed the noU values in this way

fvScalarMatrix noUEqn
(
fvm::div(v,noU)
== fvm::laplacian(d1,noU)
);

solve(noUEqn);

OFstream outCellValues("outCellValues.dat");
forAll(mesh.cells(), celli)
{
outCellValues << mesh.C()[celli].component(0) << " " << noU[celli] << endl;
}

titio July 2, 2010 11:48

Typical behaviour I guess
 
I believe you are getting the typical behaviour. If DeltaX is too high and using upwind you will get to much numerical dispersion, that disapear if you define a lower value of deltaX. Consult Versteeg for more information.

Regards,

Antonio Martins

santiagomarquezd October 2, 2010 18:47

Emanuele, I had forgotten this thread until a few days ago when I started to have the same issues with a similar problem, I reported them into the FOAM bug tracker and in the bug section of this forum:

http://www.cfd-online.com/Forums/ope...ssembling.html

problems seems to be related to the way of upwind scheme is implemented in FOAM.

Could post some info related to your problem, including books and papers where it is analyzed?

Regards.

ovie October 2, 2010 19:56

Hi,

I know this isnt related exactly to the problem in this thread, but bears some similarities nonetheless.

My question is: has anyone tried to implement InterFOAM in 1-D. I am trying to simulate Stefan problems using interFoam and apparently it looks like the solution in 1-D makes no sense while 2-D formulation appears to influence the results somewhat due to the additional boundary conditions.

If anyone has any ideas it would be nice.

Thanks.

santiagomarquezd October 2, 2010 23:07

Ovie, I've tried an 1D example of interFoam in order to study how compressive term works. It's a very interesting case because, momentum equation vanishes and only non-linear equation for phase is solved really. It allowed me to compare interFoam results with simple Matlab/Octave code. I'll be working on that again next weeks.

Maybe you can start a new thread about this topic to share some results.

Regards.

ovie October 2, 2010 23:40

Thanks Santiago,

As it is, I wasnt sure if my point had any merit to it thats why I was reluctant to start a new thread. But on your suggestion, I might just consider doing that to see if others with similar challenges can report their findings.

Thanks for your response all the same.

ovie October 3, 2010 00:59

Quote:

Originally Posted by santiagomarquezd (Post 277527)
Ovie, I've tried an 1D example of interFoam in order to study how compressive term works. It's a very interesting case because, momentum equation vanishes and only non-linear equation for phase is solved really. It allowed me to compare interFoam results with simple Matlab/Octave code. I'll be working on that again next weeks.

Maybe you can start a new thread about this topic to share some results.

Regards.

I have started a thread already.

But I am curious. How did you formulate the problem? I mean the mesh and what boundary conditions did you impose on patches? I have tried a simple approach of declaring only inlet and outlet patches for a 1-D rectangular block but when I run the computation, it is just completely useless results I get. So I would really like to see how you managed to pull this off...

Thanks

nuovodna October 4, 2010 05:53

one dimensional convection-diffusion results
 
4 Attachment(s)
Hi Santiago, these are my results.

Equation:

fvm::div(v,U) == fvm::laplacian(d,U)

with
d= 0.001
v = 1
U(0) = 0
U(1) = 1

Four schemes combination on div :
-) Gauss linear on div + Gauss linear corrected on laplacian (in figure as CDS)
-) Gauss upwind on div + Gauss linear corrected on laplacian (UPWIND)
-) Gauss linearUpwind cellMDLimited Gauss linear 1 on div + Gauss linear corrected on laplacian (LIMITERS)
-) Gauss limitedLinear 1 on div + Gauss linear corrected on laplacian (limitedLinear)


Classified according to Peclet number:

Pe = v * Delta x / d


Regards

Emanuele

titio October 4, 2010 07:29

What is the value of the time increment
 
Hi,

What is the value of the value increment? According to the figures, it looks you have a larger courant than allowed by stability requirements. Also, try to use more precise interpolation methods, such as gamma, minmod, or SFCD. Although non limited, they are much more precise than upwind...

Also, more information on this problem can be found in the book of Malaskera.

Regards,

António Martins

santiagomarquezd October 4, 2010 07:58

Emanuele. your results seems as I expected, particularly for Central Difference and Upwind. In CD the oscillations are normal due large Pe, this scheme is unstable for Pe>1. With respect of upwind it should be stable in all range of Pe numbers, but in FOAM it is not the case due the form of divergence assembling (check the link I posted a few days ago). Respect of limited schemes I would have expected a bounded behavior but it seem to have the same problems.
Could you post a paper o book in which this problem is shown? I'm searching too, but the only references I've got are for FEM.

Regards.

nuovodna October 4, 2010 08:18

expected results
 
Hi Santiago, i read your bug report and my results correspond to your alert on fvm::div assembling. This problem is described here

Finite Volume Method for Convection-Diffusion Problems

and in famous book like Peric or Veersteg

santiagomarquezd October 20, 2010 13:36

Emanuele, Professor Tung gives the right answer in slide 47 as you said, the explanation is taken from Versteeg.

Thx.


All times are GMT -4. The time now is 00:39.