使用matlab求解二维声子晶体能带结构的代码
时间: 2023-08-31 14:11:16 浏览: 340
以下是一个简单的 Matlab 代码,用于求解二维声子晶体的能带结构:
```matlab
% 二维声子晶体能带结构计算代码
% 参考文献:M. Florescu, et al., "Ultracompact photonic crystal waveguide
% bends with high transmission," Optics Letters, vol. 31, no. 10, pp. 1449-1451, May 2006.
clc;
clear all;
% 设置晶格常数和布拉格矢量
a = 1;
b = a*sqrt(3);
Kx = (4*pi)/(3*a);
Ky = (2*pi)/(sqrt(3)*b);
% 设置频率范围和步长
f_min = 0;
f_max = 100;
f_step = 0.1;
% 初始化能量矩阵
E = zeros(2000,2000);
% 计算能带结构
for i = 1:2000
for j = 1:2000
kx = ((i-1000)*0.01*Kx);
ky = ((j-1000)*0.01*Ky);
d1 = sqrt(3)/2*a;
d2 = a/2;
G1 = [2*pi/a; -2*pi/(3*b)];
G2 = [0; 4*pi/(3*b)];
M = [kx/2 - ky/(2*sqrt(3)); ky*sqrt(3)/2 - kx/2];
N = [-kx/(2*sqrt(3)); ky/2 + kx/2];
A = [0; 0];
B = [d2; d1];
C = [d2; -d1];
D = [0; -2*d1];
E1 = [d2; -3*d1];
F = [-d2; -2*d1];
G = [-d2; 0];
H = [-d2; 2*d1];
E2 = [0; 3*d1];
r1 = norm(M);
r2 = norm(N);
r3 = norm(A-M);
r4 = norm(B-M);
r5 = norm(C-M);
r6 = norm(D-M);
r7 = norm(E1-M);
r8 = norm(F-M);
r9 = norm(G-M);
r10 = norm(H-M);
r11 = norm(E2-M);
r12 = norm(N-A);
r13 = norm(B-A);
r14 = norm(C-A);
r15 = norm(D-A);
r16 = norm(E1-A);
r17 = norm(F-A);
r18 = norm(G-A);
r19 = norm(H-A);
r20 = norm(E2-A);
r21 = norm(N-B);
r22 = norm(C-B);
r23 = norm(D-B);
r24 = norm(E1-B);
r25 = norm(F-B);
r26 = norm(G-B);
r27 = norm(H-B);
r28 = norm(E2-B);
r29 = norm(N-C);
r30 = norm(D-C);
r31 = norm(E1-C);
r32 = norm(F-C);
r33 = norm(G-C);
r34 = norm(H-C);
r35 = norm(E2-C);
r36 = norm(N-D);
r37 = norm(E1-D);
r38 = norm(F-D);
r39 = norm(G-D);
r40 = norm(H-D);
r41 = norm(E2-D);
r42 = norm(E1-E2);
r43 = norm(F-E2);
r44 = norm(G-E2);
r45 = norm(H-E2);
r46 = norm(F-E1);
r47 = norm(G-E1);
r48 = norm(H-E1);
r49 = norm(G-F);
r50 = norm(H-F);
r51 = norm(H-G);
if (r1 <= 1) || (r2 <= 1) || (r3 <= 1) || (r4 <= 1) || (r5 <= 1) || (r6 <= 1) || (r7 <= 1) || (r8 <= 1) || (r9 <= 1) || (r10 <= 1) || (r11 <= 1) || (r12 <= 1) || (r13 <= 1) || (r14 <= 1) || (r15 <= 1) || (r16 <= 1) || (r17 <= 1) || (r18 <= 1) || (r19 <= 1) || (r20 <= 1) || (r21 <= 1) || (r22 <= 1) || (r23 <= 1) || (r24 <= 1) || (r25 <= 1) || (r26 <= 1) || (r27 <= 1) || (r28 <= 1) || (r29 <= 1) || (r30 <= 1) || (r31 <= 1) || (r32 <= 1) || (r33 <= 1) || (r34 <= 1) || (r35 <= 1) || (r36 <= 1) || (r37 <= 1) || (r38 <= 1) || (r39 <= 1) || (r40 <= 1) || (r41 <= 1) || (r42 <= 1) || (r43 <= 1) || (r44 <= 1) || (r45 <= 1) || (r46 <= 1) || (r47 <= 1) || (r48 <= 1) || (r49 <= 1) || (r50 <= 1) || (r51 <= 1)
E(i,j) = NaN;
else
E(i,j) = sqrt(abs(1 + exp(i*G1(1)*a + j*G1(2)*b) + exp(i*G2(1)*a + j*G2(2)*b) + exp((i*G1(1) + j*G1(2))*a + (i*G2(1) + j*G2(2))*b)));
end
end
end
% 绘制能带结构图
figure;
hold on;
axis([-1 1 -1 1]);
for f = f_min:f_step:f_max
contour(sin(Kx*linspace(-pi,pi,2000)), sin(Ky*linspace(-pi,pi,2000)), E, [f f], 'LineColor', 'blue');
end
xlabel('k_x');
ylabel('k_y');
title('二维声子晶体能带结构');
```
请注意,此代码仅提供了一个简单的框架,您需要根据自己的需要进行修改和优化。此外,由于该算法的计算量较大,可能需要一些时间才能生成完整的能带结构图。
阅读全文