Hi,
I have been trying to simulate the a photonic crystal waveguide based on your example pc_2d_basic, but with a triangular lattice. However, the non-uniform grid generator sends me the following error:
"dl = 2.250000e+01 is too small or dl = 2.250000e+01 is too large for gap size = 6.500000e+00."
and
"Error using complete_lprim1d (line 100)
grid generation failed between subgrids [-4860 -4837.5 -4815] and [-4808.5 -4786 -4763.5] with target dl
= 22.5: dl = 2.250000e+01 is too small or dl = 2.250000e+01 is too large for gap size = 6.500000e+00."
I tried to change the resolution parameters with little success. Do you have any idea where this could come from?
I solved this issue by switching to a uniform grid. However when I increased the resolution to check the convergence, the intensity of the H field keeps decreasing and does not look like it converges. I did the same with your exemple with the square lattice but the convergence is good. Is there something I am missing?I tested the convergence by probing the field going through the waveguide. I obtained the following values:
0.0414 0.0271 0.0187 0.0141 0.0107
for the set of divider for a: ad=0 25 30 35 40
I used the code below:
ad_ar=20:5:40
for i=1:length(ad_ar)
inspect_only = false;
% Create shapes.
a = 225; % lattice constant
t = 1; % slab thickness
unit=1; % unit of length in meter
% permittivity, r/a, and omegaa/(2pi*c) are taken from p.234 of John D.
% Joannopoulos? et al., "Photonic Crystals: Molding the Flow of Light," 2nd
% edition so that the frequency lies in a band gap.
r = 61%0.27a; % hole radius
wvlen = 950; % omegaa/(2pic) = ka/(2pi) = a/lambda = 0.3
slab_thickness_nm=250;
eps_diel = 3.1783^2;
ad = ad_ar(i); % divider for a
% dd = 10; % divider for d = 2*r
pml_l=6;
mx = 21+pml_l; % half integer puts domain boundary between cylinders and makes PML works better
my = 10.5;
no_hx=pml_l;
no_hy=3
slab_yn = Box([-(mx-no_hx)*a (mx-no_hx)*a; -(my-no_hy)a -1a; 0 t]);%, [a/ad, a/ad, t]);
slab_yp = Box([-(mx-no_hx)*a (mx-no_hx)a; 1a (my-no_hy)*a; 0 t]);%, [a/ad, a/ad, t]);
slab_yn_sh = Box([-(mx-no_hx)a 0a; -1a -0.5a; 0 t]);%, [a/ad, a/ad, t]);
slab_yp_sh = Box([-(mx-no_hx)a 0a; 0.5a 1a; 0 t]);%, [a/ad, a/ad, t]);
slab_yn_fast = Box([0a (mx-no_hx)a; -1a -0.5a; 0 t]);%, [a/ad, a/ad, t]);
slab_yp_fast = Box([0a (mx-no_hx)a; 0.5a 1a; 0 t]);%, [a/ad, a/ad, t]);
rod = CircularCylinder(Axis.z, t, [0 0 t/2], r);%, [2r/dd, 2r/dd, t]);
sh=0.1
rod2 = CircularCylinder(Axis.z, t, [-3a 0 t/2], r);%, [2r/dd, 2r/dd, t]);
rod3 = CircularCylinder(Axis.z, t, [0 sha t/2], r);%, [2r/dd, 2r/dd, t]);
rod4 = CircularCylinder(Axis.z, t, [0 -sha t/2], r);%, [2r/dd, 2r/dd, t]);
bc=BC.p; % Boundary condition, periodic
box=[-mxa mxa; -mya mya; 0 t];% dimension of the simulation
dl=[a/ad a/ad t];
R_pml=1e-4;% target reflectance of the Pml
% Solve the system.
gray = [0.5 0.5 0.5]; % [r g b]
src_loc = [-18a, 0, 0]; % source location
Lpml=[(no_hx-0.5)a no_hya 0];
degpml=2;
[E, H, obj_array, src_array, J] = maxwell_run(...
'OSC',unit , wvlen, ...
'DOM', {'vacuum', 'white', eps_diel},box , dl,bc , Lpml, degpml, R_pml,true, ...
'OBJ', ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yn), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yp), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yn_sh), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yp_sh), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yn_fast), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yp_fast), ...
'SRCJ', PointSrc(Axis.y,src_loc ), ...
inspect_only);
[power(i)]=powerflux_patch(E, H, Axis.x, 10a)%,[-7a 7*a; 0 1])
save(['wvlentrans_picdiv' num2str(ad) 'wvlen' num2str(wvlen) 'pml_len' num2str(pml_l)],'E','H','obj_array','src_array','J','-v7.3')
save power power ad_ar
end