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.

Units problem in functions (switching from COMSOL 4 to 5)

Please login with a confirmed email address before reporting spam

I've just switched from 4.2a to 5.2 and a quite complex PDE-based model that used to perfectly work on 4.2a, does not anymore. One first problem is a strange unit behaviour in analytical functions. I've always been very careful with that, and I can't understand what goes wrong in 5.2.

I can reproduce it from scratch very simply. The function, say f, I want to program is :

f(T) = 0.325 - 1e-3*(T-273)

where T is a temperature in K and f is dimensionless I create the analytical function f, setting the argument T in unit K, and the output unit to 1.

  1. If I type the function expression as above, it stays black so no worry. But when using function f in the expression in another analytic function, the latter becomes orange with "Unexpected unit of input"

  2. If I type as the expression of the function (as seems more rigorous)

        0.325 - 1e-3[1/K]*(T-273[K])
    

it appears directly in orange with "Inconsistent unit" !!
I wonder what is inconsistent there...

  1. If I define three parameters A to 1e-3[1/K] and B to 0.325 and T0 to 273[K] and type as expression :

        B - A*(T-T0)
    

again orange with "Inconsistent unit"

Now the funniest thing : if I plot the function in all cases, guess what : the graph is OK in any case ! If someone could explain me the logic behind that, and marginally why did all this change from 4.2 to 5... Thank's very much.


1 Reply Last Post 20.01.2018, 13:22 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 20.01.2018, 13:22 GMT-5

OK I finally found that having such expressions in orange is a specificity of early builds of COMSOL 5.2, it seems to have been corrected in later builds, and does not alter the result. Using form 1 in the above post works well, provided input and output units are correctly specified.

My problem came from another (undocumented) change in 5.x compared to 4.x. The time-dependent solver now chooses "Physics controlled" initial values and scaling, and this does not make sense in PDE mode.

In fact there are plenty of changes in the PDE-mode, among which the requirement to have units for dependent variables (same unit for variables) AND equations (same unit for all equations).
Very pleasant when you deal with coupled mass-energy transport phenomena...

It's a pity that all this is so badly documented, even if COMSOL remains an excellent code and all finally works as before (after wasting 1 full-day).

Regards.

OK I finally found that having such expressions in orange is a specificity of early builds of COMSOL 5.2, it seems to have been corrected in later builds, and does not alter the result. Using form 1 in the above post works well, provided input and output units are correctly specified. My problem came from another (undocumented) change in 5.x compared to 4.x. The time-dependent solver now chooses "Physics controlled" initial values and scaling, and this does not make sense in PDE mode. In fact there are plenty of changes in the PDE-mode, among which the requirement to have units for dependent variables (same unit for variables) AND equations (same unit for all equations). Very pleasant when you deal with coupled mass-energy transport phenomena... It's a pity that all this is so badly documented, even if COMSOL remains an excellent code and all finally works as before (after wasting 1 full-day). Regards.

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.