$\boldsymbol{P}$ (and $\psi$) may remain constant if changes in
$\hat{\boldsymbol{n}}\cdot\boldsymbol{P}\left(\boldsymbol{J}^{*}\right)$ and
$\hat{\boldsymbol{n}}\cdot\boldsymbol{P}\left(\boldsymbol{J}\right)$ cancel
out or changes in
$\hat{\boldsymbol{n}}\cdot\boldsymbol{P}\left(\boldsymbol{J}^{*}\right)$ and
$\hat{\boldsymbol{n}}\cdot\boldsymbol{P}\left(\boldsymbol{J}\right)$ are
balanced overall by the changes in mutual energy—changes in the angle between
$\boldsymbol{P}\left(\boldsymbol{J}^{*}\right)$ and
$\boldsymbol{P}\left(\boldsymbol{J}\right)$ in $\mathcal{V}$. However, the
former cancellation requires detailed balance between changes in coronal
$\boldsymbol{J}$ and convection zone $\boldsymbol{J}^{*}$ currents—collusion
between $\mathcal{V}$ and ${\mathcal{V}^{*}}$! The three individual surface
integrals may be tracked in observations and simulations to determine how the
_origin_ of the flux threading the photosphere changes during eruptions and
how a detailed balance is maintained if the photospheric flux remains constant
during explosive coronal phenomena. These surface terms provide a definitive
test: is the convection zone responding to replace flux lost during the
eruption or is the corona/chromosphere system responding to shield the
photosphere from losing flux during the eruption?

##  7 Summary and Conclusions: Implications for Modeling and Observation

This work has described the attribution of magnetic fields to current systems
for astrophysical problems. A common approach in solar physics is to decompose
a general magnetic field in $\mathcal{V}$ into a potential field
$\boldsymbol{P}$ that threads the boundary ${\partial\mathcal{V}}$ with flux
and a component $\boldsymbol{B}_{\mathrm{cl}}$ that closes on itself within
the volume $\mathcal{V}$. Both of these components can have their physical
origin in currents $\boldsymbol{J}$ in the internal volume $\mathcal{V}$ and
$\boldsymbol{J}^{*}$ in the external universe ${\mathcal{V}^{*}}$. Thus, this
representation $\left(\boldsymbol{P},\boldsymbol{B}_{\mathrm{cl}}\right)$,
while mathematically convenient, entangles magnetic field that has its
physical origin inside the volume of interest $\mathcal{V}$ with magnetic
field that has its physical origin outside the volume of interest in the
external universe ${\mathcal{V}^{*}}$. In particular, the naive implementation
of the potential magnetic field $\boldsymbol{P}$ creates a cognitive
dissonance that $\boldsymbol{P}$ is potential and curl free
$\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{P}=0$ for
$\boldsymbol{x}\in\mathcal{V}$ but physically generated by currents
$\boldsymbol{J}$ in $\mathcal{V}$ (see Figure 1 and discussion in §1,
Introduction). Alternatively, there can be magnetic field in $\mathcal{V}$
produced by currents $\boldsymbol{J}^{*}$ in ${\mathcal{V}^{*}}$ and magnetic
field in ${\mathcal{V}^{*}}$ produced by currents $\boldsymbol{J}$ in
$\mathcal{V}$ when no _net_ magnetic flux threads ${\partial\mathcal{V}}$, the
boundary between $\mathcal{V}$ and ${\mathcal{V}^{*}}$ (see Figure 2 and
discussion in §3). We have described how these non sequiturs may be resolved
by attributing the magnetic field to its origin in $\boldsymbol{J}$ or
$\boldsymbol{J}^{*}$ first and then decomposing these fields into potential
$\boldsymbol{P}\left(\boldsymbol{J}\right)$ and
$\boldsymbol{P}\left(\boldsymbol{J}^{*}\right)$ and closed
$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}\right)$ and
$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*}\right)$ components.

As presented in §2, the computation of the magnetic field produced by known
internal and unknown external current sources,
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J};t,\boldsymbol{x}\right)$ and
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$,
respectively, requires the computation of a Biot-Savart integral for
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J};t,\boldsymbol{x}\right)$
which establishes cause and effect between the internal current
$\boldsymbol{J}$ and the corresponding magnetic field. This presentation
intentionally emphasized this fundamental and intuitive formulation. However,
Biot-Savart integrals presented to compute
$\boldsymbol{A}\left(\boldsymbol{J};t,\boldsymbol{x}\right)$ and the
corresponding field
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J};t,\boldsymbol{x}\right)$ are
computationally intensive for sources $\boldsymbol{J}$ in $\mathcal{V}$ and
often cannot be performed for
$\boldsymbol{A}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$ and
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
because $\boldsymbol{J}^{*}$ is not known in ${\mathcal{V}^{*}}$. From a
practical perspective, constructing the magnetic field produced by external
current sources
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
via the Helmholtz decomposition first will be more computationally efficient
(see §2). This is particularly advantageous when only the magnetic energy is
of interest, i.e., when the vector potentials
$\boldsymbol{A}\left(\boldsymbol{J};t,\boldsymbol{x}\right)$ and
$\boldsymbol{A}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$ are not
needed. This approach involves the evaluation of only surface integrals
instead of convolutions over the entire volume of interest $\mathcal{V}$. Once
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
has been computed, the magnetic field produced by internal currents may then
be constructed by subtraction
$\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J};t,\boldsymbol{x}\right)=\boldsymbol{B}-\boldsymbol{B}_{\mathrm{BS}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$,
thereby establishing attribution of the magnetic field to a current system in
a particular domain, i.e., $\boldsymbol{J}$ in $\mathcal{V}$ or
$\boldsymbol{J}^{*}$ in ${\mathcal{V}^{*}}$, respectively. The potential and
closed components of these magnetic fields may then be constructed by standard
methods (see §4 and §5). The last computationally intensive piece is to
construct the closed vector potentials
$\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J};t,\boldsymbol{x}\right)$ and
$\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$.
We provide direct approaches in §5 and some additional approaches for the
latter vector potential in Appendix B. Note that the general results of this
work are gauge agnostic, and so our results are not tied in any way to
particular computational approaches or choices of gauge.

Previous work demonstrated that the relative magnetic helicity in Equation
(18) from Berger & Field and Finn & Antonsen (1985) may be decomposed into the
gauge invariant ‘self’ and ‘mutual’ helicities in Equation (24) from Berger
(1999, 2003). This decomposition uses the terms ‘self’ to describe the linking
of closed field $\boldsymbol{B}_{\mathrm{cl}}$ with itself,
$\boldsymbol{A}_{\mathrm{cl}}$, in $\mathcal{V}$ and ‘mutual’ to describe the
linking of closed field $\boldsymbol{B}_{\mathrm{cl}}$ with the open field
$\boldsymbol{A}_{\mathrm{P}}$ in $\mathcal{V}$. Longcope & Malanushenko (2008)
point out that these definitions of ‘self’ and ‘mutual’ helicity are
conceptually distinct from the ‘self’ and ‘mutual’ helicity of _isolated_ flux
tubes where the ‘self’ helicity depends on the internal field of each isolated
flux tube and the ‘mutual’ helicity describes how pairs of tubes are
interlinked. Longcope & Malanushenko (2008) develop further definitions of
“unconfined self helicity” and “additive self helicity” based on relative
magnetic helicity in sub-volumes of $\mathcal{V}$ (See also Malanushenko et
al., 2009; Valori et al., 2020).

