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.

using parameter values from a text file

Please login with a confirmed email address before reporting spam

Hi everyone,

im trying to use a parametric solver with a text file containing the values. However, the solver immediately gives an error saying "Error 7096: parameter list must be strictly monotone". Can anyone shed light on this?

Best regards,
Adam

8 Replies Last Post Mar 9, 2011, 1:17 p.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 Aug 24, 2009, 3:41 p.m. EDT
Hi

you can generate the same error message inside the GUI if you enter a non-monotonus series such as 1,2,3,6,4,5 : COMSOL will not accept to jump"back" from 6 to 4, neither not 1,2,3,3,4,5 the ...3,3... is one repetition too much.

So by some way either the values or the fomatting get's COMSOL to interprete your text data as a series not respecitng a striclty positive growth

I do not know of any other case, but comsol support might have more to say

Good luck
Ivar
Hi you can generate the same error message inside the GUI if you enter a non-monotonus series such as 1,2,3,6,4,5 : COMSOL will not accept to jump"back" from 6 to 4, neither not 1,2,3,3,4,5 the ...3,3... is one repetition too much. So by some way either the values or the fomatting get's COMSOL to interprete your text data as a series not respecitng a striclty positive growth I do not know of any other case, but comsol support might have more to say Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 25, 2009, 5:09 a.m. EDT
Thanks Ivar,

i didnt know what monotone meant in regard to a list of numbers but I see now. I have a model with 3 physical parameters that I have assigned a number of possible values, and I want to solve the model for every possible combination of those values.

I want to use parameters something like this:

1 1 1
2 1 1
3 1 1
1 2 1
...etc

but it seems its not possible as the list becomes non-monotonous. Should I look into using matlab with the comsol script?

Thanks,
Adam
Thanks Ivar, i didnt know what monotone meant in regard to a list of numbers but I see now. I have a model with 3 physical parameters that I have assigned a number of possible values, and I want to solve the model for every possible combination of those values. I want to use parameters something like this: 1 1 1 2 1 1 3 1 1 1 2 1 ...etc but it seems its not possible as the list becomes non-monotonous. Should I look into using matlab with the comsol script? Thanks, Adam

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 Aug 26, 2009, 6:06 a.m. EDT
Hi Adam

I'm not sure that the parameter works with lists and several values, even if in COMSOL functions shall be written "array" compatible, for postprocessing one cannot enter an array, even if it could be usefull (and logical) to ask for u,v,w in one go.
I have aleady submitted this request of array postprocessing values to COMSOL and they accepted that it was a good idea, hope they manage to get it implemented in next version, we will see.

In the mean time you might get around by manually using the "Solve - Parametric Sweep", in addition to "Solve - Solve Parameter - Parametric", and define two separate variables, and then manually scan through the combinations you need. Clearly you will end up with quite many files.

A script is probably the easiest, as you can directly add your postreatment and probably reduce your data out

Have fun
Ivar
Hi Adam I'm not sure that the parameter works with lists and several values, even if in COMSOL functions shall be written "array" compatible, for postprocessing one cannot enter an array, even if it could be usefull (and logical) to ask for u,v,w in one go. I have aleady submitted this request of array postprocessing values to COMSOL and they accepted that it was a good idea, hope they manage to get it implemented in next version, we will see. In the mean time you might get around by manually using the "Solve - Parametric Sweep", in addition to "Solve - Solve Parameter - Parametric", and define two separate variables, and then manually scan through the combinations you need. Clearly you will end up with quite many files. A script is probably the easiest, as you can directly add your postreatment and probably reduce your data out Have fun Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 26, 2009, 10:23 a.m. EDT
Again, thanks for the assistance!

I've begun trying to use Matlab to achieve my aim, although my knowledge is very rudimentary. Its going fairly well, but Im stuck on a particular part. I want to use a for loop on the m-file, each time returning a z-coordinate where the variable (concentration 'c' in this case) falls to a particular level on a specific boundary. I can use postinterp to return the c values on that boundary (in a roundabout way), but from there Im having difficulty obtaining the z-coordinate where c equals the particular value. I have tried using postmin(fem, c-value) but its not working. Any suggestions would be greatly appreciated!

Thanks again,
Adam
Again, thanks for the assistance! I've begun trying to use Matlab to achieve my aim, although my knowledge is very rudimentary. Its going fairly well, but Im stuck on a particular part. I want to use a for loop on the m-file, each time returning a z-coordinate where the variable (concentration 'c' in this case) falls to a particular level on a specific boundary. I can use postinterp to return the c values on that boundary (in a roundabout way), but from there Im having difficulty obtaining the z-coordinate where c equals the particular value. I have tried using postmin(fem, c-value) but its not working. Any suggestions would be greatly appreciated! Thanks again, Adam

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 Aug 27, 2009, 4:38 a.m. EDT
Hello

The way I understand postinterp and posteval (the other access point to the results via matlab) is that the first one gives you the resultig values at your own "interpolated" mesh points, while the latter returns the results at the actual mesh points, on a particular domain or edge.

