The Sun is so hot that its matter is in the form of plasma. The atoms and electrons are separated. The plasma acts like a fluid in that it is capable of flowing.
Moving charge causes magnetic fields to form. Actually, because of differential rotation of the Sun, rotation at different rates depending on distance from the solar equator, the magnetic fields twist and contort.
As the movement of electrical charges move they produce magnetic fields that force charged particles upward into coronal loops where magnetic energy becomes stored. These coronal loops can twist until they release the energy releasing the charged particles into space. This usually happens at a sunspot, a swirling solar storm. When sunspots are present there is a danger of a solar flare, or emission of charged particles into space.
Sunspots change their direction of rotation in a period of eleven years. This is because the Sun reverses its magnetic field, the composite of many localized magnetic fields, enery eleven years.
Comments
Do auroras and sunspots appear and behave -- and misbehave ;-D -- similarly on our Moon?