The novel magnetic field decompositions described in this paper produce
natural extensions of relative magnetic helicity and magnetic energy that
incorporate the origin of the magnetic fields in currents $\boldsymbol{J}$ in
the domain of interest $\mathcal{V}$ or $\boldsymbol{J}^{*}$ in the external
domain ${\mathcal{V}^{*}}$ beyond the boundary ${\partial\mathcal{V}}$. As
such, we propose new conceptual definitions of self and mutual helicity in
$\mathcal{V}$ that are attributed to their current sources $\boldsymbol{J}$
and $\boldsymbol{J}^{*}$ in $\mathcal{V}$ and ${\mathcal{V}^{*}}$
respectively. We have extended Berger et al.’s (1998; 2003) representation to
eight gauge invariant terms that simultaneously describe the origin of the
magnetic fields in $\boldsymbol{J}$ and $\boldsymbol{J}^{*}$ and how the field
components defined by ${\partial\mathcal{V}}$, e.g.,
$\left(\boldsymbol{A}_{\mathrm{cl}},\boldsymbol{B}_{\mathrm{cl}}\right)$ and
$\left(\boldsymbol{A}_{\mathrm{P}},\boldsymbol{B}_{\mathrm{cl}}\right)$, link
in relative magnetic helicity. Seven of these terms are independent. The sum
of the eight terms recovers previous results in Equation (24). Combinations of
these terms motivate the new definitions of self helicity and mutual helicity:
1. internal relative helicity
$\mathcal{H}\left(\boldsymbol{J},\boldsymbol{J}\right)$ — the self helicity in
$\mathcal{V}$ of magnetic fields produced by currents $\boldsymbol{J}$ in
$\mathcal{V}$;  2. external relative helicity
$\mathcal{H}\left(\boldsymbol{J}^{*},\boldsymbol{J}^{*}\right)$ — the self
helicity in $\mathcal{V}$ of magnetic fields produced by currents
$\boldsymbol{J}^{*}$ in ${\mathcal{V}^{*}}$;  3. internal-external relative
helicity
$\mathcal{H}\left(\boldsymbol{J},\boldsymbol{J}^{*}\right)$+$\mathcal{H}\left(\boldsymbol{J}^{*},\boldsymbol{J}\right)$
— the mutual helicity in $\mathcal{V}$ of magnetic fields produced by currents
$\boldsymbol{J}$ in $\mathcal{V}$ with magnetic fields produced by currents
$\boldsymbol{J}^{*}$ in ${\mathcal{V}^{*}}$. Tracking the evolution of the
seven independent terms will provide insight into how magnetic linkages change
during fundamental stellar processes such as flux emergence, coronal heating,
and eruptive phenomena. However, tracking the evolution of these terms
requires access to dense magnetic field measurement presently only available
in simulations and modeling Pariat et al. (2017). Nonetheless, further
consideration of the helicity transport across boundaries in terms of this
framework may reveal observables that can be computed from photospheric
observations alone (see the helicity transport representation developed in
Schuck & Antiochos, 2019). We have also decomposed the magnetic energy in a
volume into terms that describe the origin of the magnetic fields. This
representation results directly in terms that may be computed from surface
observations alone, and when combined with new theoretical and computational
techniques Schuck et al. (2022), it has the potential to reveal the interplay
between the photosphere, convection zone, and corona during solar eruptive
phenomena.

The concept of cause and effect from currents to magnetic fields outlined in
this work has broad application to solar physics. Attributing changes in
current systems that lead to changes in magnetic structure has the potential
to reveal causality in ‘sympathetic’ solar eruptions Bumba & Klvana (1993).
Furthermore, combining the attribution of currents in simulations presented
here with new attribution techniques, such as CICCI, applicable to the
photospheric surface has the potential to unambiguously connect the
photospheric/chromospheric magnetic fingerprints of eruptive phenomena to
coronal current systems, e.g., the photospheric fingerprints of the formation
of the flare current sheet in the corona.

We often ignore the interaction between the external universe
${\mathcal{V}^{*}}$ or equivalently boundary sources on
${\partial\mathcal{V}}$ and the evolution of magnetic fields in our volume of
interest $\mathcal{V}$. However, the current sources in ${\mathcal{V}^{*}}$
are often major players in the evolution of the magnetic field in modeling the
evolution in $\mathcal{V}$. Connecting the magnetic field with its origin in
currents provides a deeper and clearer understanding of the evolution of
astrophysical plasmas and MHD simulations.

The authors thank the referee. The authors recognize useful conversation with
James Leake, Lars Daldorf, Dana Longcope, and Brian Welsch. Peter W. Schuck
dedicates his work on this paper to Henry J. Schuck. The authors acknowledge
support from the NASA Living with a Star (H-LWS) Focused Science Topic
programs: NNH21ZDA001N-LWS “The Origin of the Photospheric Magnetic Field:
Mapping Currents in the Chromosphere and Corona” (Schuck, Linton),
NNH17ZDA001N-LWS “Developing Vector Magnetic Maps from SDO/HMI that can Drive
Space Weather Models” (Schuck), NNH16ZDA001N-LWS “Implementing and Evaluating
a Vector-Magnetogram-Driven Magnetohydrodynamic Model of the Magnetic Field in
the Low Solar Atmosphere” (Linton, Schuck), and NNH17ZDA001N-LWS
“Investigating Magnetic Flux Emergence with Modeling and Observations to
Understand the Onset of Major Solar Eruptions” (Linton, Schuck),
NNH17ZDA001N-LWS “Physics-based modeling of the magnetosphere-ionosphere-
thermosphere-mesosphere system under Carrington-scale solar driving: response
modes, missing physics and uncertainty estimates” (Schuck); the NASA
Supporting Research (H-SR) programs: NNH18ZDA001N-HSR “Investigating Magnetic
Flux Rope Emergence as the Source of Flaring Activity in Delta-Spot Active
Regions” (Linton); and the Office of Naval Research (Linton); and from the
NASA Internal Science Funding Model (H-ISFM) program “Magnetic Energy Buildup
and Explosive Release in the Solar Atmosphere” (Schuck).

##  Appendix A Woltjer’s Boundary Condition

The Woltjer (1958) boundary condition for a magnetically closed system
$\mathcal{V}$ is $\partial\boldsymbol{A}/\partial t|_{\partial\mathcal{V}}=0$.
This boundary condition certainly preserves the helicity in Equation (16), but
its complete physical consequences are not manifest and so we clarify them
below.

From Equation (16), the necessary and sufficient condition for helicity
invariance in the Gibbs gauge is:

$\frac{dH}{dt}=\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\boldsymbol{A}\boldsymbol{\times}\frac{\partial\boldsymbol{A}}{\partial
t}=0.$ (A1)

The incomplete Gibbs gauge is defined by a transformation from a potential
pair $\left(\varphi^{\prime},\boldsymbol{A}^{\prime}\right)$ to
$\left(0,\boldsymbol{A}\right)$ via

$\displaystyle\boldsymbol{A}=$
$\displaystyle\boldsymbol{A}^{\prime}+\boldsymbol{\nabla}\Lambda^{\prime},$
(A2a) $\displaystyle\varphi=$
$\displaystyle\varphi^{\prime}-\frac{1}{c}\,\frac{\partial\Lambda^{\prime}}{\partial
t}=0,$ (A2b) where
$\Lambda^{\prime}=c\,\int\limits_{-\infty}^{t}{dt}\,\varphi^{\prime},$ (A2c)

and

$\displaystyle\boldsymbol{E}=$
$\displaystyle-\frac{1}{c}\,\frac{\partial\boldsymbol{A}^{\prime}}{\partial
t}-\boldsymbol{\nabla}\varphi^{\prime}=-\frac{1}{c}\,\frac{\partial\boldsymbol{A}}{\partial
t},$ (A3a) $\displaystyle\boldsymbol{B}=$
$\displaystyle\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{A}^{\prime}=\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{A}.$
(A3b)

Rewriting Equation (A1) in an arbitrary gauge

$\frac{dH}{dt}=\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\boldsymbol{A}\boldsymbol{\times}\frac{\partial\boldsymbol{A}}{\partial
t}+\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\boldsymbol{A}\boldsymbol{\times}\frac{\partial\boldsymbol{\nabla}\Lambda}{\partial
t}+\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\boldsymbol{\nabla}\Lambda\boldsymbol{\times}\frac{\partial\boldsymbol{A}}{\partial
t}=0,$ (A4)

and using the vector identity

$\boldsymbol{\nabla}\boldsymbol{\times}\left(\phi\,\boldsymbol{a}\right)=\boldsymbol{\nabla}\phi\boldsymbol{\times}\boldsymbol{a}+\phi\,\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{a}$
(A5)

with Equation (1b) this becomes

