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.

Adjusting a parameter between study steps based on initial result

Please login with a confirmed email address before reporting spam

In my simulation I'm guessing a parameter's value, doing a stationary study - and from the result I can get a much better estimate of the parameter. (With a surface integral.)

For just one study I can manually adjust the parameter's value - but if I wanted to do a parametric sweep, is there a way to add a second stationary step that would automatically adjust the parameter's value based on a surface integral computed in the first result - for every case in the parametric sweep?

Example: I guess the parameter to be 1.0, stationary study gives the integral equal 1.3, I adjust the parameter to be 1.0/1.3 = 0.76923 which will give me the desired result.

Thank you for your help!
Maciej


8 Replies Last Post 25 déc. 2017, 11:03 UTC−5
Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 22 déc. 2017, 18:34 UTC−5

Maciej,

there may be different ways to achieve that, depending on what the parameter is actually doing. If it controls a boundary condition, you may try the following: - Duplicate the respective BC node - Use the start parameter in the first node - Use the calculated variable in the second node - Set up two successive stationary steps - Modify the physics tree: disable the second BC version in the first study and the first BC version in the second study.

This should work for any kind of physics subnode, not only BCs. If the parameter is doing something that affects geometry or mesh, things get more difficult.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Maciej, there may be different ways to achieve that, depending on what the parameter is actually doing. If it controls a boundary condition, you may try the following: - Duplicate the respective BC node - Use the start parameter in the first node - Use the calculated variable in the second node - Set up two successive stationary steps - Modify the physics tree: disable the second BC version in the first study and the first BC version in the second study. This should work for any kind of physics subnode, not only BCs. If the parameter is doing something that affects geometry or mesh, things get more difficult. Cheers Edgar

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 23 déc. 2017, 06:47 UTC−5

Dear Edgar, thank you for your reply!

One thing I don't understand - "Use the calculated variable in the second node" - how can I refer to an integral calculated in the previous study? If I would just replace parameter "p0" with "p0/intop1(w)" in the second BC, the integral would keep being evaluated and updated during the calculation of the second study. I would like to save its value from the first study and use that in the second one.

Best regards Maciej

Dear Edgar, thank you for your reply! One thing I don't understand - "Use the calculated variable in the second node" - how can I refer to an integral calculated in the previous study? If I would just replace parameter "p0" with "p0/intop1(w)" in the second BC, the integral would keep being evaluated and updated during the calculation of the second study. I would like to save its value from the first study and use that in the second one. Best regards Maciej

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 23 déc. 2017, 08:57 UTC−5

Hi Maciej,

you are right, it doesn't work this way. Actually, my suggestion didn't come out of the blue, but my case was indeed different. One other way, that comes to my mind is to duplicate the whole physics node and add a global equation to the first physics. Check here: https://www.comsol.de/blogs/using-the-previous-solution-operator-in-transient-modeling/ to see an example how to take advantage of global equations. It is again different from what you need, but it may trigger an idea.

Good luck Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Maciej, you are right, it doesn't work this way. Actually, my suggestion didn't come out of the blue, but my case was indeed different. One other way, that comes to my mind is to duplicate the whole physics node and add a global equation to the first physics. Check here: https://www.comsol.de/blogs/using-the-previous-solution-operator-in-transient-modeling/ to see an example how to take advantage of global equations. It is again different from what you need, but it may trigger an idea. Good luck Edgar

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 23 déc. 2017, 11:22 UTC−5

Dear Edgar,

Thank you for your suggestion, I used global equations instead and they work great!

Best regards
Maciej

Dear Edgar, Thank you for your suggestion, I used global equations instead and they work great! Best regards Maciej

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 23 déc. 2017, 14:22 UTC−5

Hi,

Edgar's first suggestion should work if you wrap 'w' in the withsol() operator so that you can explicitly point to the intended solution.

Regards,

Henrik

-------------------
Henrik Sönnerlind
COMSOL
Hi, Edgar's first suggestion should work if you wrap 'w' in the withsol() operator so that you can explicitly point to the intended solution. Regards, Henrik

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 23 déc. 2017, 17:37 UTC−5

Hi Henrik,

interesting! But is withsol() useable in the solver sequence in such a case? So far I assumed (and experienced) that it only works reliably in post processing? Well, it seems to work during solving in specific cases which are not documented as far as I know.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Henrik, interesting! But is withsol() useable in the solver sequence in such a case? So far I assumed (and experienced) that it only works reliably in post processing? Well, it seems to work during solving in specific cases which are not documented as far as I know. Cheers Edgar

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 25 déc. 2017, 09:41 UTC−5

Hi Edgar,

You are probably thinking of the 'with()' operator, which is only available in postprocessing.

The 'withsol()' operator (which was added in version 5.1) can be used anywhere; in expressions, variables, etc. The only restriction is that the solution you are pointing to must have been computed when the expression is evaluated.

Some examples from previous forum discussions:

https://www.comsol.com/forum/thread/90501/is-it-possible-toselect-a-particular-solution-of-a-certain-data-set-using-withsol

https://www.comsol.com/forum/thread/101611/previous-solution-as-constant

https://www.comsol.com/forum/thread/86181/reusing-solution-displacements-should-be-easy-help-please

Regards,

Henrik

-------------------
Henrik Sönnerlind
COMSOL
Hi Edgar, You are probably thinking of the 'with()' operator, which is only available in postprocessing. The 'withsol()' operator (which was added in version 5.1) can be used anywhere; in expressions, variables, etc. The only restriction is that the solution you are pointing to must have been computed when the expression is evaluated. Some examples from previous forum discussions: https://www.comsol.com/forum/thread/90501/is-it-possible-toselect-a-particular-solution-of-a-certain-data-set-using-withsol https://www.comsol.com/forum/thread/101611/previous-solution-as-constant https://www.comsol.com/forum/thread/86181/reusing-solution-displacements-should-be-easy-help-please Regards, Henrik

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 25 déc. 2017, 11:03 UTC−5

Henrik,

yes in this case the solution is finished and it is possible to point to it with withsol(). I failed with withsol() in cases when I would have had to reference a parametric solution while the auxiliary sweep is still running.

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Henrik, yes in this case the solution is finished and it is possible to point to it with withsol(). I failed with withsol() in cases when I would have had to reference a parametric solution while the auxiliary sweep is still running. Cheers Edgar

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.