Using a single Matlab function for electrical conductivity as tensor but COMSOL requires one function per tensor component

Please login with a confirmed email address before reporting spam

Hi,

I have a Matlab function that calculates the electrical conductivity of the material as a function of strain and other material constants. So I am using the Solid Mechanics and Electric Currents interfaces. I wrote a wrapper (Matlab) function that takes the strain components as vector inputs (solid.el11,solid.el22,solid.el33,solid.el12,solid.el13,solid.el23) so that my electrical conductivity function calculates the conductivity tensor. I am using this function within my Materials definition as the electrical conductivity. The issue is that my function calculates the full tensor, i.e., the 3x3 matrix for a given strain tensor (3x3 matrix) as input. In the vectorized version, it obtains a 3x3xN matrix if the solid.elxx variables are vectors of length N. However, I can't find the way to give the full tensor to COMSOL as, from the screenshot, each component of the electrical conductivity needs to be its own function. So what I had to do was to make the wrapper function to output the vectorized component of the electrical conductivity tensor for a given component. For instance, in the screenshot, the function sigma_wraper_c3 that is called for the (1,1) component takes as input 1,1 so that the function outputs only that component. Similarly for the other tensor components. This results in computing the full tensor for the whole model three times if using the diagonal form or nine times if using the full tensor, one per each component. This is why in the screenshot I am using the diagonal form to save time.

So, is it possible to pass the full tensor to COMSOL so that the tensor is calculated only once?

Additionally, I tried to use my Matlab function in "Current Conservation" within the "Electric Currents" interface. I tried this by selecting "User defined" for the electrical conductivity. But there not only I find the same issue, I see a message of "Unknown function or operator". How could this happen if my Matlab function is defined within Global Definitions?

Whether in the Materials definition or the "Electric Currents" interface, I would like a way to pass the full tensor to COMSOL.

Thanks.



Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

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.