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.

optimization module in a time dependent model

Please login with a confirmed email address before reporting spam

Hi ,

These days I am working on an optimization problem in COMSOL 4.0a. I use time dependent Nernst-Plank model. Using this model I am able to find the trend of current versus time and I have experimental trend as well. The plan is using the COMSOL model and the experimental results to find an optimum value for a physical constant. So the control variable is not changing through time. I also defined the objective variable as the integral of the RMS error between model and experimental results through time.
COMSOL all the time gives "singular matrix" error in this case. Does anyone know how I can solve this problem? If using MATLAB optimization toolbar in COMSOL with MATLAB environment is the only way, does anyone know any example that can help me. I can't figure out how I should use optimization toolbar in this case.

I greatly appericiate your help.
Atieh

2 Replies Last Post 02.04.2011, 15:43 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 28.03.2011, 06:07 GMT-4
I have some experience in using Matlab's optimization routines with Comsol. Basically, if you understand how to work with matlab's optimization routine (fmincon in my case), then it is straightforward to introduce Comsol into the scheme. You will have to save your model as a Matlab file, declare it as a function with an input vector and the output variable which would be your objective. The rest will be taken care of by fmincon or any optimization function of Matlab you use.

Keep in mind that Comsol has a java heap problem when mphint() or mphinterp() are called which severely restricts the number of times these routines can be iteratively called. They have a solution in knowledge base on how to increase the default limit and after setting it to some value over a GB made everything work fine for me.

All the best.
I have some experience in using Matlab's optimization routines with Comsol. Basically, if you understand how to work with matlab's optimization routine (fmincon in my case), then it is straightforward to introduce Comsol into the scheme. You will have to save your model as a Matlab file, declare it as a function with an input vector and the output variable which would be your objective. The rest will be taken care of by fmincon or any optimization function of Matlab you use. Keep in mind that Comsol has a java heap problem when mphint() or mphinterp() are called which severely restricts the number of times these routines can be iteratively called. They have a solution in knowledge base on how to increase the default limit and after setting it to some value over a GB made everything work fine for me. All the best.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.04.2011, 15:43 GMT-4
Thanks for the helpful answer Shakib. I declared my model as a MATLAB function. My COMSOL model defines the integral of the mean square error through time as an objective function. The name of this objective function is 'ebsilon'. the control variable which doesn't change through time is i0. I used following optimization command in MATLAB:
i0=fminsearch(@mopt,i0_init)
i0_init is the initial guess and mopt is the Matlab function. when I solve this problem, following error is shown:
"Java exception occurred"
and the solving process stops at the very initial stage.
Please let me know if you have any clue for this error.
I greatly appriciate your help.
Atieh
Thanks for the helpful answer Shakib. I declared my model as a MATLAB function. My COMSOL model defines the integral of the mean square error through time as an objective function. The name of this objective function is 'ebsilon'. the control variable which doesn't change through time is i0. I used following optimization command in MATLAB: i0=fminsearch(@mopt,i0_init) i0_init is the initial guess and mopt is the Matlab function. when I solve this problem, following error is shown: "Java exception occurred" and the solving process stops at the very initial stage. Please let me know if you have any clue for this error. I greatly appriciate your help. Atieh

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.