找回密码
 注册
Simdroid-非首页
查看: 173|回复: 2

[16.其它] MATLAB分析comsol导出的程序

[复制链接]
发表于 2012-3-26 09:57:01 | 显示全部楼层 |阅读模式 来自 江苏南京
% COMSOL Multiphysics Model M-file
% COMSOL version
clear vrsn
vrsn.name = 'COMSOL 3.5';
vrsn.ext = '';
vrsn.major = 0;
vrsn.build = 494;
vrsn.rcs = '$Name:  $';
vrsn.date = '$Date: 2008/09/19 16:09:48 $';
fem.version = vrsn;

% Create mapped quad mesh
fem.mesh=meshmap(fem, ...
                 'hauto',1);

% Geometry
g1=rect2('10','50','base','corner','pos',{'0','-20'},'rot','0');
g2=rect2('2.5','0.25','base','corner','pos',{'1.25','30'},'rot','0');
g3=rect2('2.5','0.25','base','corner','pos',{'6.25','30'},'rot','0');
g4=rect2('10','1','base','corner','pos',{'0','30'},'rot','0');
g1=scale(g1,1e-6,1e-6,0,0);
g2=scale(g2,1e-6,1e-6,0,0);
g3=scale(g3,1e-6,1e-6,0,0);
g4=scale(g4,1e-6,1e-6,0,0);
% Geometry
% Analyzed geometry
clear s
clear s
s.objs={g1,g2,g3,g4};
s.name={'R1','R2','R3','R4'};
s.tags={'g1','g2','g3','g4'};

fem.draw=struct('s',s);
fem.geom=geomcsg(fem,'repairtol',1.0E-10);

% Initialize mesh
fem.mesh=meshinit(fem, ...
                  'hauto',1, ...
                  'hmaxedg',[4,0.05e-6,7,0.05e-6,10,0.05e-6,12,0.05e-6,15,0.05e-6]);

% (Default values are not included)

% Application mode 1
clear appl
appl.mode.class = 'PiezoPlaneStrain';
appl.module = 'SME';
appl.gporder = 4;
appl.cporder = 2;
appl.sshape = 2;
appl.border = 'on';
appl.assignsuffix = '_smppn';
clear prop
prop.analysis='eigen';
appl.prop = prop;
clear bnd
bnd.electrictype = {'nD0','V','nD0','V'};
bnd.V0 = {0,-1,0,1};
bnd.constrcond = {'free','free','fixed','free'};
bnd.ind = [1,3,1,4,1,4,4,4,4,4,2,2,2,2,4,1,1];
appl.bnd = bnd;
clear equ
equ.materialmodel = {'piezoelectric','iso','iso'};
equ.nu = {0.33,0.17,0.33};
equ.epsilonrS = {{44,0,0;0,38.35,-7.27;0,-7.27,34.65},{1704.40, ...
  0,0;0,1704.40,0;0,0,1433.61},{1704.40,0,0;0,1704.40, ...
  0;0,0,1433.61}};
equ.epsilonr = {1,1.56,1};
equ.rho = {4700,'2320[kg/m^3]','2700[kg/m^3]'};
equ.cE = {{2.03e11,0.70008e11,0.57991e11,0.1288e11,0,0;0.70008e11, ...
  1.94329e11,0.90769e11,0.09551e11,0,0;0.57991e11,0.90769e11, ...
  2.22132e11,0.08579e11,0,0;0.1288e11,0.09551e11,0.08579e11, ...
  0.75769e11,0,0;0,0,0,0,0.56928e11,-0.05048e11;0,0, ...
  0,0,-0.05048e11,0.78071e11},{1.27205e11,8.02122e10,8.46702e10, ...
  0,0,0;8.02122e10,1.27205e11,8.46702e10,0,0,0;8.46702e10, ...
  8.46702e10,1.17436e11,0,0,0;0,0,0,2.29886e10,0,0; ...
  0,0,0,0,2.29886e10,0;0,0,0,0,0,2.34742e10},{1.27205e11, ...
  8.02122e10,8.46702e10,0,0,0;8.02122e10,1.27205e11,8.46702e10, ...
  0,0,0;8.46702e10,8.46702e10,1.17436e11,0,0,0;0,0, ...
  0,2.29886e10,0,0;0,0,0,0,2.29886e10,0;0,0,0,0, ...
  0,2.34742e10}};
equ.E = {2.0e11,'74e9[Pa]','70e9[Pa]'};
equ.sigma = {5.99e7,'3.774e7[S/m]','3.774e7[S/m]'};
equ.e = {{0,0,0,0,4.45553,0.29703;-1.85103,4.43829,-1.54391, ...
  0.09127,0,0;1.69223,-2.67202,2.32195,0.60415,0,0},{0, ...
  0,0,0,17.0345,0;0,0,0,17.0345,0,0;-6.62281,-6.62281, ...
  23.2403,0,0,0},{0,0,0,0,17.0345,0;0,0,0,17.0345, ...
  0,0;-6.62281,-6.62281,23.2403,0,0,0}};
equ.electricalon = {0,1,0};
equ.materialori = {'xy','xz','xz'};
equ.ind = [1,2,3,3];
appl.equ = equ;
appl.var = {'freq','1e6', ...
  'Qtot','Qes_tot_smppn'};
fem.appl{1} = appl;
fem.frame = {'ref'};
fem.border = 1;
clear units;
units.basesystem = 'SI';
fem.units = units;

