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

Negative values in a modified scalarTransportFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes
  • 1 Post By wildfire230
  • 5 Post By invadoria
  • 3 Post By invadoria
  • 1 Post By randolph

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2018, 13:16
Default Negative values in a modified scalarTransportFoam
  #1
Senior Member
 
Join Date: Jul 2013
Posts: 124
Rep Power: 12
wildfire230 is on a distinguished road
Hi all,

I am using a modified version of scalarTransportFoam which allows for variable diffusivity (although the problem I am encountering is also present for constant diffusivity). First, I solve the steady state flow profile using simpleFoam, which shows excellent convergence, approaches velocity profile I expect, and shows very small divergence errors, i.e. max(fvc::div(phi)) < 10^(-10).

This velocity field includes some recirculation near the boundary, where I impose a fixed uniform value of the scalar. Due to this convective term, my scalar concentration goes negative near the boundary, which is unphysical. I am trying to figure out exactly what numerical schemes and solvers I should be using for this problem. Currently I am using:
C
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-10;
relTol 0;
}

where C is my scalar concentration, and
div(phi,C) Gauss linearUpwind Gauss linear;
but I have also tried many alternatives including bounded Gauss upwind, Gauss linear, Gauss upwind, etc...

I would really appreciate any help!

Thanks
Adriana Correia likes this.
wildfire230 is offline   Reply With Quote

Old   April 27, 2018, 14:57
Default
  #2
New Member
 
invadoria's Avatar
 
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16
invadoria is on a distinguished road
I recommend you to use limited scheme for the divergence term to limit the scalar variable C in the range of 0 to 1. Otherwise negative values may be encountered due to the truncation errors arising from the discretization scheme.
invadoria is offline   Reply With Quote

Old   April 27, 2018, 15:22
Default
  #3
Senior Member
 
Join Date: Jul 2013
Posts: 124
Rep Power: 12
wildfire230 is on a distinguished road
Awesome, thanks for this suggestion. I didn't know there were specific schemes for this case, but from what I can gather from the documentation it seems like:

div(phi,C) Gauss limitedLinear01 1;

is the proper choice. Does that make sense? It does seem to result in smaller negative values for my scalar concentration, but it still doesn't strictly enforce positivity. Is there something I'm missing?
wildfire230 is offline   Reply With Quote

Old   April 27, 2018, 15:52
Default
  #4
New Member
 
invadoria's Avatar
 
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16
invadoria is on a distinguished road
I had used Gamma01 method to strictly bound the scalar variable.
invadoria is offline   Reply With Quote

Old   April 27, 2018, 16:29
Default
  #5
Senior Member
 
Join Date: Jul 2013
Posts: 124
Rep Power: 12
wildfire230 is on a distinguished road
Thanks, I didn't find the Gamma01 method in the fvSchemes documentation, but when I try:

div(phi,C) Gauss Gamma01 1;

in my divSchemes, I still find values of C that are negative. Am I still missing something?

Edit: following hjasak's instructions here: Schemes for scalar in LES I also switched to

laplacian(D,C) Gauss linear limited 1;

and switched to Euler for ddt scheme. I still end up with negative values for my C. Also they are not trivially small values, but almost the same order of magnitude as my positive values.

Thanks again
wildfire230 is offline   Reply With Quote

Old   April 29, 2018, 03:08
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Post your code.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   April 30, 2018, 10:36
Default
  #7
Senior Member
 
Join Date: Jul 2013
Posts: 124
Rep Power: 12
wildfire230 is on a distinguished road
Here is an example code that illustrates the problem. I am using OpenFOAM 5.0. Simply unzip the directory, run blockMesh, and then simpleFoam, which will converge in about 0.525 seconds. Then copy the T initial condition into the converged directory: "cp 0/T 0.525". Then run scalarTransportFoam. If you use paraView to look at the final result, you will see that there are negative temparature values, which are non-physical. They're not that dramatic, but they also are not negligible, and I cannot eliminate them regardless of which fvSchemes I choose.

I would greatly appreciate any help. This same problem has been a hindrance on multiple different simulations at this point.

Thanks!

Edit: Also I should note that these negative values do not appear to go away with a more refined grid.
Attached Files
File Type: zip rheometer_CFD_Online.zip (8.5 KB, 18 views)

Last edited by wildfire230; May 2, 2018 at 08:46.
wildfire230 is offline   Reply With Quote

Old   May 2, 2018, 16:25
Default
  #8
Senior Member
 
Join Date: Jul 2013
Posts: 124
Rep Power: 12
wildfire230 is on a distinguished road
I haven't done a comprehensive set of tests, but these negative values from scalarTransportFoam do not appear to go away with a finer mesh or smaller time step. I think it must be an issue with the selection of schemes, but I do not understand the details well enough.
wildfire230 is offline   Reply With Quote

Old   May 23, 2018, 13:04
Default
  #9
