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.

Using "WHILE" and "IF" statements in Comsol

Please login with a confirmed email address before reporting spam

Hi All,
I am trying to understand if it is possible to use "WHILE" and "IF" statements in Comsol. For example if I want a load to be increased "while" the stress level is below a certain value, temperature below a certain value, etc.

I assume that it's possible but am unsure as to how to implement it.

Thanks and regards,
Kevin


5 Replies Last Post 2010年1月4日 GMT-5 08:24
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 2009年12月31日 GMT-5 09:22
Hi

You do not have a written out "while" nor an "if", but you have almost the same via a bolean expression, see a couple of older discussion:

search for "conditional" on the forum

Good luck
Ivar
Hi You do not have a written out "while" nor an "if", but you have almost the same via a bolean expression, see a couple of older discussion: search for "conditional" on the forum Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2010年1月2日 GMT-5 09:16
Thanks Ivar,
I found the conditional search interesting and it may be useful if I am to implement discontinuous functions. However I'm not sure if it will help me with this situation where I simply want to terminate the solving process if the stress level in a component (anywhere on the subbdomain) becomes large than a set value (to eliminate unnecessary solving time). Perhaps what I am trying to do is not actually possible.

I thought that I could use a stop condition (and naiively) expected to be able to use a function like:

abs(sxy_smpn)<STRESS_MAX

However this gives me an error since it's not a scalar value with no variation in space....

Best regards,
Kevin

Thanks Ivar, I found the conditional search interesting and it may be useful if I am to implement discontinuous functions. However I'm not sure if it will help me with this situation where I simply want to terminate the solving process if the stress level in a component (anywhere on the subbdomain) becomes large than a set value (to eliminate unnecessary solving time). Perhaps what I am trying to do is not actually possible. I thought that I could use a stop condition (and naiively) expected to be able to use a function like: abs(sxy_smpn)

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 2010年1月2日 GMT-5 13:05
Hi

to get a value belonging to a subdomain, you have only the Bounday integration coupling variables, but these do an integration, not really what you want.

Your demand is rather similar to the tread:

"Maximum Temperature plot" from october 09 try a "search"

the reply was wait to V4


good luck
Ivar

Hi to get a value belonging to a subdomain, you have only the Bounday integration coupling variables, but these do an integration, not really what you want. Your demand is rather similar to the tread: "Maximum Temperature plot" from october 09 try a "search" the reply was wait to V4 good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2010年1月4日 GMT-5 06:47
Hi Ivar,
thanks for that update....when is V4 due for release? In the meantime I will try the work-around suggested.

An additional question.... with Comsol (in the case of a contact modelling problem) how can I make one of the bodies totally rigid (eliminating the need for meshing and reducing subsequent processing time)?

Thanks and regards,
Kevin

Hi Ivar, thanks for that update....when is V4 due for release? In the meantime I will try the work-around suggested. An additional question.... with Comsol (in the case of a contact modelling problem) how can I make one of the bodies totally rigid (eliminating the need for meshing and reducing subsequent processing time)? Thanks and regards, Kevin

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 2010年1月4日 GMT-5 08:24
Hi

Well for V4, I'm in the same situation as you I'm waiting and expecting, but I prefer astable issue rather than an unstable one, specially with my work to be done the coming weeks (by the way I'm NOT COMSOL, just a fan of multiphysics simulations ;).

Now youre question are touching one item on my several item long lists of improved load cases to be implemented. Unfortunately, I do not have a simple reply,

As you state, taking a given geometry with a density (hence mass and inertia) and transforming it into a simple Rigid Body load case for the I/F surfaces would be very handy, other FEM software have this feature, COMSOL not yet. Using the geometry as a fixed contacct I/F woul also be of interest.

If you do not mesh the geometry you cannot use it in the postprocessing, that is how COMSOL works. You select volumes, faces, edges or points, for your BC's but this is just a shortcut to select all meshed nodes belonging to the geometrical item.

But one could think of meshing a rigid part "simply" with little details and no dependent variables to avoid having it using to much RAM, then perhaps one could use a integration boundary variable or a contact pair. Finally "contact" is detected by a metrology of distance between nodes as they inerlace, you could try to replace one of the node references by a geometrical value.

It's several months since I was last playing with contacts now, so I have forgotten the variable names, would have to re-read the doc, so try to start there.

Good luck
Ivar
Hi Well for V4, I'm in the same situation as you I'm waiting and expecting, but I prefer astable issue rather than an unstable one, specially with my work to be done the coming weeks (by the way I'm NOT COMSOL, just a fan of multiphysics simulations ;). Now youre question are touching one item on my several item long lists of improved load cases to be implemented. Unfortunately, I do not have a simple reply, As you state, taking a given geometry with a density (hence mass and inertia) and transforming it into a simple Rigid Body load case for the I/F surfaces would be very handy, other FEM software have this feature, COMSOL not yet. Using the geometry as a fixed contacct I/F woul also be of interest. If you do not mesh the geometry you cannot use it in the postprocessing, that is how COMSOL works. You select volumes, faces, edges or points, for your BC's but this is just a shortcut to select all meshed nodes belonging to the geometrical item. But one could think of meshing a rigid part "simply" with little details and no dependent variables to avoid having it using to much RAM, then perhaps one could use a integration boundary variable or a contact pair. Finally "contact" is detected by a metrology of distance between nodes as they inerlace, you could try to replace one of the node references by a geometrical value. It's several months since I was last playing with contacts now, so I have forgotten the variable names, would have to re-read the doc, so try to start there. 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.