Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.
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.
saving comsol model from matlab livelink
Posted Jan 18, 2011, 12:00 p.m. EST Interfacing, Heat Transfer & Phase Change Version 4.3b 12 Replies
Please login with a confirmed email address before reporting spam
Until 3.5a, there used to be nice flsave which would save fem structure as comsol's model file. Can somebody tell what is its counterpart in 4.x series? May be I missed something but looking into docs only highlighted mphload. Since comsol's model can no longer be saved even in a mat file using save command, I was wondering how to save results for post-processing?
Thanks
Please login with a confirmed email address before reporting spam
In our case, we lost 5 hours of processing-work because of Windows automatical updates during the night. We weren't able to save or export our work. So, is there any way to save or export a model with matlab ?
Best regards
Please login with a confirmed email address before reporting spam
model.save('filename');
eg. model.save('d:\users\OSCsavetest');
(the 'model' is the object you create with command: model = ModelUtil.create('Model'); it could be other names)
with this command, it allows you to save you model object in m-file too
you can find more detail in documentation: LiveLinkForMATLABUsersGuide.pdf
I don't know if my answer is something you guys expected.
hope it is useful to you
Regards
Honghui
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
Thanx a lot Honghui
Best regards
Alex
Please login with a confirmed email address before reporting spam
Unfortunately, model = ModelUtil.load(<tag>, <filename>) is only for loading a .mph file.
Doing .mph to .m is easy (in COMSOL, File > Save as Model M-file...).
Doing .mph to model is easy (in MATLAB, see above)
Doing model to .mph is easy (in MATLAB, model.save(<filename>))
Doing model to .m is easy (in MATLAB, model.save(<filename>, 'm')
But how to do:
.m to .mph ???
or
.m to model ???
(NOTE: In COMSOL 4.1 there is no option to do a "File open" of a M-file directly)
Please login with a confirmed email address before reporting spam
I didn't try, hope it works
Please login with a confirmed email address before reporting spam
Matlab Script:
import com.comsol.model.*
import com.comsol.model.util.*
model = ModelUtil.create('Model');
model.modelPath('N:\Projects\MicFEAModelingPrograms\COMSOL42\BumpedBP\Matlab\');
model.save('test')
I receive the error:
"Error using com.comsol.model.impl.ModelImpl/save
Java exception occurred:
Exception:
com.comsol.util.exceptions.FlException: Could not create temporary model file on server
Messages:
Could not create temporary model file on server"
<stack info>
Any thoughts on what is causing this?
Please login with a confirmed email address before reporting spam
model.modelPath('N:\Projects\MicFEAModelingPrograms\COMSOL42\BumpedBP\Matlab\');
I don't know what the purpose of the modelPath property is, the documentation is mum on this. But as far as I can tell, it has no purpose.
However, the documentation does have this to say:
Use the function mphsave to save the model object linked to the MATLAB object model:
mphsave(model,'filename')
If the filename specified 'filename' [sic] does not provide a path the file is saved relatively to the local MATLAB path. The file extension determines which format to use (*.mph, *.m or *.java).
Alternatively you can use the save method:
model.save('filename');
If 'filename' does not provide a path the file is saved relatively to the local COMSOL server path.
So I guess in your case, you don't have write access to whatever the "local COMSOL server path" is. (On my machine, model.save() writes to [ComsolDir]\mli\startup for some reason.) I prefer to use mphsave() anyway, as the current Matlab working directory is usually the path I want to write to.
Please login with a confirmed email address before reporting spam
Thanks a lot.
Please login with a confirmed email address before reporting spam
I'm now using comsol4.3a and get the same error as yours. Have you figured out the reason for this error?
Thank you!
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
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.