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.

Anyone worked out how to call functions of functions?

Please login with a confirmed email address before reporting spam

Hi, I'm trying to have functions call functions inside a material. Eg., see attached.

For all I know, I have typed in the equations correctly :-)

But I can't test them because I trip over the scope definitions. In the attached, I want Pb to call Yg.

If I type mat2.def.yg(....) into the line plot, then I get the right plot, but if I call mat2.def.Pb into the line plot, then it says it cant find "yg" . If I change Pb to instead call mat2.def.yg then it *still* doesn't work.

Tricky...

Anyone got something like this working in 4.0 ?

Regards, John
p.s. If I type the functions as globals then everything works


6 Replies Last Post Jul 27, 2010, 11:42 p.m. EDT
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 19, 2010, 10:05 a.m. EDT
Hi

I believe the best is to save your modsel as a "m" file and look at the calling sequence therein. There you will find the different names.

One of the issues is that with "one" material only, your Test.mph file should normally refer to "mat1" and not "mat2", but this depends on the "history" of your model file, and I do not know how to do a "reset model" in V4 (it was nice in v3.5a to clean up the model), and after some changes and testsw on the maodel the ".m" file becomes clogged.

Furthermore, I'm not sure it's so easy to have an analytical function call another inside a material definition, as it looks like their names are rather "mat2.def.ana1.Z(...)" and ...ana2... etc. so how is one sure to refer to the right one ? is it def.ana1.Z(...), mat.def.ana1.Z or just Z() ?

Now,in your case you can always reduce the functions to one for "rho" and one for "alpha", no (probably the safest)?
--
Good luck
Ivar
Hi I believe the best is to save your modsel as a "m" file and look at the calling sequence therein. There you will find the different names. One of the issues is that with "one" material only, your Test.mph file should normally refer to "mat1" and not "mat2", but this depends on the "history" of your model file, and I do not know how to do a "reset model" in V4 (it was nice in v3.5a to clean up the model), and after some changes and testsw on the maodel the ".m" file becomes clogged. Furthermore, I'm not sure it's so easy to have an analytical function call another inside a material definition, as it looks like their names are rather "mat2.def.ana1.Z(...)" and ...ana2... etc. so how is one sure to refer to the right one ? is it def.ana1.Z(...), mat.def.ana1.Z or just Z() ? Now,in your case you can always reduce the functions to one for "rho" and one for "alpha", no (probably the safest)? -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 19, 2010, 10:19 a.m. EDT
Wow. That's pretty sexy. I've never tried saving anything as a .m file before. Will take me a little while to flog through that, however :-)

Yes, Ivar, there was a mat1. It was massively complicated (and probably wrong), that's why I deleted it before posting.

The one I posted maybe could be typed into a single line, but it would be quite messy, more generally I do need this functionality.

I think what I am going to do at the moment is get everything working using global functions, and then cut and paste into material and check I get same answer. As you say, it is a question of what syntax.
Wow. That's pretty sexy. I've never tried saving anything as a .m file before. Will take me a little while to flog through that, however :-) Yes, Ivar, there was a mat1. It was massively complicated (and probably wrong), that's why I deleted it before posting. The one I posted maybe could be typed into a single line, but it would be quite messy, more generally I do need this functionality. I think what I am going to do at the moment is get everything working using global functions, and then cut and paste into material and check I get same answer. As you say, it is a question of what syntax.

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 20, 2010, 2:57 a.m. EDT
Hi,

Just a comment about the ability to remove old and unused steps from the Model M-file/Model Java-file history. You can do that in version 4 by choosing Reset History from the File menu.

Best regards,
Magnus Ringh
COMSOL
Hi, Just a comment about the ability to remove old and unused steps from the Model M-file/Model Java-file history. You can do that in version 4 by choosing Reset History from the File menu. Best regards, Magnus Ringh COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 20, 2010, 4:43 p.m. EDT

Hi,

Just a comment about the ability to remove old and unused steps from the Model M-file/Model Java-file history. You can do that in version 4 by choosing Reset History from the File menu.

Best regards,
Magnus Ringh
COMSOL


In my experience with 4.0, reset-history would usually cause a crash or exception to be triggered. I'm looking forward to 4.0a with anticipation that this functionality will be more stable.

Regards, John
[QUOTE] Hi, Just a comment about the ability to remove old and unused steps from the Model M-file/Model Java-file history. You can do that in version 4 by choosing Reset History from the File menu. Best regards, Magnus Ringh COMSOL [/QUOTE] In my experience with 4.0, reset-history would usually cause a crash or exception to be triggered. I'm looking forward to 4.0a with anticipation that this functionality will be more stable. Regards, John

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 21, 2010, 3:53 a.m. EDT
Hei Magnus

Thanks for the indication, I found the Reset, and in V4.0a (=4.0.0.982 for me on Vitsa-32) it works fine, and its cleans up the file, without renumbering, thats nice

--
Have fun Comsoling
Ivar
Hei Magnus Thanks for the indication, I found the Reset, and in V4.0a (=4.0.0.982 for me on Vitsa-32) it works fine, and its cleans up the file, without renumbering, thats nice -- Have fun Comsoling Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 27, 2010, 11:42 p.m. EDT
Here is an example of a function calling a function inside a material, (courtesy of COMSOL support) . The syntax is to include the full path, as Ivar had suggested earlier, e.g.

mod1.mat2.def.an2(p,T)

One slight downside is these are "static" references, in that you need to know the model property tag, the material property tag, and so on.

Regards, John


Here is an example of a function calling a function inside a material, (courtesy of COMSOL support) . The syntax is to include the full path, as Ivar had suggested earlier, e.g. mod1.mat2.def.an2(p,T) One slight downside is these are "static" references, in that you need to know the model property tag, the material property tag, and so on. Regards, John

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.