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.

Can I call Table values in Derived Values

Please login with a confirmed email address before reporting spam

Hi

When doing a parametric sweep I calculate the effective refractive index for a few wavelengths I want to use the maximum value for each wavelength in another calculation. In matlab I would have written

Deltaneff=max(neff)-neff

I cant seam to do this straightaway in COMSOL so I've started by creating a table with "Maximum: mode index", but can I use the values from the table in the Derived values somehow? or is there an easier way?

How can I calculate and display this as a function of wavelength?

15 Replies Last Post Jan 6, 2012, 10:07 a.m. EST
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 Nov 20, 2010, 8:25 a.m. EST
Hi

not sure, in 3.5 I believe you must use matlab, in 4 you might get away with a min/max operator, perhaps you need also a "with()" or "at()" operator or whatever they are colled now in V4 ;) (I havent tried such a calculation yet in v4)

--
Good luck
Ivar
Hi not sure, in 3.5 I believe you must use matlab, in 4 you might get away with a min/max operator, perhaps you need also a "with()" or "at()" operator or whatever they are colled now in V4 ;) (I havent tried such a calculation yet in v4) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Nov 22, 2010, 4:26 a.m. EST
Thanks for your time, however the with and at operations require that I know which solution that has the highest (real) refractive index. Usually it is the last one, but sometimes one gets a completely out of hand solution as the last one.

But I'll try to use the with() operator and se how it goes.
Thanks for your time, however the with and at operations require that I know which solution that has the highest (real) refractive index. Usually it is the last one, but sometimes one gets a completely out of hand solution as the last one. But I'll try to use the with() operator and se how it goes.

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 Nov 22, 2010, 3:36 p.m. EST
Hi

from my knowledge you cannot do that much with table data, colum vise you have some operations in V4.1 (perhaps also there in 4.0a) and yu have some fft functions somewhere check the doc

--
Good luck
Ivar
Hi from my knowledge you cannot do that much with table data, colum vise you have some operations in V4.1 (perhaps also there in 4.0a) and yu have some fft functions somewhere check the doc -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 30, 2010, 7:07 p.m. EST
Hi,

sorry, I seem to be newer to Comsol 4 than you :-)

So as it seems I am still stuck a step earlier. I also want to do a parameter sweep (geometrical parameters) and get out effective refractive indices. As you I am also interested in the complex neff of the mode with the highest real(neff) for each parameter. So if I understand you right, you have managed to get these out of your results?

I cant seam to do this straightaway in COMSOL so I've started by creating a table with "Maximum: mode index", but can I use the values from the table in the Derived values somehow? or is there an easier way?


How did you do that? Particularly how did you get "Maximum: mode index"
I am currently trying with Results -> Derived Values -> Point Evaluation

When I select the dataset containing all my parameter values, I select table rows: Inner solutions (because neff is only accessible if I do so) and set Expression to "neff" I get a list for each solution.
But I cannot get a list over the parameters varied.

Is this the right approach?
I would really higly appreciate a hint! I was no searching for a while and I cannot really find answers...

Best regards!

Arian
(I am somehow experienced with Matlab and I have used Comsol 3.5 but now with 4.0 I wanted to switch my usual loop programming for parameter variations from matlab, encapsulating Comsol to Comsol. I was happy when I found out this should work... but no I don't know how to proceed...)
Hi, sorry, I seem to be newer to Comsol 4 than you :-) So as it seems I am still stuck a step earlier. I also want to do a parameter sweep (geometrical parameters) and get out effective refractive indices. As you I am also interested in the complex neff of the mode with the highest real(neff) for each parameter. So if I understand you right, you have managed to get these out of your results? [QUOTE]I cant seam to do this straightaway in COMSOL so I've started by creating a table with "Maximum: mode index", but can I use the values from the table in the Derived values somehow? or is there an easier way? [/QUOTE] How did you do that? Particularly how did you get "Maximum: mode index" I am currently trying with Results -> Derived Values -> Point Evaluation When I select the dataset containing all my parameter values, I select table rows: Inner solutions (because neff is only accessible if I do so) and set Expression to "neff" I get a list for each solution. But I cannot get a list over the parameters varied. Is this the right approach? I would really higly appreciate a hint! I was no searching for a while and I cannot really find answers... Best regards! Arian (I am somehow experienced with Matlab and I have used Comsol 3.5 but now with 4.0 I wanted to switch my usual loop programming for parameter variations from matlab, encapsulating Comsol to Comsol. I was happy when I found out this should work... but no I don't know how to proceed...)

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 Dec 31, 2010, 1:55 a.m. EST
Hi

