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.

Question on conditional statement

Please login with a confirmed email address before reporting spam

Hi All,

Can any one tell me the difference between these conditions:

1. if((x<1.5),k*c,0)

2. flc1hs(1.5-x,1e-8)*k*c

3. flc1hs(1.5-x,1e-20)*k*c

Because,

if i use 1 & 3 conditions then my model is stop converging in the middle of simulation. it is solving some time steps but not all.

if i use 2nd condition then my model is converging and solving complete time steps..

So, i am just confused and unable to think/imagine what went wrong with 1& 3.

I hope some one will come up with comments/ideas/suggestions..

Thanks,

Manohar

2 Replies Last Post Oct 5, 2010, 1:38 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Oct 4, 2010, 4:30 a.m. EDT
1. if((x<1.5),k*c,0)

This is a step function. meens exactly at x=1.5 you will have a very sharp change. Solvers hate it.

2. flc1hs(1.5-x,1e-8)*k*c

Means at x=1.5 you have a smoothing of 1e-8 around it. so your value increases from 0 to 1 in a 1e-8 window. It is still very small (unless you work with lasers etc)

3. flc1hs(1.5-x,1e-20)*k*c

This is bad, nearly the same as 1, since 1e-20 is effectively 0. So your increase window is 0, so it is practically a on-off swicth, like 1. Solvers hate it :)
1. if((x

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Oct 5, 2010, 1:38 a.m. EDT
Hi

Knowing that "eps" (the smallest number step distinguisable from 1) is 2.22e-16 on my PC, it is really not worth playing with ratios that compare to "eps" even to within a few tousand time.

The binary number system is far from "perfect" and rather different from our decimal representation

--
Good luck
Ivar
Hi Knowing that "eps" (the smallest number step distinguisable from 1) is 2.22e-16 on my PC, it is really not worth playing with ratios that compare to "eps" even to within a few tousand time. The binary number system is far from "perfect" and rather different from our decimal representation -- Good luck Ivar

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.