Ansys Learning Forum › Forums › Discuss Simulation › Photonics › MFD in a port › Reply To: MFD in a port
Hello,Â
Normally MFD is slighlty larger than the core radius, as for a gaussian mode some light travels in the cladding as well. EME solver recognizes the MFD of the mode that travels in the core, but you can simply check it by using scripting.
A good estimation would be to check the mode profile as a line plot, setting z=0 and check, for instance, the full width at half maximum. Some usefuld links are the following:
https://optics.ansys.com/hc/en-us/articles/360034395354-Calculating-the-effective-mode-area-of-a-waveguide-mode
Use the FDE solver and send to output the E field in the script worspace. Then you can use the following script to check the MFD of the mode of your choice.This script calculates and reeturns the MFD at the x and y axis.
function getMax(E) {
  Ex = E.Ex;
  Ey = E.Ey;
  Ez = E.Ez;
  Â
  E2 = abs(Ex)^2 + abs(Ey)^2 + abs(Ez)^2;
  Â
  sizeE2 = size(E2);
  Â
  n = find(E2, max(E2));
  indices = matrix(length(sizeE2));
  Â
  for(i=1:length(sizeE2)) {
    mod_dividend = n;
    mod_divisor = sizeE2(i);
    mod_remainder = mod(mod_dividend, mod_divisor);
    if (mod_remainder == 0) {
      mod_remainder = sizeE2(i);
    }
    indices(i) = mod_remainder;
    n = (n+(sizeE2(i)-mod_remainder))/sizeE2(i);
  }
  Â
  return indices;  Â
}
function getMFD(E) {
  MFD = matrix(2);
  Ex = E.Ex;
  Ey = E.Ey;
  Ez = E.Ez;
  x = E.x;
  y = E.y;
  z = E.z;
  Â
  if (length(x)==1) { d = "x-normal"; }
  if (length(y)==1) { d = "y-normal"; }
  if (length(z)==1) { d = "z-normal"; }
  Â
  if (d=="x-normal") { X = "y"; Y = "z"; }
  if (d=="y-normal") { X = "x"; Y = "z"; }
  if (d=="z-normal") { X = "x"; Y = "y"; }
  Â
  E2 = abs(Ex)^2 + abs(Ey)^2 + abs(Ez)^2;
  E2 = pinch(E2);
  indices = getMax(E);
  indices = indices(find(indices>1));
  if (length(indices)!=2) {
    ?"Error on dimension";
    return 0;
  }
  Â
  XX = E.getparameter(X);
  x0 = XX(indices(1));
  YY = E.getparameter(Y);
  y0 = YY(indices(2));
  Â
  E2x = pinch(E2, 2, indices(2));
  E2y = pinch(E2, 1, indices(1));
  Â
  nx = find(E2x>=max(E2x)/2);
  ny = find(E2y>=max(E2y)/2);
  Â
  MFD(1) = XX(nx(end))-XX(nx(1));
  MFD(2) = YY(ny(end))-YY(ny(1));
  return MFD;
}
MFD = getMFD(E);
?MFD*1e6;
Â