Quality factor calculations for a resonant cavity