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.

dependent variables: sweep over "initial values" and "variables not solved for"?

Please login with a confirmed email address before reporting spam

Hello all-

I have 2 Studies in my 2D model:

Study 1 solves for various fields within my geometry. These fields are different for each wavelength (lam0).
Study 2 takes the lam0-dependent fields from Study 1 and solves other fields, which are my solution.

Right now, I am manually choosing fields from Study 1 (ie. I am choosing fields whose solutions depend on a specific lam0 value) for input as 'initial values' and 'values not solved for', under the Values of Dependent Variables menu.

But, there are a whole heck of a lot of lam0, so I'm wondering if its possible to automate this.

In summary, I sure wish there was an 'All' option under Study 2> Values of Dependent Variables>Method (Solution)>Study 1>Selection.. (options now are Auto,First, Last, Manual.. all of which input only 1 lam0 at a time)

Thanks for your suggestions!

Devin

9 Replies Last Post 16.07.2013, 14:08 GMT-4
Josh Thomas Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.07.2013, 10:19 GMT-4
Devin-

Interesting because usually there is an option available called "All" that will use all the solutions from the previous study.

Would you be able to upload your model using "Attach File"? You can clear solutions and meshes before saving and uploading to save space. Use Edit>Clear Meshes and Edit>Clear Solutions to do this.

Regards,
Josh Thomas
AltaSim Technologies
Devin- Interesting because usually there is an option available called "All" that will use all the solutions from the previous study. Would you be able to upload your model using "Attach File"? You can clear solutions and meshes before saving and uploading to save space. Use Edit>Clear Meshes and Edit>Clear Solutions to do this. Regards, Josh Thomas AltaSim Technologies

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.07.2013, 11:55 GMT-4
sure thing. please see attached.
thanks for your time!
sure thing. please see attached. thanks for your time!


Josh Thomas Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.07.2013, 14:00 GMT-4
Devin-

I may have a solution for you.

Under your Study 2 the "Values of variables not solved for" does have an "All" option under Selection.

To handle, the "Initial values of variables solved for" you can set the Selection to Automatic and then use the Study Extensions section to define the wavelength (lam0) as 2nd continuation parameter (besides the V_appl which you already have). Move the lam0 parameter first in the list and then specify "Sweep type" as All Combinations.

I think this will work for you for Study 2.

See attached mph file.

Best regards,
Josh Thomas
AltaSim Technologies
Devin- I may have a solution for you. Under your Study 2 the "Values of variables not solved for" does have an "All" option under Selection. To handle, the "Initial values of variables solved for" you can set the Selection to Automatic and then use the Study Extensions section to define the wavelength (lam0) as 2nd continuation parameter (besides the V_appl which you already have). Move the lam0 parameter first in the list and then specify "Sweep type" as All Combinations. I think this will work for you for Study 2. See attached mph file. Best regards, Josh Thomas AltaSim Technologies


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.07.2013, 14:43 GMT-4
Josh-

You rock! This is exactly what I needed. You just saved me many, many hours of manual entry :)

Thanks very much!
Devin
Josh- You rock! This is exactly what I needed. You just saved me many, many hours of manual entry :) Thanks very much! Devin

Josh Thomas Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 15.07.2013, 14:46 GMT-4
Great. Glad to hear it.

All the best,
Josh
Great. Glad to hear it. All the best, Josh

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.07.2013, 13:44 GMT-4
Josh,
A follow-up question for you: I've done a few runs, using this technique, and it is working as expected, except for a few small bugs, which may be related to one another:

