Discussion ClosedThis 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.

Operators not Allowed in User Defined Functions

Please login with a confirmed email address before reporting spam

I am trying to solve a multidimensional time-dependent problem in Comsol using the Coefficient Form PDE framework. My question is related to defining the initial condition, however. I would like to set:When I try to do this using the sum() operator as described in thisarticle, I get the error "Operators not allowed in user defined functions". My question is how else can I achieve this? Of course I know I could write this function out term-by-term but I would ideally like to take N to be quite large which makes that infeasible (or at least very tedious). Is there anyway around this?


2 Replies Last Post 2023年10月10日 GMT+2 19:07
Dave Greve Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 11 months ago 2023年10月10日 GMT+2 18:47
Updated: 11 months ago 2023年10月10日 GMT+2 18:46

Since your h function appears to be a Fourier series, what is the function that it is a Fourier series for? Maybe you can use that directly as an initial condition.

Reminds me of the time I inserted a series expansion of a Bessel function, not realizing that Bessel functions were already in Comsol.

By the way- I believe your sum is over i not n??

Since your h function appears to be a Fourier series, what is the function that it is a Fourier series for? Maybe you can use that directly as an initial condition. Reminds me of the time I inserted a series expansion of a Bessel function, not realizing that Bessel functions were already in Comsol. By the way- I believe your sum is over i not n??

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 11 months ago 2023年10月10日 GMT+2 19:07

Mark,

an alternative may be to define a variable instead of the function. Quite a bit more complex is an external function using a DLL that needs to be coded in C.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Mark, an alternative may be to define a variable instead of the function. Quite a bit more complex is an external function using a DLL that needs to be coded in C. Cheers Edgar

Note that while COMSOL employees may participate in the discussion forum, COMSOL®software users who are on-subscription should submit their questions via theSupport Centerfor a more comprehensive response from the Technical Support team.

Baidu
map