【DDSCAT——离散偶极近似仿真程序07】模型设计Matlab代码:圆环套多个圆柱

       文献中的最后一种模型。

 

一、设计圆环套多个圆柱模型

       1)Matlab代码

%%All cylinders are oriented such that the incident light
%%is along the x axis and strikes the circular face of the cylinder
R = [35, 5, 5, 5, 5, 5, 5, 5, 5]; %ring outer radius
Ri = 25; %ring inner radius
r = [5, 5, 5]; %inner cylinder radius
H = [20, 20, 20, 20, 20, 20, 20, 20, 20]; %ring height
cylinders = 9; %number of cylinders (including ring)
offX = zeros(1,cylinders);
offY = zeros(1,cylinders);
offZ = zeros(1,cylinders);
% offX = [0,-40,40];
offY = [0,19,-19,0,0,13,13,-13,-13];
offZ = [0,0,0,19,-19,13,-13,13,-13];
%% calculation parameters used for output documentation file
X = H;
Y = R;
Z = R;
Xd = X; %diameter
Yd = Y*2;
Zd = Z*2;
ri = r; %inner cylinder radius
Xs = ri*2;
Ys = ri*2;
Zs = ri*2;
Out = [0 0 0 0 0 0 0];
d = 1; %dipole #
di = 1; %inner dipole #
off = 1;
for i = (-Z(1,off)+offZ(1,off)):(Z(1,off)+offZ(1,off))
    for j = (-Y(1,off)+offY(1,off)):(Y(1,off)+offY(1,off))
        for k = (0+offX(1,off)):(X(1,off)+offX(1,off))
            L = ((i-offZ(1,off))^2 + (j-offY(1,off))^2)^.5;
            if L <= R(1,off) && L >= Ri
                Out = [Out; d k j i 2 2 2];
                d = d + 1;
            end
        end
    end
end

for off = 2:cylinders
    for i = (-Z(1,off)+offZ(1,off)):(Z(1,off)+offZ(1,off))
        for j = (-Y(1,off)+offY(1,off)):(Y(1,off)+offY(1,off))
            for k = (0+offX(1,off)):(X(1,off)+offX(1,off))
                L = ((i-offZ(1,off))^2 + (j-offY(1,off))^2)^.5;
                if L <= R(1,off)
                    Out = [Out; d k j i 1 1 1];
                    d = d + 1;
                    di = di + 1;
                end
            end
        end
    end
end

Out(1,:) = [];

d = d - 1;
di = di - 1;

fid = fopen('output.txt', 'w');
fprintf(fid, ' >TARCEL: Special Shape:Ring w/ Particles; AX,AY,AZ= %7.4f %7.4f %7.4f BX,BY,BZ= %7.4f %7.4f %7.4f', Xd, Yd, Zd, Xs, Ys, Zs);
fprintf(fid, '\r\n %8.0f %8.0f = NAT, NIN,', d, di);
fprintf(fid, '\r\n 1.000000 0.000000 0.000000 = A_1 vector\r\n 0.000000 1.000000 0.000000 = A_2 vector')
fprintf(fid, '\r\n 1.000000 1.000000 1.000000 = lattice spacings (d_x,d_y,d_z)/d')
fprintf(fid, '\r\n -0.50000 -0.50000 -0.50000 = lattice offset x0(1-3) = (x_TF,y_TF,z_TF)/d for dipole 0 0 0')
fprintf(fid, '\r\n JA IX IY IZ ICOMP(x,y,z)\r\n');
fprintf(fid,'%7d %3d %3d %3d %1d %1d %1d\r\n', Out');
fclose(fid);
foldername = sprintf('Ring%dR%dRi%dH%dparticles%dr%dh',R(1,1),Ri(1,1),H(1,1),cylinders,r(1,1),H(1,1));
folderpath = strcat(foldername,'/');
filename = sprintf('Ring%dR%dRi%dH%dparticles%dr%dh.txt',R(1,1),Ri(1,1),H(1,1),cylinders,r(1,1),H(1,1));
mkdir(foldername);
copyfile('output.txt',filename);
copyfile('output.txt','shape.dat');
movefile(filename, folderpath);
movefile('shape.dat',folderpath);% 将shape.dat文件移动到 %dSpheres%dR%dr/ 文件夹中

% 后面的也是一些文件复制移动的操作,大家可以注释掉,需要用的话得去掉注释自行修改代码,否则会报错
% copyfile('Ag.txt',folderpath);
% copyfile('Ti.txt',folderpath);
% copyfile('ddscat.exe',folderpath);
% copyfile('ddscat2.par','ddscat.par');
% movefile('ddscat.par',folderpath);
% disp(['Sucess, file saved to: ', foldername]);

 

       2)ddscat.par文件

