Study of phase-matching geometries in bulk and periodically-poled lithium niobate and their use in intracavity terahertz optical parametric oscillators