Open stevengj opened 4 years ago
i.e. if the waveguide is in the y direction, rotate the coordinates to (y,z,x), and if the waveguide is in the z direction, rotate them to (z,x,y)
(The tricky part is just to make sure that we do this consistently. You have to transform all the inputs, lattice vectors etcetera, and also all of the outputs like fields and group velocity.)
Examples of place that would need to be change:
d
direction is in Meep coordinates, but kdir
and G
will be in MPB coordinates, so you will have to use a "rotated" version of d
as an index into these arrays.parity
to the rotated coordinates)Note that you have to cycle both the (x,y,z) coordinates and the field components (Ex,Ey,Ez). There will be some coordcycle
which says to cycle the coordinates by 0, 1, or 2. Going from Meep to MPB you would cycle by +coordcycle
and going from MPB to Meep you would cycle in the opposite direction (by -coordcycle
)
For example, d - X
becomes (d - X + coordcycle) % 3
.
Note that the parity flags are defined here. In particular, you should think of parity
as a bit field of flags: each bit of the integer is set by one of the *_PARITY
flags.
We define our own bits for EVEN_X_PARITY = 16
(4th bit) and ODD_X_PARITY = 32
(the 5th bit). The caller can pass any combination of these. Your code will then have to shift these flags (e.g. if X shifts to Y then you have to shift the 4th and 5th bits to the 2nd and 3rd bits).
Two questions related to implementation:
eig_vol
(assuming it is a line in 1d or a plane in 2d). However, the situation is more complicated if eig_vol
has all of its dimensions with non-zero size (e.g., a photonic-crystal waveguide). Assume the user does not set direction=mp.NO_DIRECTION
and specifies the waveguide direction using kpoint_func
.coordcycle
be a function (with a single input parameter eig_vol
) or a global variable? How can the existing interface of meep_mpb_eps
and fields::get_eigenmode
(the two functions in src/mpb.cpp
where coordcycle
is to be used) be preserved?coordcycle
will have to be stored in the eigenmode_data
This would be nice, as discussed in NanoComp/mpb#72. However, implementing it in MPB is rather subtle as discussed in NanoComp/mpb#74 because of the interaction with MPB's transverse basis.
Seems like it might be more straightforward to just do a cyclic rotation of the coordinates in Meep's
src/mpb.cpp
so that the x direction is always the propagation direction.