# Incompressible Magnetohydrodynamics
## Background

The equations of incompressible magnetohydrodynamics are similar to the Navier-Stokes equations, but can show a variety of other phenomena. This section assumes that the reader is familiar with the material covered for the Navier-Stokes case here. Their mathematical investigation of the incompressible magnetohydrodynamics equations is also in as poor a state as that of the Navier Stokes equations. A physical introduction to these equations can be found in Carbone and Pouquet, Chandrasekhar, Davidson, Gerbeau, Le Bris and Lelièvre, Schnak and Verma. A more general overview can be found here. Under the assumption that fluid velocities are significantly smaller than the speed of light, and the fluid is nearly incompressible, dimensionless equations are given as
    ${\frac {\partial \mathbf {u} }{\partial t}}+\mathbf {u} \cdot \nabla \mathbf {u} =-\nabla p+\mathbf {b} \cdot \nabla \mathbf {b} -\nabla \left(\mathbf {b} \cdot \mathbf {b} \right)+\Delta \mathbf {u}$         ( 1)
    ${\frac {\partial \mathbf {b} }{\partial t}}+\mathbf {u} \cdot \nabla \mathbf {b} =\mathbf {b} \cdot \nabla \mathbf {u} +\Delta \mathbf {b}$         ( 2)
    $\nabla \cdot \mathbf {u} =0$.         ( 3)
    $\nabla \cdot \mathbf {b} =0$.         ( 4)
In these equations, $\mathbf {u} (x,y,z)=(u,v,w)$ is the fluid velocity with components in the $x$, $y$ and $z$ directions, $\mathbf {b} (x,y,z)=(bx,by,bz)$ is the magnetic field with components in the $x$, $y$ and $z$ directions, $p$ is pressure field. Equation 1 represents conservation of momentum, eq. 2 corresponds to Maxwell's equations for nonrelativistic flows for which the time evolution of the electric field is neglected (see Verma), eq. 3 is the continuity equation which represents conservation of mass for an incompressible fluid and eq. 4 represents the fact that there are no magnetic monopole sources.

## The Two Dimensional Case

We will first consider the two-dimensional case. A difficulty in simulating the incompressible magnetohydrodynamic equations is the numerical satisfaction of the constraints in eqs. 3 and 4 , these are sometimes referred to as a divergence free conditions or a solenoidal constraints. To automatically satisfy these constraints in two dimensions, where
$\mathbf {u} (x,y)=\left(u(x,y),v(x,y)\right)$
and
$\mathbf {b} (x,y)=\left(bx(x,y),by(x,y)\right)$
it is possible to re-write the equations using a potential formulation. In this case, we let
$u={\frac {\partial \psi }{\partial y}}$
$v=-{\frac {\partial \psi }{\partial x}}$
$bx={\frac {\partial \phi }{\partial y}}$
and
$by=-{\frac {\partial \phi }{\partial x}}$
where $\psi (x,y)$ is the streamfunction and $\phi (x,y)$ the magnetic potential. Note that
$\nabla \cdot \mathbf {u} ={\frac {\partial u}{\partial x}}+{\frac {\partial v}{\partial y}}={\frac {\partial ^{2}\psi }{\partial x\partial y}}-{\frac {\partial ^{2}\psi }{\partial y\partial x}}=0$,
and
$\nabla \cdot \mathbf {b} ={\frac {\partial bx}{\partial x}}+{\frac {\partial by}{\partial y}}={\frac {\partial ^{2}\phi }{\partial x\partial y}}-{\frac {\partial ^{2}\phi }{\partial y\partial x}}=0$,
so eqs. 3 and 4 are automatically satisfied. Making this change of variables, we obtain a reduced system of two coupled partial differential equation by taking the curl of the momentum equation, eq. 1 and the magnetic transport eq. 2 . We define the fluid vorticity $\omega$, so that
$\omega =\nabla \times \mathbf {u} ={\frac {\partial v}{\partial x}}-{\frac {\partial u}{\partial y}}=-\Delta \psi$
and the magnetic vorticity so that
$\alpha =\nabla \times \mathbf {b} ={\frac {\partial by}{\partial x}}-{\frac {\partial bx}{\partial y}}=-\Delta \phi$
and eqs. 1 and 2 become
    ${\frac {\partial \omega }{\partial t}}+u{\frac {\partial \omega }{\partial x}}+v{\frac {\partial \omega }{\partial y}}=bx{\frac {\partial \alpha }{\partial x}}+by{\frac {\partial \alpha }{\partial y}}+\mu \Delta \omega +{\frac {\partial fy}{\partial x}}-{\frac {\partial fx}{\partial y}}$         ( 5)
    ${\frac {\partial \alpha }{\partial t}}+u{\frac {\partial \alpha }{\partial x}}+v{\frac {\partial \alpha }{\partial y}}=bx{\frac {\partial \omega }{\partial x}}+by{\frac {\partial \omega }{\partial y}}+\eta \Delta \alpha$         ( 6)
    $\Delta \psi =-\omega$.         ( 7)
