Ansys Learning Forum › Forums › Discuss Simulation › Photonics › Arbitrary sign for eigen mode › Reply To: Arbitrary sign for eigen mode
Here is the result I got directly from your script (except line 34 is modified):
?abs(Smat);
result:Â
0.000439021 Â 0.0166555 Â 0.017211 Â 0.000397579 Â
0.0028741 Â 0.00273113 Â 0.017198 Â 0.000322681 Â
0.00300699 Â 0.00305221 Â 0.00322448 Â 0.000252065 Â
0.000378088 Â 0.00033553 Â 0.000237014 Â 0.000287072 Â
After the straight waveguide is added, I use the following script:
## solver
addfdtd;
set("x min",-x_shift/2);set("x max",(K+0.5)*x_shift);
set("y",0);set("y span",K*y_shift+2e-6);
set("z",0);set("z span",1e-6);
set("mesh accuracy", 4);
setresource("FDTD", "GPU", true);
setnamed("FDTD", "express mode", true);
## ports in the middle of each block
for (k=0:K){
addport();
set("x", k*x_shift);
}
selectpartial("FDTD::ports::port");
set("auto update", false);
set("frequency dependent profile", false);
set("mode selection", "user select");
set("selected mode numbers", 2); # 2nd mode is antisymmetric and will show the issue
clearportmodedata;
seteigensolver("correct backward propagating modes", false);
seteigensolver("correct backward propagating modes when pml is present", false);
Â
wavelength = 1560e-9;
setglobalsource("set frequency", true);
setglobalsource("center wavelength", wavelength);
setglobalsource("wavelength span", 0);
setglobalmonitor("wavelength center", wavelength);
setglobalmonitor("frequency points", 1);
setglobalmonitor("wavelength span", 0);
setglobalmonitor("use source limits", 1);
##
save("sign_arb.fsp");
Â
## s-parameter sweep
addsweep(3);
runsweep;
sweepdata = getsweepresult("s-parameter sweep","S matrix");
Smat = pinch(sweepdata.S); # scattering matrix
Â
### see the issue when propagating from port 3 to 4 vs from
?conj(Smat(3,1))*Smat(4,1); # excite port 1, and look at the propagating from port 3 to 4
?conj(Smat(3,2))*Smat(4,2); # excite port 2, and look at the propagating from port 3 to 4
?conj(Smat(2,4))*Smat(1,4); # excite port 4, and look at the propagating from port 2 to 1
?conj(Smat(2,3))*Smat(1,3); # excite port 3, and look at the propagating from port 2 to 1
Â
##
neff_list = matrix(K+1);
S0 = matrix(K+1,K+1);
for (k=1:K+1){
NEFF = getresult("FDTD::ports::port "+num2str(k), "neff");
neff_list(k) = NEFF.neff;
mode1 = getresult("FDTD::ports::port "+num2str(k), "mode profiles");
for (j=1:K+1){
mode2 = getresult("FDTD::ports::port "+num2str(j), "mode profiles");
cr12 = pinch(cross(mode1.E2, mode2.H2));
cr11 = pinch(cross(mode1.E2, mode1.H2));
cr22 = pinch(cross(mode2.E2, mode2.H2));
cr12 = integrate(pinch(cr12(:,:,1)), [1,2], pinch(mode1.y), pinch(mode1.z));
cr11 = integrate(pinch(cr11(:,:,1)), [1,2], pinch(mode1.y), pinch(mode1.z));
cr22 = integrate(pinch(cr22(:,:,1)), [1,2], pinch(mode1.y), pinch(mode1.z));
S0(j,k) = cr12/sqrt(cr11*cr22);
}
}
## modes have minus signs
image(real(S0));
I got the result:
Please use ONE staright waveguide for testing.
Â
Â