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.

Replace variable with scalar expression

Please login with a confirmed email address before reporting spam

Hi folks,

I was wondering if it is possible to replace a variable in COMSOL like spf.rho using an scalar expression define in the "Definitions->Variables" so it applies to the whole model.

Allow me to elaborate: let's say that I want to replace the turbulent dissipation (ep) with the following expression ep=eptil+D.

Can this be applied to he whole model or do I have to replace it one by one in the Equation View mode?
Basically, replacing the ep variable in comsol with a custom one provided by me, globally.

Hope I was clear.

Best Regards,

Rui Silva

2 Replies Last Post Feb 6, 2012, 7:16 a.m. EST
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 Feb 3, 2012, 2:39 p.m. EST
Hi

Many things are possible. For the material properties such as rho you can either edit the material node, or you select "User Defined" in the physics node and enter an expression defined in a parameter, or a variable or ... (note you might make a circular dependency that cannot be solved, then you get an error message and must find another way, often via an ODE) or mostly you make your model non-linear and might need some tweaking to get it to solve smoothly, but you can loop it around at your will.

If you want to redefine an internal COMSOL variable, there are a few ways, without redefining the full physics yourself, but you must check carefully what you are doing: turn on the "equation view" (see preferences) then dig into the equationsto identify where COMSOL defines your variable and edit the equation. This will lock the equation and COMSOl is partly jammed and will require that you reset or define manually any new changes, as COMSOL has no longer any built in way to redefine any user modified node. This might work well, but there are a few caveats. I.e if the node or variable is overridden you must find the "master" node. If you have contributing nodes, you might have to edit several equations in differet nodes.

Basically many thigns are possible, provided you check what you are doing, and understand a little about the COMOSL internals

--
Good luck
Ivar
Hi Many things are possible. For the material properties such as rho you can either edit the material node, or you select "User Defined" in the physics node and enter an expression defined in a parameter, or a variable or ... (note you might make a circular dependency that cannot be solved, then you get an error message and must find another way, often via an ODE) or mostly you make your model non-linear and might need some tweaking to get it to solve smoothly, but you can loop it around at your will. If you want to redefine an internal COMSOL variable, there are a few ways, without redefining the full physics yourself, but you must check carefully what you are doing: turn on the "equation view" (see preferences) then dig into the equationsto identify where COMSOL defines your variable and edit the equation. This will lock the equation and COMSOl is partly jammed and will require that you reset or define manually any new changes, as COMSOL has no longer any built in way to redefine any user modified node. This might work well, but there are a few caveats. I.e if the node or variable is overridden you must find the "master" node. If you have contributing nodes, you might have to edit several equations in differet nodes. Basically many thigns are possible, provided you check what you are doing, and understand a little about the COMOSL internals -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Feb 6, 2012, 7:16 a.m. EST
Hello Ivar,

I have already done the modifications that I mentioned above.

And I get convergence for a mesh, however, when i refine or change the inlet speed I get an error :

Undefined value found.
- Detail: Undefined value found in the equation residual vector.
There are 3 degrees of freedom giving NaN/Inf in the vector for the variable mod1.ep
at coordinates: (0.0154199,-0.015), (0.0151245,-0.0144765), (0.0157084,-0.0144734), ...
There are 3 degrees of freedom giving NaN/Inf in the vector for the variable mod1.k
at coordinates: (0.0154199,-0.015), (0.0151245,-0.0144765), (0.0157084,-0.0144734), ...

I believe the model is numerically non-linear or really unstable.
Why does this happen only when I refine the mesh, or change the inlet velocity.

Can you provide some insight into this?
For some reason I cannot upload the file...I keep getting an extension error...

Thank you.

Best Regards,

Rui Silva
Hello Ivar, I have already done the modifications that I mentioned above. And I get convergence for a mesh, however, when i refine or change the inlet speed I get an error : Undefined value found. - Detail: Undefined value found in the equation residual vector. There are 3 degrees of freedom giving NaN/Inf in the vector for the variable mod1.ep at coordinates: (0.0154199,-0.015), (0.0151245,-0.0144765), (0.0157084,-0.0144734), ... There are 3 degrees of freedom giving NaN/Inf in the vector for the variable mod1.k at coordinates: (0.0154199,-0.015), (0.0151245,-0.0144765), (0.0157084,-0.0144734), ... I believe the model is numerically non-linear or really unstable. Why does this happen only when I refine the mesh, or change the inlet velocity. Can you provide some insight into this? For some reason I cannot upload the file...I keep getting an extension error... Thank you. Best Regards, Rui Silva

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.