If the device has more than one grating plus phase shifts, the coupled mode equations
can be solved by the Transfer Matrix Method. This method can also be used very
effectively in the analysis of almost-periodic gratings. The general idea of TMM is that
the grating structure is divided into a number of uniform grating sections, which have an analytic transfer matrix. The transfer matrix for the entire structure can be obtained
by multiplying the individual transfer matrices. The Coupled Mode Equations can be
solved with the initial values.