Optimization of the process of frequency tripling and quadrupling in double grating quasi-phase matched structures