$\frac{dH}{dt}=\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\boldsymbol{A}\boldsymbol{\times}\frac{\partial\boldsymbol{A}}{\partial
t}+\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\boldsymbol{\nabla}\boldsymbol{\times}\left(\Lambda\,\frac{\partial\boldsymbol{A}}{\partial
t}-\frac{\partial\Lambda}{\partial
t}\,\boldsymbol{A}\right)+\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\cdot\left(\frac{\partial\Lambda}{\partial
t}\,\boldsymbol{B}-\Lambda\,\frac{\partial\boldsymbol{B}}{\partial t}\right).$
(A6)

The second surface integral involving the curl is identically zero and the
third surface integral is zero for an arbitrary gauge transformation if
$\hat{\boldsymbol{n}}\cdot\boldsymbol{B}|_{\partial\mathcal{V}}=0$. Thus, the
boundary condition
$\hat{\boldsymbol{n}}\cdot\boldsymbol{B}|_{\partial\mathcal{V}}=0$ to ensure
gauge invariance is an implicit assumption in Equation (16).

The well-known jump conditions on the observable electric and magnetic fields
across a boundary ${\partial\mathcal{V}}$ are: (see pp. 19-20 in Jackson,
1975)

$\displaystyle\left\llbracket{\hat{\boldsymbol{n}}\cdot\boldsymbol{E}}\right\rrbracket=$
$\displaystyle 4\,\pi\,\sigma,\qquad$
$\displaystyle\left\llbracket{\hat{\boldsymbol{n}}\boldsymbol{\times}\boldsymbol{E}}\right\rrbracket=$
$\displaystyle 0,$ (A7a)
$\displaystyle\left\llbracket{\hat{\boldsymbol{n}}\cdot\boldsymbol{B}}\right\rrbracket=$
$\displaystyle 0,\qquad$
$\displaystyle\left\llbracket{\hat{\boldsymbol{n}}\boldsymbol{\times}\boldsymbol{B}}\right\rrbracket=$
$\displaystyle\frac{4\,\pi}{c}\,\boldsymbol{K},$ (A7b) where $\sigma$ is the
surface charge, $\boldsymbol{K}$ is the surface current, and
$\left\llbracket{a}\right\rrbracket=\left.a\right|_{{\partial\mathcal{V}}^{+}}-\left.a^{*}\right|_{{\partial\mathcal{V}}^{-}}$
is shorthand for the jump conditions from above the surface in $\mathcal{V}$
(denoted with a superscript “+”) to below the surface in ${\mathcal{V}^{*}}$
(denoted with a superscript “-”) (see p. 20 in Jackson, 1975). The jump
condition on the tangential components of the magnetic field may be recast as
a surface continuity equation Arnoldus (2006)
$\left\llbracket{\hat{\boldsymbol{n}}\cdot\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{B}}\right\rrbracket=-\frac{4\,\pi}{c}\,\boldsymbol{\nabla}_{\perp}\cdot\boldsymbol{K}.$
(A7c)

The kinematic boundary condition at a fluid-fluid interface is

$\left\llbracket{\hat{\boldsymbol{n}}\cdot\boldsymbol{v}}\right\rrbracket=0.$
(A8)

The jump conditions on $\boldsymbol{E}$ and $\boldsymbol{B}$ rigorously
correspond to jump conditions on the vector potential in the Gibbs
gauge111111Note that for a Dupin (1813) surface (in particular see A3.24 in
Van Bladel, 2007)
$\hat{\boldsymbol{n}}\boldsymbol{\times}\left(\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{A}\right)=\boldsymbol{\nabla}_{\perp}{A_{n}}-\frac{A_{1}}{R_{1}}\,\hat{\boldsymbol{e}}_{1}-\frac{A_{2}}{R_{2}}\,\hat{\boldsymbol{e}}_{2}-\frac{\partial\boldsymbol{A}_{\perp}}{\partial
n},$ where $A_{1}$ and $A_{2}$ are the components of $\boldsymbol{A}$ in the
principle directions $\hat{\boldsymbol{e}}_{1}$ and $\hat{\boldsymbol{e}}_{2}$
and $R_{1}$ and $R_{2}$ are the respective principle curvatures. Since $A_{1}$
and $A_{2}$ are continuous across ${\partial\mathcal{V}}$ they do not appear
in boundary conditions (A9b) derived from Equation (A7b).

$\displaystyle\left\llbracket{\frac{\partial A_{n}}{\partial
t}}\right\rrbracket=$ $\displaystyle-4\,\pi\,c\,\sigma,\qquad$
$\displaystyle\left\llbracket{\frac{\partial\boldsymbol{A}_{\perp}}{\partial
t}}\right\rrbracket=$ $\displaystyle 0,$ (A9a)
$\displaystyle\left\llbracket{\boldsymbol{A}_{\perp}}\right\rrbracket=$
$\displaystyle 0,\qquad$
$\displaystyle\left\llbracket{\boldsymbol{\nabla}_{\perp}{A_{n}}-\frac{\partial\boldsymbol{A}_{\perp}}{\partial
n}}\right\rrbracket=$ $\displaystyle\frac{4\,\pi}{c}\,\boldsymbol{K}.$ (A9b)

The gauge invariance condition (2) implies that
$\hat{\boldsymbol{n}}\cdot\boldsymbol{B}|_{\partial\mathcal{V}}=\hat{\boldsymbol{n}}\cdot\boldsymbol{\nabla}\boldsymbol{\times}\boldsymbol{A}|_{\partial\mathcal{V}}=0$
and thus
$\hat{\boldsymbol{n}}\boldsymbol{\times}\boldsymbol{A}|_{\partial\mathcal{V}}=\hat{\boldsymbol{n}}\boldsymbol{\times}\boldsymbol{\nabla}\Lambda$.121212Note
that
$\boldsymbol{\nabla}\boldsymbol{\times}\hat{\boldsymbol{n}}|_{\partial\mathcal{V}}=0$
for a Dupin surface. The jump condition
$\left\llbracket{\partial\boldsymbol{A}_{\perp}/{\partial
t}}\right\rrbracket=0$ in the Gibbs gauge (15) combined with the kinematic
boundary condition (A8) and
$\hat{\boldsymbol{n}}\cdot\boldsymbol{B}|_{\partial\mathcal{V}}=0$ requires
either
$\hat{\boldsymbol{n}}\cdot\boldsymbol{v}^{*}|_{{\partial\mathcal{V}}^{-}}=\hat{\boldsymbol{n}}\cdot\boldsymbol{v}|_{{\partial\mathcal{V}}^{+}}=0$
or
$\left\llbracket{\hat{\boldsymbol{n}}\boldsymbol{\times}\boldsymbol{B}}\right\rrbracket=0$
(no surface current $\boldsymbol{K}$). Since $\boldsymbol{K}$ is explicitly
considered by Woltjer (1958), the former condition
$\hat{\boldsymbol{n}}\cdot\boldsymbol{v}|_{\partial\mathcal{V}}=0$ is implied.
This then implies $\partial\boldsymbol{A}_{\perp}/{\partial
t}|_{\partial\mathcal{V}}=0$ _on the boundary_ (not to be confused with
$\left\llbracket{\partial\boldsymbol{A}_{\perp}/{\partial
t}}\right\rrbracket=0$), which is sufficient to ensure that the surface
integral in Equation (16) is zero, i.e., that the system is _sufficiently
‘isolated,’_ to preserve helicity.131313We emphasize that enforcing gauge
invariance is not sufficient for dynamical conservation of helicity $H$. See
footnote 1. This condition does not inherently preclude the existence of a
surface charge $\sigma$ or surface current $\boldsymbol{K}$ on
${\partial\mathcal{V}}$ in boundary conditions (A9a)-(A9b). Indeed, since
$B_{n}=0$ and $v_{n}=0$ on ${\partial\mathcal{V}}$, then the electric field is
always normal to the boundary $\boldsymbol{E}=E_{n}\,\hat{\boldsymbol{n}}$ and
the Poynting vector
$c\,\boldsymbol{E}\boldsymbol{\times}\boldsymbol{B}/\left(4\,\pi\right)=\left(\boldsymbol{v}_{\perp}\boldsymbol{\times}\boldsymbol{B}_{\perp}\right)\boldsymbol{\times}\boldsymbol{B}_{\perp}/\left(4\,\pi\right)$
is always tangent to the boundary ${\partial\mathcal{V}}$—no _net_
electromagnetic energy crosses the boundary, but collusion is permitted!
Regardless of the gauge condition $\boldsymbol{\nabla}\cdot\boldsymbol{A}$,
the jump condition on the tangential components
$\left\llbracket{\boldsymbol{A}_{\perp}}\right\rrbracket=0$ follows by analogy
from the jump conditions on the tangential components of the electric field.
Just as $\left\llbracket{\boldsymbol{E}_{\perp}}\right\rrbracket=0$ because
$\partial\boldsymbol{B}_{\perp}/\partial t$ must be finite in the surface
${\partial\mathcal{V}}$, so $\left\llbracket{A_{\perp}}\right\rrbracket=0$
because $\boldsymbol{B}_{\perp}$ must be finite in the surface
${\partial\mathcal{V}}$. However, in analogy with the jump conditions on the
normal component of the electric field, the normal component of the vector
potential in the Gibbs gauge may be discontinuous,
$\left\llbracket{A_{n}}\right\rrbracket\neq 0$. Consequently, the jump
conditions for the surface current $\boldsymbol{K}$ involve derivatives of all
three components of the vector potential. Of course if
$\boldsymbol{A}^{\prime}$ is in the Coloumb gauge with
$\boldsymbol{\nabla}\cdot\boldsymbol{A}^{\prime}=0$ then it is apparent that
$\left\llbracket{\boldsymbol{A}^{\prime}_{n}}\right\rrbracket=0$ (see p. 242
in Griffiths, 1999). Woltjer (1958) imposes quite reasonable, but more
stringent, boundary conditions for a magnetically closed system, namely,
$\partial\boldsymbol{A}/\partial t|_{\partial\mathcal{V}}=0$ in the Gibbs
gauge, which requires $\sigma=0$ and
$\boldsymbol{v}\boldsymbol{\times}\boldsymbol{B}|_{\partial\mathcal{V}}=0$.
Under these conditions $\left\llbracket{{\partial\boldsymbol{A}}/{\partial
t}}\right\rrbracket=0$ and, in the absence of free charge at the boundary, the
Gibbs gauge reduces to the Coulomb gauge on the boundary with
$\left\llbracket{\boldsymbol{A}}\right\rrbracket=0$ with
$\left\llbracket{{\partial\boldsymbol{A}_{\perp}}/{\partial
n}}\right\rrbracket={4\,\pi}{c}^{-1}\,\boldsymbol{K}$.

