Theoretical Study of Mode Competition in Terahertz Gyrotron With Second Harmonic Oscillation