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.

calling variables in COMSOL

Please login with a confirmed email address before reporting spam

Hi,

I am creating a heat transfer model. I have imported a file as a parameter under Global Definitions, but COMSOL automatically labels the first column t and the second column f(t). In reality, the first column is actually T, temperature.

I am mainly confused because I extract data for the properties for thermal conductivity and Cp. I want certain values to only be used during specific temperature intervals. For example, I have imported files called, Cp_material1, Cp_material2, Cp_material3, k_material1, k_material2, and k_material3. Each of these files have the first column referring to temperature (not time) and the second column referring to the material property. When the temperature is below 200K I want the model to be using properties for material1, when the temperature is between 200-500K I want the model to be using properties for material2, and when the temperature is above 500K I want the model to use properties of material3.

I currently have something like this for k: k_material1(t<200)+k_material2(t>=500)+k_material3(200<=t<500).

What is COMSOL referring to as t and T? Should the expression above be using T instead of t?

Thanks

7 Replies Last Post 20 giu 2012, 19:03 GMT-4
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 8 apr 2012, 04:22 GMT-4
Hi

I agree at the beginning the function definitions can be surprising, mostly COMSOL proposes a name for the argument and the expression, but it's a dummy argument only used for the function definition, you can define it with a t (usually used for time) but then call it with a T temperature or x, position or u displacement etc.

Think of the definition argument as a name separted from the final one, a "dummy" argument.

Depending on which funtion you choose you can overwrite the argument name and use something closer to your wish, but not in all cases.

"t" is a default definition set to time, so you cannot use t for both time and dummy argument T within the same expression. so there you must find another way around.

Then do not forget that using boolean expressions makes Dirac function steps in the expression, and these are very difficult to handle for the solver, as the solving process uses the estimated derivatives of te expressions for the slope estimation, and at a step you have 2 or more derivatives hence convergence isues when solving. The rect() or step() built in functions are there to give you smooth but steep transition, continuously (or at least a couple of times) derivative

--
Good luck
Ivar
Hi I agree at the beginning the function definitions can be surprising, mostly COMSOL proposes a name for the argument and the expression, but it's a dummy argument only used for the function definition, you can define it with a t (usually used for time) but then call it with a T temperature or x, position or u displacement etc. Think of the definition argument as a name separted from the final one, a "dummy" argument. Depending on which funtion you choose you can overwrite the argument name and use something closer to your wish, but not in all cases. "t" is a default definition set to time, so you cannot use t for both time and dummy argument T within the same expression. so there you must find another way around. Then do not forget that using boolean expressions makes Dirac function steps in the expression, and these are very difficult to handle for the solver, as the solving process uses the estimated derivatives of te expressions for the slope estimation, and at a step you have 2 or more derivatives hence convergence isues when solving. The rect() or step() built in functions are there to give you smooth but steep transition, continuously (or at least a couple of times) derivative -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 29 apr 2012, 14:41 GMT-4
Thanks, Ivar.

Just to be clear then, what variable should I be using when trying to reference the material properties? I tried using other dummy variables such as k(S) but S was not really defined anywhere and is now giving me issues with the Jacobian. What would you suggest I do?

Thanks.
Thanks, Ivar. Just to be clear then, what variable should I be using when trying to reference the material properties? I tried using other dummy variables such as k(S) but S was not really defined anywhere and is now giving me issues with the Jacobian. What would you suggest I do? Thanks.

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 29 apr 2012, 15:23 GMT-4
Hi

if you define a function with an internal argument such as "t" i.e. my_k(t), then you might call it somehere inside a COMSOL entry field by my_k(T), COMSOL will map "T" to the internal argument name "t" of your function and give out the result.

he only thing you must check are the units, either they are defined in the function (possible for certain functions) or you must pass the argument unitless, and add units on to the results such as "my_k(T[1/K])*1[W/m/K]" where T is mapped to a number reppresented by an absolute Kelvin value, and my_k is returned with heat conduction units

Hope it's clearer ;)

--
Good luck
Ivar
Hi if you define a function with an internal argument such as "t" i.e. my_k(t), then you might call it somehere inside a COMSOL entry field by my_k(T), COMSOL will map "T" to the internal argument name "t" of your function and give out the result. he only thing you must check are the units, either they are defined in the function (possible for certain functions) or you must pass the argument unitless, and add units on to the results such as "my_k(T[1/K])*1[W/m/K]" where T is mapped to a number reppresented by an absolute Kelvin value, and my_k is returned with heat conduction units Hope it's clearer ;) -- Good luck Ivar

Nagi Elabbasi Facebook Reality Labs

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 29 apr 2012, 23:41 GMT-4
As Ivar mentioned the “t” is just a dummy argument. You should call the function with “T” instead and check the units. If I understand your intent correctly I would define k as: k_material1(T)*(t<200)+k_material2(T)*(t>=500)+k_material3(T)*(t>=200)*(t <500).

Nagi Elabbasi
Veryst Engineering
As Ivar mentioned the “t” is just a dummy argument. You should call the function with “T” instead and check the units. If I understand your intent correctly I would define k as: k_material1(T)*(t=500)+k_material3(T)*(t>=200)*(t

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 9 mag 2012, 04:30 GMT-4
Thank you for your help! :)
Thank you for your help! :)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 20 giu 2012, 17:06 GMT-4
I did a simpler model to double check that everything is working correctly and it seems like the model is only working for part of it.

This is what I am inputting for the thermal properties under Head Transfer in Solids:
material1*(t<200)+material2*(200<=t<300)+material3*(t>=300)

where material1, material 2, material 3 are interpolation functions that were imported under global definitions. Under the t column, Temperatures were imported, and under the f(t) column, the material properties were inputed. The model seems to switch the material properties correctly at Temperature=200 but instead of using the properties of material 3 after Temperature=300, the model continues to use the properties of material 2. Is the syntax I am using correct? Or how can I solve this problem?

Thank you!
I did a simpler model to double check that everything is working correctly and it seems like the model is only working for part of it. This is what I am inputting for the thermal properties under Head Transfer in Solids: material1*(t

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 20 giu 2012, 19:03 GMT-4
Please disregard my previous message. I did not correctly read your earlier response and therefore did not implement the correct syntax you had suggested. Sorry about that. Thanks for your help!
Please disregard my previous message. I did not correctly read your earlier response and therefore did not implement the correct syntax you had suggested. Sorry about that. Thanks for your help!

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.