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.

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 this article, 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 13:07 GMT-4
Dave Greve Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 7 months ago 2023/10/10 12:47 GMT-4
Updated: 7 months ago 2023/10/10 12:46 GMT-4

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: 7 months ago 2023/10/10 13:07 GMT-4

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 the Support Center for a more comprehensive response from the Technical Support team.