-if I do a large sweep of wavelength (say, range(500[nm],2[nm],1100[nm]), and let it run overnight, the convergence plot indicates that somewhere in the middle of the sweep (say, at 800nm), the maximum number of iterations (which I had set to 500) was reached, and the solution isn't converged. I regret not having saved the convergence plot for analysis.

-if I then clear all solutions and restart the simulation at 780nm, for instance, the solver finds a solution (in this case, current, calculated via a boundary probe) for 780nm and longer just fine, but the 780-798nm solutions differ substantially (~%70) from the initial solution.

It seems as though there is a residual effect, coming from the hours of calculations, and the only way I discovered it was due to the solver not converging at 800nm... I'm concerned the data from 500-800nm is flawed now too..

I'm using the same model you edited.

Any ideas? Any simple checks or settings within the solver that I can adjust to prohibit the long-term divergence of the solution?

Thanks again for your assistance
Devin
Josh, A follow-up question for you: I've done a few runs, using this technique, and it is working as expected, except for a few small bugs, which may be related to one another: -if I do a large sweep of wavelength (say, range(500[nm],2[nm],1100[nm]), and let it run overnight, the convergence plot indicates that somewhere in the middle of the sweep (say, at 800nm), the maximum number of iterations (which I had set to 500) was reached, and the solution isn't converged. I regret not having saved the convergence plot for analysis. -if I then clear all solutions and restart the simulation at 780nm, for instance, the solver finds a solution (in this case, current, calculated via a boundary probe) for 780nm and longer just fine, but the 780-798nm solutions differ substantially (~%70) from the initial solution. It seems as though there is a residual effect, coming from the hours of calculations, and the only way I discovered it was due to the solver not converging at 800nm... I'm concerned the data from 500-800nm is flawed now too.. I'm using the same model you edited. Any ideas? Any simple checks or settings within the solver that I can adjust to prohibit the long-term divergence of the solution? Thanks again for your assistance Devin

Josh Thomas Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.07.2013, 14:03 GMT-4
Devin,

I never did any checks to see that the model I set-up was operating as you'd expect. Although, it seems to be working because the solver was converging for all parameter values. I would recommend still checking the results against the "manual" method that you are sure works.

It would be surprising to me if COMSOL is converging to different answers for the same problem definition. Are we sure that the problem definition is the same in both cases (i.e. same initial values of solution variables and values of variables not solved for)? I would be surprised if the discrepancy is due to some relaxed tolerance in the solver settings that is causing the solution to diverge. You could try tightening up the relative tolerance, but a 70% difference is pretty extreme. Even if you are looking at maximum or minimum values. The default tolerance is 0.1% for the non-linear solver and I believe also for the linear system solvers.

Hope that helps some.

Best,
Josh
Devin, I never did any checks to see that the model I set-up was operating as you'd expect. Although, it seems to be working because the solver was converging for all parameter values. I would recommend still checking the results against the "manual" method that you are sure works. It would be surprising to me if COMSOL is converging to different answers for the same problem definition. Are we sure that the problem definition is the same in both cases (i.e. same initial values of solution variables and values of variables not solved for)? I would be surprised if the discrepancy is due to some relaxed tolerance in the solver settings that is causing the solution to diverge. You could try tightening up the relative tolerance, but a 70% difference is pretty extreme. Even if you are looking at maximum or minimum values. The default tolerance is 0.1% for the non-linear solver and I believe also for the linear system solvers. Hope that helps some. Best, Josh

Josh Thomas Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.07.2013, 14:06 GMT-4
One more thought...if you clear all solutions and restart, wouldn't you lose the appropriate values of "variables not solved for"? Or, are you also re-running step 1? From my understanding, the step 1 results have a direct effect on step 2 results and you wouldn't want to clear all solutions.
One more thought...if you clear all solutions and restart, wouldn't you lose the appropriate values of "variables not solved for"? Or, are you also re-running step 1? From my understanding, the step 1 results have a direct effect on step 2 results and you wouldn't want to clear all solutions.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16.07.2013, 14:08 GMT-4
Thanks Josh. That does help. I'll compare with 'manual' data points at various wavelengths throughout the spectrum, to ensure accuracy. Perhaps it was a local phenomenon, which caused the solver to diverge in the first place.

Edit: yep, re-ran Study 1 after clearing all solutions. So you're right, I have some tracing to do..

Again, thanks very much for your help!
Devin
Thanks Josh. That does help. I'll compare with 'manual' data points at various wavelengths throughout the spectrum, to ensure accuracy. Perhaps it was a local phenomenon, which caused the solver to diverge in the first place. Edit: yep, re-ran Study 1 after clearing all solutions. So you're right, I have some tracing to do.. Again, thanks very much for your help! Devin

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.