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.

How to call an interpolation function from a method?

Please login with a confirmed email address before reporting spam

I have a couple of interpolation functions in the definitions node for component 1. I am using model methods to do some of the more complicated model set-up for an analysis I am working on. It would be really helpful to be able to call an interpolation function from a method, but I can't figure out to do this call. I see how to set parameters in the interpolation node, but not how to compute a result. Conceptually, I'd like to be able to do something like:

double interpvalue = model.component("comp1").func("int5").computeValue(12, 13);

Any hints would be much appreciated!


2 Replies Last Post 2021年9月27日 GMT-4 08:36
Gunnar Andersson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 2021年9月27日 GMT-4 03:48

For an interpolation function defined in the Global Definitions I think that

model.param().evaluate("int5(12,13)")

should work, but I don't think that there's anything similar available for functions defined in components. Maybe you can consider moving the functions from the component to Global Definitions.

For an interpolation function defined in the Global Definitions I think that model.param().evaluate("int5(12,13)") should work, but I don't think that there's anything similar available for functions defined in components. Maybe you can consider moving the functions from the component to Global Definitions.

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 2021年9月27日 GMT-4 08:36

Thanks! I'll give that a try.

-Erik

Thanks! I'll give that a try. -Erik

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.