##  Appendix B Other expressions for
$\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
from
$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$

As mentioned in § 5.2, the expression (50) for
$\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
is conceptually simple, but involves a computationally intensive convolution
integral of
$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
in $\mathcal{V}$. However, alternative representations may be derived from the
HD of
$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
in Equation (7) of §2 in terms of the internal vorticity of
$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)$
and its tangential components on the bounding surface ${\partial\mathcal{V}}$

$\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)=\boldsymbol{\nabla}\boldsymbol{\times}\left[\frac{1}{4\,\pi}\,\int\limits_{\mathcal{V}}{d^{3}x^{\prime}}\frac{\boldsymbol{\nabla}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}^{\prime}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}+\frac{1}{4\,\pi}\,\oint\limits_{\partial\mathcal{V}}{dS^{\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}^{\prime}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\right]\qquad\boldsymbol{x}\in\mathcal{V}.$
(B1)

This implies

$\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)=\frac{1}{4\,\pi}\,\int\limits_{\mathcal{V}}{d^{3}x^{\prime}}\,\frac{\boldsymbol{\nabla}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}^{\prime}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}+\frac{1}{4\,\pi}\oint\limits_{\partial\mathcal{V}}{dS^{\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}^{\prime}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\qquad\boldsymbol{x}\in\mathcal{V}.$
(B2)

However, as written, this also requires a computationally intensive Biot-
Savart type convolution, but over
$\boldsymbol{\nabla}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}^{\prime}\right)$.
One alternative is to substitute (46b) into (B2)

