Modeling of Quasi-Phase-Matched Second Harmonic Generation in a Doubly Resonant Cavity