### Refine

#### Keywords

Relative magnetic helicity, as a conserved quantity of ideal magnetohydrodynamics, has been highlighted as an important quantity to study in plasma physics. Due to its nonlocal nature, its estimation is not straightforward in both observational and numerical data. In this study we derive expressions for the practical computation of the gauge-independent relative magnetic helicity in three-dimensional finite domains. The derived expressions are easy to implement and rapid to compute. They are derived in Cartesian coordinates, but can be easily written in other coordinate systems. We apply our method to a numerical model of a force-free equilibrium containing a flux rope, and compare the results with those obtained employing known half-space equations. We find that our method requires a much smaller volume than half-space expressions to derive the full helicity content. We also prove that values of relative magnetic helicity of different magnetic fields can be compared with each other in the same sense as free-energy values can. Therefore, relative magnetic helicity can be meaningfully and directly compared between different datasets, such as those from different active regions, but also within the same dataset at different times. Typical applications of our formulae include the helicity computation in three-dimensional models of the solar atmosphere, e.g., coronal-field reconstructions by force-free extrapolation and discretized magnetic fields of numerical simulations.

Context. For magnetically driven events, the magnetic energy of the system is the prime energy reservoir that fuels the dynamical evolution. In the solar context, the free energy (i.e., the energy in excess of the potential field energy) is one of the main indicators used in space weather forecasts to predict the eruptivity of active regions. A trustworthy estimation of the magnetic energy is therefore needed in three-dimensional (3D) models of the solar atmosphere, e. g., in coronal fields reconstructions or numerical simulations.
Aims. The expression of the energy of a system as the sum of its potential energy and its free energy (Thomson's theorem) is strictly valid when the magnetic field is exactly solenoidal. For numerical realizations on a discrete grid, this property may be only approximately fulfilled. We show that the imperfect solenoidality induces terms in the energy that can lead to misinterpreting the amount of free energy present in a magnetic configuration.
Methods. We consider a decomposition of the energy in solenoidal and nonsolenoidal parts which allows the unambiguous estimation of the nonsolenoidal contribution to the energy. We apply this decomposition to six typical cases broadly used in solar physics. We quantify to what extent the Thomson theorem is not satisfied when approximately solenoidal fields are used.
Results. The quantified errors on energy vary from negligible to significant errors, depending on the extent of the nonsolenoidal component of the field. We identify the main source of errors and analyze the implications of adding a variable amount of divergence to various solenoidal fields. Finally, we present pathological unphysical situations where the estimated free energy would appear to be negative, as found in some previous works, and we identify the source of this error to be the presence of a finite divergence.
Conclusions. We provide a method of quantifying the effect of a finite divergence in numerical fields, together with detailed diagnostics of its sources. We also compare the efficiency of two divergence-cleaning techniques. These results are applicable to a broad range of numerical realizations of magnetic fields.

Coronal mass ejections (CMEs) erupt and expand in a magnetically structured solar corona. Various indirect observational pieces of evidence have shown that the magnetic field of CMEs reconnects with surrounding magnetic fields, forming, e.g., dimming regions distant from the CME source regions. Analyzing Solar Dynamics Observatory (SDO) observations of the eruption from AR 11226 on 2011 June 7, we present the first direct evidence of coronal magnetic reconnection between the fields of two adjacent active regions during a CME. The observations are presented jointly with a data-constrained numerical simulation, demonstrating the formation/intensification of current sheets along a hyperbolic flux tube at the interface between the CME and the neighboring AR 11227. Reconnection resulted in the formation of new magnetic connections between the erupting magnetic structure from AR 11226 and the neighboring active region AR 11227 about 200 Mm from the eruption site. The onset of reconnection first becomes apparent in the SDO/AIA images when filament plasma, originally contained within the erupting flux rope, is redirected toward remote areas in AR 11227, tracing the change of large-scale magnetic connectivity. The location of the coronal reconnection region becomes bright and directly observable at SDO/AIA wavelengths, owing to the presence of down-flowing cool, dense (1010 cm(-3)) filament plasma in its vicinity. The high-density plasma around the reconnection region is heated to coronal temperatures, presumably by slow-mode shocks and Coulomb collisions. These results provide the first direct observational evidence that CMEs reconnect with surrounding magnetic structures, leading to a large-scale reconfiguration of the coronal magnetic field.

There is a recurring question in solar physics regarding whether or not electric currents are neutralized in active regions (ARs). This question was recently revisited using three-dimensional (3D) magnetohydrodynamic (MHD) numerical simulations of magnetic flux emergence into the solar atmosphere. Such simulations showed that flux emergence can generate a substantial net current in ARs. Other sources of AR currents are photospheric horizontal flows. Our aim is to determine the conditions for the occurrence of net versus neutralized currents with this second mechanism. Using 3D MHD simulations, we systematically impose line-tied, quasi-static, photospheric twisting and shearing motions to a bipolar potential magnetic field. We find that such flows: (1) produce both direct and return currents, (2) induce very weak compression currents-not observed in 2.5D-in the ambient field present in the close vicinity of the current-carrying field, and (3) can generate force-free magnetic fields with a net current. We demonstrate that neutralized currents are in general produced only in the absence of magnetic shear at the photospheric polarity inversion line-a special condition that is rarely observed. We conclude that. photospheric flows,. as magnetic flux emergence, can build up net currents in the solar atmosphere, in agreement with recent observations. These results thus provide support for eruption models based on pre-eruption magnetic fields that possess a net coronal current.