【DDSCAT——离散偶极近似仿真程序05】模型设计Matlab代码:多核壳球 、多核壳圆柱

简洁明了,后面及部分给出的都是模型设计的Matlab代码,这些代码都来自于一篇文章:Chin C W S. Localized Surface Plasmon Resonance with the use of Silver and Titanium Oxide Nanostructures[J]. 2011.一、设计多个核壳球形结构 1)Matlab代码...
摘要由CSDN通过智能技术生成

       简洁明了,后面及部分给出的都是模型设计的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
  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值