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.

Postprocessing Variable Access

Please login with a confirmed email address before reporting spam

I am simulating some photonic crystal fibre (PCF) structures in comsol 3.4 and need access to the variable which holds the solutions (effective index). I tried neff_rfwv but had errors. I want to have access to the solutions in matlab (I have already connected comsol to matlab)

I will be grateful if someone could help.

9 Replies Last Post 2011年11月18日 GMT-5 10:19

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年2月2日 GMT-5 07:55
Hi,

I did not work with the RF module so far, but I already accessed solutions of models in Matlab.

In Matlab, you should add the path /COMSOL_INSTALLATION_PATH/Comsol41/mli

Then execute: mphstart

You might have to do this as well:
import com.comsol.model.*
import com.comsol.model.util.*

Finally, in Comsol: File -> Export Model to Server

In Matlab: model = ModelUtil.model('NAME'); where NAME is the name you assigned when exporting from Comsol.

Now you can access any variables of the solution of your model with:
model_data = mpheval(model, 'VARIABLE', 'edim',3, 't',1000,'Solnum',1,'refine',1); where VARIABLE is the variable you want to access.
(you should adjust this command to your needs).


Hope this helps,
Juergen

Hi, I did not work with the RF module so far, but I already accessed solutions of models in Matlab. In Matlab, you should add the path /COMSOL_INSTALLATION_PATH/Comsol41/mli Then execute: mphstart You might have to do this as well: import com.comsol.model.* import com.comsol.model.util.* Finally, in Comsol: File -> Export Model to Server In Matlab: model = ModelUtil.model('NAME'); where NAME is the name you assigned when exporting from Comsol. Now you can access any variables of the solution of your model with: model_data = mpheval(model, 'VARIABLE', 'edim',3, 't',1000,'Solnum',1,'refine',1); where VARIABLE is the variable you want to access. (you should adjust this command to your needs). Hope this helps, Juergen

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年2月2日 GMT-5 08:28
I am using comsol 3.4 and not 4.x. I can't seem to find the folder called mli in the path you specified.

I am using comsol 3.4 and not 4.x. I can't seem to find the folder called mli in the path you specified.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年2月2日 GMT-5 09:35
My last time working with v3.5 is a while ago and my old matlab scripts are on another computer.

If I remember correctly, you don't have to add a path in matlab then.
You can export the fem structure and it should appear in your matlab workspace then.

The command you might use to access the variables could be "postinterp" for example.
I don't remember the syntax, but maybe you find an explanation in the comsol documentation of the matlab interface.

Good luck,
Juergen
My last time working with v3.5 is a while ago and my old matlab scripts are on another computer. If I remember correctly, you don't have to add a path in matlab then. You can export the fem structure and it should appear in your matlab workspace then. The command you might use to access the variables could be "postinterp" for example. I don't remember the syntax, but maybe you find an explanation in the comsol documentation of the matlab interface. Good luck, Juergen

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年2月3日 GMT-5 12:02
Thanks for your help but I couldn't get it to work. I guess Comsol is quite difficult to use for photonics. Please let me know if there are any options.
Thanks for your help but I couldn't get it to work. I guess Comsol is quite difficult to use for photonics. Please let me know if there are any options.

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 2011年2月3日 GMT-5 13:55
Hi

in v4.1 I find it rather easy and very instructuve to do RF/optics calculations, but I agree you need a very dense mesh, and a powerfull PC

--
Good luck
Ivar
Hi in v4.1 I find it rather easy and very instructuve to do RF/optics calculations, but I agree you need a very dense mesh, and a powerfull PC -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年2月4日 GMT-5 10:21
Kindly help me out with parsing contents of the solution variable (effective index) in comsol to any variable in matlab. I think Comsol should be made easier like other softwares. We have invested a lot of money into comsol but cannot really make good use of it because of how difficult it is to do simple tasks.

Any help in resolving this issue is welcomed.

Thanks
Kindly help me out with parsing contents of the solution variable (effective index) in comsol to any variable in matlab. I think Comsol should be made easier like other softwares. We have invested a lot of money into comsol but cannot really make good use of it because of how difficult it is to do simple tasks. Any help in resolving this issue is welcomed. Thanks

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 2011年2月4日 GMT-5 13:34
Hi

And me, that is so pleased with COMSOL as it is so much easier to use, and more powerfull, not to say cheaper than the heavy but excellent, well known FEM programme I used before ! Obviously it all depends from where we come and what we are doing.

Unfortunately I connot really help much for your issue, as I have dropped 3.5 for more than a year now, and with V4 I do not need matlab any more (and the new way to interface Matlab requires time that I do not have had yet, to learn it all over again). I agree that this is annoying, but on the other side, COMSOL can do so many things that no other software can, that I know about, that it is just marlvellous to use (for me ;). each day I'm saying to myself: what if I had had something like that 30 years ago when I was studying physics !

So I believe you should go through the doc again, in V4 you have also the "table export" direct into a txt file or an Excel file

--
Good luck
Ivar
Hi And me, that is so pleased with COMSOL as it is so much easier to use, and more powerfull, not to say cheaper than the heavy but excellent, well known FEM programme I used before ! Obviously it all depends from where we come and what we are doing. Unfortunately I connot really help much for your issue, as I have dropped 3.5 for more than a year now, and with V4 I do not need matlab any more (and the new way to interface Matlab requires time that I do not have had yet, to learn it all over again). I agree that this is annoying, but on the other side, COMSOL can do so many things that no other software can, that I know about, that it is just marlvellous to use (for me ;). each day I'm saying to myself: what if I had had something like that 30 years ago when I was studying physics ! So I believe you should go through the doc again, in V4 you have also the "table export" direct into a txt file or an Excel file -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年11月18日 GMT-5 08:41
Hi,
I use comsol 3.5 and I don't know the command to extract n_eff from RF module but with fem structure, I think it is quite easy. Just extract sol from fem.sol.lambda for example and calculate n_eff via beta/k0. Anyway, you can access to all variables solution in fem.sol.
Regards
Hi, I use comsol 3.5 and I don't know the command to extract n_eff from RF module but with fem structure, I think it is quite easy. Just extract sol from fem.sol.lambda for example and calculate n_eff via beta/k0. Anyway, you can access to all variables solution in fem.sol. Regards

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 2011年11月18日 GMT-5 10:19
Hi

all that is getting very old, I do remember there was something in one of the doc, or the model library examples exactly on n_eff. but I'm also almost sure we discussed this on the FORUM a couple of years ago. have you tried a search with n_eff ?

--
Good luck
Ivar
Hi all that is getting very old, I do remember there was something in one of the doc, or the model library examples exactly on n_eff. but I'm also almost sure we discussed this on the FORUM a couple of years ago. have you tried a search with n_eff ? -- Good luck Ivar

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.