我是靠谱客的博主 老迟到未来,最近开发中收集的这篇文章主要介绍comsol matlab 循环,comsol保存为m文件,怎样在m文件里面加入for循环 - 仿真模拟 - 小木虫 - 学术 科研 互动社区...,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

我利用comsol做好一个案例后,需要大量改变一个参数值,于是我将mph文件保存为m文件,加入了一个for循环,利用comsol with matlab运行,但是显示错误,哪位大神晓得怎样在comsol生成的m文件里加入for循环?下面是程序:

% COMSOL Multiphysics Model M-file

% Generated by COMSOL 3.5a (COMSOL 3.5.0.603, $Date: 2008/12/03 17:02:19 $)

% Some geometry objects are stored in a separate file.

% The name of this file is given by the variable 'flbinaryfile'.

flclear fem

% COMSOL version

clear vrsn

vrsn.name = 'COMSOL 3.5';

vrsn.ext = 'a';

vrsn.major = 0;

vrsn.build = 603;

vrsn.rcs = '$Name: $';

vrsn.date = '$Date: 2008/12/03 17:02:19 $';

fem.version = vrsn;

flbinaryfile='lianxi1.mphm';

% Constants

fem.const = {'d','0.127', ...

'Rm','1'};

% Global expressions

fem.globalexpr = {'R','R'};

% Geometry

clear draw

g10=flbinary('g10','draw',flbinaryfile);

g11=flbinary('g11','draw',flbinaryfile);

g12=flbinary('g12','draw',flbinaryfile);

g13=flbinary('g13','draw',flbinaryfile);

g14=flbinary('g14','draw',flbinaryfile);

g15=flbinary('g15','draw',flbinaryfile);

g16=flbinary('g16','draw',flbinaryfile);

g17=flbinary('g17','draw',flbinaryfile);

g18=flbinary('g18','draw',flbinaryfile);

g19=flbinary('g19','draw',flbinaryfile);

g4=flbinary('g4','draw',flbinaryfile);

g5=flbinary('g5','draw',flbinaryfile);

g6=flbinary('g6','draw',flbinaryfile);

g7=flbinary('g7','draw',flbinaryfile);

g8=flbinary('g8','draw',flbinaryfile);

g9=flbinary('g9','draw',flbinaryfile);

draw.p.objs = {g10,g11,g12,g13,g14,g15,g16,g17,g18,g19,g4,g5,g6, ...

g7,g8,g9};

draw.p.name = {'PT1','PT10','PT11','PT12','PT13','PT14','PT15','PT16','PT2', ...

'PT3','PT4','PT5','PT6','PT7','PT8','PT9'};

draw.p.tags = {'g10','g11','g12','g13','g14','g15','g16','g17','g18','g19','g4', ...

'g5','g6','g7','g8','g9'};

g20=flbinary('g20','draw',flbinaryfile);

g3=flbinary('g3','draw',flbinaryfile);

draw.s.objs = {g20,g3};

draw.s.name = {'CO1','R1'};

draw.s.tags = {'g20','g3'};

fem.draw = draw;

fem.geom = geomcsg(fem);

fem.mesh = flbinary('m1','mesh',flbinaryfile);

% (Default values are not included)

for Rt=1:100:101 %在这里加了一个for循环

R=Rt;

% Application mode 1

clear appl

appl.mode.class = 'EmConductiveMediaDC';

appl.mode.type = 'axi';

appl.module = 'ACDC';

appl.assignsuffix = '_emdc';

clear bnd

bnd.index = {0,0,'A0','M1','M2','A1A2',0};

bnd.I0 = {0,0,1,0,0,0,0};

bnd.type = {'V0','cont','fp','fp','fp','fp','nJ0'};

bnd.name = {'jiedi','lianxu','A0','M1','M2','A1A2','jueyuan'};

bnd.ind = [7,1,7,7,7,1,6,7,6,7,5,7,4,7,3,7,4,7,5,7,6,7,6,2,1,1,1];

appl.bnd = bnd;

clear equ

equ.sigma = {'Rm','R'};

equ.ind = [1,2];

appl.equ = equ;

fem.appl{1} = appl;

fem.sdim = {'r','z'};

fem.frame = {'ref'};

fem.border = 1;

clear units;

units.basesystem = 'SI';

fem.units = units;

% Descriptions

clear descr

descr.const= {'Rt','原始地层电阻率','d','井径','Rm','泥浆电阻率'};

fem.descr = descr;

% ODE Settings

clear ode

clear units;

units.basesystem = 'SI';

ode.units = units;

fem.ode=ode;

% Multiphysics

fem=multiphysics(fem);

% Extend mesh

fem.xmesh=meshextend(fem, ...

'dofversion',1);

% Retrieve solution

fem.sol=flbinary('sol1','solution',flbinaryfile);

% Save current fem structure for restart purposes

fem0=fem;

% Solve problem

fem.sol=femstatic(fem, ...

'solcomp',{'VconstrA1A2_g1_emdc','V','VconstrM1_g1_emdc','VconstrA0_g1_emdc','VconstrM2_g1_emdc'}, ...

'outcomp',{'VconstrA1A2_g1_emdc','V','VconstrM1_g1_emdc','VconstrA0_g1_emdc','VconstrM2_g1_emdc'}, ...

'blocksize','auto');

% Save current fem structure for restart purposes

fem0=fem;

% Plot solution

postplot(fem, ...

'tridata',{'V','cont','internal','unit','V'}, ...

'trimap','Rainbow', ...

'title','表 面: 电 位 能 [V]', ...

'axis',[-0.793279592983885,1.042060306844656,-0.60629039726251,0.2511602709237917]);

end

最后

以上就是老迟到未来为你收集整理的comsol matlab 循环,comsol保存为m文件,怎样在m文件里面加入for循环 - 仿真模拟 - 小木虫 - 学术 科研 互动社区...的全部内容,希望文章能够帮你解决comsol matlab 循环,comsol保存为m文件,怎样在m文件里面加入for循环 - 仿真模拟 - 小木虫 - 学术 科研 互动社区...所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部