and
    $\Delta \phi =-\alpha$.         ( 8)
where $fx$ and $fy$ represent the $x$ and $y$ components of the force $\mathbf {f}$.

## The Three Dimensional Case

In the three dimensional case, a potential formulation of the equations is not as convenient. Consequently, it is convenient to introduce the notion of a magnetic pressure to allow for a simple algorithm for enforcing the divergence free magnetic field constraint. The equations then become,
    ${\frac {\partial \mathbf {u} }{\partial t}}={\frac {1}{\text{Re}}}\Delta \mathbf {u} +\mathbf {b} \cdot \nabla \mathbf {b} -\mathbf {u} \cdot \nabla \mathbf {u} -\nabla \left(\mathbf {b} \cdot \mathbf {b} \right)+\nabla \Delta ^{-1}\left[\nabla \cdot \left(\mathbf {u} \cdot \nabla \mathbf {u} \right)-\left(\mathbf {b} \cdot \nabla \mathbf {b} \right)\right]$,         ( 9)
and
    ${\frac {\partial \mathbf {b} }{\partial t}}={\frac {1}{\text{Rem}}}\Delta \mathbf {b} +\mathbf {b} \cdot \nabla \mathbf {u} -\mathbf {u} \cdot \nabla \mathbf {b} +\nabla \Delta ^{-1}\left[\nabla \cdot \left(\mathbf {u} \cdot \nabla \mathbf {b} \right)-\left(\mathbf {b} \cdot \nabla \mathbf {u} \right)\right]$,         ( 10)
both of which can be discretized by the implicit midpoint rule. Here $Re$ denotes the fluids Reynolds number and $Rem$ the magnetic Reynolds number. The fluid pressure is given by
$\Delta ^{-1}\left[\nabla \cdot \left(\mathbf {u} \cdot \nabla \mathbf {u} \right)-\left(\mathbf {b} \cdot \nabla \mathbf {b} \right)\right]-\mathbf {b} \cdot \mathbf {b}$
and the magnetic ``pressure" is given by
$\Delta ^{-1}\left[\nabla \cdot \left(\mathbf {u} \cdot \nabla \mathbf {b} \right)-\left(\mathbf {b} \cdot \nabla \mathbf {u} \right)\right]$

## Serial Programs

We first write Matlab programs to demonstrate how to solve these equations on a single processor. The first program uses implicit midpoint rule timestepping to solve the two-dimensional magnetohydrodynamic equations and is in listing A . In this program, an additional equation is solved for a passive scalar with a diffusion constant $D_{\theta }$
    ${\frac {\partial \theta }{\partial t}}+\mathbf {u} \cdot \nabla \theta =D_{\theta }\Delta \theta$         ( 11)
The second program uses the implicit midpoint rule to do timestepping for the three-dimensional incompressible Magnetohydrodynamics equations and it is in listing B .

## Fortran Programs

The programs in this section are based on those for the Navier-Stokes equations in https://en.wikibooks.org/wiki/Parallel_Spectral_Numerical_Methods/The_Two-_and_Three-Dimensional_Navier-Stokes_Equations.

## Parallel Fortran Programs

To make a parallel program, the library 2DECOMP&FFT is used for the domain decomposition and the Fourier transforms. 2DECOMP&FFT is available from http://www.2decomp.org/index.html. The website includes some examples which indicate how this library should be used, in particular the sample code at http://www.2decomp.org/case_study1.html is a very helpful indication of how one converts a code that uses FFTW to one that uses MPI and the aforementioned library. To get the programs to work, first compile 2DECOMP&FFT, update the link in the makefile, and then compile the parallel Fortran program.

## Other Publicly Available Fourier Spectral Programs for Solving the Magnetohydrodynamics Equations

One other publicly available Fast Fourier Transform based program for solving the incompressible magnetohydrodynamics equations is:
Tarang available from http://turbulencehub.org/index.php/codes/tarang/

## Exercises

