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.

accessing the conductivity parameter

Please login with a confirmed email address before reporting spam

I am new to COMSOL, trying to use it as a forward solver for an optimization problem in the Matlab environment. I have looked at all the manuals and read all the sections I think are relevant. I am stuck. I want to be able to specify the conductivity of a subdomain externally, letting it vary during the optimization process, but cannot figure out how to find it in the fem structure.

I am hoping to use Matlab's own optimization routines, not the COMSOL Optimization Module, becasue 1) I will have more flexibility and 2) I cannot figure out how to bring out the conductiviy as a variable in the Optimization Module

3 Replies Last Post Jul 27, 2009, 11:49 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 23, 2009, 7:49 p.m. EDT
An update: I exported my model as an M-file, and found out where the conductivity was set (equ.sigma). I tried to very it in a for loop, but got inconsistent results. Then I include more of the M-file in the for loop and still got inconsistent results. Finally I went back to the first versioono without a loop and manually changed the conductivity in one subdomain - still inconsistent!. ANy ideas?

An update: I exported my model as an M-file, and found out where the conductivity was set (equ.sigma). I tried to very it in a for loop, but got inconsistent results. Then I include more of the M-file in the for loop and still got inconsistent results. Finally I went back to the first versioono without a loop and manually changed the conductivity in one subdomain - still inconsistent!. ANy ideas?


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 24, 2009, 12:47 p.m. EDT
Hi

I cannot open your model because you have most probably done a "reset model", then COMSOL (for "complex" geometry but this definition is internal to COMSOL) mostly saves the geometry separately, see your line:

flbinaryfile='circ3_1inc.mphm';

so pls add this file (perhaps there are others too), else it is tough for us others to understand, I'm still no that fluent in COMSOl internals with out any geoemtry ;)

To start with matlab/script and COMSOL, really do simple task, run a few (4-5) examples from the doc so you get used to the approach, dont give up, I remember I was very frustatrated in the beginning, but once you got the trick you'll love it.

Good luck
Ivar
Hi I cannot open your model because you have most probably done a "reset model", then COMSOL (for "complex" geometry but this definition is internal to COMSOL) mostly saves the geometry separately, see your line: flbinaryfile='circ3_1inc.mphm'; so pls add this file (perhaps there are others too), else it is tough for us others to understand, I'm still no that fluent in COMSOl internals with out any geoemtry ;) To start with matlab/script and COMSOL, really do simple task, run a few (4-5) examples from the doc so you get used to the approach, dont give up, I remember I was very frustatrated in the beginning, but once you got the trick you'll love it. Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 27, 2009, 11:49 a.m. EDT
Place the for loop in the beginning of your m-file. Put your variable inside the equ.sigma definition.

Example:

conduct = [0.001 0.01 0.1 1 10 100 1000];

for o = 1:length(conduct)

cond = conduct(o)

<- beginning of COMSOl m-file ->

...
clear equ
equ.sigma = {1.11,cond,3.33,4.44};
equ.ind = [1,2,3,4];
appl.equ = equ;
...

<- end of COMSOl m-file ->

end

That worked for me.

Greetz,

Maarten.
Place the for loop in the beginning of your m-file. Put your variable inside the equ.sigma definition. Example: conduct = [0.001 0.01 0.1 1 10 100 1000]; for o = 1:length(conduct) cond = conduct(o) ... clear equ equ.sigma = {1.11,cond,3.33,4.44}; equ.ind = [1,2,3,4]; appl.equ = equ; ... end That worked for me. Greetz, Maarten.

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.