NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.17k stars 598 forks source link

Possible issue with orientation of MPB solver #2610

Closed pwflanigan closed 11 months ago

pwflanigan commented 11 months ago

I don't know if this is necessarily a bug, but when I posted this question to the mailing list it didn't appear.

I was looking at this Python example and I tried making a schematic of sorts by putting in

    import numpy as np
    import matplotlib.pyplot as plt
    y_grid = np.arange(-sc_y/2,sc_y/2,1/resolution)
    z_grid = np.arange(-sc_z/2,sc_z/2,1/resolution)
    eps = ms.get_epsilon()
    plt.figure()
    plt.pcolormesh(y_grid,z_grid,eps,shading='nearest',cmap='binary')
    plt.xlabel('$y$ [$\mu$m]')
    plt.ylabel('$z$ [$\mu$m]')
    plt.xlim([-sc_y/2,sc_y/2])
    plt.ylim([-sc_z/2,sc_z/2])
    plt.colorbar()

I got this (I made w = 1.0 so it's easier to see which is the long axis of the rectangle):image

I was under the impression that the vertical axis would be z and the horizontal axis would be y, but this image is "rotated" with the waveguide's z-length being w = 1.0. I assumed that the axes here are the same as what you get if you use mp.plot2d on a similar case (using mp.plot2d on this example at the location of the source gives you y horizontal and z vertical).

The reason I bring this up is because I'm studying a case where there is no substrate (same material all around the waveguide), so if y- and z-axes are not where I thought they were, this could cause confusion when defining the TE and TM modes. Is this a problem, or does the physics work out the same in the end?

stevengj commented 11 months ago

Nope, this is just a plotting thing. MPB's xyz axes are internally consistent, when you interface to a plotting library like matplotlib it may not show the orientation you expect. (Just because you label the axes a certain way doesn't make it so.)

stevengj commented 11 months ago

(Note that a waveguide like this does not have purely polarized TE and TM modes per se. Its only symmetry is a z=0 mirror plane, so the modes can be categorized as even/odd with respect to that mirror planes. If the waveguide is thin enough, this leads to modes that are mostly polarized. For more information, see e.g. chapter 7 of our Photonic Crystals: Molding the Flow of Light textbook.)