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 functions in functions for material definitions

Andrew Prudil Nuclear Materials

Please login with a confirmed email address before reporting spam

Hi,
Please bear with me, I'm a COMSOL beginner.

I've encountered some interesting behavior when trying to implement functions in a user defined material. I am trying to define material properties which are very complicated, non-linear functions of several variables. For this reason the problem has been broken into several simpler parts (to be more manageable) which are multiplied together in another function. Note that all these functions are defined as part of a user defined material through the Material/Coefficient library.

For example:
Thermal-conductivity k = k_func(x1,x2)
k_func(x1,x2) = function1(x1)*function2(x2)
function1(x)= 1+x+x^2...
function2(x)= sin(x)

The interesting behavior comes in when I try to solve a problem with this setup. If COMSOL is not connected to MatLAB this setup does not seem to work at all because k_func(x1,x2) cannot find function1 or function2. Normally I would assume that this means that one user defined function cannot call another userdefined function, however when MatLAB is connected all appears to work. Presumably this means that MatLAB is managing the functions, and MatLAB's engine allows this behavior. Is this right? Could someone point me to documentation of this behavior?

My question is how will this behavior influence the solution time? I would think that MatLAB would slow things down?

If I tried to capture all this behavior in a single function it would be very long and difficult to manage (though I could use Maple or some other program to help).

Alternatively I could define these relationships elsewhere such as under global or sub-domain expressions however this strikes me as less than ideal for a few reasons. Some of the functions are piece-wise functions so I wouldn't be able to put them all global expressions without using step-functions. Would using global expressions take more RAM because it would solve for these values in areas where they are not needed? (Ie in other materials where these equations don't apply?)

Any ideas?

0 Replies Last Post 2010年3月25日 GMT-4 15:16
COMSOL Moderator

Hello Andrew Prudil

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.

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.