If you are looking for the Z coordinate, I beleive you are better getthing there with the posteval. The return structure (see the command.pdf) is giving you access to the different elements by indexes, try the function first on a simple case with few items until you feel comfortable with the approach, otherwise you might get the feeling I often had, being lost in the complexity of index and index to index ...

I believe I have seen somewhere an description of your need, but I cannot just now remember if it is in one of the books/.pdf or in one of the courses I have followed.

Good luck
Ivar
Hello The way I understand postinterp and posteval (the other access point to the results via matlab) is that the first one gives you the resultig values at your own "interpolated" mesh points, while the latter returns the results at the actual mesh points, on a particular domain or edge. If you are looking for the Z coordinate, I beleive you are better getthing there with the posteval. The return structure (see the command.pdf) is giving you access to the different elements by indexes, try the function first on a simple case with few items until you feel comfortable with the approach, otherwise you might get the feeling I often had, being lost in the complexity of index and index to index ... I believe I have seen somewhere an description of your need, but I cannot just now remember if it is in one of the books/.pdf or in one of the courses I have followed. Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 31, 2009, 8:07 a.m. EDT
From the Multiphysics user guide

"When solving for several parameters, the list must be monotonic in the first parameter. Enter the list as a vector where the parameter sets are stored consecutively. For example, if there are two solver parameters, the entry 0 5 2 3 4 8 in the Parameter values edit field means that the parametric solver is called with the parameter-value pairs (0, 5), (2, 3), and finally (4, 8). For three solver parameters, the same list would correspond to the parameter sets (0, 5, 2) and (3, 4, 8). To avoid the constraint that the list must be monotonic in the first parameter, you can use a dummy variable as the first parameter. If you want to use the parameter-value pairs (7, 8), (4, 12), and (1, 6), for example, add an unused dummy parameter, say p0, first in the Parameter names edit field. Then use the entry 1 7 8 2 4 12 3 1 6 in the Parameter values edit field. The parametric solver then uses the parameter sets (1, 7, 8), (2, 4, 12), and (3, 1, 6), where the first value in each set applies to the first parameter, p0, which is a dummy parameter that does not appear in the model settings.
You can also use the Load Parameter Values From File option. This option loads the values from a text file into the Parameter values edit field. In this text file, the parameter sets must be listed row-wise with the values in each set separated by a space or tab."

So you cannot input them as a matrix, but you have to from the combinations yourself and list them all after each other on one line.

Best regards,

Maarten.
From the Multiphysics user guide "When solving for several parameters, the list must be monotonic in the first parameter. Enter the list as a vector where the parameter sets are stored consecutively. For example, if there are two solver parameters, the entry 0 5 2 3 4 8 in the Parameter values edit field means that the parametric solver is called with the parameter-value pairs (0, 5), (2, 3), and finally (4, 8). For three solver parameters, the same list would correspond to the parameter sets (0, 5, 2) and (3, 4, 8). To avoid the constraint that the list must be monotonic in the first parameter, you can use a dummy variable as the first parameter. If you want to use the parameter-value pairs (7, 8), (4, 12), and (1, 6), for example, add an unused dummy parameter, say p0, first in the Parameter names edit field. Then use the entry 1 7 8 2 4 12 3 1 6 in the Parameter values edit field. The parametric solver then uses the parameter sets (1, 7, 8), (2, 4, 12), and (3, 1, 6), where the first value in each set applies to the first parameter, p0, which is a dummy parameter that does not appear in the model settings. You can also use the Load Parameter Values From File option. This option loads the values from a text file into the Parameter values edit field. In this text file, the parameter sets must be listed row-wise with the values in each set separated by a space or tab." So you cannot input them as a matrix, but you have to from the combinations yourself and list them all after each other on one line. Best regards, Maarten.

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 Aug 31, 2009, 4:19 p.m. EDT
Hi Maarten

Thanks for the precision, it's true that several parameters/GUI fields can be entered as lists (but by far not all), I had not noticed, nor remebered, that this applies for the parameter field too. Nice work around too.

I hope COMSOL could either make all list accept paramters (i.e. for the postprocessing too), or to "flag" them with an optional [ ] or something like that, it would help us to remember where we must use scalars and where vectors/arrays might be accepted

Thanks again
Ivar
Hi Maarten Thanks for the precision, it's true that several parameters/GUI fields can be entered as lists (but by far not all), I had not noticed, nor remebered, that this applies for the parameter field too. Nice work around too. I hope COMSOL could either make all list accept paramters (i.e. for the postprocessing too), or to "flag" them with an optional [ ] or something like that, it would help us to remember where we must use scalars and where vectors/arrays might be accepted Thanks again Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 9, 2011, 1:17 p.m. EST
If you are using Mac, be sure to specify UTF-8 encoding...the default setting is UTF-16 in TextEdit and it seems to give a syntax error.
If you are using Mac, be sure to specify UTF-8 encoding...the default setting is UTF-16 in TextEdit and it seems to give a syntax error.

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.