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.

Define varialbes

Please login with a confirmed email address before reporting spam

Hi,

I set up a PDE model in COMSOL v4.3. the independent variables are BX,BY,BZ. and a group of dependent variables are HX,HY,HZ, where [HX HY HZ] = fun(BX,BY,BZ). fun() is a nonlinear function defined in matlab.

In COMSOL, I can only allocate variable values one by one as follow:
HX = fun(BX,BY,BZ);
HY = fun(BX,BY,BZ);
HZ = fun(BX,BY,BZ).

Then the function fun is run by 3 times, which consumes a lot of unnecessary time. When the derivatives are included, the simulation speed is even worse, because my derivatives are also calculated using fun(). Theoretically, the fun() only need to be run by once, and HX,HY,HZ and all the derivatives are ready to use. Do you know how to allocate values of all the variables through calling fun() once?

Now, I try to set up a global structure variable G_data. G_data = fun(BX,BY,BZ), and
HX = G_data.HX;
HY = G_data.HY;
HZ = G_data. HZ.

Do you think this method can solve the problem?


Thanks a lot

Dan

0 Replies Last Post Sep 4, 2012, 3:37 p.m. EDT
COMSOL Moderator

Hello Zhangxian Deng

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.