Table of Contents
Fetching ...

MHSXtraPy -- A Python code for the extrapolation of magnetohydrostatic fields on the Sun using analytical solutions

Lilli Nadol, Thomas Neukirch

TL;DR

This work addresses the need for fast, physically consistent solar magnetic-field extrapolations from photospheric data that incorporate both magnetic and plasma forces. It presents MHSXtraPy, a Python tool implementing analytical magnetohydrostatic solutions with a current density form $\mu_0 \mathbf{j} = \alpha \mathbf{B} + f(z) \nabla B_z \times \hat{\mathbf{z}}$ and a poloidal–toridal decomposition to compute $\mathbf{B}$, $\mathbf{j}$, $p$, and $\rho$. Three forms for the transition function $f(z)$ are implemented (Low 1991/1992 exponential, Neukirch 2019 with a tanh-based profile, and Nadol 2025 step-function), along with potential and linear force-free extrapolations for benchmarking. The code emphasizes speed through FFT-based boundary treatment, Numba acceleration, and open-source availability on GitHub, enabling researchers and educators to perform time-efficient extrapolations from SHARP magnetograms and related data.

Abstract

We present a Python code for calculating and displaying magnetic field extrapolations from given two-dimensional boundary conditions, specifically from solar surface magnetograms. The code implements analytical magnetohydrostatic models that incorporate the transition from non-force-free to force-free magnetic fields in the solar atmosphere. It allows for different parameterisations of this transition and includes functions to compute magnetic fields, plasma pressure, and density. Fast Fourier methods ensure efficient computation, and the output includes three-dimensional visualisations of field lines and plasma structures. The implementation is optimised for accessibility and speed, making it suitable for both research and educational purposes. The only prerequisite for running the code is a Python compiler. All source code, examples, input files, solutions, and instructions are available for download from GitHub.

MHSXtraPy -- A Python code for the extrapolation of magnetohydrostatic fields on the Sun using analytical solutions

TL;DR

This work addresses the need for fast, physically consistent solar magnetic-field extrapolations from photospheric data that incorporate both magnetic and plasma forces. It presents MHSXtraPy, a Python tool implementing analytical magnetohydrostatic solutions with a current density form and a poloidal–toridal decomposition to compute , , , and . Three forms for the transition function are implemented (Low 1991/1992 exponential, Neukirch 2019 with a tanh-based profile, and Nadol 2025 step-function), along with potential and linear force-free extrapolations for benchmarking. The code emphasizes speed through FFT-based boundary treatment, Numba acceleration, and open-source availability on GitHub, enabling researchers and educators to perform time-efficient extrapolations from SHARP magnetograms and related data.

Abstract

We present a Python code for calculating and displaying magnetic field extrapolations from given two-dimensional boundary conditions, specifically from solar surface magnetograms. The code implements analytical magnetohydrostatic models that incorporate the transition from non-force-free to force-free magnetic fields in the solar atmosphere. It allows for different parameterisations of this transition and includes functions to compute magnetic fields, plasma pressure, and density. Fast Fourier methods ensure efficient computation, and the output includes three-dimensional visualisations of field lines and plasma structures. The implementation is optimised for accessibility and speed, making it suitable for both research and educational purposes. The only prerequisite for running the code is a Python compiler. All source code, examples, input files, solutions, and instructions are available for download from GitHub.

Paper Structure

This paper contains 13 sections, 13 equations, 9 figures.

Figures (9)

  • Figure 1: Flow chart representing the application of MHSXtraPy.
  • Figure 2: Examples for the two background atmospheres implemented in MHSXtraPy. The two figures in the top row show the temperature curves both for the full extrapolation height $40$ Mm (on the left) and for a region around the transition region (up to $4$ Mm above the photosphere). The hyperbolic tangential temperature profile (blue) is calculated with photospheric temperature $5600$ K and coronal temperature $2$x$10^6$ K. The linear temperature profile (black) is interpolated between $5600$ K, $5200$ K, $10^4$ K, $5x10^5$ K, $10^6$ K and $2$x$10^6$ K at heights $0$ Mm, $0.5$ Mm, $2.0$ Mm, $2.2$ Mm, $5.0$ Mm and $40.0$ Mm above the photosphere. The two figures in the bottom row show the resulting pressure and density curves, respectively, for the two temperature profiles.
  • Figure 3: Magnetic and coronal observations of the investigated active region on the Sun. Top panel: Radial SHARP magnetogram as observed by SDO/HMI on 2011-02-14 at 23:58:12 TAI. Bottom panel: Extreme ultraviolet image from the Atmospheric Imaging Assembly (AIA) at 171 Å, taken shortly after on 2011-02-15 at 00:00:00 TAI, displaying the coronal loops associated with the active region.
  • Figure 4: Field lines visualised by MHSXtraPy resulting from the magnetic field extrapolation above active region NOAA 11158.
  • Figure 5: Variations in plasma pressure and density with height $z$ above the photosphere, between $z=0$ Mm and $z=4$ Mm. The change from non-force-free to force-free occurs between approximately $z=1.8$ and $z=2.2$ Mm, which is particularly obvious in the density variation.
  • ...and 4 more figures