Tamm Problem And Terahertz Radiation In Nonlinear Optics