Photonic engineering of CW, ultrabroad gain, aperiodic quantum cascade lasers at terahertz frequencies integrations with 2D materials and study of the optical mode dynamics