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.

COMSOL 5.3 extract the electric field with mphinterp

Please login with a confirmed email address before reporting spam

Hi everyone,
I have a problem with the command mphinterp, since in the version 5.1 my code was working fine, while when i switched to the version 5.3, it is not working anymore.
I am using an adaptive mesh refinement as follows:

model.sol('sol1').feature('e1').create('ad1', 'Adaption');

And to extract the electric field (x component for example) of the modes of my fiber:

Ex_data = mphinterp(model, 'emw.Ex', 'coord',p, 'solnum',[Mode_num],'dataset','dset2');

When I run my simulation with the version 5.3, I have the following error:

The following feature has encountered a problem:

- Feature: Eigenvalue Solver 1 (sol1/e1)

Cannot use adaptation without referring to a study.

I am using the same code I was using with the version 5.1. I am wondering if something is changed between the two versions.
Many thanks for any answer.

3 Replies Last Post Aug 22, 2017, 9:31 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Aug 7, 2017, 2:34 p.m. EDT
I would like to add also that now with mphinterp (without the adaptive mesh refinement), I obtain the real and the immaginary part of the field, while with the version 5.1 was not the case.
Thanks for your help.
I would like to add also that now with mphinterp (without the adaptive mesh refinement), I obtain the real and the immaginary part of the field, while with the version 5.1 was not the case. Thanks for your help.

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Aug 22, 2017, 7:05 a.m. EDT
Hi Alessandro

We have in version 5.2a changed mphinterp, mphevel and mphgloabal such that they by default return complex numbers if your expressions are complex. Previously you had to use the argument 'complexout' in order to tell these functions that you wanted complex values.

All functions in LiveLink for Matlab now return complex values when needed.


For the problem you are having with mphinterp I can probably help if you can attach you model file.

--
Lars Gregersen
Comsol Denmark
Hi Alessandro We have in version 5.2a changed mphinterp, mphevel and mphgloabal such that they by default return complex numbers if your expressions are complex. Previously you had to use the argument 'complexout' in order to tell these functions that you wanted complex values. All functions in LiveLink for Matlab now return complex values when needed. For the problem you are having with mphinterp I can probably help if you can attach you model file. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Aug 22, 2017, 9:31 a.m. EDT
Hi Lars,
first of all, thank you for the answer.
I was expecting an answer like your. I am just wondering if the results of mphinterp that I obtained with version 5.1, are the same as the real part of the results with version 5.3.
I have to simulate multimode fibers, so I need the field of every mode. For the adaptation problem, now I am not using it, because it required a lot of computational time, but I guess that with the new version, the line codes are different. Before I used:

model.sol('sol1').feature('e1').create('ad1', 'Adaption');
model.sol('sol1').feature('e1').feature('ad1').set('ngen', '2');

And then to extract the field (for example Ex):

Ex_data = mphinterp(model, 'emw.Ex', 'coord',p, 'solnum',[Mode_num],'dataset','dset2');
Hi Lars, first of all, thank you for the answer. I was expecting an answer like your. I am just wondering if the results of mphinterp that I obtained with version 5.1, are the same as the real part of the results with version 5.3. I have to simulate multimode fibers, so I need the field of every mode. For the adaptation problem, now I am not using it, because it required a lot of computational time, but I guess that with the new version, the line codes are different. Before I used: model.sol('sol1').feature('e1').create('ad1', 'Adaption'); model.sol('sol1').feature('e1').feature('ad1').set('ngen', '2'); And then to extract the field (for example Ex): Ex_data = mphinterp(model, 'emw.Ex', 'coord',p, 'solnum',[Mode_num],'dataset','dset2');

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.