' ========== Parameter file for v7.3 ===================' 
'**** Preliminaries ****'
'NOTORQ' = CMTORQ*6 (DOTORQ, NOTORQ) -- either do or skip torque calculations
'PBCGS2' = CMDSOL*6 (PBCGS2, PBCGST, GPBICG, QMRCCG, PETRKP) -- CCG method
'GPFAFT' = CMETHD*6 (GPFAFT, FFTMKL) -- FFT method
'GKDLDR' = CALPHA*6 (GKDLDR, LATTDR, FLTRCD) -- DDA method
'NOTBIN' = CBINFLAG (NOTBIN, ORIBIN, ALLBIN)
'**** Initial Memory Allocation ****'
150 150 150 = dimensioning allowance for target generation
'**** Target Geometry and Composition ****'
'FROM_FILE' = CSHAPE*9 shape directive
no SHPAR parameters needed
2         = NCOMP = number of dielectric materials
'../diel/SiO2' = file with refractive index 1
'../diel/Au_evap' = file with refractive index 2
'**** Additional Nearfield calculation? ****'
1 = NRFLD (=0 to skip nearfield calc., =1 to calculate nearfield E)
0.0 0.0 0.0 0.0 0.0 0.0 (fract. extens. of calc. vol. in -x,+x,-y,+y,-z,+z)
'**** Error Tolerance ****'
1.00e-5 = TOL = MAX ALLOWED (NORM OF |G>=AC|E>-ACA|X>)/(NORM OF AC|E>)
'**** Maximum number of iterations ****'
2000     = MXITER
'**** Integration cutoff parameter for PBC calculations ****'
1.00e-2 = GAMMA (1e-2 is normal, 3e-3 for greater accuracy)
'**** Angular resolution for calculation of <cos>, etc. ****'
0.5	= ETASCA (number of angles is proportional to [(3+x)/ETASCA]^2 )
'**** Vacuum wavelengths (micron) ****'
0.300 0.300 1 'LIN' = wavelengths (first,last,how many,how=LIN,INV,LOG)
'**** Refractive index of ambient medium'
1.0000 = NAMBIENT
'**** Effective Radii (micron) **** '
0.03 0.03 1 'LIN' = eff. radii (first, last, how many, how=LIN,INV,LOG)
'**** Define Incident Polarizations ****'
(0,0) (1.,0.) (0.,0.) = Polarization state e01 (k along x axis)
2 = IORTH  (=1 to do only pol. state e01; =2 to also do orth. pol. state)
'**** Specify which output files to write ****'
1 = IWRKSC (=0 to suppress, =1 to write ".sca" file for each target orient.
'**** Specify Target Rotations ****'
0.    0.   1  = BETAMI, BETAMX, NBETA  (beta=rotation around a1)
0.    0.   1  = THETMI, THETMX, NTHETA (theta=angle between a1 and k)
0.    0.   1  = PHIMIN, PHIMAX, NPHI (phi=rotation angle of a1 around k)
'**** Specify first IWAV, IRAD, IORI (normally 0 0 0) ****'
0   0   0    = first IWAV, first IRAD, first IORI (0 0 0 to begin fresh)
'**** Select Elements of S_ij Matrix to Print ****'
6	= NSMELTS = number of elements of S_ij to print (not more than 9)
11 12 21 22 31 41	= indices ij of elements to print
'**** Specify Scattered Directions ****'
'LFRAME' = CMDFRM (LFRAME, TFRAME for Lab Frame or Target Frame)
1 = NPLANES = number of scattering planes
0.  0. 180. 5 = phi, theta_min, theta_max (deg) for plane A
90. 0. 180. 5 = phi, theta_min, theta_max (deg) for plane B

 

       3)近场图

  

       4)模型的3D散点图

 

       关于一些样例模型暂时就介绍完了。。。

posted @ 2019-10-10 09:58  XD_Yangf  阅读(149)  评论(0)    收藏  举报