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.
Any way to export/import analytic functions (without MATLAB)?
Posted 7 ago 2014, 05:06 GMT-4 6 Replies
Please login with a confirmed email address before reporting spam
It is rather heavy to save a .m file, or the generate a Report, and then to cut&paste tens of functions....
Global parameters can be saved, why global functions do not?
A possibility should be that of using the Comsol/Matlab connection and defining all my functions in matlab, but I would like to avoid it.
Suggestions?
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
but that's pretty similar to copy and paste from a generated Comsolo Report.
When developing a model sometimes I write 20-30 functions, that I would like to re-use in another model. Today, for example, I build an EM model in 3D and I would like to import functions for dielectric mixtures coming from a different 2D model... I had to do it by hand (with copy & paste).
Roberto
Please login with a confirmed email address before reporting spam
Sometimes one can use a workaround:
1) create a user defined material;
2) drag and drope all your functions into the material;
3) save the material in a user difined materil library;
4) in a new (target) file import your new material definded at previous steps, it will be imported with all the functions;
5) drag and drope the functions to the Global definitions node.
The above mentioned scenario works only with Analytic, Interpolation, and Piecewise functions.
The user defined material library is stored in the mph-file. "The file path on Windows might be similar to C:\Users\Your_Name\.comsol\v44\materials" You can take this file with you, to your new COMSOL vertion or to another computer, and import it.
In new vertion 5.0 I still cannot find any sign that one can export functions. However in v5.0 you can refer to the functions stored in your material during solution or postprocessing. Say, in Global probe you can add mat4.def.Cp(T) in an Expression field, or select the corresponding line in the "Replace Expression" drope down menu.
Maxim
Please login with a confirmed email address before reporting spam
Sometimes one can use a workaround:
1) create a user defined material;
2) drag and drope all your functions into the material;
Pretty cool. This works great. How in the _world_ did you think of it :)
Please login with a confirmed email address before reporting spam
Kind regards
--
Gerardo E. Villarreal-Garcia
Centre for Quantum Photonics
H.H. Wills Physics Laboratory
University of Bristol
Tyndall Avenue
Bristol
BS8 1TL, UK
Email: g.villarreal@bristol.ac.uk
Please login with a confirmed email address before reporting spam
If you save your functions to a material library, open that mph file, then save as JAVA,
you'll get a relatively small file with all your functions in it. Yes, there's some cruft you'll
need to delete to use it in another application, but it's better than typing in all those equations from scratch, or cut/pasting them individually.
Also, since you can also import the JAVA file, you can use your favorite editor to
mess with the functions and not have to deal with COMSOL's "assistance" during
their reformulation.
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.
Suggested Content
- KNOWLEDGE BASE An error is returned when running mphlaunch and mphstart
 - FORUM Nesting analytic functions
 - BLOG How to Manually Work with Entity Numbers in Selections
 - KNOWLEDGE BASE How can I Migrate my Local Model Manager to the Database of a Model Manager Server
 - FORUM error 6250 with Piecewise Analytic Functions
 
