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.

(inconsistent) Units and Functions

Please login with a confirmed email address before reporting spam

In order to solve for a fluid flow, I specify initial velocities through (analytical) functions (defined under definitions) with arguments x and y. For example, I have defined a function F(x,y)=(x^2-y^2)/R^2 (where R has been defined as a parameter with dimension, i.e. R=0.5[m]) and use this function to specify the initial x-velocity (for the time-dependent laminar flow). When substituting the function for the initial value, the text becomes orange (instead of black) indicating that I am using inconsistent units. I can understand this because F is in fact dimensionless. F should have the dimension [m/s] in order for Comsol not to complain. So how can I add to the function F the dimension of speed so that the text for the initial velocity becomes black instead of orange?

Thanks in advance,
Leon

5 Replies Last Post Mar 15, 2011, 4:52 a.m. EDT
Lechoslaw Krolikowski

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 14, 2011, 11:53 a.m. EDT
Hi,
Define F(x,y)=a(x^2-y^2)/R^2 where a=1[m/s] is defined as a parameter.
Regards,
Andrzej
Hi, Define F(x,y)=a(x^2-y^2)/R^2 where a=1[m/s] is defined as a parameter. Regards, Andrzej

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 14, 2011, 12:07 p.m. EDT
No, this does not help (have tried it already). The text remains orange.
No, this does not help (have tried it already). The text remains orange.

Lechoslaw Krolikowski

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 14, 2011, 3:13 p.m. EDT
Hi,
Define F=a(x^2-y^2)/R^2 as a parameter. It works.
Regards,
Andrzej

Hi, Define F=a(x^2-y^2)/R^2 as a parameter. It works. Regards, Andrzej

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 15, 2011, 4:01 a.m. EDT
Hi,

The expression a*(x^2+y^2)/R^2 works fine if you type it directly into a text box for a velocity.

Functions in COMSOL expect dimensionless inputs and outputs, so you need to "de-dimensionalize" the inputs:

F(x[1/m],y[1/m])

to remove the orange unit inconsistency indication.

Best regards,
Magnus Ringh, COMSOL
Hi, The expression a*(x^2+y^2)/R^2 works fine if you type it directly into a text box for a velocity. Functions in COMSOL expect dimensionless inputs and outputs, so you need to "de-dimensionalize" the inputs: F(x[1/m],y[1/m]) to remove the orange unit inconsistency indication. Best regards, Magnus Ringh, COMSOL

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 Mar 15, 2011, 4:52 a.m. EDT
Hi Magnus

Indeed this works for the function call variables, but the function itself is returning without units, so one need to multiply the function by *1[my_function_units] (or just F(x[1/m],y[1/m])[my_function_units] )

One can also define "F" as a variable, then the units are ported correctly. But, then the "F(x,y)" (one only uses "F") is "implicit" (this implicit notation is mostly not understood by the users, and it took me quite some time to catch the concept, and to understand where it really applies)

One also have to take care with Parametric or Continuation sweeps, the parameter used is supposed to be dimensionless, but this is not always nice in the tables or the plots, where one would prefer to see the full units not just a normalised value running from 0 to 1.
Therefore many users set up a parameter that runs over their variable range, there too one must add the units in the BC references.

Final case where I notice we often remain with orange color, even if everything is OK: when referring to other physics dependent variables. Sometimes we need to load the initial conditions to get all oranges returning to black.

Once you know about it, its easily to check, I highly appreciate these units checks, as it regularly corrects small typos and formula mismatches

--
Good luck
Ivar
Hi Magnus Indeed this works for the function call variables, but the function itself is returning without units, so one need to multiply the function by *1[my_function_units] (or just F(x[1/m],y[1/m])[my_function_units] ) One can also define "F" as a variable, then the units are ported correctly. But, then the "F(x,y)" (one only uses "F") is "implicit" (this implicit notation is mostly not understood by the users, and it took me quite some time to catch the concept, and to understand where it really applies) One also have to take care with Parametric or Continuation sweeps, the parameter used is supposed to be dimensionless, but this is not always nice in the tables or the plots, where one would prefer to see the full units not just a normalised value running from 0 to 1. Therefore many users set up a parameter that runs over their variable range, there too one must add the units in the BC references. Final case where I notice we often remain with orange color, even if everything is OK: when referring to other physics dependent variables. Sometimes we need to load the initial conditions to get all oranges returning to black. Once you know about it, its easily to check, I highly appreciate these units checks, as it regularly corrects small typos and formula mismatches -- 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.