Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

how to avoid negative concentration

Please login with a confirmed email address before reporting spam

Hi,

I have a dynamic diffusion problem. I do not know why after running some time, I can get some negative values...I have checked the boundary conditions and they are correct...The concentration can not go for minus values...but actually I got negative values and I could not explain why...

Is there someone could hlep me to solve this problem or give me some suggestions?

Thanks in advance.

Xin

14 Replies Last Post Feb 8, 2016, 2:13 a.m. EST

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 17, 2010, 1:12 p.m. EDT
Is there anyone could help me? This problem is really strange...

I have checked...at some point I already got a zero flux at boundary which means the concentration will remain the same but it was not...The concentration still decrease...I am confused by this results because the boundary flux was already zero how can I get decreased concentration even minus concentration?

I read from the Knowledge Base that we could use smooth step function to avoid this but I did not really get how to do it...

I will appreciate if some could help me to work this out.

Thanks!

Xin
Is there anyone could help me? This problem is really strange... I have checked...at some point I already got a zero flux at boundary which means the concentration will remain the same but it was not...The concentration still decrease...I am confused by this results because the boundary flux was already zero how can I get decreased concentration even minus concentration? I read from the Knowledge Base that we could use smooth step function to avoid this but I did not really get how to do it... I will appreciate if some could help me to work this out. Thanks! Xin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 17, 2010, 5:49 p.m. EDT
I had the same problem. Seems that it results from too rude mesh.
Using "Refine Mesh" command always helped me,
though at first I have not expected that I need such a refined mesh to eliminate
large variations of concentration and its negative values.

Good luck,
Arsen
I had the same problem. Seems that it results from too rude mesh. Using "Refine Mesh" command always helped me, though at first I have not expected that I need such a refined mesh to eliminate large variations of concentration and its negative values. Good luck, Arsen

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 18, 2010, 5:06 a.m. EDT
Hi Arsen,

Thanks for your suggestions. But it was not suitable for my problem...do you have any other suggestions? Thanks a lot.

Xin
Hi Arsen, Thanks for your suggestions. But it was not suitable for my problem...do you have any other suggestions? Thanks a lot. Xin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 18, 2010, 1:35 p.m. EDT
It is possible that you have instability problems, which are common with high convection PDEs.

Try using "artificial diffusion". This way you will not get overshoots and undershoots around c=0. Also try refining the mesh where the element has high C.

There is a KnowledgeBase dedicated to this kind of problems. please search negative concentration.
It is possible that you have instability problems, which are common with high convection PDEs. Try using "artificial diffusion". This way you will not get overshoots and undershoots around c=0. Also try refining the mesh where the element has high C. There is a KnowledgeBase dedicated to this kind of problems. please search negative concentration.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 19, 2010, 12:12 p.m. EDT
Thanks for everyone's help. The problem is finally solved by using smoothing step function as introduced in the knowledge base.
Thanks for everyone's help. The problem is finally solved by using smoothing step function as introduced in the knowledge base.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 23, 2010, 12:20 p.m. EDT
Hello.

I have a similar problem. Could you explain me how to use the smoothing function introduced in the KnowledgeBase?

Thanks a lot.
Hello. I have a similar problem. Could you explain me how to use the smoothing function introduced in the KnowledgeBase? Thanks a lot.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 24, 2010, 6:30 a.m. EDT
for my case, because I have a negative concentration which I guess it is because of the boundary conditions.

the boundary condition is:

N = kc*(Csurface-Cair)

with smoothing function

N = flc2hs(Cair-Csurface,dC)*kc*(Csurface-Cair)

where the variable dC is a constant that defines the smoothing interval width. Define this variable on the Options>Constants menu. It will take some experimenting to find a good value; start with a large value (large enough so that negative values do not occur), then decrease it as far as possible while keeping the solution positive.

I hope it helps.

Good luck,

Xin
for my case, because I have a negative concentration which I guess it is because of the boundary conditions. the boundary condition is: N = kc*(Csurface-Cair) with smoothing function N = flc2hs(Cair-Csurface,dC)*kc*(Csurface-Cair) where the variable dC is a constant that defines the smoothing interval width. Define this variable on the Options>Constants menu. It will take some experimenting to find a good value; start with a large value (large enough so that negative values do not occur), then decrease it as far as possible while keeping the solution positive. I hope it helps. Good luck, Xin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 25, 2010, 6:45 a.m. EDT
Hi.