* The three dimensional program we have written is not the most efficient since one can use a real to complex transform to halve the work done. Implement a real to complex transform in one of the Navier-Stokes programs.
* The programs we have written can also introduce some aliasing errors. By reading a book on spectral methods, such as Canuto et al., find out what aliasing errors are. Explain why the strategy explained in Johnstone can reduce aliasing errors.
* See if you can find other open source Fast Fourier Transform based solvers for the incompressible magnetohydrodynamics equations and add them to the list above.
* There are suggestions that the incompressible magnetohydrodynamics equations can exhibit singular behavior by having one of the norms of the derivatives of the magnetic or velocity field becoming infinite. Experiment with simulations to see if you can find evidence for this. One of the first papers reporting computational experiments in this area is Orszag and Tang.
* Translate one of the programs above to another language. The following site may help, http://rosettacode.org/wiki/Rosetta_Code
* The full magnetohydrodynamic equations are
    ${\frac {\partial \mathbf {U} }{\partial t}}+\mathbf {U} \cdot \nabla \mathbf {U} =-\nabla p+\Delta \mathbf {U} +\mathbf {J} \times \mathbf {B}$         ( 12)
    ${\frac {\partial \mathbf {H} }{\partial t}}-\nabla \times \mathbf {B} =-\mathbf {J}$         ( 13)
    ${\frac {\partial \mathbf {B} }{\partial t}}+\nabla \times \mathbf {H} =0$         ( 14)
    $\nabla \cdot \mathbf {B} =0$         ( 15)
    $\nabla \cdot \mathbf {U} =0$         ( 16)
    $\mathbf {J} =\sigma \left(\mathbf {H} +\mathbf {U} \times \mathbf {B} \right)$         ( 17)
where $\mathbf {U}$ is the velocity, $\mathbf {p}$ is the pressure, $\mathbf {J}$ is the current density, $\mathbf {B}$ is the magnetic field and $\mathbf {H}$ is the electric field. Simulate these full equations in two and three dimensions - it is at present unknown whether solutions to these equations exist for all time in three dimensions see Germain, Ibrahim and Masmoudi, though Masmoudi shows that some solutions are well behaved in two dimensions. Analysis of the reduced equations is in Duvaut and Lions and can also be found in Gerbeau, Le Bris, and Lelièvre. An example program is in listing H
* A compressible magnetohydrodynamic model is
    ${\frac {\partial \rho }{\partial t}}+\nabla \left(\rho \mathbf {u} \right)=0$         ( 18)
    ${\frac {\partial \left(\rho \mathbf {u} \right)}{\partial t}}+\nabla \left(\rho \mathbf {u} \mathbf {u} ^{T}\right)+\nabla p=\nabla \cdot \mathbf {\tau } +\mathbf {J} \times \mathbf {B}$         ( 19)
    ${\frac {\partial \left(\rho E\right)}{\partial t}}+\nabla \left(\rho E\mathbf {u} \right)+\nabla \cdot (p\mathbf {u} )=-\nabla \cdot \mathbf {q} +\nabla \cdot (\mathbf {\tau } \mathbf {u} )$         ( 20)
    ${\frac {\partial \mathbf {H} }{\partial t}}-\nabla \times \mathbf {B} =-\mathbf {J}$         ( 21)
    ${\frac {\partial \mathbf {B} }{\partial t}}+\nabla \times \mathbf {H} =0$         ( 22)
    $\nabla \cdot \mathbf {B} =0$         ( 23)
    $\mathbf {J} =\sigma \left(\mathbf {H} +\mathbf {U} \times \mathbf {B} \right)$         ( 24)
    $p=\rho RT$         ( 25)
    $\mathbf {q} =-K\nabla T$         ( 26)
    $E=C_{v}T+{\frac {\mathbf {u} \cdot \mathbf {u} }{2}}+{\frac {\mathbf {H} \cdot \mathbf {H} }{2}}+{\frac {\mathbf {B} \cdot \mathbf {B} }{2}}$         ( 27)
    $\mathbf {\tau } =\mu \left[\nabla \mathbf {u} +(\nabla \mathbf {u} )^{T}\right]+\lambda \left(\nabla \cdot \mathbf {u} \right)\mathbf {I}$         ( 28)
where $\mathbf {U}$ is the velocity, $\mathbf {p}$ is the pressure, $\mathbf {J}$ is the current density, $\mathbf {B}$ is the magnetic field, $\mathbf {H}$ is the electric field, $\mathbf {E}$ is the energy density, $\mathbf {\tau }$ is the viscous fluid stress, $T$ is the temperature field, $C_{v}$ is the constant volume specific heat capacity, $R$ is the ideal gas constant, $\mathbf {q}$ is the heat flux. Simulate these full equations in two and three dimensions.

## Notes

