Don't Understand how COMSOL component changes when parameters change

I am trying to change the parameters for my COMSOL program using loops in MATLAB. The parameters I wanted to change were set to be taken as parameters in the model function. Once I change the parameters I have the program find results of the simulation. My problem is that in MATLAB, the graphs of the results for the different parameter combinations were looking incorrect . I put the resulting parameters directly into COMSOL Multiphysics and ran it there and the results were fine. When I looked at the compact code of the new model for those new parameters I noticed that the numbers changed in two pieces of the geometry however I'm not sure how to automate the update of these numbers in the MATLAB code. I don't want to need to rely on plugging the values into COMSOL every time.
Here is the original piece code for the first set of parameters: (% is the line that changes)
model.component('comp1').selection.create('sel2', 'Explicit');
model.component('comp1').selection('sel2').geom('geom1', 1);
model.component('comp1').selection('sel2').set([22 23 24 28 29 30 31 32 33 34 36]);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
model.component('comp1').selection.create('sel3', 'Explicit');
model.component('comp1').selection('sel3').geom('geom1', 1);
model.component('comp1').selection('sel3').set([6 7 8 9 10 11 13 14 16 17 21]);%%%%%%%%%%%%%%%%%%%%%
Here is the code after I change the parameters:
model.component('comp1').selection.create('sel2', 'Explicit');
model.component('comp1').selection('sel2').geom('geom1', 1);
model.component('comp1').selection('sel2').set([23 24 25 27 29 30 31 32 33 34 36]);%%%%%%%%%%%
model.component('comp1').selection.create('sel3', 'Explicit');
model.component('comp1').selection('sel3').geom('geom1', 1);
model.component('comp1').selection('sel3').set([6 7 8 9 10 11 13 14 16 17 20]);%%%%%%
I could really use some help understanding where these numbers come from and how to automate the update process in a loop so I can get reliable results. Thanks!

 採用された回答

Marissa Whitby
Marissa Whitby 2021 年 10 月 16 日

0 投票

For anyone who has a similar problem I've figured it out:
I had tried to add parameters to the compact history function I downloaded from COMSOL. The better way is to just load the model (using mphload) and then update parameters in a loop (using model.param.set) and then to run the model just use model.study('std1').run. This will run the model you want with the given parameters and it will automatically change the numbers I was confused about.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by