I am very new to Comsol, and I cannot find where to write this equation.

Is it in the NS model or in the CD one ? Can you more specific please ?

Thank you so much.
Hi. I am very new to Comsol, and I cannot find where to write this equation. Is it in the NS model or in the CD one ? Can you more specific please ? Thank you so much.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 25, 2010, 7:25 a.m. EDT
first, you need to make sure where you want to have this smooth function.

my example is just my case, for yours, you must think about where you want this? at boundary condition or some other expressions. then you can just put the smooth function in front of your equation.

flc2hs(a,dC)*your equation.

the equation can be at boundaries or at any global expression.

I hope it is clear now
first, you need to make sure where you want to have this smooth function. my example is just my case, for yours, you must think about where you want this? at boundary condition or some other expressions. then you can just put the smooth function in front of your equation. flc2hs(a,dC)*your equation. the equation can be at boundaries or at any global expression. I hope it is clear now

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 19, 2010, 5:45 a.m. EDT
If the dependent variable is something like mass or particle density that must always be a positive quantity, another solution is to rewrite the original DE in terms of the logarithm of the variable. This would then require using the equation form to set up the model, and the terms might be complicated, but at least you would automatically be guaranteed that the results would be positive, regardless of whatever instability that there might be because of a too-course meshing.
If the dependent variable is something like mass or particle density that must always be a positive quantity, another solution is to rewrite the original DE in terms of the logarithm of the variable. This would then require using the equation form to set up the model, and the terms might be complicated, but at least you would automatically be guaranteed that the results would be positive, regardless of whatever instability that there might be because of a too-course meshing.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 25, 2010, 2:42 p.m. EDT

the boundary condition is:

N = kc*(Csurface-Cair)



Hi Xin,

I am currently setting up my very first coupled convection/diffusion and fluid flow testcase in COMSOL and thus I have an extremely basic question, but I just don't see how it is done. How do you specify this flux in a case where you have convection and diffusion? Or rather how do you address the variable "C on the boundary" and "C in the flow"? Thank you very much for your help.

Franz
[QUOTE] the boundary condition is: N = kc*(Csurface-Cair) [/QUOTE] Hi Xin, I am currently setting up my very first coupled convection/diffusion and fluid flow testcase in COMSOL and thus I have an extremely basic question, but I just don't see how it is done. How do you specify this flux in a case where you have convection and diffusion? Or rather how do you address the variable "C on the boundary" and "C in the flow"? Thank you very much for your help. Franz

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 25, 2010, 4:15 p.m. EDT
To rephrase my question from above (I have looked all over tutorials, model files and such and could not find this): What is the proper syntax to define a Flux Discontinuity at a fluid/solid (or solid/solid) interface in the form: N = k*(c_surface - c_flow) ?
Thank you for any help on this.

Franz
To rephrase my question from above (I have looked all over tutorials, model files and such and could not find this): What is the proper syntax to define a Flux Discontinuity at a fluid/solid (or solid/solid) interface in the form: N = k*(c_surface - c_flow) ? Thank you for any help on this. Franz

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Feb 7, 2016, 2:09 p.m. EST
Hi,
I am also facing the problem of negative concentration.
I have gone through your post.
In my model when I am using the modified flux condition in your post,
'N = flc2hs(Cair-Csurface,dC)*kc*(Csurface-Cair)'
it is displaying inconsistent units.
Can you help me with this?
Hi, I am also facing the problem of negative concentration. I have gone through your post. In my model when I am using the modified flux condition in your post, 'N = flc2hs(Cair-Csurface,dC)*kc*(Csurface-Cair)' it is displaying inconsistent units. Can you help me with this?

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Feb 8, 2016, 2:13 a.m. EST
Function flc2hs is nagging due to inconsistent units because it is a plain function without any units. Yet, it does not harm the computation. You can try writing

flc2hs((Cair-Csurface)/C0, dC/C0)

where C0 is a parameter 1 mol/L (the standard concentration).

BR
Lasse
Function flc2hs is nagging due to inconsistent units because it is a plain function without any units. Yet, it does not harm the computation. You can try writing flc2hs((Cair-Csurface)/C0, dC/C0) where C0 is a parameter 1 mol/L (the standard concentration). BR Lasse

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.