in V4.1 you can do some analysis (now for me the max(abs(neff)) i an increasing series depending on the numbner of eigenmodes you ask for so there I do not follow you exactly)

If you take the step index mode example of the Model library, you add a parameter "Radius=8[um]" and set the inner circle radius to "Radius" and not fixedat just 8[um]

then you add a parametric sweep before the current mode solver (right click +add) you select Radius and set a range i.e. 2,4,6,8,10

You add a Probe selecting emw.neff, and solve

this will give you the first value for each case, you need to then adapt the settings of the probe Global variable node to add an operation on the Data Series Operations (last line)

But I'm not sure I'm getting the max for each case, need still some investigations but that is the best I can propose, without going directly to Matlab

PS I'm not sure this woorks in 4.0 so get hands on the latest version it's much smoother, check with your rep

--
Good luck
Ivar
Hi in V4.1 you can do some analysis (now for me the max(abs(neff)) i an increasing series depending on the numbner of eigenmodes you ask for so there I do not follow you exactly) If you take the step index mode example of the Model library, you add a parameter "Radius=8[um]" and set the inner circle radius to "Radius" and not fixedat just 8[um] then you add a parametric sweep before the current mode solver (right click +add) you select Radius and set a range i.e. 2,4,6,8,10 You add a Probe selecting emw.neff, and solve this will give you the first value for each case, you need to then adapt the settings of the probe Global variable node to add an operation on the Data Series Operations (last line) But I'm not sure I'm getting the max for each case, need still some investigations but that is the best I can propose, without going directly to Matlab PS I'm not sure this woorks in 4.0 so get hands on the latest version it's much smoother, check with your rep -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 31, 2010, 2:25 a.m. EST
The maximum neff is always the last in the list... So I think it can be accessed with the command with(10,'emw.neff') if 10 is the number of solutions


However, i gave up geting this done in comsol since i could not plot it the way I wanted anyway. So I continued in Matlab instead.

emw.neff is a global value so try global evaluation instead.
The maximum neff is always the last in the list... So I think it can be accessed with the command with(10,'emw.neff') if 10 is the number of solutions However, i gave up geting this done in comsol since i could not plot it the way I wanted anyway. So I continued in Matlab instead. emw.neff is a global value so try global evaluation instead.

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 Dec 31, 2010, 10:33 a.m. EST
Hi

in v4.1 you can select first, last or just some from a lit.
Note that the neff last value depends on how many you as for , by default there are 6 first eigenvalues selected

--
Good luck
Ivar
Hi in v4.1 you can select first, last or just some from a lit. Note that the neff last value depends on how many you as for , by default there are 6 first eigenvalues selected -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 1, 2011, 10:30 a.m. EST
Thank you so far! That was really quick. I am just trying your suggestions. I did not yet get it running. But that might be my fault. Btw, I am a bit disappointed that things like this are not included in the manual. But nevertheless, you already helped me :-).
Unfortunately just now, as I wanted to try, my Comsol always (also with older files which worked before...) shows me an error message... which I have to get rid of before becoming productive again.
When my parameter sweep with all solutions has finished a error window appears

"COMSOL Error with the content: Invalid property value. - Property: title 'Title' is a string."

To be honest I have no idea what that means... but maybe I should post this question on another topic in another discussion.
Thank you so far! That was really quick. I am just trying your suggestions. I did not yet get it running. But that might be my fault. Btw, I am a bit disappointed that things like this are not included in the manual. But nevertheless, you already helped me :-). Unfortunately just now, as I wanted to try, my Comsol always (also with older files which worked before...) shows me an error message... which I have to get rid of before becoming productive again. When my parameter sweep with all solutions has finished a error window appears "COMSOL Error with the content: Invalid property value. - Property: title 'Title' is a string." To be honest I have no idea what that means... but maybe I should post this question on another topic in another discussion.

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 Jan 1, 2011, 11:53 a.m. EST
Hi

