In this paper
AbstractIntroductionMethodResultsTest setupAccuracy of the solverMultiplicity of the solutionImpact of boundary conditionImpact of off-centre dataDivergence of the magnetic fieldNode-based atmosphere assumptionDiscussionConclusions and outlookElectric current spatial and cumulative distributions at additional optical depthsAccuracy of the solverHeights of optical depth layersSpatial distribution of heights of optical depth layersWilson depressionReferencesWorksPhysics and Astronomy
Accuracy of electric current inference assuming three-dimensional hydrostatic equilibrium
Abstract
The chromospheric and coronal heating problem is among the major open questions in solar physics. Some of the possible mechanisms that can explain the rise in temperature that is needed to reproduce the observations require the estimation of electric currents. Since these depend on the spatial derivatives of the magnetic field components, it is necessary to obtain the full magnetic field vector from observational data in a 3D geometrical grid. We developed a new method to obtain the 3D geometrical configuration of the atmosphere using the approximation of hydrostatic equilibrium in three dimensions to determine the gas pressure and density as a function of optical depth, column mass, or geometrical distance. This development has been designed as an extension for any inversion code that outputs a stratification of temperature and gas pressure or density to enable the estimation of electric current densities from observations. We investigated our approach using a snapshot from a sunspot MHD simulation. The difference between the solver output and the simulation, taken as the ground truth, is mostly between 30 and 45 %, showing a similar pattern over a large optical depth range. Additional tests also showed that the solver provides a unique solution, has a scarce sensitivity to the boundary condition and is only marginally impacted by the viewing angle. We conclude that the electric currents can be inferred at a reasonable accuracy with this approach using the simulation parameters as input. We also tested set-ups that aim at mimicking more realistic cases, where the code performed equally well. The results in this work show promise with respect to future applications to spectropolarimetric data, however, some additional challenges will need to be adressed when moving from the controlled input of the simulation to observational data.
Introduction
While the study of the solar atmosphere has seen good progress both in observations using modern telescopes and instruments and in state-of-the-art simulations (see e.g. [16]; [6]; [15]; Pontin & Priest 2022, for reviews on specific topics), there are a number of open questions remaining. One of the major open questions in solar physics is the chromospheric and coronal heating problem. This refers to the fact that the temperature in the chromosphere of the Sun is higher than what we would be able to explain solely considering radiation transport as the heating mechanism (Athay [3]). Additionally, measurements of the amount of energy that is radiated away by the chromosphere are shown to be higher than what would otherwise be expected. Indeed, original studies quantified the average radiative losses in the chromosphere to be around 5 kW m in the quiet Sun and around 20 kW m in active regions (e.g. Withbroe & Noyes 1977; Vernazza et al. 1981). More recent studies, using up-to-date instruments with a much higher resolution, have found local rates of up to 160 kW m (Díaz Baso et al. [12]) or temporal variations (Morosin et al. [21]), further highlighting the importance of determining the contributions of individual mechanisms and comparing them to the radiative losses.
Over recent decades, a wide range of mechanisms have been proposed, which can be broadly categorised into two groups. The first one contains processes that relate to waves and instabilities (see Srivastava et al. 2021, for a review), such as magnetoacoustic waves (e.g. van Ballegooijen et al. 2011; Abbasvand et al. 2020). The second one describes the dissipation of electric currents through processes such as Ohmic heating (Louis et al. [18]; Socas-Navarro 2005; Tritschler et al. 2008) and, extending to the generalised Ohm’s law, ambipolar diffusion mechanisms (see e.g. Nóbrega-Siverio, D. et al. 2020; Khomenko & Collados [14]; Shelyag et al. 2016). Even though many of them have been found in both observations and simulations to contribute to the heating (see Abbasvand et al. 2020; Morton et al. [22]; de la Cruz Rodríguez et al. [8]; Brady & Arber [5], for some examples), the specific contribution of each mechanism at different features and depths has not been well established thus far.
A popular method for gaining insights into the physical parameters of the solar atmosphere from observations is the inversion of spectropolarimetric data using models stratified along the line of sight. Inversion codes typically minimise a metric that compares a synthetic spectrum produced by a radiative transfer module with the observations (see del Toro Iniesta & Ruiz Cobo [11]; de la Cruz Rodríguez & van Noort [10], for a review). This approach makes use of data taken from facilities equipped with spectropolarimeters, which are observing spectral lines that probe the solar atmosphere at different heights. Common examples that are used to constrain the magnetic field vector in the photosphere and chromosphere are the Fe i line at 6173 Å (hereafter referred to as 6173) and the Ca ii line at 8542 Å (hereafter referred to as 8542) lines. Some examples of these inversion codes are STiC (de la Cruz Rodríguez et al. 2019), SNAPI (Milić & van Noort [20]), NICOLE (Socas-Navarro et al. 2015), De-SIRe (Ruiz Cobo et al. 2022), and TIC (Li et al. 2022). All these codes operate under the assumption of 1D hydrostatic equilibrium, while also adopting a vertical depth scale given in column mass or optical depth. These two assumptions allow for an individual processing of all pixels in the FOV as horizontal radiative coupling is also ignored. The resulting mapping to a Cartesian vertical axis is inconsistent across the FOV: the origin is unconstrained, while the sampling (set by 1D hydrostatic equilibrium) can also be largely inconsistent. A few exceptions, such as FIRTEZ-dz (Pastor Yabar et al. (2019); Borrero et al. [4]), account for horizontal pressure balance and the Lorentz force. These automatically introduce physical coupling between neighbouring pixels and allow for the inversion to be carried out on a fixed (pure) Cartesian grid.
To estimate the contribution of the aforementioned electric current-related dissipation mechanisms, we need an estimation of the electric currents via , which depends on the spatial derivatives. Computing spatial derivatives from a model that has been reconstructed under the assumption of 1D hydrostatic equilibrium is not sufficiently accurate to derive meaningful estimates of the current vector due to the aforementioned limitations of the derived vertical axis (see, Puschmann et al. 2010).
In this study, we have developed a module for imposing 3D hydrostatic equilibrium in a Cartesian grid. This additional processing takes as input the stratifications of temperature and gas pressure or density from the spectropolarimetric result and the 3D Cartesian grid from the user. Given these inputs, it determines the 3D gas pressure so that hydrostatic equilibrium is ensured in 3D and the temperature stratification along optical depth is kept constant. We prefer to explore here the potential of this conservative approach because, in contrast to the photosphere, the determination of the full magnetic field vector (and its 180 degree ambiguity resolution) in extended areas of the Sun in the chromosphere is far from being systematic. The method will allow us to calculate the electric currents where observations are providing reliable magnetic field vector inferences, without having to resort to extrapolation methods and approximations. Following this, we can then calculate constraints on the contribution of Ohmic heating and ambipolar diffusion, which additionally requires atomic data such as cross-sections and number densities. Furthermore, it will also enable a comparison between the heating values and the radiative losses in the chromosphere.
We discuss our approach on how to solve hydrostatic equilibrium in 3D and our implementation in Sect. 2. In Sect. 3, we then show the results of our validation tests using a snapshot from a radiative MHD simulation, which are discussed in Sect. 4. Finally, we present our conclusions and provide an outlook on future improvements and plans for the application of this method to real data in Sect. 5.
Method
Most radiative magnetohydrodynamic simulations use a resistive equation of motion to resemble the plasma in the solar atmosphere as closely as possible. As a first simplification, the ideal
The MHD equation of motion can be written as
ignoring viscosity and ohmic resistance. Here is the density, is the solar surface gravity, is the velocity of the fluid, is the magnetic field vector, the electric current, and the pressure. Since we are only able to determine the line-of-sight velocity from the inversions and perpendicular velocities pose strong challenges, it is common to leave these terms out of consideration. Dropping the velocity terms then leaves us with the magnetohydrostatic equilibrium approximation,
where gravity, pressure gradients, and the Lorentz force are left in the force-balance. If we further simplify the equation by neglecting the Lorentz force, we arrive at hydrostatic equilibrium in 3D via
Most inversion codes today adopt the vertical component of Eq. (3) to calculate a pressure scale, while ignoring horizontal pressure balance between neighbouring pixels. This assumption allows processing pixels from the observation independently, but it also precludes the code from deriving a common vertical scale axis for all pixels.
This is where our method will come into play. It will take the output of an inversion; namely, the temperature and a first guess for the pressure or density. We then use it to solve the first-order system in Eq. (3) in 3D. In addition, we need a boundary condition to prevent the atmosphere from globally shifting in the vertical direction. We can use a fourth-order finite difference scheme for the pressure derivatives, turning Eq. (3) into a system of linear equations , using the step size from the input grid. In a system with number of spatial grid points, is a matrix containing the coefficients of the finite difference scheme, is a vector of a size containing the gravitational term of the force balance and the solution with entries.
An example of the matrix for a small number of pixels is shown in Figure 1, where the derivatives are ordered in z-, x-, and y-direction for each pixel. The same applies for the right-hand-side vector, , which means that only the entries with the index 0, 3, 6, ... are non-zero. Here we also note that we implemented all the equations and operations in logarithm, where we divide by the pressure from the previous iteration, making use of the logarithmic derivative on the left-hand-side. This was done to both improve stability, as the solver now does not have to handle values spanning multiple orders of magnitude any longer and to ensure the solver will not produce negative values for the pressure.

