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 Oct 10, 2023, 1:07 p.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Oct 10, 2023, 12:47 p.m. EDT
Updated: 1 year ago Oct 10, 2023, 12:46 p.m. EDT

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: 1 year ago Oct 10, 2023, 1:07 p.m. EDT

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.