invalid properties are mostly material data not fully filled in. If you use the built in advanced material data these are often temperature or pressure dependent, and you must define a default temperature or pressure in the physics node. It might also be related to the physics selected if you ask for index values in the RF and these might not be defined in the material section.

Therefore always, in v4, check the material properties AGAIN before doing a solve, but once you have finished filled in your model settings, to check that there are no "red" flags left behind.

Furthrmore, I can only suggest to get hands on the latest v4.1, and patch it (see main web update site) it is working far smother than the v4.0 ;)

--
Good luck
Ivar
Hi invalid properties are mostly material data not fully filled in. If you use the built in advanced material data these are often temperature or pressure dependent, and you must define a default temperature or pressure in the physics node. It might also be related to the physics selected if you ask for index values in the RF and these might not be defined in the material section. Therefore always, in v4, check the material properties AGAIN before doing a solve, but once you have finished filled in your model settings, to check that there are no "red" flags left behind. Furthrmore, I can only suggest to get hands on the latest v4.1, and patch it (see main web update site) it is working far smother than the v4.0 ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 2, 2011, 10:46 a.m. EST
Hello again :-)

With your help I got my model running.
But one thing which I still do not get running is, getting the neff values out for each solution during the parameter sweep as explained before.

1st approach:
I added a point in the Model1 -> Geometry -> Point 1
I added a Point evaluation under Results -> Derived Values. There I selected the point and added Expression: neff
I select my solution "Solution 8" as the dataset. Solution 8 is before defined under Results -> Data Sets -> Solution 8 to be Solution: Parametric, Model: Model 1
I guess, this should be fine?

Error: It tells me "
Failed to evaluate variable.
Variable: neff
Geometry: 1 Point: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Failed to evaluate expressen.
Expression: real(neff)
Expression: real(neff)

I also tried with emw.neff, which also does not work. Then I trief with lambda or beta, both give some result. But I want to get the complete complex neff! Btw, why does Comsol always make the real(neff) out of it if I type neff?
With lambda or beta e.g. I get some results in a table, left column "Effective mode index", unfortunately only the real parts... and right column "parameter = ..., lambda, Point: 8"

I guess I am very near to a solution! There are some values, but still not the variable which I wannt (complex neff). The next step would then be to get for each parameter set the neff with the highest real part.

I did find an intermediate solution by going to matlab, connecting via livelink and using some code, which I found on this forum. But this is not a real solution as I have to solve this task finally in Comsol itself.
In Matlab, for your information, I use the following code, I do not fully understand how it works, I must admit:

for solindex=19:45
% With 19 to 45 being the index of the available, calculated solutions, just as they were called in the parameter sweep.
[sz,ndofs,list,name,type]=mphgetp(model,'solname',strcat('sol',solindex));
neff(index,:)=1j*list/(2*pi/wavelength)';
neffmax(index,1)=max(neff(index,:));
end

2nd approach:

I added a global probe under Model1 -> Definitions and in it I selected Expression: neff
When executing study 1 under Results -> Data Sets a "Probe Solution 9" appears with "Solution: Parametric, Model:1"
And under Results -> Derived Values "Global Variable Probe 1" appears with "Data Set: Probe Solution 9" and all parameter values selected.

But also here, neff is not available for selection. When I type Expression: neff (same for emw.neff) I get the error message:
Variable: neff
Global scope: Failed to evaluate expression.
Expression: real(neff)
Failed to evaluate expression:.
Expression: real(neff)


Sorry... that I ask again. But there must be something which I really do not see.
Do you have any suggestions?
Than you very much in advance!

Best regards

