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
Posted 22 dic 2017, 17:30 GMT-5 Optimization, Parameters, Variables, & Functions, Studies & Solvers Version 5.3 8 Replies
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
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
Dear Edgar,
Thank you for your suggestion, I used global equations instead and they work great!
Best regards
Maciej
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
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
Please login with a confirmed email address before reporting spam
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
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.