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.

Problem with Conditional Statement

Please login with a confirmed email address before reporting spam

Hello all,

I am working on a dissolution and multiple precipitation problem. I am using Diffusion and Moving Mesh (ALE) application modes in COMSOL 3.4 v. I have to set a conditional statement on one of the boundary in such way that it should stop moving after it reaches a value.

for example,

if r<1.5 then v=dr/dt=k*c
if r >1.5 then v=dr/dt=0

So, I am using a conditional statement like this: if((r<1.5),k*c,0). But the problem is it is stopping the whole simulation when it reaches the value of 1.5.

What i expected is :It should stop moving that boundary and it should take 0 and have to run the simulation for later times but it's not doing that. I have no answer.

I tried using the smooth function "flch1s" (like this: flch1s(1.5-r,1e-8)*k*c) instead of if, and it's working but there is a slight variation in my solution due to smoothing. if increase the error from 1e-8 to 1e-20, then it is behaving just like if statement.

I would greatly appreciate, if some one come up with an answer.

Thanks,

Manohar


2 Replies Last Post 18 mars 2014, 02:56 UTC−4
COMSOL Moderator

Hello Manohar Gottapu

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18 mars 2014, 00:25 UTC−4
Hi,

I am dealing with a very similar problem. Did you figure it out ?

Thanks in advance,
Sanket
Hi, I am dealing with a very similar problem. Did you figure it out ? Thanks in advance, Sanket

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18 mars 2014, 02:56 UTC−4
How about defining the variable directly as k*c*(r<1.5) ?


Hello all,

I am working on a dissolution and multiple precipitation problem. I am using Diffusion and Moving Mesh (ALE) application modes in COMSOL 3.4 v. I have to set a conditional statement on one of the boundary in such way that it should stop moving after it reaches a value.

for example,

if r<1.5 then v=dr/dt=k*c
if r >1.5 then v=dr/dt=0

So, I am using a conditional statement like this: if((r<1.5),k*c,0). But the problem is it is stopping the whole simulation when it reaches the value of 1.5.

What i expected is :It should stop moving that boundary and it should take 0 and have to run the simulation for later times but it's not doing that. I have no answer.

I tried using the smooth function "flch1s" (like this: flch1s(1.5-r,1e-8)*k*c) instead of if, and it's working but there is a slight variation in my solution due to smoothing. if increase the error from 1e-8 to 1e-20, then it is behaving just like if statement.

I would greatly appreciate, if some one come up with an answer.

Thanks,

Manohar


How about defining the variable directly as k*c*(r

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.