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.

Parametric Sweep Results as Initial Values

Please login with a confirmed email address before reporting spam

Hello everyone

I'm trying to take the results of a Parametric Sweep in Study 1 as Initial Values of the same Parametric Sweep (same parameter and values) in Study 2.

But when looking at initial values, it always corresponds to the last parameter value. The Values of Dependen Variables of the Study Step in Study 2 are set as: - Settings: User controlled - Method: Solution - Study: Study 1 - Solution: Parametric Solutions 1 - Use: Current - Time(s): Last

So, how do I cycle through the solutions in the Parametric Solutions 1 for the initial values?

Thanks in advance


3 Replies Last Post May 31, 2019, 5:58 p.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 5 years ago May 29, 2019, 3:41 a.m. EDT
Updated: 5 years ago May 31, 2019, 5:56 p.m. EDT

Hi Gustavo,

I had the same problem a while ago, I am interested if you find a good solution. In my case I realized the double sweep was not needed, but the solution I was experimenting with before that was the following:

  • Create a default solver in your study, if its Solver configurations branch is empty
  • In the 2nd step, set the Initial values of variables solved for to Physics controlled.
  • In the equation of the dependent variable X, create a second Initial values entry and set the initial value to withsol('sol_tag', X, setval(p, p)) where sol_tag in the tag of the solution node for step 1, and p is the parameter varied in your sweep
  • In the 1st step go to Physics and Variables Selection, tick the Modify model configuration for study step and disable in the model the new initial values you just created (otherwise they would override the original initial settings).
  • Optionally, to be extra safe: In the 2nd step go to Physics and Variables Selection, tick the Modify model configuration for study step and disable the original initial values.

I have not fully tested this. Please let me know how it goes or if you find a better solution !

Hi Gustavo, I had the same problem a while ago, I am interested if you find a good solution. In my case I realized the double sweep was not needed, but the solution I was experimenting with before that was the following: * Create a default solver in your study, if its **Solver configurations** branch is empty * In the 2nd step, set the *Initial values of variables solved for* to **Physics controlled**. * In the equation of the dependent variable `X`, create a second **Initial values** entry and set the initial value to `withsol('sol_tag', X, setval(p, p))` where `sol_tag` in the tag of the solution node for step 1, and `p` is the parameter varied in your sweep * In the 1st step go to **Physics and Variables Selection**, tick the *Modify model configuration for study step* and disable in the model the new initial values you just created (otherwise they would override the original initial settings). * Optionally, to be extra safe: In the 2nd step go to **Physics and Variables Selection**, tick the *Modify model configuration for study step* and disable the original initial values. I have not fully tested this. Please let me know how it goes or if you find a better solution !

Please login with a confirmed email address before reporting spam

Posted: 5 years ago May 30, 2019, 1:35 p.m. EDT
Updated: 5 years ago May 30, 2019, 1:34 p.m. EDT

Hi Alexis

Thank you for your response! It worked, with some modifications.

Instead of

withsol('sol_tag', X, getVal(p, p))

it is

withsol('sol_tag', X, setval(p, p))

At least in version 5.4.

If one needs to find it, in a result expression, it is in (along with withsol):

Built in > Operators > Evaluation

Hi Alexis Thank you for your response! It worked, with some modifications. Instead of > withsol('sol_tag', X, **getVal**(p, p)) it is > withsol('sol_tag', X, **setval**(p, p)) At least in version 5.4. If one needs to find it, in a result expression, it is in (along with **withsol**): Built in > Operators > Evaluation

Please login with a confirmed email address before reporting spam

Posted: 5 years ago May 31, 2019, 5:58 p.m. EDT
Updated: 5 years ago May 31, 2019, 5:59 p.m. EDT

Glad to see it worked!

I have edited my answer to match your correction, to make it easier for future visitors. Please let me know if you encounter issue with this, because I am probably going to use it as well. It seems that this solves faster than the alternative I ended up using in my case.

Glad to see it worked! I have edited my answer to match your correction, to make it easier for future visitors. Please let me know if you encounter issue with this, because I am probably going to use it as well. It seems that this solves faster than the alternative I ended up using in my case.

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.