I remember from my days of teaching school science that we used to demagnetize nails by hitting them with a hammer and magnetize them by stroking with a magnet until the atoms aligned in the same direction.
My friend was showing me an app on his phone where the accelerometer sometimes fails and you are advised to reset it by moving the phone in a figure of 8. I was curious why the figure of 8. I'll break my question into 2 separate parts as that's what my feeble brain needs :) If you are kind enough to respond to this, please can you address the sub-questions in turn. For simplicity I am assuming the accelerometer is just a magnet
a) When atoms reorient themselves to be magnetized do they turn clockwise, anticlockwise or both directions (just curious)?
b) How does the figure of 8 movement reset a magnet? The electromagnetic field lines on either side of a bar magnet do look like a figure of 8 on its side. My days of knowing electromagnetism are long gone but is it a fair simplification to say by following the magnetic field lines that should be around your phone if its magnet were 'working,' you actually realign the atoms in the magnet. If that is the case I'm not sure how this works as it is not as obvious as the notion of stroking a nail with a magnet to realign the atoms. If my simplification is correct I do not need to know how this works as that probably requires a physics degree so all I would ask is that confirm or disconfirm my suggestion (unless there is a simple explanation). If my simplification is wrong, please could you offer a correct one. I appreciate simplifications are difficult in the field of electromagnetism.
Thank you for taking the time to read this question.