Figure 1. Partial image of the matrix and its structure for the case of a 5 × 5 × 5 grid. The pixels in blue represent positive values, the pixels in red negative. The matrix was filled according to the fourth-order finite difference scheme, using z,x,y order. We used the third-order forward and backward scheme for the respective boundaries.
Since the system is overdetermined due to the three derivatives per grid-point, we use the set of normal equations to obtain a square matrix, multiplying the system by its transpose. We solve this sparse system of linear equations using iterative methods like the biconjugate gradient stabilized method (BiCGSTAB, van der Vorst 1992). While the formation of the normal equations squares the condition number, this configuration using the aforementioned solver with the default diagonal preconditioner proved to be the fastest of the implemented solvers in the Eigen Guennebaud et al. [13] We make use of the Eigen library, as it provides an efficient implementation of sparse matrix operations, including a multi-threaded implementation of BiCGSTAB.
The solution of Eq. (3) is a new estimate of gas pressure, whose combination with the temperature and an equation of state (EOS) leads to a new density estimate. Thus, the right-hand-side of Eq. (3) is modified and the system has to be solved again, turning into an iterative procedure. Furthermore, this method is designed to be applied after a spectropolarimetric inversion has been performed. If it is carried out as described thus far, the method presented here will change the gas pressure (and density) on the geometrical grid, changing the relation between geometrical distance and optical depth. Consequently, the physical parameters may not have the same optical depth variation as in the input data. Thus, the final atmosphere will not necessarily reproduce the same spectra. To account for this effect, we introduce an additional iterative step within the previous one every time a new gas pressure is calculated. This additional step keeps the optical depth dependence of the temperature identical. In other words, there are two nested iterative procedures: the outer one modifies the gas pressure, while the inner one ensures that the optical depth stratification of the temperature remains identical for every outer loop iteration. Figure 2 shows a flowchart sketch, summarizing the iterative implementation of the method. Further details of each step are provided below:

