CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Why the initial residual is not zero?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Tobi
  • 1 Post By chaochaoyoyo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2016, 02:47
Unhappy Why the initial residual is not zero?
  #1
New Member
 
Zhanchao Hu
Join Date: Apr 2016
Posts: 8
Rep Power: 10
chaochaoyoyo is on a distinguished road
Hi All:

I 'm trying to solve transient buoyant-driven flow in a 2D cavity by my own solver. What makes me confused is when temperature field is uniform, the initial residual of temperature is not zero, which equals to 0.000188696!

The temperature of top and bottom wall are set equal to internal field, and the two side wall are zeroGradient. Besides, phi is zero, lambda and cv are dimensionedscalar (constant).

Any suggestion will be appreciated.

Code:
	

fvScalarMatrix TEqn
(
    fvm::ddt(rho, T)
  + fvm::div(phi, T)
  - fvm::laplacian(lambda/cv, T)	  
);
chaochaoyoyo is offline   Reply With Quote

Old   April 12, 2016, 06:39
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

we are doing iterative modeling. Think about that. You get numerical errors, discretization errors, interpolation errors and much more. Also if we simulate a flow in a simple pipe with inlet outlet and converged solution we could obtain p in the last iteration like 1e-4 that is actually not even zero too.

In your case it is clear for us that it should be zero but in the numerical point of view not really. Normally if you did everything correct you should get 0 of course (hex mesh and everything is well done). You can check that out with scalarTransportFoam. If you set U to zero -> phi = 0, set T initial and boundary to the same value you will get:

Code:
DILUPBiCG:  Solving for S, Initial residual = 0, Final residual = 0, No Iterations 0
Time = 0.0002
But here we are solving for incompressible flow:
Code:
            solve
            (
                fvm::ddt(S)
              + fvm::div(phi, S)
              - fvm::laplacian(DT, S)
             ==
                fvOptions(S)
            );
So I think you get the non zero values due to your time derivation. Which is at last:
\frac{\partial}{\partial t} ( \rho S ) = \rho \frac{\partial S} {\partial t} + S \frac{\partial \rho} {\partial t}

\rho \frac{\partial S} {\partial t} + S \frac{\partial \rho} {\partial t} = \rho^o \frac{S^n - S^o} {\Delta t} + S^0 \frac{\rho^n - \rho^o} {\Delta t}

Rho is calculated by thermodynamics and could return numerical errors. That would be the reason in your case. You can try to fix rho to a const value. Then each term should vanish and you should end up with zero.
SamPrabhu likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 24, 2016, 11:45
Smile
  #3
New Member
 
Zhanchao Hu
Join Date: Apr 2016
Posts: 8
Rep Power: 10
chaochaoyoyo is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hi,

we are doing iterative modeling. Think about that. You get numerical errors, discretization errors, interpolation errors and much more. Also if we simulate a flow in a simple pipe with inlet outlet and converged solution we could obtain p in the last iteration like 1e-4 that is actually not even zero too.

In your case it is clear for us that it should be zero but in the numerical point of view not really. Normally if you did everything correct you should get 0 of course (hex mesh and everything is well done). You can check that out with scalarTransportFoam. If you set U to zero -> phi = 0, set T initial and boundary to the same value you will get:

Code:
DILUPBiCG:  Solving for S, Initial residual = 0, Final residual = 0, No Iterations 0
Time = 0.0002
But here we are solving for incompressible flow:
Code:
            solve
            (
                fvm::ddt(S)
              + fvm::div(phi, S)
              - fvm::laplacian(DT, S)
             ==
                fvOptions(S)
            );
So I think you get the non zero values due to your time derivation. Which is at last:
\frac{\partial}{\partial t} ( \rho S ) = \rho \frac{\partial S} {\partial t} + S \frac{\partial \rho} {\partial t}

\rho \frac{\partial S} {\partial t} + S \frac{\partial \rho} {\partial t} = \rho^o \frac{S^n - S^o} {\Delta t} + S^0 \frac{\rho^n - \rho^o} {\Delta t}

Rho is calculated by thermodynamics and could return numerical errors. That would be the reason in your case. You can try to fix rho to a const value. Then each term should vanish and you should end up with zero.
Thank you for your reply. After using relative temperature rather than absolute temperature, this problem is solved! I think it is mainly caused by machine accuracy. Your reply has given me a lot of inspiration.
Tobi likes this.
chaochaoyoyo is offline   Reply With Quote

Old   July 4, 2016, 09:51
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Dear all,

to clear the topic... the above equation is only valid if we solve explicit. As we can see from the implementation, we solve implicit. That means that we create a matrix that has to be solved. Solving the algebraic set of equations will result in numerical errors that would lead to the initial error here (:
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   November 22, 2017, 10:49
Default
  #5
Member
 
Join Date: May 2017
Posts: 44
Rep Power: 9
bbita is on a distinguished road
Dear Foamers,

I am facing the same problem in different solvers. The density is not the reason as I tried to remove density from the equation and the same thing happened. Using relative parameter (e.g. zero instead of 300K for temperature) solved the issue. My problem is if I have some variation in my system, even if when my temperature become steady, I have some initial residual and my simulation is not speeding up. Any idea?
bbita is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
simpleFoam error - "Floating point exception" mbcx4jc2 OpenFOAM Running, Solving & CFD 12 August 4, 2015 03:20
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 14:12
pimpleFoam: turbulence->correct(); is not executed when using residualControl hfs OpenFOAM Running, Solving & CFD 3 October 29, 2013 09:35
calculation stops after few time steps sivakumar OpenFOAM Running, Solving & CFD 7 March 17, 2013 07:37
Orifice Plate with a fully developed flow - Problems with convergence jonmec OpenFOAM Running, Solving & CFD 3 July 28, 2011 06:24


All times are GMT -4. The time now is 23:19.