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.

COMSOL error: Cannot evaluate expression. Undefined variable.

Maximilian Hohenberger

Please login with a confirmed email address before reporting spam

I am trying to include an external function in COMSOL. I copied the example from the manual about sin(x)/x. Compiled it into a .dll and included the library via Global Definitions > Functions > External. Then I have set function name "eval" and Arguments "x". In Plot Parameters, I have set the limits to 0 and 10. Now when I hit "Plot" I will get an error message:

Cannot evaluate expression. Undefined variable. - Variable: x - Global scope Failed to evaluate expression. - Expression: x

x is defined in Parameters with some Value. But it would make more sense to me, that x, in this case, is drawn upon the pool of the limit range.

Anyway, how do I have to set up x, so that my test plot will accept the variable and also, so that I can use the function elsewhere to evaluate?


2 Replies Last Post Jan 31, 2024, 2:54 a.m. EST
Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 months ago Jan 23, 2024, 8:23 a.m. EST

Hi Maximilian,

If you follow our example, you should call the function with its name, extsinc, and not the eval method. It's also worth checking that the Allow external processes setting on the Security page in the Preferences window is selected (by default, it is not selected).

Best regards,

Magnus

Hi Maximilian, If you follow our example, you should call the function with its name, `extsinc`, and not the `eval` method. It's also worth checking that the **Allow external processes** setting on the **Security** page in the **Preferences** window is selected (by default, it is not selected). Best regards, Magnus

Maximilian Hohenberger

Please login with a confirmed email address before reporting spam

Posted: 9 months ago Jan 31, 2024, 2:54 a.m. EST

Hi Maximilian,

If you follow our example, you should call the function with its name, extsinc, and not the eval method. It's also worth checking that the Allow external processes setting on the Security page in the Preferences window is selected (by default, it is not selected).

Best regards,

Magnus

Thank you very much. I was able to reproduce the example in the manual and now have a working solution to start with. Much appreciated!

>Hi Maximilian, > >If you follow our example, you should call the function with its name, `extsinc`, and not the `eval` method. It's also worth checking that the **Allow external processes** setting on the **Security** page in the **Preferences** window is selected (by default, it is not selected). > >Best regards, > >Magnus Thank you very much. I was able to reproduce the example in the manual and now have a working solution to start with. Much appreciated!

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.