Arian
PS:
BTW the strange error message vanished after I had restarted Comsol for 3 times... it even appeared when I loaded a mph file which peviously worked fine. I guess this was just a complicated minor bug.
What I now did:
Hello again :-) With your help I got my model running. But one thing which I still do not get running is, getting the neff values out for each solution during the parameter sweep as explained before. 1st approach: I added a point in the Model1 -> Geometry -> Point 1 I added a Point evaluation under Results -> Derived Values. There I selected the point and added Expression: neff I select my solution "Solution 8" as the dataset. Solution 8 is before defined under Results -> Data Sets -> Solution 8 to be Solution: Parametric, Model: Model 1 I guess, this should be fine? Error: It tells me " Failed to evaluate variable. Variable: neff Geometry: 1 Point: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Failed to evaluate expressen. Expression: real(neff) Expression: real(neff) I also tried with emw.neff, which also does not work. Then I trief with lambda or beta, both give some result. But I want to get the complete complex neff! Btw, why does Comsol always make the real(neff) out of it if I type neff? With lambda or beta e.g. I get some results in a table, left column "Effective mode index", unfortunately only the real parts... and right column "parameter = ..., lambda, Point: 8" I guess I am very near to a solution! There are some values, but still not the variable which I wannt (complex neff). The next step would then be to get for each parameter set the neff with the highest real part. I did find an intermediate solution by going to matlab, connecting via livelink and using some code, which I found on this forum. But this is not a real solution as I have to solve this task finally in Comsol itself. In Matlab, for your information, I use the following code, I do not fully understand how it works, I must admit: for solindex=19:45 % With 19 to 45 being the index of the available, calculated solutions, just as they were called in the parameter sweep. [sz,ndofs,list,name,type]=mphgetp(model,'solname',strcat('sol',solindex)); neff(index,:)=1j*list/(2*pi/wavelength)'; neffmax(index,1)=max(neff(index,:)); end 2nd approach: I added a global probe under Model1 -> Definitions and in it I selected Expression: neff When executing study 1 under Results -> Data Sets a "Probe Solution 9" appears with "Solution: Parametric, Model:1" And under Results -> Derived Values "Global Variable Probe 1" appears with "Data Set: Probe Solution 9" and all parameter values selected. But also here, neff is not available for selection. When I type Expression: neff (same for emw.neff) I get the error message: Variable: neff Global scope: Failed to evaluate expression. Expression: real(neff) Failed to evaluate expression:. Expression: real(neff) Sorry... that I ask again. But there must be something which I really do not see. Do you have any suggestions? Than you very much in advance! Best regards Arian PS: BTW the strange error message vanished after I had restarted Comsol for 3 times... it even appeared when I loaded a mph file which peviously worked fine. I guess this was just a complicated minor bug. What I now did:

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 Jan 2, 2011, 2:21 p.m. EST
Hi

I suspoect that several of yur issues are related to v4.0, this early version it was very sensitive to model changes (and it history, such as not always updating correctly the hole line of linked values down in the sover sub nodes, so this could be an issue). When I used it I often needed to rebuild my model from scratch after several model changes.

This is no longer so in v4.1, and mostly with a file - clear solution, clear mesh - reset model + save, and then restart COMSOL you get around many funny issues that otherwise make you loose quite some time

--
Good luck
Ivar
Hi I suspoect that several of yur issues are related to v4.0, this early version it was very sensitive to model changes (and it history, such as not always updating correctly the hole line of linked values down in the sover sub nodes, so this could be an issue). When I used it I often needed to rebuild my model from scratch after several model changes. This is no longer so in v4.1, and mostly with a file - clear solution, clear mesh - reset model + save, and then restart COMSOL you get around many funny issues that otherwise make you loose quite some time -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 6, 2012, 5:29 a.m. EST
Hi all,

i use Comsol V4.2a, In Results there is Tables, i would like to insert new Table, and then i want to import my Data into this Table, but i don't know what kind of Format?

Do you have ideas?

Thanks you very much

Hi all, i use Comsol V4.2a, In Results there is Tables, i would like to insert new Table, and then i want to import my Data into this Table, but i don't know what kind of Format? Do you have ideas? Thanks you very much

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 Jan 6, 2012, 6:19 a.m. EST
Hi

the Table is populated automatically when you calculate "Define Probe" data or when you define Results Derived Values ... Try a right click on the Derived data and calculate something useful, i.e. the surface of a element by integrating over a boundary (in 3D) of the operand 1 (simple example easy to verify to start with)