Senior Member
 
Join Date: Jul 2013
Posts: 124
Rep Power: 12
wildfire230 is on a distinguished road
Hi all, I am still trying to solve this problem. Does anyone know the requirements on grid size for stability of the scalarTransportFoam solver for a given diffusivity coefficient and velocity field? For example, here: https://en.wikipedia.org/wiki/Numeri...usion_equation there is a condition listed as h < 2a/u, where a is the diffusivity coefficient, h is the grid size, and u is the fluid velocity. However, I believe this is specifically for the case of forward Euler centered difference.


Does anyone know the restrictions on grid size for scalarTransportFoam for a given diffusivity coefficient. Specifically, in my case the diffusivity is very small, so that the Peclet number is large.
wildfire230 is offline   Reply With Quote

Old   August 26, 2018, 19:15
Default
  #10
Senior Member
 
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 10
randolph is on a distinguished road
Quote:
Originally Posted by wildfire230 View Post
Hi all, I am still trying to solve this problem. Does anyone know the requirements on grid size for stability of the scalarTransportFoam solver for a given diffusivity coefficient and velocity field? For example, here: https://en.wikipedia.org/wiki/Numeri...usion_equation there is a condition listed as h < 2a/u, where a is the diffusivity coefficient, h is the grid size, and u is the fluid velocity. However, I believe this is specifically for the case of forward Euler centered difference.


Does anyone know the restrictions on grid size for scalarTransportFoam for a given diffusivity coefficient. Specifically, in my case the diffusivity is very small, so that the Peclet number is large.
Hi,

I have encountered the same issue. I am having the scalar negative. I think its the solver issue more than the scheme. I am planning dig into the multiphase solver to check the implementation. Have you gotta any updates?

Thanks,
Rdf
Adriana Correia likes this.
randolph is offline   Reply With Quote

Old   August 27, 2018, 00:58
Default
  #11
Senior Member
 
piu58's Avatar
 
Uwe Pilz
Join Date: Feb 2017
Location: Leipzig, Germany
Posts: 744
Rep Power: 15
piu58 is on a distinguished road
> This velocity field includes some recirculation near the boundary, where I impose a fixed uniform value of the scalar. Due to this convective term, my scalar concentration goes negative near the boundary, which is unphysical.

I assume this is an outlet with a zero gradient b.c. for velocity.

If you give zero gradient than it has to be there. The simulation is overstrained to enforce this. If possible, extend the outflow area to give the flow room for homogenizing.
__________________
Uwe Pilz
--
Die der Hauptbewegung überlagerte Schwankungsbewegung ist in ihren Einzelheiten so hoffnungslos kompliziert, daß ihre theoretische Berechnung aussichtslos erscheint. (Hermann Schlichting, 1950)
piu58 is offline   Reply With Quote

Old   August 28, 2018, 08:29
Default
  #12
Senior Member
 
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 10
randolph is on a distinguished road
After some playing around with the code, it looks like this problem is associated with the boundary condition when the flow is pointing outwards. If you apply a fixedValues or a fixedGradient BC (centrally a fixedValues types too), the outgoing flux on that face will be calculated with the values that you specified which potentially will be larger than the quantity in that cell and produce a negative value. This is also should be the reason why there is the inletOutlet BC in the OpenFOAM (zeroGradient for outflow and fixedValue for inflow). Someone correct me if I am wrong.

Now for the most of the problem that you can avoid the inflow (reverse flow), you can just take care of this problem when you compute the flow field.
randolph is offline   Reply With Quote

Old   July 15, 2021, 04:10
Unhappy negative temperature using periodic temperature boundary
  #13
New Member
 
Yanjun Tong
Join Date: Jul 2020
Posts: 13
Rep Power: 5
Hughtong is on a distinguished road
Quote:
Originally Posted by randolph View Post
Hi,

I have encountered the same issue. I am having the scalar negative. I think its the solver issue more than the scheme. I am planning dig into the multiphase solver to check the implementation. Have you gotta any updates?

Thanks,
Rdf
Hi, I'm dealing with a periodic channel in the streamwise direction and periodic temperature BCs are applied, and the results got the negative, which is totally non-physical, but with the process of nondimensionless, the profile of temperature with the function of yplus can match with DNS database
Hughtong 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
Preventing negative scalar (UDS) values?? Matthew Brannock FLUENT 5 September 1, 2020 12:32
Cannot achieve negative wall shear stress values in CFD Post (ANSYS) SAtkins CFX 3 August 3, 2016 14:27
Negative values for minimum alphas Taataa OpenFOAM Running, Solving & CFD 0 June 28, 2016 04:04
Problem using large writeInterval values in Modified interPhaseChangeFoam vasava OpenFOAM Running, Solving & CFD 4 January 27, 2015 03:02
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 13:06


All times are GMT -4. The time now is 11:41.