Propagation of polarized photons through a cavity with an anisotropic metamaterial