The development of activities in space and of the corresponding technologies requires research on the behavior of both matter and biological organisms under weightless conditions. Various methods have been invented in order to simulate weightlessness, for example, drop towers, sounding rockets, or parabolic flights. Magnetic field ground-based devices have also been developed. This paper introduces an optimization method of the magnetic field so as to obtain magnetic levitation in a two-dimensional cylindrical geometry.