2011年11月21日 星期一
Matlab 迴圈
file_name=get(findobj('tag','T_file_name'),'string');
eig_matrix=[];
for cir=0:3
for spacing_k=0:0.1:1
% COMSOL Multiphysics Model M-file
% Generated by COMSOL 3.5a (COMSOL 3.5.0.603, $Date: 2008/12/03 17:02:19 $)
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;
% Import mesh
marr = meshimport('C:\Users\kendrick\Desktop\COMSOL_with_MATLAB_分析檔\3D\3D_5x1_08x004_聲子晶體\3D_5x1\5x1_m1.mphbin');
fem.mesh = marr{1};
switch cir
case 0
kx=0;
ky=0;
% Constants
fem.const = {'kx',kx+spacing_k,'ky',ky};
case 1
kx=1;
ky=0;
% Constants
fem.const = {'kx',kx,'ky',ky+spacing_k};
case 2
kx=1;
ky=1;
% Constants
fem.const = {'kx',kx-spacing_k,'ky',ky};
case 3
kx=0;
ky=1;
% Constants
fem.const = {'kx',kx,'ky',ky-spacing_k};
end
% (Default values are not included)
% Application mode 1
clear appl
appl.mode.class = 'PiezoSolid3';
appl.module = 'SME';
appl.gporder = 4;
appl.cporder = 2;
appl.sshape = 2;
appl.assignsuffix = '_smpz3d';
clear prop
prop.analysis='eigen';
appl.prop = prop;
clear bnd
bnd.electrictype = {'nD0','V0'};
bnd.ind = [1,1,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1];
appl.bnd = bnd;
clear equ
equ.epsilonrS = {{'mat1_epsilonrS_1_1_','mat1_epsilonrS_1_2_','mat1_epsilonrS_1_3_'; ...
'mat1_epsilonrS_2_1_','mat1_epsilonrS_2_2_','mat1_epsilonrS_2_3_';'mat1_epsilonrS_3_1_', ...
'mat1_epsilonrS_3_2_','mat1_epsilonrS_3_3_'}};
equ.rho = 'mat1_rho';
equ.cE = {{'mat1_cE_1_1_','mat1_cE_1_2_','mat1_cE_1_3_','mat1_cE_1_4_', ...
'mat1_cE_1_5_','mat1_cE_1_6_';'mat1_cE_2_1_','mat1_cE_2_2_','mat1_cE_2_3_', ...
'mat1_cE_2_4_','mat1_cE_2_5_','mat1_cE_2_6_';'mat1_cE_3_1_','mat1_cE_3_2_', ...
'mat1_cE_3_3_','mat1_cE_3_4_','mat1_cE_3_5_','mat1_cE_3_6_';'mat1_cE_4_1_', ...
'mat1_cE_4_2_','mat1_cE_4_3_','mat1_cE_4_4_','mat1_cE_4_5_','mat1_cE_4_6_'; ...
'mat1_cE_5_1_','mat1_cE_5_2_','mat1_cE_5_3_','mat1_cE_5_4_','mat1_cE_5_5_', ...
'mat1_cE_5_6_';'mat1_cE_6_1_','mat1_cE_6_2_','mat1_cE_6_3_','mat1_cE_6_4_', ...
'mat1_cE_6_5_','mat1_cE_6_6_'}};
equ.e = {{'mat1_e_1_1_','mat1_e_1_2_','mat1_e_1_3_','mat1_e_1_4_','mat1_e_1_5_', ...
'mat1_e_1_6_';'mat1_e_2_1_','mat1_e_2_2_','mat1_e_2_3_','mat1_e_2_4_','mat1_e_2_5_', ...
'mat1_e_2_6_';'mat1_e_3_1_','mat1_e_3_2_','mat1_e_3_3_','mat1_e_3_4_','mat1_e_3_5_', ...
'mat1_e_3_6_'}};
equ.ind = [1];
appl.equ = equ;
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'},{{},{},'w'},{{},'u',{}},{{}, ...
'v',{}},{{},'V',{}},{{},'w',{}}};
bnd.map = {{'1','1','1'},{'1','1','1'},{'1','1','1'},{'1','1','1'},{'1','1', ...
'1'},{'1','1','1'},{'1','1','1'},{'1','1','1'}};
bnd.ind = {{'1','3','4','5','6','7','8','9','10','11','12','13','14', ...
'15','16','17','18','19','20','21','22','23','24','25'},{'2'},{'26'}};
src{1} = {{},{},bnd,{}};
elem.src = src;
geomdim = cell(1,1);
clear bnd
bnd.map = {{{},{},'2'},{{},{},'2'},{{},{},'2'},{{},{},'2'},{'3',{},{}}, ...
{'3',{},{}},{'3',{},{}},{'3',{},{}}};
bnd.ind = {{'1'},{'2','3','4','5','6','7','8','9','10','11','12','13', ...
'14','15','16','17','18','19','20','21','22','23','24','26'},{'25'}};
geomdim{1} = {{},{},bnd,{}};
elem.geomdim = geomdim;
elem.var = {'pconstr1','pconstr2','pconstr3','pconstr4','pconstr5', ...
'pconstr6','pconstr7','pconstr8'};
map = cell(1,3);
clear submap
submap.type = 'unit';
map{1} = submap;
clear submap
submap.type = 'linear';
submap.sg = '1';
submap.sv = {'33','2','3','34'};
submap.dg = '1';
submap.dv = {'26','1','24','25'};
map{2} = submap;
clear submap
submap.type = 'linear';
submap.sg = '1';
submap.sv = {'26','33','34','41','39','36','37','48','32','40','46','47','38','35','45','44','31','30','43','42','29','28','27','25'};
submap.dg = '1';
submap.dv = {'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'};
map{3} = 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 = {{'0','0','0','0','pconstr5-(u*exp(ky*i*pi))','pconstr6-(v*exp(ky*i*pi))', ...
'pconstr7-(V*exp(ky*i*pi))','pconstr8-(w*exp(ky*i*pi))'},{'pconstr1-(u*exp(kx*i*pi))', ...
'pconstr2-(v*exp(kx*i*pi))','pconstr3-(V*exp(kx*i*pi))','pconstr4-(w*exp(kx*i*pi))', ...
'0','0','0','0'}};
bnd.cpoints = {{'2','2','2','2','2','2','2','2'},{'2','2','2','2','2','2','2', ...
'2'}};
bnd.ind = {{'1'},{'25'}};
elem.geomdim = {{{},{},bnd,{}}};
elemcpl{2} = elem;
fem.elemcpl = elemcpl;
% Library materials
clear lib
lib.mat{1}.name='AT-cut';
lib.mat{1}.varname='mat1';
lib.mat{1}.variables.e={{'0.171','-0.1523','-0.01869','0.06704','0','0'},{'0','0','0','0','0.1076','-0.0949'},{'0','0','0','0','-0.0761','0.06707'}};
lib.mat{1}.variables.epsilonrS={{'4.4284','0','0'},{'4.4973','0.09689'},{'4.56507'}};
lib.mat{1}.variables.rho='2651';
lib.mat{1}.variables.cE={{'86.74e9','-8.261e9','27.15e9','-3.655e9','0','0'},{'129.8e9','-7.418e9','5.7e9','0','0'},{'102.8e9','9.921e9','0','0'},{'38.61e9','0','0'},{'68.81e9','2.534e9'},{'29.01e9'}};
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, ...
'conjugate','on', ...
'solcomp',{'w','v','u','V'}, ...
'outcomp',{'w','v','u','V'}, ...
'rowscale','off', ...
'blocksize','auto', ...
'neigs',120, ...
'linsolver','spooles');
freq=(0.5*abs(imag(fem.sol.lambda))/pi).';
for num=1:120
eig_matrix=[eig_matrix;cir+spacing_k,freq(num)];
end
xlswrite(file_name,eig_matrix) ;
end
end
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言