--
Good luck
Ivar
Hi the Table is populated automatically when you calculate "Define Probe" data or when you define Results Derived Values ... Try a right click on the Derived data and calculate something useful, i.e. the surface of a element by integrating over a boundary (in 3D) of the operand 1 (simple example easy to verify to start with) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 6, 2012, 9:28 a.m. EST
Hi,

Thanks for your answer.My idea ist that when you have a table of experiment (i.e *.xls, *.dat,*.txt...), you can import into the Result, then when you run your Modell, you can compare your result of Simulation with the Data of experiment. you can see in the attach file, the yellow and pink line are result of Simulation and the different lines are result of experiment. The format of this file can be *.txt or *.csv.

For example:
% File: Experiment.txt
1 21.4379997253418 21.4899997711182 21.55299949646 21.488000869751 21.4440002441406 21.4990005493164 21.5949993133545 22.69700050354
119 21.6352005004883 21.3376998901367 21.5445003509521 21.5062007904053 21.4645004272461 21.5466003417969 21.6525993347168 21.9328994750977
237 21.5757007598877 21.4720001220703 21.6172008514404 21.5347995758057 21.5081005096436 20.926399230957 21.6548004150391 20.0454998016357
356 21.5076007843018 21.2481002807617 21.5997009277344 21.5496006011963 21.3297996520996 20.1819000244141 21.6119995117188 17.8924007415771
474 21.4606990814209 20.9230995178223 21.593599319458 21.5757999420166 21.0433006286621 19.2859001159668 21.5632991790771 16.8924007415771
592 21.2175006866455 20.6334991455078 21.4689998626709 21.4855995178223 20.6396007537842 18.3082008361816 21.5403995513916 15.1507997512817
711 21.0100994110107 20.1448001861572 21.3588008880615 21.2950992584229 20.2367992401123 17.2724990844727 21.4027996063232 13.5739002227783
829 20.7943000793457 19.7229995727539 21.13450050354 21.082799911499 19.8227996826172 16.2073001861572 21.2614002227783 11.6111001968384


Best regards

QTran
Hi, Thanks for your answer.My idea ist that when you have a table of experiment (i.e *.xls, *.dat,*.txt...), you can import into the Result, then when you run your Modell, you can compare your result of Simulation with the Data of experiment. you can see in the attach file, the yellow and pink line are result of Simulation and the different lines are result of experiment. The format of this file can be *.txt or *.csv. For example: % File: Experiment.txt 1 21.4379997253418 21.4899997711182 21.55299949646 21.488000869751 21.4440002441406 21.4990005493164 21.5949993133545 22.69700050354 119 21.6352005004883 21.3376998901367 21.5445003509521 21.5062007904053 21.4645004272461 21.5466003417969 21.6525993347168 21.9328994750977 237 21.5757007598877 21.4720001220703 21.6172008514404 21.5347995758057 21.5081005096436 20.926399230957 21.6548004150391 20.0454998016357 356 21.5076007843018 21.2481002807617 21.5997009277344 21.5496006011963 21.3297996520996 20.1819000244141 21.6119995117188 17.8924007415771 474 21.4606990814209 20.9230995178223 21.593599319458 21.5757999420166 21.0433006286621 19.2859001159668 21.5632991790771 16.8924007415771 592 21.2175006866455 20.6334991455078 21.4689998626709 21.4855995178223 20.6396007537842 18.3082008361816 21.5403995513916 15.1507997512817 711 21.0100994110107 20.1448001861572 21.3588008880615 21.2950992584229 20.2367992401123 17.2724990844727 21.4027996063232 13.5739002227783 829 20.7943000793457 19.7229995727539 21.13450050354 21.082799911499 19.8227996826172 16.2073001861572 21.2614002227783 11.6111001968384 Best regards QTran


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 Jan 6, 2012, 10:07 a.m. EST
Hi

you can even do more :)

If you import your experimental results into a piecewise or interpolation function, then you can define a material property variable as a ODE dependent variable and solve in a mean square way to adapt a particular variable or property to your experimental data.

--
Good luck
Ivar
Hi you can even do more :) If you import your experimental results into a piecewise or interpolation function, then you can define a material property variable as a ODE dependent variable and solve in a mean square way to adapt a particular variable or property to your experimental data. -- 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.