简洁明了,后面及部分给出的都是模型设计的Matlab代码,这些代码都来自于一篇文章:Chin C W S. Localized Surface Plasmon Resonance with the use of Silver and Titanium Oxide Nanostructures[J]. 2011.
一、设计多个核壳球形结构
1)Matlab代码
Matlab代码生成shape文件,shape.dat会被自动放在当前路径下的一个文件夹里。
%**************************************************************************
% 希望此代码能帮助各位学习DDSCAT的网友更近一步
% 作者:XD_Yangf
% 来源:CSDN
% 原文:Chin C W S. Localized Surface Plasmon Resonance with the use of Silver and Titanium Oxide Nanostructures[J]. 2011.
% 版权声明:本文为博主原创文章,转载请附上博文链接!
% Date:2019-05-15
%**************************************************************************
clear;
clc;
%**************************************************************************
Ls = 15; %sphere radius for calculations
Li = 8; %inner sphere radius
spheres = 2; %number of spheres
offX = zeros(1,spheres);
offY = zeros(1,spheres);
offZ = zeros(1,spheres);
offX = [0,0,40,0,0,0];
offY = [-20,20,0,40,80,120];
% offZ = [0,20,-20,0,20];
%% calculation parameters for output file documentation
X = Ls; %sphere radius
Y = Ls;
Z = Ls;
Xd = X*2; %diameter
Yd = Y*2;
Zd = Z*2;
Xs = Li*2;
Ys = Li*2;
Zs = Li*2;
Out = [0 0 0 0 0 0 0];
d = 1; %dipole #
di = 1; %inner dipole #
off = 1;
for off = 1:spheres
for i = (-Z+offZ(1,off)):(Z+offZ(1,off))
for j = (-Y+offY(1,off)):(Y+offY(1,off))
for k = (-X+offX(1,off)):(X+offX(1,off))
L = ((i-offZ(1,off))^2 + (j-offY(1,off))^2 + (k-offX(1,off))^2)^.5;
if L <= Ls
if L <= Li
Out = [Out; d k j i 1 1 1];
d = d + 1;
di = di + 1;
else
Out = [Out; d k j i 2 2 2];
d = d + 1;
end
end
end
end
end
end
Out(1,:) = [];
d = d - 1;
di = di - 1;
fid = fopen('output.txt', 'w');
fprintf(fid, ' >TARCEL: concentric spheres; 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('%dSpheres%dR%dr',spheres,Ls,Li);
folderpath = strcat(foldername,'/');
filename = sprintf('%dSpheres%dR%dr.txt',spheres,Ls,Li);
mk