Optimized Design of Passive Shimming in NMR Magnets