% Coupling variable elements
clear elemcpl
% Extrusion coupling variables
clear elem
elem.elem = 'elcplextr';
elem.g = {'1'};
src = cell(1,1);
clear bnd
bnd.expr = {{'u',{}},{'v',{}},{'V',{}}};
bnd.map = {{'1','1'},{'1','1'},{'1','1'}};
bnd.ind = {{'1','3'},{'2','4','5','6','7','8','9','10','11','12','13', ...
  '14','15','16','17'}};
src{1} = {{},bnd,{}};
elem.src = src;
geomdim = cell(1,1);
clear bnd
bnd.map = {{{},'2'},{{},'2'},{{},'2'}};
bnd.ind = {{'1','2','3','4','5','6','7','8','9','10','11','12','13', ...
  '14','15'},{'16','17'}};
geomdim{1} = {{},bnd,{}};
elem.geomdim = geomdim;
elem.var = {'pconstr1','pconstr2','pconstr3'};
map = cell(1,2);
clear submap
submap.type = 'unit';
map{1} = submap;
clear submap
submap.type = 'linear';
submap.sg = '1';
submap.sv = {'12','13'};
submap.dg = '1';
submap.dv = {'1','2'};
map{2} = submap;
elem.map = map;
elemcpl{1} = elem;
% Point constraint variables (used for periodic conditions)
clear elem
elem.elem = 'elpconstr';
elem.g = {'1'};
clear bnd
bnd.constr = {{'pconstr1-(u)','pconstr2-(v)','pconstr3-(V)'}};
bnd.cpoints = {{'2','2','2'}};
bnd.ind = {{'16','17'}};
elem.geomdim = {{{},bnd,{}}};
elemcpl{2} = elem;
fem.elemcpl = elemcpl;

% Descriptions
clear descr
descr.const= {'T','Air temperature','eps_PIB','Relative permittivity of PIB','M_DCM','Molar mass of DCM','p','Air pressure','R','Gas constant','nu_PIB','Poissons ratio of PIB','rho_PIB','Density of PIB','rho_DCM_PIB','Mass concentration of DCM in PIB','c_DCM_air','DCM concentration in air','E_PIB','Young''s modulus of PIB','K','PIB/air partition constant for DCM'};
fem.descr = descr;

% Library materials
clear lib
lib.mat{1}.name='Aluminum';
lib.mat{1}.varname='mat1';
lib.mat{1}.variables.nu='0.33';
lib.mat{1}.variables.E='70e9[Pa]';
lib.mat{1}.variables.mur='1';
lib.mat{1}.variables.C='900[J/(kg*K)]';
lib.mat{1}.variables.nMurn='-3.5e11[Pa]';
lib.mat{1}.variables.mMurn='-3.3e11[Pa]';
lib.mat{1}.variables.muLame='2.6e10[Pa]';
lib.mat{1}.variables.k='160[W/(m*K)]';
lib.mat{1}.variables.lMurn='-2.5e11[Pa]';
lib.mat{1}.variables.sigma='3.774e7[S/m]';
lib.mat{1}.variables.alpha='23e-6[1/K]';
lib.mat{1}.variables.epsilonr='1';
lib.mat{1}.variables.lambLame='5.1e10[Pa]';
lib.mat{1}.variables.rho='2700[kg/m^3]';
lib.matgroups{1}.name='Resistivity';
lib.matgroups{1}.variables={'alphares','T0','res0'};
lib.matgroups{1}.descr={'Temperature coefficient','Reference temperature','Resistivity at reference temperature'};


fem.lib = lib;

% 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);

% Solve problem
fem.sol=femeig(fem, ...
               'solcomp',{'v','u','V'}, ...
               'outcomp',{'v','u','V'}, ...
               'rowscale','off', ...
               'blocksize','auto', ...
               'shift',-2.293363e9*i);

% Save current fem structure for restart purposes
fem0=fem;

% Plot solution
postplot(fem, ...
         'tridata',{'disp_smppn','cont','internal','unit','m'}, ...
         'trimap','jet(1024)', ...
         'deformsub',{'u','v'}, ...
         'deformscale',2, ...
         'solnum',1, ...
         'title','eigfreq_smppn(1)=3.263351e8    表 面: 总 位 移 [m]   变 形: 位 移', ...
         'axis',[-7.491556108794067E-5,8.500368391696315E-5,-4.093064192308338E-5,5.6458037874358056E-5]);
% Plot solution
postplot(fem, ...
         'tridata',{'disp_smppn','cont','internal','unit','m'}, ...
         'trimap','jet(1024)', ...
         'deformsub',{'u','v'}, ...
         'deformscale',2, ...
         'solnum',3, ...
         'title','eigfreq_smppn(3)=3.674194e8    表 面: 总 位 移 [m]   变 形: 位 移', ...
         'axis',[-7.491556108794067E-5,8.500368391696315E-5,-4.6472818051107585E-5,6.200021400238225E-5]);
% Plot solution
postplot(fem, ...
         'tridata',{'disp_smppn','cont','internal','unit','m'}, ...
         'trimap','jet(1024)', ...
         'deformsub',{'u','v'}, ...
         'deformscale',2, ...
         'solnum',4, ...
         'title','eigfreq_smppn(4)=3.676275e8    表 面: 总 位 移 [m]   变 形: 位 移', ...
         'axis',[-7.491556108794067E-5,8.500368391696315E-5,-4.612025131637252E-5,6.164764726764718E-5]);

 楼主| 发表于 2012-3-26 09:59:59 | 显示全部楼层 来自 江苏南京
Simdroid开发平台
这个怎么写循环啊?
回复 不支持

使用道具 举报

发表于 2013-10-18 08:25:37 | 显示全部楼层 来自 湖北武汉
同求:handshake:handshake:handshake:handshake。楼主现在知道不?
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-9-20 15:00 , Processed in 0.028658 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表