CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   Negative concentration (

Gab September 9, 2005 15:45

Negative concentration
Hi, all

For a Additional variable(say 'bacteria'), a source term was given to describe the bacteria decay kinetics.

The question is that, if the inital concentration in certain zones of the domain is very small,can the the concentration of 'bacteria' gradually reduce to less than zero.

If yes, how to avoid this?




Robin K September 10, 2005 13:25

Re: Negative concentration
Hi, To prevent concentrations diving below zero, I would try Putting a MAX statement (assuming you're using USER FORTRAN).

(1) If your additional variable is a function of CFX VARIABLE, then, (say for TEMPERATURE,T or SCALAR1),


(2) OR, for one of your own variable (e.g., DENT), then you can try something like this:

MAX(DENT, 1.0E-08)

Hope this helps,


Gab September 10, 2005 20:17

Re: Negative concentration
Thanks, Robin.

Unfortunitely, I am not using User Fortran. Are there other ways to solve this problem?



Robin K September 10, 2005 20:55

Re: Negative concentration
Hi, Gab

Sorry, then I assume ur using CFX 5/10. I am a user of CFX 4 only...and so not aware of syntax in CFX 5.

Sorry, can't be much of help in this regards, but if you have a look at the CFX 5 reference guide on the CEL. maxVal<var> may have the same effect as I was trying to convey earlier...


Gab September 10, 2005 22:43

Re: Negative concentration
Thanks anyway. I will search this in helpfile.

Best regards!


Jeff September 10, 2005 23:46

Re: Negative concentration
Bacterial decay rates are usually exponential functions of the local concentration. As the concentration gets smaller, the rate gets smaller as well. A sufficiently small time step should prevent negative concentrations, at least it has in the calcs I've done.


Gab September 12, 2005 09:26

Re: Negative concentration
Thanks, Jeff

I did see some negative values in my solution. This may be caused by relative big time step or by wrong cel fuction I defined.

I will try as you suggested.

Best Regards!


matej September 17, 2005 06:21

Re: Negative concentration

I guess you define the kinetics in CEL under CFX5 or 10?

then you can use the min and max as Robin posted in the Expression editor too!


Rui September 17, 2005 13:16

Re: Negative concentration

I think Gab is using a transport equation to solve the bacteria concentration. Thus, it isn't possible via CEL to define the bacteria concentration with min or max functions.But, as Jeff mentioned, if the decay rate gets to zero as the concentration gets to zero, a "sufficiently" small time step shall prevent negative concentrations.

But I think that even with a quite small time you may get negative concentrations, but those negative values will be so small you may ignore them.

If you need the bacteria concentration (C) for other calculations, and if it's important that the concentration isn't negative, you may create another expression, or if you need so another variable, C'=max(0,C) or C'=max(1e-8,C)

All times are GMT -4. The time now is 04:12.