$\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)=-\frac{1}{4\,\pi\,c}\,\int\limits_{\mathcal{V}}{d^{3}x^{\prime}}\,\frac{1}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\,\boldsymbol{\nabla}^{\prime}\oint\limits_{{\partial\mathcal{V}}}{dS^{\prime\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime\prime}\cdot\boldsymbol{J}\left(t,\boldsymbol{x}^{\prime\prime}\right)}{\left|\boldsymbol{x}^{\prime}-\boldsymbol{x}^{\prime\prime}\right|}+\frac{1}{4\,\pi}\oint\limits_{\partial\mathcal{V}}{dS^{\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\qquad\boldsymbol{x}\in\mathcal{V}.$
(B3)

Integrating by parts

$\displaystyle\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)=$
$\displaystyle-\frac{1}{4\,\pi\,c}\,\int\limits_{\mathcal{V}}{d^{3}x^{\prime}}\,\boldsymbol{\nabla}^{\prime}\left[\frac{1}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\,\oint\limits_{{\partial\mathcal{V}}}{dS^{\prime\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime\prime}\cdot\boldsymbol{J}\left(t,\boldsymbol{x}^{\prime\prime}\right)}{\left|\boldsymbol{x}^{\prime}-\boldsymbol{x}^{\prime\prime}\right|}\right]+\frac{1}{4\,\pi}\oint\limits_{\partial\mathcal{V}}{dS^{\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}$
$\displaystyle\qquad-\frac{1}{4\,\pi\,c}\,\boldsymbol{\nabla}\int\limits_{\mathcal{V}}\frac{d^{3}x^{\prime}}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\,\oint\limits_{{\partial\mathcal{V}}}{dS^{\prime\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime\prime}\cdot\boldsymbol{J}\left(t,\boldsymbol{x}^{\prime\prime}\right)}{\left|\boldsymbol{x}^{\prime}-\boldsymbol{x}^{\prime\prime}\right|}\qquad\boldsymbol{x}\in\mathcal{V}.$
(B4)

Using the Gauss-Ostrogradsky theorem applied to the gradient of a scalar

$\int\limits_{\mathcal{V}}{d^{3}x}\,\boldsymbol{\nabla}{\phi}=-\oint\limits_{\partial\mathcal{V}}{dS}\,\hat{\boldsymbol{n}}\,\phi,$
(B5)

$\boldsymbol{A}_{\mathrm{cl}}$ may be written as a double convolution

$\displaystyle\boldsymbol{A}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)=$
$\displaystyle\frac{1}{4\,\pi\,c}\,\oint\limits_{\partial\mathcal{V}}{dS^{\prime}}\,\oint\limits_{{\partial\mathcal{V}}}{dS^{\prime\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime}\hat{\boldsymbol{n}}^{\prime\prime}\cdot\boldsymbol{J}\left(t,\boldsymbol{x}^{\prime\prime}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|\,\left|\boldsymbol{x}^{\prime}-\boldsymbol{x}^{\prime\prime}\right|}+\frac{1}{4\,\pi}\oint\limits_{\partial\mathcal{V}}{dS^{\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime}\boldsymbol{\times}\boldsymbol{B}_{\mathrm{cl}}\left(\boldsymbol{J}^{*};t,\boldsymbol{x}\right)}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}$
$\displaystyle\qquad-\frac{1}{4\,\pi\,c}\,\boldsymbol{\nabla}\int\limits_{\mathcal{V}}\frac{d^{3}x^{\prime}}{\left|\boldsymbol{x}-\boldsymbol{x}^{\prime}\right|}\,\oint\limits_{{\partial\mathcal{V}}}{dS^{\prime\prime}}\,\frac{\hat{\boldsymbol{n}}^{\prime\prime}\cdot\boldsymbol{J}\left(t,\boldsymbol{x}^{\prime\prime}\right)}{\left|\boldsymbol{x}^{\prime}-\boldsymbol{x}^{\prime\prime}\right|}\qquad\boldsymbol{x}\in\mathcal{V}$
(B6)

over just boundary values. The last term is simply the gradient of a gauge
function and may be ignored in our gauge invariant approach.

## References

  * Arnoldus (2006) Arnoldus, H. F. 2006, Optics Communications, 265, 52, doi: https://doi.org/10.1016/j.optcom.2006.03.024
  * Berger (1984) Berger, M. A. 1984, Geophysical and Astrophysical Fluid Dynamics, 30, 79, doi: 10.1080/03091928408210078
  * Berger (1985) —. 1985, Geophysical & Astrophysical Fluid Dynamics, 34, 265, doi: 10.1080/03091928508245446
  * Berger (1985) Berger, M. A. 1985, ApJS, 59, 433, doi: 10.1086/191079
  * Berger (1999) Berger, M. A. 1999, Plasma Physics and Controlled Fusion, 41, B167.  http://stacks.iop.org/0741-3335/41/i=12B/a=312
  * Berger (2003) Berger, M. A. 2003, in Advances in Nonlinear Dynamos, ed. A. Ferriz-Mas & M. Núñez, The Fluid Mechanics of Astrophysics and Geophysics (CRC Press), 354–374, doi: 10.1201/9780203493137.ch10
  * Berger & Field (1984) Berger, M. A., & Field, G. B. 1984, Journal of Fluid Mechanics, 147, 133
  * Berger et al. (1998) Berger, T. E., Loefdahl, M. G., Shine, R. S., & Title, A. M. 1998, ApJ, 495, 973
  * Berghmans et al. (2021) Berghmans, D., Auchère, F., Long, D. M., et al. 2021, A&A, 656, L4, doi: 10.1051/0004-6361/202140380
  * Bian & Jiang (2023) Bian, X., & Jiang, C. 2023, Frontiers in Astronomy and Space Sciences, 10, doi: 10.3389/fspas.2023.1097672
  * Biot & Savart (1820) Biot, J.-B., & Savart, F. 1820, Ann. Chem. Phys, 15, 222.  https://e-magnetica.pl/ref/biot-savart_1820
  * Blackman (2014) Blackman, E. G. 2014, Space Science Reviews, 188, 59, doi: 10.1007/s11214-014-0038-6
  * Bladel (1991) Bladel, J. G. V. 1991, Singular Electromagnetic Fields and Sources, IEEE/OUP series on electromagnetic wave theory (Wiley-IEEE Press), 252, doi: 10.1109/9780470546420
  * Brading & Brown (2000) Brading, K., & Brown, H. R. 2000, arXiv e-prints, hep, doi: 10.48550/arXiv.hep-th/0009058
  * Brading (2002) Brading, K. A. 2002, Studies in History and Philosophy of Science Part B: Studies in History and Philosophy of Modern Physics, 33, 3, doi: 10.1016/s1355-2198(01)00033-8
  * Brandenburg (2006) Brandenburg, A. 2006, Astronomische Nachrichten, 327, 461, doi: 10.1002/asna.200610558
  * Brandenburg (2020) —. 2020, The Astrophysical Journal, 901, 18, doi: 10.3847/1538-4357/abad92
  * Bumba & Klvana (1993) Bumba, V., & Klvana, M. 1993, Ap&SS, 199, 45, doi: 10.1007/BF00612976
  * Candelaresi et al. (2021) Candelaresi, S., Hornig, G., MacTaggart, D., & Simitev, R. D. 2021, Communications in Nonlinear Science and Numerical Simulation, 103, 106015, doi: https://doi.org/10.1016/j.cnsns.2021.106015
  * Carrington (1859) Carrington, R. C. 1859, MNRAS, 20, 13, doi: 10.1093/mnras/20.1.13
  * Courant & Hilbert (1989a) Courant, R., & Hilbert, D. 1989a, Wiley classics library, Vol. 1, Methods of mathematical physics. Vol. 1 / by R. Courant and D. Hilbert., 1st edn. (New York: Interscience Publishers, John Wiley & Sons), doi: 10.1002/9783527617210
  * Courant & Hilbert (1989b) —. 1989b, Wiley classics library, Vol. 2, Methods of mathematical physics. Vol. 2, Partial differential equations / by R. Courant and D. Hilbert. (New York: Interscience Publishers, John Wiley & Sons), doi: 10.1002/9783527617234
  * Călugăreanu (1959) Călugăreanu, G. 1959, Math. Pures Appl., 4, 5
  * Demoulin et al. (2006) Demoulin, P., Pariat, E., & Berger, M. A. 2006, Sol. Phys., 233, 3, doi: 10.1007/s11207-006-0010-z
  * Dixon et al. (1989) Dixon, A. M., Berger, M. A., Priest, E. R., & Browning, P. K. 1989, A&A, 225, 156
  * Dupin (1813) Dupin, C. 1813, Développements de Géométrie, avec des applications à la stabilité des Vaisseaux, aux Déblais et Remblais, au Défilement, à l’Optique, etc. Ouvrage Approuvé par l’Institut de France pour faire suite à la géométrie descriptive et à la géométrie analytique de m. Monge. (Paris: V. Courcier)
  * Field & Carroll (2000) Field, G. B., & Carroll, S. M. 2000, Physical Review D, 62, doi: 10.1103/physrevd.62.103008
  * Finn & Antonsen (1985) Finn, J., & Antonsen, T. 1985, Comments Plasma Phys. Controlled Fusion, 9, 111
  * Fiolhais & Providencia (2008) Fiolhais, M. C. N., & Providencia, C. 2008, arXiv e-prints, arXiv:0811.2598, doi: 10.48550/arXiv.0811.2598
  * Frenkel et al. (1982) Frenkel, A., Levich, E., & Stilman, L. 1982, Physics Letters A, 88, 461, doi: https://doi.org/10.1016/0375-9601(82)90541-2
  * Frisch et al. (1975) Frisch, U., Pouquet, A., LÉOrat, J., & Mazure, A. 1975, Journal of Fluid Mechanics, 68, 769–778, doi: 10.1017/S002211207500122X
  * Gary et al. (1987) Gary, G. A., Moore, R. L., Hagyard, M. J., & Haisch, B. M. 1987, ApJ, 314, 782, doi: 10.1086/165104
  * Gauss (1867) Gauss, C. F. 1867, in Werke, ed. C. Schäfe, Vol. 5 (Leipzig, Berlin: Königliche Gesellschaft der Wissenschaften zu Göttingen)
  * Gibbs (1896) Gibbs, J. W. 1896, Nature, 53, 509, doi: 10.1038/053509a0
  * Girault & Raviart (1986) Girault, V., & Raviart, P. 1986, Finite Element Methods for Navier-Stokes Equations: Theory and Algorithms, Springer Series in Computational Mathematics (Springer-Verlag Berlin Heidelberg).  https://books.google.com/books?id=8C7vCAAAQBAJ
  * Griffiths (1999) Griffiths, D. 1999, Introduction to Electrodynamics (Prentice Hall).  https://books.google.com/books?id=M8XvAAAAMAAJ
  * Gui & Dou (2007) Gui, Y. F., & Dou, W.-B. 2007, Progress In Electromagnetics Research, 69, 287
  * Hammond (1960) Hammond, P. 1960, Proceedings of the IEE - Part C: Monographs, 107, 306.  https://digital-library.theiet.org/content/journals/10.1049/pi-c.1960.0047
  * Heyvaerts & Priest (1984) Heyvaerts, J., & Priest, E. R. 1984, A&A, 137, 63
  * Jackson (1975) Jackson, J. D. 1975, Classical Electrodynamics, 2nd edn. (New York: John Wiley & Sons)
  * Jackson (2002) Jackson, J. D. 2002, American Journal of Physics, 70, 917, doi: 10.1119/1.1491265
  * Jensen & Chu (1984) Jensen, T. H., & Chu, M. S. 1984, Physics of Fluids, 27, 2881, doi: 10.1063/1.864602
  * Karatas & Kowalski (1990) Karatas, D. L., & Kowalski, K. L. 1990, American Journal of Physics, 58, 123, doi: 10.1119/1.16219
  * Kellogg (1929) Kellogg, O. D. 1929, Die Grundlehren der mathematischen Wissenschaften in Einzeldarstellungen, Vol. 31, Foundations of Potential Theory, 1st edn. (Berlin Heidelberg: Springer-Verlag), 384, doi: 10.1007/978-3-642-90850-7
  * Kemmer (1977) Kemmer, N. 1977, Vector Analysis: A Physicist’s Guide to the Mathematics of Fields in Three Dimensions (Cambridge University Press), doi: 10.1017/CBO9780511569524
  * Kempka et al. (1996) Kempka, S. N., Glass, M. W., Peery, J. S., Strickland, J. H., & Ingber, M. S. 1996, Accuracy considerations for implementing velocity boundary condiditons in vorticity formulations, Tech. Rep. SAND-96-0583, Sandia National Laboratory, Albuquerque, NM, doi: 10.2172/242701
  * Klimchuk & Sturrock (1992) Klimchuk, J. A., & Sturrock, P. A. 1992, ApJ, 385, 344, doi: 10.1086/170943
  * Knizhnik et al. (2017) Knizhnik, K. J., Antiochos, S. K., DeVore, C. R., & Wyper, P. F. 2017, ApJ, 851, L17, doi: 10.3847/2041-8213/aa9e0a
  * Koenigl & Choudhuri (1985) Koenigl, A., & Choudhuri, A. R. 1985, ApJ, 289, 173, doi: 10.1086/162876
  * Kusano et al. (1995) Kusano, K., Suzuki, Y., & Nishikawa, K. 1995, ApJ, 441, 942, doi: 10.1086/175413
  * Kustepeli (2016) Kustepeli, A. 2016, Electromagnetics, 36, 135, doi: 10.1080/02726343.2016.1149755
  * Laurence & Avellaneda (1991) Laurence, P., & Avellaneda, M. 1991, Journal of Mathematical Physics, 32, 1240, doi: 10.1063/1.529321
  * Leake et al. (In Prep. 2023) Leake, J. E., Daldorff, L. K. S., Schuck, P. W., & Linton, M. G. In Prep. 2023, ApJ
  * Linan et al. (2020) Linan, L., Pariat, É., Aulanier, G., Moraitis, K., & Valori, G. 2020, A&A, 636, A41, doi: 10.1051/0004-6361/202037548
  * Linan et al. (2018) Linan, L., Pariat, É., Moraitis, K., Valori, G., & Leake, J. 2018, ApJ, 865, 52, doi: 10.3847/1538-4357/aadae7
  * Liu et al. (2023) Liu, Y., Welsch, B. T., Valori, G., et al. 2023, The Astrophysical Journal, 942, 27, doi: 10.3847/1538-4357/aca3a6
  * Longcope & Malanushenko (2008) Longcope, D. W., & Malanushenko, A. 2008, ApJ, 674, 1130, doi: 10.1086/524011
  * Low & Lou (1990) Low, B. C., & Lou, Y. Q. 1990, ApJ, 352, 343, doi: 10.1086/168541
  * Malanushenko et al. (2009) Malanushenko, A., Longcope, D. W., Fan, Y., & Gibson, S. E. 2009, The Astrophysical Journal, 702, 580, doi: 10.1088/0004-637X/702/1/580
  * Moffatt (1969) Moffatt, H. K. 1969, Journal of Fluid Mechanics, 35, 117–129, doi: 10.1017/S0022112069000991
  * Moffatt (1978) Moffatt, H. K. 1978, Magnetic field generation in electrically conducting fluids (Cambridge, England: Cambridge University Press), 353
  * Moraitis et al. (2014) Moraitis, K., Tziotziou, K., Georgoulis, M. K., & Archontis, V. 2014, Sol. Phys., 289, 4453, doi: 10.1007/s11207-014-0590-y
  * Morse & Feshbach (1953) Morse, P. M., & Feshbach, H. 1953, International Series in Pure and Applied Physics, Vol. 1, Methods in Theoretical Physics (New York: McGraw-Hill Pubublishing Co.)
  * Newton (1942) Newton, H. W. 1942, Monthly Notices of the Royal Astronomical Society, 102, 2, doi: 10.1093/mnras/102.1.2
  * Noether (1918) Noether, E. 1918, Nachrichten von der Gesellschaft der Wissenschaften zu Göttingen, Mathematisch-Physikalische Klasse, 1918, 235.  http://eudml.org/doc/59024
  * Pariat et al. (2017) Pariat, E., Leake, J. E., Valori, G., et al. 2017, A&A, 601, A125, doi: 10.1051/0004-6361/201630043
  * Priest (2014) Priest, E. 2014, Magnetohydrodynamics of the Sun, doi: 10.1017/CBO9781139020732
  * Przeszowski et al. (1996) Przeszowski, J., Naus, H. W. L., & Kalloniatis, A. C. 1996, Phys. Rev. D, 54, 5135, doi: 10.1103/PhysRevD.54.5135
  * Sakurai (1987) Sakurai, T. 1987, Sol. Phys., 113, 137, doi: 10.1007/BF00147692
  * Schrijver & Zwaan (2000) Schrijver, C. J., & Zwaan, C. 2000, Solar and Stellar Magnetic Activity, Cambridge astrophysics series (New York: Cambridge University Press)
  * Schuck & Antiochos (2019) Schuck, P. W., & Antiochos, S. K. 2019, ApJ, 882, 151, doi: 10.3847/1538-4357/ab298a
  * Schuck et al. (2022) Schuck, P. W., Linton, M. G., Khizhnik, K., & Leake, J. 2022, ApJ, 936, 94, doi: 10.3847/1538-4357/ac739a
  * Sudol & Harvey (2005) Sudol, J. J., & Harvey, J. W. 2005, ApJ, 635, 647, doi: 10.1086/497361
  * Sun et al. (2017) Sun, X., Hoeksema, J. T., Liu, Y., Kazachenko, M., & Chen, R. 2017, The Astrophysical Journal, 839, 67, doi: 10.3847/1538-4357/aa69c1
  * Tanaka & Nakagawa (1973) Tanaka, K., & Nakagawa, Y. 1973, Sol. Phys., 33, 187, doi: 10.1007/BF00152390
  * Tarr et al. (2013) Tarr, L., Longcope, D., & Millhouse, M. 2013, ApJ, 770, 4, doi: 10.1088/0004-637X/770/1/4
  * Taylor (1974) Taylor, J. B. 1974, Physical Review Letters, 33, 1139, doi: 10.1103/PhysRevLett.33.1139
  * Taylor (1986) Taylor, J. B. 1986, Rev. Mod. Phys., 58, 741, doi: 10.1103/RevModPhys.58.741
  * Thomson (1868) Thomson, S. 1868, Transactions of the Royal Society of Edinburgh, 25, 217–260, doi: 10.1017/S0080456800028179
  * Thomson (1845) Thomson, W. 1845, Journal de Mathématiques Pures et Appliquées, 1e série, 10.  http://www.numdam.org/item/JMPA_1845_1_10__364_0/
  * Tousey (1973) Tousey, R. 1973, in Space Research XIII, International Science Symposium No. 2, Space Research XIII: Proceedings of the Open Meetings of Working Groups on Physical Sciences of the Fifteenth Plenary Meeting of COSPAR (Berlin: Akademie-Verlag), 713–730
  * Valori et al. (2020) Valori, G., Démoulin, P., Pariat, E., et al. 2020, A&A, 643, A26, doi: 10.1051/0004-6361/202038533
  * Van Bladel (2007) Van Bladel, J. 2007, Electromagnetic Fields, 2nd edn., IEEE Press Series on Electromagnetic Wave Theory (Hoboken, NJ: Wiley - IEEE Press).  http://books.google.com/books/about/Electromagnetic_Fields.html
  * Wang (1992) Wang, H. 1992, Sol. Phys., 140, 85, doi: 10.1007/BF00148431
  * Wang (2006) —. 2006, ApJ, 649, 490, doi: 10.1086/506320
  * Wang et al. (1994) Wang, H., Ewell, M. W., J., Zirin, H., & Ai, G. 1994, ApJ, 424, 436, doi: 10.1086/173901
  * White (1969) White, J. H. 1969, American Journal of Mathematics, 91, 693.  http://www.jstor.org/stable/2373348
  * Woltjer (1958) Woltjer, L. 1958, Proceedings of the National Academy of Science, 44, 489, doi: 10.1073/pnas.44.6.489
  * Yang et al. (1983) Yang, H.-S., Chang, H.-M., & Harvey, J. W. 1983, Sol. Phys., 84, 139, doi: 10.1007/BF00157453
  * Zhang (2016) Zhang, H. 2016, Sol. Phys., 291, 3501, doi: 10.1007/s11207-016-1009-8
  * Zuccarello et al. (2018) Zuccarello, F. P., Pariat, E., Valori, G., & Linan, L. 2018, ApJ, 863, 41, doi: 10.3847/1538-4357/aacdfc


*[inlinelist,1]label=(),

10(2,2) 18th Int. Conf. on Acc. and Large Exp. Physics Control Systems
ISBN: 978-3-95450-221-9 ISSN: 2226-0358  10(11.4,2) ICALEPCS2021, Shanghai,
China JACoW Publishing
doi:10.18429/JACoW-ICALEPCS2021-MOPV042

# PLCverif: status of a formal verification tool for Programmable Logic
Controller

I. D. Lopez-Miguel<EMAIL_ADDRESS>J-C. Tournier  B.
Fernandez  CERN  Geneva  Switzerland

###### Abstract

Programmable Logic Controllers (PLC) are widely used for industrial automation
including safety systems at CERN. The incorrect behaviour of the PLC control
system logic can cause significant financial losses by damage of property or
the environment or even injuries in some cases. Therefore ensuring their
correct behaviour is essential. While testing has been for many years the
traditional way of validating the PLC control system logic, CERN developed a
model checking platform to go one step further and formally verify PLC logic.
This platform, called PLCverif, was first released internally for CERN usage
in 2019, is now available to anyone since September 2020 via an open source
licence. In this paper, we will first give an overview of the PLCverif
platform capabilities before focusing on the improvements done since 2019 such
as the larger support coverage of the Siemens PLC programming languages, the
better support of the C Bounded Model Checker backend (CBMC) and the process
of releasing PLCverif as an open-source software.

##  1 Introduction

Programmable Logic Controllers (PLC) are widely used for industrial automation
including safety systems at CERN. The incorrect behaviour of the PLC control
system logic can cause significant financial losses by damage of property or
the environment or even injuries in some cases. Therefore ensuring their
correct behaviour is essential. While testing has been for many years the
traditional way of validating the PLC control system logic, it is often not
sufficient as the sole verification method: testing, even when automated, can
not be exhaustive, thus can not guarantee the correctness of a logic. Some
types of requirements, such as safety (i.e. an unsafe state can never be
reached) or invariant (formulas which shall be true over all possible system
runs), can be very difficult, if not impossible, to test. Model checking is a
formal verification technique which complements the testing activities in
order to fully validate and verify a PLC control system logic. Model checking
assesses the satisfaction of a formalised requirement on a mathematical model
of the system under analysis. It checks the requirement’s satisfaction with
every input combination, with every possible execution trace. In addition, if
a violation is found, a trace leading to the violated requirement is provided.
The main hurdle to the widespread usage of model checking within the PLC
community is twofold: (1) the mathematical model representing the system under
analysis can be difficult to write and requires in-depth understanding of the
model checking tools; and (2) many real-life PLC logics are too complex and
face the state-space explosion problem, i.e. the number of possible input
combinations and execution traces is too big to be exhaustively explored.

In 2019 CERN developed the PLCverif platform with the goals of easing the
usage of model checking tools for the PLC developers community by automating
the translation of the PLC programs to their mathematical models and to
implement several abstraction algorithms to limit the state-space explosion
problem. Since September 2020, the platform has been released under an open
source license to foster the usage and the development of the tool within the
PLC community. The objective of this paper is to give a status of the PLCverif
platform focusing on the latest developments improving the usability and
performance of the tool.

The rest of the paper is organized as follows: Section PLCverif Overview gives
an overview of PLCverif to better understand the scope and the architecture of
the platform. Section Open Source Release focuses on the open source release
of PLCverif by describing the process of releasing the source code and
presenting the code organization. Finally sections Latest developments and On-
going Challenges and Developments present respectively the latest and ongoing
developments.

##  2 PLCverif Overview

This section gives an overview of the PLCverif platform
[blancovinuela:icalepcs2019] before presenting the latest developments.

###  2.1 Verification Workflow

Out of the box, PLCverif offers a model checking workflow for the analysis of
PLC programs. The verification workflow is shown in Figure 1 and it has the
following main steps:

PLCverifPLC programparserRequirementrepresentationXXXXXXCFA reductionsExternal
modelcheckingXXXXXXReportingPLC programUser requirementFormal representation
(CFA)Verification problem(CFA + TL requirement)Reduced verification problemRaw
verification resultsVerification report(s) Figure 1: Formal verification
workflow of PLCverif

  1. 1.

PLC program parsing. PLCverif parses the PLC program (located in one or
several files) to be analysed. By choosing the entry point of the
verification, the analysis can be limited to a part of the program. The parsed
PLC program is automatically translated into a mathematical, control flow-
based representation, producing so-called Control Flow Automata (CFA). This
precise description will serve as the basis for the analysis.

  2. 2.

Requirement representation. The user should describe the precise requirement
to be checked. This, however, does not mean that the user needs to describe
the requirement using mathematical formulae. Currently, two requirement
description methods are supported:

     * •

Assertion-based requirements: special comments in the source code (e.g.
//#ASSERT On<>Off) can describe expressions (invariants) which are expected to
be always satisfied at a given location of the program. The verification job
will then check if the violation of any of the selected assertions is
possible.

     * •

Pattern-based requirements: the user chooses a requirement pattern that is a
precisely-phrased plain text sentence with some placeholders, e.g. “ _If
$\alpha$ is true at the end of the PLC cycle, then $\beta$ should always be
true at the end of the same cycle._”. The gaps in the requirement pattern
($\alpha$ and $\beta$ in the previous example) shall be filled with
expressions over the PLC variables. For each requirement pattern, a defined
temporal logic representation is defined which will be used in the next steps.

If needed, new types of requirement representations can be defined, adapted to
the specific needs.

  3. 3.

CFA reductions. The formal, precise CFA representation of the program,
including also the requirement, may need to be reduced in order to make the
verification feasible and efficient. These reductions will not change the
verification result for the given requirement; however, they may remove parts
of the program which do not influence the result of the currently checked
requirement [Darvas:FORTE2014].

  4. 4.

External model checking. The model checking itself is performed by widely used
model checker tools. In this step,  1 the reduced CFA is translated into the
input syntax of the chosen model checker tool,  2 the model checker tool is
executed, and  3 its output, notably the counterexample if available, is
parsed to PLCverif’s internal representation.

Currently the following external model checkers are supported: NuSMV
[Cimatti:CAV02], nuXmv [Cavada:CAV2014], Theta [Toth:FMCAD2017] and CBMC
[Clarke:TACAS2004]. These model checkers have different strengths and
weaknesses. In addition, not every feature is supported by every model
checker.

  5. 5.

Reporting. The last step of the formal verification workflow is to produce
verification reports. Some of these reports are in human-readable form and
target the user of PLCverif. Other reports are machine-readable and serve as
descriptions for the execution environment or as artifacts for later summary
reports.

##  3 Open Source Release

PLCverif is available publicly since September 2020 along with its source code
under an EPL-2.0111https://www.eclipse.org/legal/epl-2.0/ license on
GitLab222https://gitlab.com/plcverif-oss. This section presents the reasons
for open sourcing PLCverif, as well as the process to choose the open source
license and the code organization as found in the GitLab repository.

###  3.1 Motivations

PLCverif has been entirely developed at CERN and therefore fits CERN’s needs.
Nevertheless, the platform could be beneficial to two different communities
outside CERN: the PLC developers community and the model checker community.
For PLC developers, PLCverif could be used out of the box if the language used
is among the ones already supported, i.e. Siemens Statement List (STL) and
Siemens Structure Control Language (SCL). The current coverage333Coverage was
calculated as the number of instructions that are implemented in PLCverif vs.
the number of instructions in a given grammar for a given PLC. Binary
arithmetic operations like addition or subtraction, and binary logic
operations like conjuntion or disjuntion are not taken into account when the
coverage for SCL is calculated. That is the main reason why the figures for
SCL are much lower than for STL. of Siemens STL and SCL in PLCverif is
currently at 66% and 40%, respectively, for S7-300/400 PLCs, and at 55% and
25%, respectively, for S7-1200/1500 PLCs. This covers most of the
functionalities of PLC programs developed at CERN as the instructions
implemented represent the core of those languages. However, support for a
missing instruction could be easily added if needed. Similarly, the support of
a new programming language could also be developed taking as a reference the
current implementation for the Siemens languages. For the model checking
community, PLCverif offers the possibility to be integrated in a platform
verifying real-life PLC code: it is a great opportunity for this community to
test new algorithms or improvements of existing model checkers.

###  3.2 License Selection

From the different open source licenses available, the choice has been made to
release the PLCverif platform source code under the Eclipse Public License 2.0
(EPL444See footnote 1.). This license is similar to the GNU General Public
License (GPL555https://www.gnu.org/licenses/gpl-3.0.en.html) but allows to
link the code to proprietary applications: it then allows to use and extend
the tool, even for commercial purposes. The reason for choosing the EPL-2.0
license was driven by the fact that is a weak copyleft license, but also that
most of the components used by PLCverif are already under the EPL-2.0 (more
details in [blancovinuela:icalepcs2019]).

###  3.3 GitLab Repository

The PLCverif platform has been developed within the Eclipse ecosystem: it is
mainly written in Java (Java 11), Xtend and Xtext. The modularity is assured
via the split of the code among several distinct projects and Eclipse plugins.
The main projects of the platform are:

  * •

PLCverif Backend666https://gitlab.com/plcverif-oss/cern.plcverif is the core
of the PLCverif platform and is responsible for all the CFA manipulations
represented in Figure 1. It is also responsible for interacting with the
external model checkers via dedicated Eclipse plugins.

  * •

Siemens Support777https://gitlab.com/plcverif-oss/cern.plcverif.plc.step7 is
responsible for the parsing of the Siemens STL and SCL code, i.e. transforms
the PLC user code into the PLCverif internal CFA representation.

  * •

PLCverif Frontends888https://gitlab.com/plcverif-
oss/cern.plcverif.gui,999https://gitlab.com/plcverif-oss/cern.plcverif.cli are
the visible parts from a user point of view. The GUI project provides a
graphical application embedding a PLC code editor, a specification requirement
editor and a report visualization part. The CLI project is the way to execute
the PLCverif workflow via the command line allowing the execution of headless
verification jobs such as in a CI/CD (Continuous Integration / Continuous
Deployment) pipeline for PLC code.

##  4 Latest developments

Since the publication of [blancovinuela:icalepcs2019] in 2019, several
improvements have been made. Some of them are summarized below:

  * •

The C code used to run CBMC was originally produced directly converting the
intermediate model to a C code using goto instructions. CBMC is however not
efficient with this kind of programs since it is not able to find loops. This
method has been changed in order to produce a structured C code without gotos,
being able to efficiently use the option –partial-loops of CBMC. With this
option, CBMC will execute loops only partially. The disadvantage of this
option is that the counterexample might be spurious.

  * •

In order to confirm the feasibility of a counterexample produced by PLCverif
when a property is violated, it is common to try to reproduce that situation
in a real PLC or via simulation. In order to automate this process, it is now
possible to automatically generate a file with the values of all the variables
that can be used as an input to the simulator or to the real PLC.

  * •

Safety programs in Siemens are written in function block diagram (FBD)
language. After exporting them with OpennessScripter101010TIA Portal Openness
API., an XML file is produced. A new feature in PLCverif has been developed in
order to import those XML files into PLCverif translating them into STL code.

  * •

The coverage of Siemens programs was increased both for STL and SCL. More
built-in functions from TIA portal were included.

  * •

Support of latest Theta version was included. Theta is being actively
developed and new releases have been launched. In order to keep up with the
latest improvements, PLCverif has been adapted to correctly parse Theta
output. Currently, PLCverif supports Theta v2.21.0.

  * •

The intermediate model Control Flow Instance had the limitation that it could
not be used with dynamic indexing arrays. However, Theta supports this feature
and PLCverif has been adapted to generate Theta programs with dynamic indexes.

  * •

The grammar implemented in PLCverif to parse Siemens PLC programs has been
extended to include partial support of Schneider PLC programs.

  * •

Upgrade to Java 11. PLCverif was originally developed in Java 8. However, in
order not to lose support and to be able to run the latest versions of some
model checkers (Theta), it was needed to upgrade to Java 11.

##  5 On-going Challenges and Developments

###  5.1 Simplification of numeric variables

As observed in the large code base of CERN industrial PLC systems, one of the
main challenges to perform PLC model checking is the state-space explosion
originated by the inclusion of numeric variables. PLCverif represents input
variables as non-deterministic in the intermediate model. This means that a
16-bit integer is going to have $2^{16}\approxeq 7\cdot 10^{4}$ possible
values that the model checker needs to explore.

There exist some techniques to handle this type of variables, such as
counterexample-guided-abstraction refinement (CEGAR) [clarke:cegar] or
Satisfiability Modulo Theories (SMT). However, other approaches to directly
simplify the PLCverif intermediate model are under investigation, highly
improving the performance of the NuSMV model checker [lopez:memocode21].

###  5.2 Iterative verification

It is common practice to have different modules within PLC projects (see
[Fernandez:ICALEPCS2021] for an example). Some of these projects are too large
to be verified by PLCverif yet. However, if the program is split into parts,
the verification cases are smaller and can be successfully executed. If it
would be possible to combine all the results together, it would be feasible to
verify these large programs. To this end, different compositional verification
approaches have been analysed but no generic method has been found yet to be
applied to PLC projects.

Nonetheless, other abstraction techniques are under consideration, such as
abstracting away the different modules. With this approach, a verification
case is executed with all the functions abstracted away (all their outputs are
going to be non-deterministic). If the property is satisfied, the original
program satisfies that property too. On the other hand, if it is violated, one
needs to check if the abstracted functions can produce the outputs leading to
the violation. If it is not possible, a function is concretized (it comes back
to its original form) and a new verification case is executed. This process is
continued until a feasible counterexample is found or until all functions are
concretized (coming back to the original program). Different strategies and
improvements can be investigated for this method.

###  5.3 Counterexample analysis

When a program is verified and the result is a violation of the property, a
counterexample is given by PLCverif. If the program is composed of several
variables and they interact with each other (see [Fernandez:ICALEPCS2021] for
an example), the counterexample is going to be large. Therefore, it will be
difficult to analyse what part of the code made the property fail.

Some investigations have been done in this direction in order to point the
user to possible locations in the code that have an impact on the final
assertion. This way, the user would not need to go through all the code but
just focus on the highlighted parts.

###  5.4 Other

Since the release of PLCverif, there has been some progress in the development
of more efficient model checkers. As already explained previously, the latest
version of Theta has been integrated into PLCverif. However, although CBMC is
efficient, it is a SAT-based model checker that uses few abstraction
techniques. Therefore, an SMT-based model checker like ESBMC [Mikhail:ASE2018]
could improve the performance of CBMC.

##  6 Conclusion

This paper presented the latest developments of the PLCverif platform to
formally verify PLC programs. The developments can be grouped into two main
lines of work:

  * •

Promoting and easing the use of PLCverif by making it open source, by
supporting more PLC manufacturers (i.e. Schneider Electric), and by guiding
the user to the root cause of an issue when a property is violated
(counterexample analysis).

  * •

Improving the performance of the verification time by simplifying numerical
variables without loosing meaningful information and by implementing an
iterative verification process allowing to verify even more complex
applications.

All the different developments presented in this paper are in different stages
of maturity and are in the pipeline to be included into PLCverif. In addition
some new developments will be carried on to support Schneider safety programs
and to integrate new model checkers such as ESBMC.