Optimal control of Nuclear Magnetic Resonance periodic systems