Figure 2. Flowchart of the presented module, showing the iterative procedure solving for the pressure and the density. The parameters that are used in each element are also marked with indices that refer to the iteration number.
Input data: from the output of any spectropolarimetric code, we take the temperature and gas pressure or density, denoted with the index 0, and a column mass, optical depth, or height scale. These are, strictly speaking, the only mandatory input parameters required to solve HE in 3D. In addition, any additional physical parameter to be considered afterwards has to be provided to keep its optical depth variation (see below).
Solve Eq. (3): the solution of the system provides the spatial variation of the gas pressure without an absolute reference; i.e. any constant pressure shift yields an equally valid solution.
Set gas pressure reference value: we enforce a pressure reference such that the average pressure of a given optical depth layer is kept constant. The average pressure at this layer is calculated in each iteration. The value is then subtracted from all points of the 3D volume followed by adding the value from the previous iteration, thereby keeping the average pressure the same. The reference optical-depth layer is chosen by the user depending on which lines are used in the input data (i.e. where these lines are sensitive within the model domain). In doing so, we can ensure that the formation region is kept within the volume considered when solving Eq. (3). Specifically, in this work, we chose , as we expect that most real applications will include observations that probe the low photosphere.
Inner loop: update the geometrical variation of T to keep its optical depth dependence identical. As the gas pressure is iteratively modified, so is the optical depth. To avoid this change in the temperature stratification with optical depth, we re-interpolate the temperature at any iteration to the input one, . This is also done via an iterative procedure, where the temperature is interpolated with the new optical depth and then fed into the EOS to update again. This process is repeated until the relative optical depth change is below a given threshold of 0.2%. The temperature interpolation will modify the original geometrical stratification by locally stretching or compressing it, but it will keep the optical-depth stratification identical. This step also updates the density to be used in the next iteration if necessary.
Check for convergence: this iterative procedure between solving for the pressure and updating the density is done until convergence, which is deemed the case once the change be-
tween iterations is below an average relative difference per pixel of 0.2% in our tests, but can be chosen by the user.
Remap the remaining inversion parameters: we adjust any additional inversion parameters (magnetic field, LOS velocity, microturbulent velocity) so that they remain the same value at each optical depth point, to ensure that the synthetic spectra produced by the radiative transfer module are the same as they were before solving for hydrostatic equilibrium in 3D.
Electric current density calculation: Once converged, the solver essentially yields an updated optical depth based on the stratification of the plasma parameters, which then allows us to compute the spatial distribution of currents using the magnetic field components from the inversion.
Results
We used a snapshot from an r-MHD simulation to evaluate the validity of our approach and investigate the behaviour of the solver. This sunspot simulation was performed by Rempel (2012) using the radiative MHD code MURaM (Vögler et al. 2005). Our snapshot contains data points with a horizontal sampling of dx, dy = 12 km and a vertical sampling of dz = 8 km.
The resulting continuum intensity map is shown in Figure 3. For our investigations, we limited the data to a field of view (FOV) containing a mix of quiet Sun, penumbra and umbra, with a size of , highlighted as a lime rectangle in the image. Here, we also marked the two sub-FOVs that were used in one of our tests in cyan and blue, together with a pixel in the penumbra that was chosen to judge the accuracy of electric currents over optical depth, where we expected clear deviations from hydrostatic equilibrium.
Figure 3. Map of surface intensity from simulation snapshot. The green rectangle marks the FOV used for the tests. The blue and cyan colored rectangles mark the sub-fields used when investigating the impact of the chosen size of the data cube. The white square marks the pixel in the penumbra used in the plots that show the variation of current-components with optical depth.
For our assessment, we compared the electric current components from the spatial derivatives of the magnetic field at the same optical depth. As an investigation of the currents is our primary interest, we did not study the plasma parameters with the same level of detail. We note that enforcing horizontal gas-pressure balance is expected to cause the pressure to deviate from that in the simulation, because some terms in Eq. (1) are neglected. Additionally, the horizontal pressure balance requirement means that if the FOV contains regions with very different features (such as the quiet Sun, penumbra, and umbra as in the case presented here), the pressure and density from the solver can differ by several orders of magnitude and should be taken with care. Therefore, we did not consider the gas pressure and density themselves for the comparison and we focussed on the electric currents instead.
We can use the relative difference to quantify the accuracy, as its value is straightforward to interpret via
This metric is calculated for every grid point, where we take the median to have a single value characterising the comparison between cases. Since the metric above is not stable where the reference is around zero and the magnetic field determined from observations will contain noise, we masked all the pixels below a certain threshold. We determined the threshold by creating Gaussian noise with a sigma of 10 (2) Gauss for the horizontal (vertical) magnetic field and calculating the electric current components. The numbers we used were chosen as an optimistic lower limit and in real applications of depth-dependent spectropolarimetric inversions, we can expect higher values (see for instance Arramy et al. [2], where they have estimations for the chromospheric magnetic fields of approximately 80 (70) G for 3D spatially regularized inversions and 160 (140) G for more common spectropolarimetric inversions). We then used the peak in the distribution of values as the threshold, which was around 0.025 MGs for all three components. In the following, this threshold was used over the MHD counterpart to select the currents to be considered in the relative difference calculation. In most comparisons, this meant that we considered roughly 50% of the pixels. Although the chosen noise level is quite optimistic and will, in practice, heavily depend on the chosen model and observational setup, higher noise will further reduce the number of pixels considered in the analysis. In our experience, this will initially lead to a lower relative difference, until a certain electric current value is reached and only the strongest currents are considered; then, the relative difference rises again, as the HE3D prediction usually underestimates the strongest currents (see 3.2).
Test setup
In the following, we present the results for the various comparisons that we used to address the accuracy of the method aiming at evaluating the impact of different assumptions. To do so, we considered five different datasets, focussing on the electric current density coming from each of them:
MHD case (labelled MHD): in this case, we took the magnetic field vector (), temperature (), and gas pressure () from the r-MHD simulation, denoted with 0 in Figure 2. From these, we computed the optical depth and electric current density ( and ) compatible with the equation of state, chemical abundance set, and differentiation scheme. We then used these as the ground truth in the comparison with the method described here.
Node-sampled MHD case (labelled MHD_node): in this second case, we followed a similar procedure, but first modifying the and temperature () so that they would mimic an observationally driven case in which the inference of these parameters was done using the concept of ‘nodes’ (i.e. a subset of model parameters at a reduced number of grid points along the line of sight from which the model parameters at the radiative transfer grid is interpolated). This case serves as a more realistic scenario for comparison because, in future applications of this method, the initial guess of the parameters will come from observationally driven inferences. To mimic a node-based case, we interpolated the
quantities to a grid of equidistant points in height. We chose 13 points, as this resulted in 4–5 points in the optical depth range of , which is an optimistic, but still realistic value. We then minimized the squared difference between the values at those points and the simulation to obtain a result that is less dependent on the location of the nodes. In this process, the thermodynamics were modified, leading to a new optical depth stratification ; thus, the parameters could then be interpolated back to the original grid. In the process, was further modified – not only due to the usage of nodes, but also because of the difference in optical depth – thereby leading to .
Solver run (labelled HE3D): in this run, we took the full MHD stratification of the temperature and gas pressure ( and ) as input to the solver, as well as the magnetic field vector, to estimate the electric currents (). In this case, the HE3D-solver will accept and as the initial state to work on, denoted with 0 in the flowchart, and end up in a solution characterised by , , and , denoted as ’n’ in Figure 2.
Solver runs on shifted MHD case (labelled HE3D_shift): the input from the MHD simulation contains horizontal structure, as it employs physical constraints also in the horizontal directions. To remove that horizontal structure in the temperature, pressure, and density as well as test its implications, we applied a shift to every pixel in the input so that is at the same height. In this process, the stratification for each pixel individually in height is preserved.
Node-sampled solver run (labelled HE3D_node): this case is fairly similar to the HE3D case, but instead of taking MHD inputs, we took the node-sampled MHD stratifications from MHD. The rest of the procedure was kept the same. This case is aimed at checking the limitations the method faces over a more realistic case.
Accuracy of the solver
The first and main test was to investigate the accuracy of our method and how much difference the assumption of 3D hydrostatic equilibrium would induce. We use the parameters from the simulation as the input for the solver and compare the resulting output. In Figure 4, we show maps of the x-component of the currents for the two cases at an optical depth of , where MHD is on the upper panel and HE3D in the lower panel (maps for the other two components as well as for other optical depth values can be found in Figs. A.1 to A.8). It is immediately apparent that most of the spatial features and structures are amply reproduced by the solver output, with the exception of the smallest scales, although the amplitude differs significantly for the larger peaks. To quantitatively assess the performance, we calculated the relative error: for , the median is 0.31 (x), 0.38 (y), and 0.30 (z).
Figure 4. Maps of at for the MHD (upper) and for the HE3D case (lower).
This means that 50% of pixels have a difference lower than around 30% to 38%. The difference is mainly induced by the absence of the additional terms in the equation used in the simulation compared to the employed hydrostatic equilibrium Eq. (3) in our solver.
In addition to the comparison of the spatial distribution at specific optical depths, we also investigated the current components in the range of for a pixel in the region of the penumbra (square in Figure 3). From Figure 5, we see that the solver output, with a few exceptions, follows the same trend as the simulation, but can differ significantly when looking at the exact values. This is expected, as here in the penumbra the other terms contribute significantly to the force-balance, therefore the assumption of hydrostatic equilibrium is least accurate in this part. Similarly to the values at specific optical depths, the median relative difference for this optical depth range are 0.25 for , 0.25 for and 0.26 for .
Figure 5. Components of the electric current vector of an individual pixel in the penumbra for an optical depth range of , giving the four different cases.
Since we know that around 0.01% of pixels show relative differences higher than 100 even with the mask, we wanted to investigate the current density profiles where these extremely large differences occur. According to Eq. (4), these extreme differences must be located where the solver output is strongly overestimating (in absolute value) compared to the simulation. For this purpose, we show the two electric current density (x-component) stratifications for the MHD and HE3D cases together with the relative difference over optical depth in Figure 6. Here, the residual curve is discontinuous, as we omit the optical depth where the MHD current density (in absolute value) is below the threshold. We can see that the highest peaks of residuals are mostly at smaller currents and locations with large gradients of electric current densities. The latter is particularly common, as even a shift of one pixel of the slope location means a very high relative difference even when the MHD value is large.
Figure 6. Top: for an optical depth for both the MHD and HE3D cases. Bottom: Residuals between the two curves shown above, where the aforementioned mask is applied, causing the discontinuities.
To compare the difference between the three components, we also calculated the cumulative distribution, summing up the residuals for all pixels cumulatively, starting from the lowest. Therefore, we know that having smaller differences will introduce a large contribution to the right side of the plot, causing the curve to rise faster. The resulting functions are shown in Figure 7 at . Other optical depths are given in the appendix, where it becomes clear that there are only slight differences between the three directions, which change between different optical depths. Therefore, there is no conclusive trend seen for any component with respect to being steadily better or worse than the others.
Figure 7. Cumulative distribution functions for the three different components, with the relative differences between HE3D and MHD at .
In addition to the accuracy of the currents with respect to the optical depth, we also investigated whether the solver output is able to place the currents at the correct relative height. To do so, we calculated the absolute difference of the height at which a specific optical depth is found compared to the height at which the reference optical depth is located: . Therefore, we looked at the distribution of height differences between different optical depth layers () for the MHD and HE3D cases (Fig. 8). While the distribution of relative height differences in the MHD simulation is wider than their counterparts for the HE3D case, the majority of height differences are similar. Thus, the electric currents are generally set at the correct heights relative to each other but with a smaller spread in heights. This difference is likely caused by the flattened pressure gradients in the horizontal directions. A striking property of the HE3D height difference distributions is their double-peaked shape. This structure is a consequence of having narrower distributions for three distinct populations associated with the quiet Sun, penumbra, and umbra (as shown in Fig. B.1) that show smaller differences for the umbral regions and larger ones for quiet Sun and penumbral areas. Interestingly, the spatial distribution of the absolute change in height difference between MHD and HE3D (; see Appendix C for an example) shows that the largest differences generally occur in the penumbra and intergranular lanes. However, the correlation between height differences and residuals of electric currents is minimal. Using the Pearson correlation coefficient as implemented in scipy.stats.pearsonr, we found a value of 0.06, which shows that the errors of electric currents do not coincide with .
Multiplicity of the solution
Up to this point, we included a significant amount of information, which would not be given in the input to the solver in real applications. For example, the MHD input has information about a force balance that is absent when considering physical parameters from spectropolarimetric inversions. To evaluate the performance of the method on a less favorable case, we compared the HE3D to the original HE3D, calculating the relative difference between the two solutions. The resulting for both are shown in Figure 9 at an optical depth of . Overall, the comparison shows a significant resemblance both in its spa partial distribution and regarding their amplitudes. We found median relative differences of 0.016, 0.020, and 0.020 for , , and , respectively, after excluding the masked pixels because they were below the previously mentioned noise threshold.
Figure 9. Map of solutions of , where the upper map shows the solution from the solver using the unchanged input. The lower map shows the solution obtained with the shifted input.
Therefore, while the two solutions are not exactly identical, they are indeed very close. In Figure 10, we plot the cumulative distribution of relative differences between the two solutions for the three optical depths, where the graph shows that the residuals exhibit a scarce dependence on the optical depth. The relative difference over the full optical depth range further emphasizes this fact, where we have a median of 0.017 for the x-component, 0.020 for the y-component and 0.024 for the z-component. From these numbers, we can conclude that the solution is unique, as the relative difference between the two solutions is an order of magnitude smaller than the relative difference between the solution and simulation.
Figure 10. Cumulative distribution of relative difference between the original and the shifted solution, plotted for three different optical depths.
Figure 11 presents the current components over the optical depth for a pixel in the penumbra (white square in Figure 3) showing that both curves look very similar for the most part and only seem to differ significantly from each other at very few depth-points, depending on which component. Clearly, these differences are much smaller than the difference to the simulation. As this does not affect the ability of the code to reproduce the larger structure of the currents, which can be seen in the maps in Figure 9, the solver does not appear to be affected by different starting points of the data.
Figure 11. Electric current components for an optical depth comparing both the original and shifted HE3D-run to the MHD simulation.
Impact of boundary condition
The method we developed and implemented in this study is sensitive to imposing a boundary condition on gas pressure, which we chose to be a constraint on the average pressure value for a specific iso-optical depth layer. To investigate the impact this boundary condition has on the result, we carried out two additional runs with smaller sub-fields, which are highlighted in Figure 3 by the green and cyan rectangles. The first, intermediate-sized, contains 256×512×256 pixels, whereas the second, which we call the small-sized, has 128 × 128 × 256 pixels. The values for the pressure reference were 9.8 · dyn cm for the large, 7.9 · dyn cm for the intermediate and 7.7 · dyn cm for the small FOV. We then restricted the analysis to the smallest field of view, the maps of of the three cases, and the simulation are shown in Figure 12 for an optical depth of .
Figure 12. Maps of for the three different sub-fields and the simulation. The simulation is shown in a), the large FOV in b), c) represents the intermediate and d) the small FOV. All maps are at .
We then calculated the relative difference of these runs compared to the simulation, finding a median of 0.40 for the large area, 0.38 for the intermediate, and 0.38 for the small FOV. All three cases have almost identical numbers and when looking at the maps, we can see the spatial features are also virtually indistinguishable. For the -component, the numbers are very similar with relative differences of 0.40 (large) and 0.38 for both intermediate and small. In the case of , we found median residuals of 0.28 in the case of the large FOV and 0.27 for the two smaller ones. The cumulative distribution functions of the residuals for all three areas are plotted in the graph of Figure 13. Although they show some small differences for very small residuals, all three curves become nearly indistinguishable beyond small residuals and reach 1 at a similar value, which means that all those chosen sub-fields perform very similarly with minimal deviations.
Figure 13. Cumulative distribution of relative difference of three differently sized FOVs compared to the simulation, specifically at an optical depth of
Extending the analysis to the optical depth range , we found that despite the very different gas pressure and density stratifications among the three runs (not shown), which is expected due to the 3D hydrostatic equilibrium hypothesis, the retrieved electric currents have similar accuracy to the original large area that was considered in the other tests. In numbers, the smaller FOVs had a median residual of 0.25, whereas the full area showed a median of 0.26. The same numbers were found for the -component. For the -component, the median relative difference was 0.21 for all three FOVs.
Impact of off-centre data
The implementation of the solver presented here assumes regular spatial sampling along the -, -, and -direction (not necessarily equal in all three directions). This is suitable for the setup we consider here, but in reality, the equal sampling is done along the detector elements rather than the solar surface and along the axis chosen to invert the data (optical depth, column mass, or line of sight geometrical distance). Since the inversion of spectropolarimetric data is usually performed on a node configuration, we could interpolate the inversion result in these nodes so that the atmosphere fulfills the regular spatial sampling required for the solver.
It is also possible to reformulate the matrix, A, so that the implementation of the derivative accounts for the actual irregular samplings, although this approach will make the calculation of the finite difference scheme more complex, as we need to move to higher orders to achieve the same precision. Instead, here we chose to explore the consequences of ignoring the above and just assume a regular spatial sampling for an irregular one in a pessimistic real-case scenario. Rather than evaluating an individual dx and dy per pixel and using it to estimate the pixel dependent magnetic field component derivatives, we will use the two extreme values of dx and dy that we will find in a FOV size similar to that of the CRISP-2 instrument ((Scharmer et al. 2026, 2008)) on the Swedish Solar Telescope (SST, (Scharmer et al. 2003)). As this is a high resolution instrument with one of the largest FOVs, the calculation will provide one of the more extreme differences in dx and dy. We assume a viewing angle , which is usually the maximum we should allow when applying the inversion code, as the plane-parallel atmosphere assumption will start to break when going further towards the limb. The result is that if the CRISP-instrument on the SST would have a spatial sampling of 12 km, it will vary between 11 and 14 km in the extremes.
Therefore, we ran the solver two times, changing the step size in both horizontal directions to 11 and 14 km, respectively, to account for the maximum possible difference that is to be expected. The results are then compared to the original HE3D-run, using the relative difference. The maps of the three runs with different pixel-sizes are shown in Figure 14, where the upper map shows the standard solver output, the middle shows the currents with the output using a dx/dy of 11 km, and the lower map the same but with 14 km. As in the previous tests, we show at an optical depth of . There, we found a median relative difference of 0.32 for 11 km and 0.32 for 14 km, compared to the 0.31 for the HE3D-run we already showed earlier. For the -component, the median relative difference using the 11 km step size was 0.38 and using 14 km was 0.39, compared to the 0.38 of the original run. Finally, for the vertical component, the case of the smaller step size showed a difference of 0.30 and a difference of 0.34 for the larger one; whereas the difference was 0.30 in the original HE3D case.
Figure 14. Map of for the solution with normal step size (upper), and the solutions using 11 (middle) and 14 (lower) km as the step size in both horizontal directions.
Looking at the cumulative distribution functions in Figure 15 confirms the minimal impact of the change in step size. In the plot all three functions are almost overlapping each other, with the two off-centre cases rising slightly slower due to their higher residuals. However, these differences are small compared to the overall deviation from the simulation.
Figure 15. Cumulative distribution of relative differences between the original solver output and the output with changed step sizes.
We also looked at the median relative difference over the whole optical depth range we also used in previous cases. Starting with , we found a median relative difference to the MHD case of 0.27, 0.26 for the 11 and 14 km cases, compared to 0.25 for the 12 km case. Following with , the resulting median difference was found to be 0.27 and 0.28 for the two step sizes compared to 0.25. In the case of , the calculation resulted in median residuals of 0.28 and 0.30, which is almost the same as 0.26 for the original HE3D output (see also Table 1).
| case | reference | |||
| HE3D | MHD | 0.31 (0.25) | 0.38 (0.25) | 0.30 (0.26) |
| MHD | MHD | 0.74 (0.60) | 0.75 (0.68) | 0.66 (0.63) |
| HE3D | MHD | 0.84 (0.69) | 0.85 (0.76) | 0.76 (0.70) |
| HE3D | MHD | 0.34 (0.25) | 0.41 (0.27) | 0.36 (0.28) |
| HE3D | HE3D | 0.016 (0.017) | 0.020 (0.020) | 0.020 (0.024) |
| HE3D | MHD | 0.40 (0.26) | 0.40 (0.26) | 0.28 (0.21) |
| HE3D | MHD | 0.38 (0.25) | 0.38 (0.25) | 0.27 (0.21) |
| HE3D | MHD | 0.38 (0.25) | 0.38 (0.25) | 0.27 (0.21) |
| HE3D | MHD | 0.32 (0.27) | 0.38 (0.27) | 0.30 (0.28) |
| HE3D | MHD | 0.32 (0.26) | 0.39 (0.28) | 0.34 (0.30) |
Table 1. All median relative differences both at an optical depth of and for the entire range of in brackets.
Divergence of the magnetic field
An additional parameter that can be estimated once we have solved the hydrostatic equilibrium in 3D is the magnetic field divergence. From a theoretical point of view the divergence of the magnetic field should vanish and it does so numerically in the simulation itself (using a fourth order centered differential scheme). However, assuming hydrostatic equilibrium in 3D to set the geometrical scale in the domain can potentially distort this property. In Figure 16, we present the PDF of the magnetic field divergence, which is evidently no longer 0. This is to be expected as assuming hydrostatic equilibrium in 3D involves some local stretching or compression of the physical property stratifications along the vertical direction and with that, also changes in the horizontal derivatives as the stretching or compressing will differ between pixels. Despite the long tails of the distribution, approximately 78% (99%) of the grid points considered here are characterised by G/km ( G/km). As we noted previously, this encouraging result is mostly due to the fact that magnetic field divergence is a parameter with local dependency and on that scale, the assumption of hydrostatic equilibrium in 3D is not that inaccurate.
Figure 16. Probability density function of the magnetic field divergence for .
Node-based atmosphere assumption
While the relative difference between the MHD and HE3D cases looks promising, this is a very idealised case where we feed the solver both a temperature and magnetic field components that are very detailed in the spatial 3D domain compared to what is realistic for an inversion, where the height is represented by a few nodes. To have a better insight into this situation, we consider an ideal case with a node-sampled atmosphere, MHD (i.e. the difference only comes from the representation of the atmosphere with nodes). The map of for is shown in the top graph of Figure 17. For the top of these nodes, the structures seem to be smeared out, and a lot of the small-scale features are no longer present. The larger structure is still replicated though and when looking at the top maps of Figure 4 and Figure 17, the locations that contain the largest amplitudes are the same. However, the amplitudes themselves do not match, where the nodes representation produces much smaller peaks. This trend is visible for all three components across different optical depths, and is further reinforced by looking at the distribution of relative differences. Looking at the median relative difference at this optical depth, we found 0.74 (x), 0.75 (y) and 0.66 (z) for the respective components. In general, these numbers are significantly higher than for the HE3D-run shown before.
Figure 17. Maps of for MHD (upper) and HE3D (lower). Both of the maps are at .
The cumulative distributions for are plotted in Figure 18, where we also showed the difference of the previously discussed HE3D case for reference. The cumulative distributions show that the solver output is significantly closer to the simulation than the node-sampled atmosphere.
Figure 18. Cumulative distribution function of relative differences between for different cases at .
Examining the behaviour over the optical depth range shown in Figure 5, it is clear that the node-sampled atmosphere can only represent a very limited amount of the structure present in the currents. Most of the strong peaks are heavily damped and a lot of the small-scale features are entirely missing, especially compared to the performance of the HE3D output. The median relative difference over the range of was found to be 0.60, 0.68, and 0.63 for , , and , respectively, which are also consistently higher than for HE3D.
Although the number of nodes employed will have a clear impact, it is evident from these results that the currents obtained after assuming a node-based model representation are different. That is the reason why we investigate the impact of the method (HE3D) implemented in this work, on these interpolated parameters as input for the solver. The map of is shown on the lower panel of Figure 17 for the same optical depth of . In Figure 18, the cumulative distribution of relative errors compared to the simulation, but also the difference between the node sampled atmosphere and HE3D (i.e. output versus input) is shown.
We can see that the output using the interpolated input reproduces the structure quite well, although it naturally shows the same smearing as well as the significantly lower amplitudes as the input map above. A look at the cumulative distribution confirms this, as HE3D performs only slightly worse than MHD when comparing to the simulation. Additionally, when calculating the relative difference between the two, marked in the plot by the violet curve, we can see that it is very similar to the original solver output HE3D to MHD comparison (black). The latter is shown by looking at the median value for the different cases: for the comparison to MHD, we find values of 0.84, 0.85 and 0.76 for , and . If we compare them to the node-sampled input, the relative differences are 0.34 (x), 0.41 (y), and 0.36 (z). Following up by looking at the behaviour in Figure 5, we see that HE3D is close to the node-sampled MHD-atmosphere, but suffers the same shortcomings. Compared to the MHD-case, the small-scale features are now missing, but the large-scale structure is successfully reproduced. Comparing to MHD, the difference is reasonably small, and the areas with the largest current amplitudes are the same. We also looked at the median relative difference of the data cube within the optical depth range, where we found a difference of 0.69, 0.76, and 0.70 for x-,y-, and z-component. In doing the comparison with the node-based atmosphere input, we find numbers of 0.25 for , 0.27 for , and 0.28 for . From these results, we conclude that the method performs similarly when provided with either a node-based atmospheric representation or a much more spatially detailed input.
Discussion
Table 1 shows a summary of the median relative error values from the various runs presented above. The results show promise, as the difference is low enough to allow us to obtain good constraints on the distribution of heating terms based on . Although the amplitudes of the peaks are off compared to the simulation, the regions that contain the strongest currents are the same, which allows us to determine the areas where heating takes place and provide lower limit constraints on dissipative heating rates. In possible future applications of the presented method to observational data, the ground truth will be unknown. Therefore, the mask to exclude noise can only be applied to the end result of the solver. To test the impact of this, we also calculated the error with the mask determined by the HE3D case numbers, not MHD. The median values at were 0.35, 0.40 and 0.28. Over the optical depth range of , the median residuals were 0.27, 0.32 and 0.26, which are very similar to the ones in Table 1 (i.e. the statistical performance is still similar).
We also saw that the method performed similarly well for configurations aiming to represent realistic cases more closely, such as the lower depth resolution used in inversion codes. The main factor that sets the accuracy of the reconstruction of the electric current density vector is the mapping between optical depth to geometrical distance, which does actually come from the assumption of hydrostatic equilibrium in 3D. This relation appears due to the fact that the spectra are sensitive to the various physical parameters in optical depth and its transformation to geometrical distance comes from absorption occurring along the path traveled by radiation.
Although we have not considered radiation explicitly in this work, it has entered into the method as we impose that temperature has to be kept the same at each optical depth point. In doing so, we enforce that the spectra synthesized from any of the runs is the same. This is the main reason behind the differences we determined in Sect. 3.2. In that case, the only reason for the difference in the electric current density estimation comes from the local expansion and compression of the physical parameters stratification associated with the change in how the opacity occurs. The fact that this expansion and contraction (at least in the optical depth range ) is not extreme is the reason why this method achieves such acceptable electric current density estimation. This surprising result is due to the fact that the electric current density calculation depends on physical parameters only locally, and that is why this method is reasonably good at estimating electric current densities. From Fig. 8, we can also conclude that the current densities are generally placed at the correct relative heights, with only small differences. Similarly, we have seen that the assumption of hydrostatic equilibrium in 3D induces a non-zero magnetic field divergence (as compared to the simulation), but the deviations are small with more than 70% of the grid points with G/km. As for the electric current density estimation, this is possible due to the local dependency of this parameter on the magnetic field vector. However, if we consider other parameters that are global in nature (such as the Wilson depression; see e.g. in Fig. D.1), then this method cannot retrieve any meaningfully acceptable result, as it strongly modifies the pressure balance over the entire volume.
One of the major advantages of this method is that it suffers little impact from external constraints. It does not rely on disambiguating the magnetic field vector, which is still challenging to perform for the chromosphere and it does not require having the magnetic field inferred for large FOV. Moreover, it relies on a single boundary condition that has little impact on the result, regardless of the size of the FOV or its boundaries. Finally, the method converges to equivalent solutions independently of the initial state.
We validated these results over the range of , meaning that this method potentially enables the inference of electric current densities from the photosphere to the chromosphere. We have seen that the method recovers a magnetic-field divergence close to zero without using the magnetic field itself to determine the geometry. This property could be used to further constrain the magnetic field 180° ambiguity (Metcalf et al. [19], and references therein). More generally, the ability to generally extract the distances between optical depth layers with reasonable accuracy could also prove useful in other applications for determining the geometrical locations of other physical phenomena such as enhanced radiative losses events.
With the application of the method to observational data in mind, we evaluated the effect of non-uniform step size introduced when analyzing data taken away from the disc centre and found that it has less of an impact than other sources of uncertainty or limitations tested here. It is important to emphasize that even though we have evaluated the performance of the method in some set-ups that aimed at mimicking realistic scenarios, its future application to observational data ought to consider additional instrument-specific effects. The accuracy of the reconstructed atmospheric parameters will depend on the instrument and observational setup, including the selected spectral lines, integration time, spectral and spatial resolution, and instrumental systematics. Data-reduction procedures and inversion choices will introduce further uncertainties in the atmospheric parameters used as input to the method. It is therefore unrealistic to expect a similar accuracy to what is shown in this work with the input from the simulation. As a final remark, while the method does need significant computational expense on its own, its computational cost is several orders of magnitude lower than what is needed by the inversion code.
Conclusions and outlook
In this paper, we present a method to solve the hydrostatic equilibrium equations in 3D in a Cartesian grid. We developed this solver to be able to estimate electric currents, which require the calculation of spatial derivatives of the magnetic field. Specifically, we designed it to be applied on the inferred physical parameters of depth-stratified spectropolarimetric inversion codes as a final post-processing step. We used a snapshot from an r-MHD simulation to test the validity of our approach.
Starting with the general performance of the method, we found that the method is able to retrieve around 50% of the grid points with less than 30% of relative difference. Furthermore, it performs similarly in cases where the amount of information in the vertical stratification of the physical properties is reduced. This case is more similar to what common depth-stratified inversion codes infer. We also ascertained that the solution is unique (within numerical precision), regardless of the amount of spatial information contained in the input (i.e. if the input has horizontal force balance or not), as well as the impact of using different boundary conditions for the gas pressure. Furthermore, we have tested real-world scenarios, both addressing the effect of having observations out of the disc centre and the usage of nodes to represent the state of the atmosphere (most common approach in spectropolarimetric observations).
Overall, these more realistic applications maintain a similar performance of the implemented method, thereby promising the determination of electric current densities (lower boundaries) and, by extension, stemming lower limits of dissipative heating terms. The code will now be implemented into the STockholm inversion Code STiC (de la Cruz Rodríguez et al. 2019; de la Cruz Rodríguez 2019) as an optional module, where we plan to apply it to spectropolarimetric observations of the chromosphere and use the final output to estimate the ohmic heating and ambipolar diffusion terms. While we successfully tested the code assuming hydrostatic equilibrium in three dimensions, in a future paper, we will consider implementing other approximations that would allow us to infer additional information.
Acknowledgements. The Institute for Solar Physics is supported by a grant for research infrastructures of national importance from the Swedish Research Council (registration number 2021-00169). APY acknowledges support from the Swedish Research Council (grant 2023-03313). This project has been funded by the European Union through the European Research Council (ERC) under the Horizon Europe program (MAGHEAT, grant agreement 101088184). We also thank Mathias Rempel for making his simulation publicly available and the volunteers that keep developing the Eigen library. We also wish to thank the referee for the comments and suggestions to improve this work.
Electric current spatial and cumulative distributions at additional optical depths
Accuracy of the solver
Figures A.1 to A.8 show maps of , , and for the comparison of the MHD and HE3D cases at . These are complementary to the results described in Sect. 3.2.
Figure A.1. Map of solutions of , the upper case is the MHD simulation, the lower is the solution from the solver, at .
Figure A.2. Same as Fig. A.1 but for .
Figure A.3. Same as Fig. A.1 but for .
Figure A.4. Map of solutions of , the upper case is the MHD simulation, the lower is the solution from the solver, at .
Figures A.9 and A.10 show the cumulative distributions of relative differences for all three components at and , respectively. The median relative differences for are 0.28 (x), 0.30 (y), 0.28 (z) and 0.27 (x), 0.37 (y), 0.27 (z) for .
Figure A.5. Same as Fig. A.4 but for .
Figure A.6. Map of solutions of , the upper case is the MHD simulation, the lower is the solution from the solver, at .
Figure A.7. Same as Fig. A.6 but for .
Figure A.8. Same as Fig. A.6 but for .
Figure A.9. Cumulative distribution functions for the three different components, with the relative differences between HE3D and MHD at .
Figure A.10. Cumulative distribution functions for the three different components, with the relative differences between HE3D and MHD at .
Heights of optical depth layers
Figure B.1. Distribution of height differences with for cases of MHD and HE3D, divided into quiet Sun, penumbra and umbra
Figure B.1 shows the distribution of distances between optical depth layers similar to Fig. 8 with , but now divided into quiet Sun, penumbra and umbra to highlight the differences between these regions.
Spatial distribution of heights of optical depth layers
Figure C.1. Map of change in height differences for the HE3D and MHD cases.
Figure C.1 on the other hand shows the spatial distribution of . The largest deviations are found in the intergranular lanes and penumbra, which is expected due to the fact that terms neglected in Eq. (3) will play a strong role in these parts.
Wilson depression
Figure D.1. Maps of height in kilometers at , i.e. Wilson depression for the MHD (upper) and HE3D (lower) case.
Figure D.1 shows the Wilson depression, which is a map of the absolute height within the simulation domain at an optical depth of , for both MHD and HE3D. As discussed in Sect. 4, the HE3D case fails to recover the global structure that is present in the simulation, though the granules in the quiet sun are visible.
References
- [2]Arramy, D., de la Cruz Rodríguez, J., Pastor Yabar, A., & Leenaarts, J. 2026, A&A
- [3]Athay, R. G. 1976, The solar chromosphere and corona: Quiet sun, Vol. 53
- [4]Borrero, J. M., Pastor Yabar, A., Rempel, M., & Ruiz Cobo, B. 2019, A&A, 632, A111
- [5]Brady, C. S. & Arber, T. D. 2016, ApJ, 829, 80
- [6]Carlsson, M., De Pontieu, B., & Hansteen, V. H. 2019, A&A, 57, 189
- [8]de la Cruz Rodríguez, J., De Pontieu, B., Carlsson, M., & Rouppe van der Voort, L. H. M. 2013, ApJ, 764, L11
- [10]de la Cruz Rodríguez, J. & van Noort, M. 2017, Space Sci. Rev., 210, 109
- [11]del Toro Iniesta, J. C. & Ruiz Cobo, B. 2016, Living Reviews in Solar Physics, 13, 4
- [12]Díaz Baso, C. J., de la Cruz Rodríguez, J., & Leenaarts, J. 2021, A&A, 647, A188
- [13]Guennebaud, G., Jacob, B., et al. 2010, Eigen, https://libeigen.gitlab.io
- [14]Khomenko, E. & Collados, M. 2012, ApJ, 747, 87
- [15]Lagg, A., Lites, B., Harvey, J., Gosain, S., & Centeno, R. 2017, Space Sci. Rev., 210, 37
- [16]Leenaarts, J. 2020, Living Reviews in Solar Physics, 17, 3
- [18]Louis, R. E., Prasad, A., Beck, C., Choudhary, D. P., & Yalim, M. S. 2021, A&A, 652, L4
- [19]Metcalf, T. R., Leka, K. D., Barnes, G., et al. 2006, Sol. Phys., 237, 267
- [20]Milić, I. & van Noort, M. 2018, A&A, 617, A24
- [21]Morosin, R., de la Cruz Rodríguez, J., Díaz Baso, C. J., & Leenaarts, J. 2022, A&A, 664, A8
- [22]Morton, R. J., Verth, G., Jess, D. B., et al. 2012, Nature Communications, 3, 1315














