Magnetic anisotropy engineering in square magnetic elements