Shape of Earth's magnetic field

Why earth's magnetic field is compressed on day side and extended like tail on night side, like this

I know that it's due to solar wind but not how that compression and extension happens.

• "Most of the volume of the tail is taken up by two large bundles of nearly parallel magnetic field lines (see drawing). The bundle north of the equator points earthwards and leads to a roughly circular region including the northern magnetic pole, while the southern bundle points away from Earth and is linked to the southern polar region. – Árpád Szendrei Jun 6 '18 at 16:59
• These two bundles, known as the "tail lobes", extend far from Earth: ISEE-3 and Geotail found them well-defined even at 200-220 RE (Earth radii) from Earth. At those distances the lobes are already penetrated by some solar wind plasma, but near Earth they are almost empty. One may compare typical plasma densities:" Please see here: www-spof.gsfc.nasa.gov/Education/wtail.html – Árpád Szendrei Jun 6 '18 at 17:00
• Start simple and think of a windsock then add magnetic fields, then tilt the source of the magnetic fields away from orthogonal to the solar wind flow, and then add magnetic reconnection. – honeste_vivere Jun 7 '18 at 18:12

Honeste painted an excellent qualitative picture, but here’s a more mathematical answer:

First of all, note that the distorted magnetic field is the sum of a dipole field created by currents in the earth’s core (essentially unaffected by the solar wind) and a further contribution from hard-to-describe currents induced in the wind itself.

The plasma in the solar wind is a conductive fluid. When a conductive fluid moves through a magnetic field, the field induces currents, which distort the field, while reactive $J\times B$ forces affect the fluid flow. You could even say that in the limit of infinite conductivity, the field lines would be frozen into the fluid (i.e., the fluid’s velocity would be parallel to the field lines). The picture shows clearly that the field lines run parallel to the wind’s flow in the tail.

The MHD “induction equation” used to calculate the distorted field is $$\dot{B}=(B\cdot \nabla )V-(V\cdot \nabla )B+\tfrac{1}{4\pi \sigma }{{\nabla }^{2}}B$$ To derive it, throw $J=\sigma (E+V\times B)$, $curl(E)=-\dot{B}$, and $curl(B)=4\pi J+o({{c}^{-2}})$ into a cauldron, don a wizard’s pointed hat, and stir.

The Earth's magnetosphere is formed by the internal magnetic fields generated by a dynamo. The global field geometry is roughly that of a magnetic dipole. Were it not for the solar wind, the Earth's field would look like a rotating dipole.

Why earth's magnetic field is compressed on day side and extended like tail on night side, like this

The asymmetry between the dayside(sunward side) and nightside(anti-sunward side) of the magnetosphere results from the dynamic and magnetic pressure exerted on the magnetosphere by the supersonic, magnetized solar wind plasma. The compression and expansion of the dayside and nightside, respectively, magnetic fields occurs in a similar way to that of flow lines in wind tunnel experiments with blunt obstacles like spheres.

I know that it's due to solar wind but not how that compression and extension happens.

There is an additional complication arising from the presence of magnetic fields and a plasma called magnetic reconnection. That is, the magnetic fields reconfigure on the dayside and drape around to the nightside where they again reconfigure. The new topology in the nightside experiences an unbalanced magnetic tension and "relaxes" to less strained state, i.e., the fields become more dipolar which is viewed in simulations as the stretched fields becoming less stretched. This process is dynamic and continuously evolving. The stretched nightside part of the magnetosphere is called the magnetotail and its relaxation results in processes that lead to the aurora.