What is the effect of switching the polarity in an electromagnet?