Optimal design of superconducting coils for quench