* ↑ Carbone and Pouquet (2009)
* ↑ Chandrasekhar (1961)
* ↑ Davidson (2001)
* ↑ Gerbeau, Le Bris and Lelièvre (2006)
* ↑ Schnak (2009)
* ↑ Verma (2004)
* ↑ Magnetohydrodynamics
* ↑ Verma (2004)
* ↑ Canuto et al (2006)
* ↑ Canuto et al (2007)
* ↑ Johnstone (2012)
* ↑ Orszag and Tang (1979)
* ↑ Germain, Ibrahim and Masmoudi (2012)
* ↑ Masmoudi (2010)
* ↑ Duvaut and Lions (1972)
* ↑ Gerbeau, Le Bris, and Lelièvre (2006)

## References

Canuto, C.; Hussaini, M.Y.; Quarteroni, A.; Zang, T.A. (2006). Spectral Methods: Fundamentals in Single Domains. Springer.
Canuto, C.; Hussaini, M.Y.; Quarteroni, A.; Zang, T.A. (2007). Spectral Methods: Evolution to Complex Geometries and Applications to Fluid Dynamics. Springer.
Carbone, V.; Pouquet, A. (2009). "An Introduction to Fluid and MHD Turbulence for Astrophysical Flows: Theory, Observational and Numerical Data, and Modeling". Turbulence in Space Plasmas. Lecture Notes in Physics. Vol. 778. Springer-Verlag. pp. 71–128. doi:10.1007/978-3-642-00210-6_3. ISBN 978-3-642-00209-0. {{cite book}}: Check |authorlink2= value (help); External link in |authorlink2= (help)
Chandrasekhar, Subrahmanyan (1961). Hydrodynamic and Hyrdomagnetic Stability. Dover. ISBN 0-486-64071-X. {{cite book}}: Check |authorlink= value (help); External link in |authorlink= (help)
Davidson, P.A. (2001). An Introduction to Magnetohydrodynamics. Cambridge University Press. doi:10.1017/CBO9780511626333. ISBN 9780521794879. {{cite book}}: Check |authorlink= value (help); External link in |authorlink= (help)
Dorch, Soren (2007). "Magnetohydrodynamic". Scholarpedia. 2 (4): 2295. doi:10.4249/scholarpedia.2295. {{cite journal}}: Check |authorlink= value (help); External link in |authorlink= (help)
Duvaut, G.; Lions, J.L. (1972). "Inéquations en thermoélasticité et magnétohydrodynamique". Archive for Rational Mechanics and Analysis. 46 (4): 241–279. doi:10.1007/BF00250512. S2CID 120571424.
Gerbeau, J.-F.; Le Bris, C.; Lelièvre, T. (2006). Mathematical Methods for the Magnetohydrodynamics of Liquid Metals. Oxford University Press. doi:10.1093/acprof:oso/9780198566656.001.0001. ISBN 978-0-19-856665-6. {{cite book}}: Check |authorlink2= value (help); Check |authorlink3= value (help); Check |authorlink= value (help); External link in |authorlink2=, |authorlink3=, and |authorlink= (help)
Germain, P.; Ibrahim, S.; Masmoudi, N. (2012). "Well Posedness of the Navier-Stokes-Maxwell Equations". arΧiv:1207.6187 [math.AP].
Johnstone, R. (2012). "Improved Scaling for Direct Numerical Simulations of Turbulence". HECTOR distributed Computational Science and Engineering Report.
Masmoudi, N. (2010). "Global well posedness for the Maxwell-Navier-Stokes system in 2D" (PDF). J. Math. Pures. Appl. 93: 559–571. doi:10.1017/S002211207900210X. S2CID 123354420. {{cite journal}}: Check |authorlink= value (help); External link in |authorlink= (help)
Orszag, S.; Tang, C.M. (1979). "Small-scale structure of two-dimensional magnetohydrodynamic turbulence". Journal of Fluid Mechanics. 90 (1): 129–143. doi:10.1017/S002211207900210X. S2CID 123354420.
Schnack, D.D. (2009). Lectures in Magnetohydrodynamics. Lecture Notes in Physics. Vol. 780. Springer. doi:10.1007/978-3-642-00688-3. ISBN 978-3-642-00687-6.
Sermange, M.; Temam, R. (1983). "Some mathematical questions related to the MHD equations" (PDF). Communications on Pure and Applied Mathematics. 36 (5): 635–664. doi:10.1002/cpa.3160360506. {{cite journal}}: Check |authorlink2= value (help); External link in |authorlink2= (help)
Verma, Mahendra (2004). "Statistical theory of magnetohydrodynamic turbulence: recent results". Physics Reports. 401 (5–6): 220–380. arXiv:nlin/0404043. doi:10.1016/j.physrep.2004.07.007. S2CID 119352240. {{cite journal}}: Check |authorlink= value (help); External link in |authorlink= (help)
"Magnetohydrodynamics".
Zheng, Linjin, ed. (2009). Topics in Magnetohydrodynamics. InTech. doi:10.5772/2080. ISBN 978-953-51-0211-3.