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.

Small question: How to change (conditional) statement to give an actual value instead of just 0 or 1?

Please login with a confirmed email address before reporting spam


Dear COMSOL enthusiasts, I have a (relatively) small question this time.

I made a function that describes the decrease of matter in an element. Now, when the amount of matter reaches, for example, 1% of the initial mass (so 99% is gone), I want another function to start (a PDE).
I used IF statements to do this, but this gives instabilities as I explained in this thread:

[www.comsol.com/community/forums/general/thread/27497/] (Numerical instability when (conditionally) switching a PDE on).
I still don't know why the instabilities happen, but I did found out that if I just put in a number for the time that the condition is met (for example t=2000s), there are no instabilities.

So I do get them using:
if(m_H2O_l_kg>=0.01*Moisture_init_wtkg_zone,0,1)

And I don't get hem using :
if(t<2083.8,0,1) (which is almost insane since both equations give exactly the same result)
The point is that (in reality) I don't know in advance at what time this will happen because this is dependent on many factors.

So my question is this: is there a way to make a (conditional) statement to calculate the actual time instead of making a (step-type) function go from 0 to 1 (like usual conditional statements do) ? Maybe if I calculate the time and then put that in I don't get the instabilities.

I am looking forward to any replies. Many thanks for your time and help.
Kind regards,

Raymond

PS.
I included 2 graphs. The first shows the result of the first equation (unstable), the second shows the results from the second equation (smooth), green is the funcion in question and red is the activation of the conditional statement.


1 Reply Last Post 8 avr. 2012, 08:08 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 avr. 2012, 08:08 UTC−4
So, I just need a statement that give me the value for the time when this statement is true:
if(m_H2O_l_kg>=0.01*Moisture_init_wtkg_zone,0,1)

Any ideas?

Kind regards,

Ray
So, I just need a statement that give me the value for the time when this statement is true: if(m_H2O_l_kg>=0.01*Moisture_init_wtkg_zone,0,1) Any ideas? Kind regards, Ray

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.