Invariance principles in the theory and computation of transport coefficients

Abstract In this work, we elaborate on two recently discovered invariance principles, according to which transport coefficients are, to a large extent, independent of the microscopic definition of the densities and currents of the conserved quantities being transported (energy, momentum, mass, charge). The first such principle, gauge invariance, allows one to define a quantum adiabatic energy current from density-functional theory, from which the heat conductivity can be uniquely defined and computed using equilibrium ab initio molecular dynamics. When combined with a novel topological definition of atomic oxidation states, gauge invariance also sheds new light onto the mechanisms of charge transport in ionic conductors. The second principle, convective invariance, allows one to extend the analysis to multi-component systems. These invariance principles can be combined with new spectral analysis methods for the current time series to be fed into the Green–Kubo formula to obtain accurate estimates of transport coefficients from relatively short molecular dynamics simulations. Graphic abstract


Introduction
Transport coefficients are archetypal examples of offequilibrium properties, which describe in fact entropy production and the approach to equilibrium in extended systems, thus giving a quantitative meaning and a conceptual framework to the very notion of irreversibility and the arrow of time. While non-equilibrium statistical mechanics is still a very active and largely unsettled field of research, the relaxation of small off-equilibrium fluctuations and the response of systems to small perturbations have been given a rigorous theoretical foundation back in the fifties by the Green-Kubo (GK) theory of linear response [1][2][3][4]. Among other achievements, this theory provides a rigorous and elegant way to cast the computation of transport coefficients into the evaluation of equilibrium time correlation functions of suitably defined fluxes, thus making it accessible to equilibrium molecular dynamics (EMD) simulations. This feat notwithstanding, the several conceptual subtleties underlying the linear-response theory of transport coefficients are often dodged or disguised with a clumsy notation that makes it difficult to fully appreciate their scope and impact on the design and use of computer simulation methodologies. Also due to this predicament, a number of misconceptions have affected the otherwise mature and fecund field of computer simulation of transport in condensed matter, thus unduly lima e-mail: federico.grasselli@epfl.ch (corresponding author) iting its scope. Foremost among these misconceptions is that the intrinsic indeterminacy of any local representations of an extensive quantity, such as the density or atomic break-up of the energy (or charge and mass, for that matter), would undermine the uniqueness of the transport coefficients that are derived from them. While similar reservations should apply to classical and quantum ab initio simulations alike, they have in fact impacted mainly the latter, to the extent that until recently it had been believed that the GK theory of heat transport could not be combined with quantum simulation methods based on electronic-structure theory. This quandary has been recently overcome, mainly thanks to the introduction of a so-called gauge invariance principle of transport coefficients [5,6], which basically states that, under well-defined conditions, the value of a transport coefficient is largely independent of the detailed form of the conserved densities and fluxes from which they are derived through the GK formulae. In full generality, gauge invariance implies that the value of a transport coefficients is unchanged if the flux from which it is calculated is modified by adding to it a vector process whose power spectrum vanishes at ω = 0 (such a process is conveniently dubbed non-diffusive). Further difficulties may arise in the case of multi-component systems, where the interaction among different fluxes make the transport of one conserved quantity (such as, e.g., energy), depend on the dynamics of the other hydrodynamical variables (such as, e.g., the number of different molecular species), thus muddling the definition of heat conductivity in these systems. This difficulty is solved by defining, e.g., the thermal conductivity as the ratio between the energy flux and the temperature gradient, when all the other conserved fluxes vanish. In this case, a further invariance principle, dubbed convective invariance [7], states that the thermal conductivity results to be unchanged if the definition of the energy flux is altered by adding to it an arbitrary linear combination of the mass fluxes of the molecular species constituting the system. While the value of the transport coefficients enjoys the invariance properties mentioned above, the statistical properties of the flux time series from which they are derived do depend on the microscopic representation of the conserved densities and current densities, thus substantially affecting the statistical error of the transport coefficient being computed. This dependence opens the way to optimizing this representation, so as to minimize the resulting statistical errors. This freedom can be exploited in conjunction with the recently introduced cepstral analysis of the current spectra [8] to substantially reduce the length of the EMD simulations needed to evaluate a transport coefficient to a given target accuracy.
In this paper, we review the concepts of gauge and convective invariance in the classical theory of transport in condensed matter, with emphasis on their application to the computation of transport coefficients from the GK theory of linear response and EMD, as well as some concepts and tools for the spectral analysis of the current time series, which can be used in conjunction with these invariance principles to substantially reduce the statistical errors affecting the EMD estimate of various conductivities. In Sect. 2, we briefly lay down the GK linear-response theory of transport, aiming at establishing some general terminology and notations. In Sect. 3, we introduce the concept of gauge invariance, whereas convective invariance is discussed in Sect. 4. In Sect. 5, we discuss a newly introduced spectral method (dubbed cepstral analysis) to evaluate and systematically reduce the statistical error affecting the estimate of transport coefficients from EMD. In Sect. 6, we specialize our discussion to ab initio heat transport and report a general expression for the microscopic heat flux suitable to density functional theory. In Sect. 7, we show how gauge invariance can be combined with concepts from topology to reveal some unexpected features of charge transport in ionic conductors. Section 8 finally contains our conclusions.

Theory
Transport theory is essentially a dynamical theory of hydrodynamical variables, i.e. of the long-wavelength components of the densities of conserved, extensive, variables, which in short we refer to as conserved charges and densities. In a simple fluid, for instance, the conserved charges are the energy, the three components of total momentum, and the total number of molecules of each chemical species. The corresponding transport coefficients are the thermal conductivity, the viscosity, and the various diffusivities. LetQ be one such conserved charge, andq(r) the corresponding density:Q = q(r)dr. Here and in the following we adopt the convention that a hat, as inÂ, indicates an implicit dependence on the system's phase-space variables, Γ:Â = A(Γ), where Γ = {x, p} is the set of all the atomic coordinates and momenta. When neither a hat nor the phase-space argument are present, A indicates the expectation ofÂ over some suitably defined phase-space distribution, ρ(Γ) (most frequently the canonical or micro-canonical equilibrium distributions): When it will be necessary to distinguish between the expectation of a quantity, A, and its phase-space representation, A(Γ), the latter will be referred to as a phase-space sample of the former. Sometimes, we will need to indicate explicitly the implicit time dependence of a phase-space variable (no pun intended). When this is done, we will mean the phase-space variableÂ(t) = A(Γ, t) .
= A(Γ t ), as a function of time and of the initial condition, Γ = Γ 0 , of a phase-space trajectory, Γ t , as determined by Hamilton's equations of motion.
Locality implies that for any conserved density, q(r), a (conserved) current density, j(r), can be defined, such that the two of them satisfy the continuity equation,q(r, t) + ∇ · j(r, t) = 0, whereq indicates the time derivative of q. A current density, j(r, t), satisfying the continuity equation with a conserved density, q(r, t), will be said to be conjugate to q. Strictly speaking, the continuity equation holds for the expectations of conserved densities and current densities, as well as for their phase-space samples,q(r, t) = q(r, Γ t ) j(r, t) = j(r, Γ t ). For the sake of unburdening the notation as much as possible, we will sometimes overlook the distinction between phase-space samples and their expectations.
The Fourier transform of the continuity equation reads:q whereq(k) = q(r)e ik·r dr is the Fourier transform of q, and similarly for j(r) and any other function of r. Equation (1) shows that the smaller the wavevector, |k|, i.e. the longer the wavelength, the slower the dynamics of conserved densities and fluxes. This means that, at sufficiently long wavelength, conserved densities and current densities are adiabatically decoupled from the (zillions of) other atomically fast degrees of freedom. Also, translational invariance implies that conserved densities at different wavevectors do not interact with each other. As a consequence, the dynamics of hydrodynamic variables is determined by a handful of equations that couple them with each other at fixed wavevector. When the intensive variables conjugate to the conserved quantities depend on position sufficiently slowly, the system can be thought of as locally in thermal equilibrium and conserved currents can then be connected to the thermodynamical affinities (i.e. to the gradients of the intensive variables) through the socalled constitutive equations [9]. By combining the constitutive equations with the continuity equations of all the conserved densities and currents, the Navier-Stokes equation of classical hydrodynamics can be derived [9]. Let us consider a system described by a Hamiltonian H • and subject to a time-dependent external perturbation,V (t) = i v i (r, t)q i (r)dr, where {q i } is a set of conserved densities. The perturbed Hamiltonian reads: Here the v i s are to be treated as strengths of the perturbation in linear-response theory. As such, they are not phase-space functions, and they dependence on time only explicitly. To first order in the vs, the expected value of the conserved current densities conjugate to the qs, {ĵ i }, can be obtained from the GK theory of linear response [3,4] as [10]: where k B is the Boltzmann's constant, T the system's temperature, and the correlation function, · , is defined for a pair of general phase-space variables,X andŶ , as the equilibrium expectation over the initial conditions of a molecular trajectory, Γ t , of the time-lagged product of the values of the variables: The dependence of the correlation function in Eq. (4) on the time difference is due to time-translation invariance ensuing from the equilibrium condition. By the same token, space-translation invariance makes the correlation function in Eq.
(3) only depend on r − r , turning the integral in dr into a convolution. Using the continuity equation to replace the time derivative of the density with the divergence of the conjugate current density, Eq. (3) can be cast into a linear relation between the Fourier transforms of the longitudinal component of the current density and the forces acting on the system: whereg (k) = 1 k k ·g(k) indicates the Fourier transform of the longitudinal component of a generic vector field g(r), χ ij (k, t) = 1 kB T j i (k, t)j j (−k, 0) is the longitudinal susceptibility of the current densities, and f i (r) = −∇v i (r) is the force field associated with the v i perturbing potential. For the sake of streamlining the notation and without much loss of generality, we will restrict ourselves to longitudinal perturbations and response currents, and drop the " " suffix from currents and forces. If the external perturbation is independent of time, in the long-wavelength limit Eq. (5) results in the Onsager relation between particle fluxes and applied forces [11,12]: where the index n = (i, α) denotes for short the combination of the indices i, for the conserved charge, and α, for the Cartesian component; the fluxes J n = 1 Ωj n (0) and forces F n = 1 Ωf n (0) are the macroscopic averages of the current densities and force fields, respectively; Ω is the system's volume, and is the matrix of Onsager's transport coefficients [11,12].
In the case of a charged fluid, for instance, the steady state charge flux, J , induced by a stationary electric field, E, is given by J = σE, where the static electrical conductivity is σ = Ω kB T ∞ 0 J (t) · J (0) dt. We can reformulate the GK expression of Onsager's coefficients in another equivalent representation, the socalled Helfand-Einstein (HE) formula, which will be expedient in the following and is also better behaved statistically, based on the identity: valid for any even function, f (−t) = f (t). Let J (t) be a stationary stochastic process representing a conserved flux, so that f (t, t ) = J (t) · J (t ) only depends upon |t − t |. By applying the identity above, we obtain (9) This is called the HE formula, which gives a transport coefficient of some conserved charge, as the ratio of the mean-square dipole, D(T ) = T 0 J (t)dt, displaced by the conserved flux, J , in a time t and time itself. This argument was first exploited by Einstein in his celebrated paper on Brownian motion [13] to establish the relation between diffusivity and velocity autocorrelation functions, and later extended by Helfand to general transport phenomena [14]. A comparison between the numerical performance of the GK and the HE formulas is displayed in Fig. 1 in the case of charge transport in a molten salt. The better stability of the HE integral is evident: not only does the HE integral converge faster than the GK one, but the variance on the first, even though growing linearly with time, is much smaller than the one on the second.
To understand the better statistical behaviour of the HE representation of transport coefficients with respect to the GK one, we leverage the relation between conductivities and the spectral properties of the conserved fluxes, which will also be instrumental in our subsequent considerations on data analysis in Sect. 5. Let us define where One has where Using the Parseval-Plancherel identity [15], one gets where X = GK or HE andΘ T where sinc(x) . = sin(x)/x is the cardinal sine function, are displayed in Fig. 2: as T → ∞, they both tend to 2πδ(ω), where δ indicates the Dirac delta function. One sees that the statistical accuracy of the HE estimate of the transport coefficients is higher than GK's. Using the findings of Sect. 5, in Appendix A we demonstrate that, in the large-T limit, one has indeed the following relation between the statistical uncertainties:

General theory
The gauge-invariance principle of transport coefficients is the condition by which transport coefficients are largely insensitive to the specific definition of the fluxes. In fact, from a microscopic standpoint, any two conserved densities,q (r, t) andq(r, t), whose integrals over a volume Ω differ by a quantity that scales as the volume boundary, should be considered equivalent in the large volume limit, Ω → ∞. For instance, two equivalent densities may differ by the divergence of a (bounded) vector fieldb(r, t): In this sense,q(r, t) andq (r, t) can be thought of as different gauges of the same scalar field. SinceQ = Ωq (r, t)dr is also conserved, for any given gauge of the conserved density,q(r, t), a conserved current density can be defined,ĵ(r, t), to satisfy the continuity equation, Eq. (1). By combining Eqs. (16) and (1) we see that conserved current densities, as well as macroscopic fluxes, transform under a gauge transformation aŝ , and where the dot indicates the Poisson brackets with the unperturbed Hamiltonian. We conclude that the macroscopic energy fluxes in two different energy gauges differ by the total time derivative of a bounded phase-space vector function. Nonetheless, both definitions must lead to the same transport coefficient. To prove such a gauge-invariance principle, let us consider a generic transport process with conserved flux represented by the stochastic stationary process J (t), and define the (generalised, conserved) charge displacement per unit volumeD(T ) = T 0 J (t) dt. According to the HE formulation we can express the transport coefficient of the process, σ, as where the factor c is specific to the transport process considered. The addition of a time-bounded termB(T ) toD(T ), resulting in the new displacementD (T ) ≡ D(T )+B(T ) produces a transport coefficient σ which coincides with σ. In fact, by direct calculation, we have

Some considerations on boundary conditions
To conclude this section, we spend a few words to examine the role of boundary conditions (BC) in practical molecular dynamics simulations of a finite sample of the system. First of all, the simulation box must be larger than the relevant correlation/diffusion lengths of the system, for equilibrium properties to be independent of specific BC adopted in the simulation. In EMD simulations, periodic BC (PBC) are preferred since (1) they minimize size effects, and (2) the limit lim T →∞ T 0 J (t) J (0) dt commutes with thermodynamic limit, where L, N → ∞ while the density L 3 /N is kept fixed. This commutation no longer holds in open BC (OBC) at thermodynamic equilibrium, where the asymptotic time limit, T → ∞, must be taken only after the thermodynamic limit is performed.
Differently stated, PBC have to be preferred with respect to OBC, since they are the only ones which can sustain a steady-state flux [16]. Nonetheless, this poses some issues in the definitions of the fluxes, since the textbook definition relying on the first moment of the time-derivative of the (periodic) charge densityq(r, t), cannot be employed since r is ill-defined in extended, PBC-closed systems. Strictly speaking, Eq. (20) is illdefined in PBC for the very same reason why macroscopic polarisation is so in insulators [17]. The formal meaning of this equation is that it should be considered as the leading order of a Taylor series of the Fourier transform of the time derivative of the conserved density in powers of its argument:q(k, t) = −ik · J (t) + O(k 2 ). Computer simulations performed for systems of any finite size, L, give access to the Fourier components of conserved (current) densities at finite wavevectors whose minimum magnitude is |k min | = 2π L . Let c L (t) = ĵ (k min , t) ·ĵ(−k min , 0) L be the (spatial Fourier transform of the) current-current correlation function evaluated at k = k min , which can be easily evaluated from a MD simulation. Unfortunately, c L (t) cannot be directly used to estimate, not even by extrapolation, the values of the transport coefficients, because the corresponding GK integral vanishes for any finite system size. In practice, the flux to be used to evaluate transport coefficients from the GK formula is obtained from Eq. (20) by formal manipulations that make the flux boundary insensitive. The time correlation function C L (t) . = J (t) · J (0) L , computed for a system of size L, is well-defined as well, and has the property that, for any given t, The tricky thing is the convergence of the limit in Eq. (21) is not uniform and, while ∞ 0 C L (t)dt is the non-vanishing GK integral yielding the transport coefficient we are after. Therefore, definitions for the fluxes suitable to PBC must be properly designed not only from the speculative standpoint, but also to run meaningful simulations. In what follows, we shall largely use these PBC-based definitions together with the gauge invariance principle to draw general conclusions on transport properties which do not depend on the system size, and hold in the thermodynamic limit.

Convective invariance
In a multicomponent system, the (relevant) conserved charges are the energy and the particles number (or, equivalently, the masses) of each atomic species. Since the total-mass flux (i.e. the total linear momentum) is itself a constant of motion, for a K-species system the number of independent conserved fluxes is equal to K (energy, plus K − 1 partial masses) [18]. Further constraints may reduce the number of relevant conserved fluxes. For instance, energy flux becomes the only relevant conserved flux in solids or in one-component molecular liquids, as long as the molecules do not dissociate. In true multicomponent systems (molten salts, solutions, etc.), neither the mass fluxes of the single atomic species are constant of motion nor their integral is a bound quantity. This fact must be taken into account in practical simulations of heat transport since the thermal conductivity relates, by definition, a gradient of temperature to the induced energy flux in the absence of convection, i.e. when the non-equilibrium average of the macroscopic mass flux vanishes.
To make things simpler but also more quantitative, let us consider a two-component system, like, e.g. a molten salt. The conserved fluxes are the energy flux J E and the mass flux of one of the species J M . The following system of phenomenological equations holds: where Δμ is the difference between the chemical potentials of the two species [19], and where J M ≡ J M1 = −J M2 , J M l being the mass flux of species l, the last step following from the conservation of linear momentum. When we set the mass flux J M = 0, which can be substituted in the first equation of the system to finally find where we employed the symmetric property Λ EM = Λ ME . In the light of GK theory, the thermal conductivity κ is obtained by removing from the GK integral of the energy flux a term which represents the contributions of convection/mass diffusion to heat flow [20]. It is straightforward to verify that a change in the definition of the microscopic energy flux by any multiple of the mass flux, does not affect κ, even if such change does change each of the Onsager coefficients in Eq. (25). We dub this peculiar property the "convective invariance" principle. This can be easily extended to more than two species, K > 2, thanks to standard linear algebra techniques. In such case, κ becomes where L = {Λ M l Mm } is the square matrix of Onsager coefficients of the mass fluxes. The convective-invariance principle reads Any linear combination of the mass fluxes can be added to the energy flux without affecting the thermal conductivity. This statement has a direct, crucial consequence concerning ab initio calculations: the heat conductivity cannot in fact depend on whether atomic cores contribute to the definition of the atomic energy, as they would in an all-electron calculation, or not, as they would when using pseudo-potentials. In the latter case, the energy of isolated atoms would depend on the specific form of pseudo-potential adopted, which is to a large extent arbitrary, while the heat conductivity in all cases should not. Thanks to convective invariance, shifting the zero of energy of each species by a quantity δE l would result in a change δE l M l J M l which does not affect κ, just like physical intuition would suggest. Finally, from a more practical way, convective invariance also avoids the calculation of partial enthalpies to dispose of the spurious self-energy effects, a rather tedious and cumbersome task [21][22][23].

Wiener-Khinchin theorem
Cepstral analysis is a powerful spectral method introduced in the '60s for the analysis of time series, mainly in the field of speech recognition and sound engineering [24]. To deploy its power to extract the transport coefficient from the time series of the relevant conserved fluxes, we must shift to a Fourier-space representation of stochastic processes, as allowed by the Wiener-Khinchin theorem [25,26]. The latter states that the expectation of the squared modulus of the Fourier transform of a stationary process is the Fourier transform of its time correlation function. We can thus apply this result to the case where the stochastic process is a conserved flux,Ĵ(t) [the Cartesian indices have been omitted for clarity], and generalize Eq. (9) to the finite-frequency regime as follows: More generally, when several fluxes interact with each other, one can define the cross-spectrum of the conserved fluxes as the Fourier transform of the cross timecorrelation functions: Onsager's coefficients can be thus expressed as As we shall see, one can leverage on the Wiener-Khinchin theorem and the gauge invariance principles to obtain good estimates (i.e. within 10% accuracy) of the transport coefficients with relatively short EMD simulations (i.e. 10-100 ps). In practice, this result is based on a particular spectral method named cepstral analysis of time series, which we describe below.

Periodograms and power spectra
Let us focus on one specific flux. In MD simulation, we shall have it as a (discrete time) sample, here denoted with the calligraphic font, of the flux process: Here is the sampling period, in general a multiple of the timestep of the simulation Δ t , so that N is the total length of the simulation. The discrete Fourier transform of the flux time series is defined bỹ for 0 ≤ k ≤ N − 1. The sample power spectrum S k (i.e. the periodogram) is defined as and, for large N , it is an unbiased estimator of the power spectrum of the process, as defined in Eq. (29), evaluated at namely Since J n ∈ R, we havẽ which, in the continuous limit, amounts to saying that the power spectrum is an even function of frequency: S (ω) = S (−ω). Thanks to this last point, periodograms are usually reported for 0 ≤ k ≤ N 2 and their Fourier transforms are evaluated as discrete cosine transforms. The space autocorrelations of conserved currents j(r, Γ(t)) are usually short-ranged. Therefore, in the thermodynamic limit, the corresponding fluxes J(Γ(t)) = Ω −1 Ω j(r, Γ(t)) dr can be considered sums of (almost) independent identically distributed (iid) stochastic variables: according to the central-limit theorem their equilibrium distribution is Gaussian. Generalizing this argument allows us to conclude that any conserved-flux process is Gaussian as well. The flux time series is in fact a multivariate stochastic variable that, in the thermodynamic limit, results from the sum of (almost) independent variables, thus tending to a multivariate normal deviate. In particular, • for k = 0 or k = N 2 ,J k ∼ N 0, N S(ω k ) ∈ R; • for k / ∈ 0, N 2 , ReJ k and ImJ k are independent and both ∼ N 0, N 2 S(ω k ) .
Here N (μ, σ 2 ) indicates a normal deviate with mean μ and variance σ 2 . In conclusion, in the large-N (i.e. longtime) limit the periodogram of the time series reads: the ξ ∼ 1 2 χ 2 2 being independent random variables, where χ 2 2 is the chi-square distribution with 2 degrees of freedom and is the number of independent samples of the current (for instance, = 3 when the 3 equivalent Cartesian components of the flux are considered). In particular, ξ = 1 and var ξ = 1/ .
Equation (38) shows that S k=0 is an unbiased estimator of the zero-frequency value of the power spectrum, i.e. that S 0 = S(0), and, through Eq. (31), of the Onsager coefficient we are after. However, this estimator is not consistent, i.e. its variance does not vanish in the large-N limit: The multiplicative nature of the statistical noise makes it difficult to disentangle it from the signal. A way to solve the problem is to apply the logarithm to Eq. (38) to turn the multiplicative noise into an additive one by defining the log-periodogram, L k , as The quantities log(ξ k ) are iid stochastic variables whose statistics is well known: their mean and variance are simply expressed in terms of the digamma and trigamma functions, ψ( ) and ψ ( ), respectively [27]. Furthermore, whenever the number of significant (inverse) Fourier components of log(S(ω)) is much smaller than the length of the time series, applying a low-pass filter to Eq. (39) would result in a reduction of the power of the noise, without affecting the signal.
To exploit this idea, we define the cepstrum of the time series as the inverse Fourier transform of its sample logspectrum [28]: A generalized central-limit theorem for Fourier transforms of stationary time series ensures that, in the large-N limit, these coefficients are a set of independent (almost) identically distributed zero-mean normal deviates [29,30]. It also follows that: Figure 3 confirms the typical behaviour of cepstral coefficients calculated from the low-frequency region of the periodogram. We see that only a few coefficients are in fact substantially different from zero, within statistical uncertainty.
Let us indicate by P * the smallest integer such that C n ≈ 0 for P * ≤ n ≤ N − P * . By limiting the Fourier transform of the sample cepstrum, Eq. (40), to P * coefficients, we obtain an efficient estimator of the zerofrequency component of the log-spectrum, L * 0 , whose expectation and variance are var(L * 0 ) = ψ ( ) We thus see that the logarithm of the Onsager coefficient we are after can be estimated from the cepstral coefficients of the flux time series through Eqs. (42)(43), and that the resulting estimator is always a normal deviate whose variance depends on the specific system only through the number of these coefficients, P * . Notice that the absolute error on the logarithm of the conductivity directly and nicely yields the relative error on the conductivity itself. The efficacy of this approach obviously depends on our ability to estimate the number of coefficients necessary to keep the bias introduced by the truncation to a value smaller than the statistical error, while maintaining the magnitude of the latter at a prescribed acceptable level. In Ref. [8], it has been proposed to estimate P * using the Akaike's information criterion [31], even if other more advanced model selection approaches may be more effective [32]. A plot of L * 0 vs P * is shown in Fig. 4. We immediately realize that P * returned by the AIC (vertical dashed line) is indeed capable to find the correct value for the logspectrum-within statistical error-of lowest variance. Furthermore, thanks to the convective invariance principle described in Sect. 4, the cepstral analysis can be extended to multicomponent systems [7]. This multivariate cepstral method has been recently applied to calculate the ab initio thermal conductivity of water at planetary conditions from trajectories as short as a few tens of picoseconds [33]. It has been also shown that the multivariate cepstral analysis is able to substantially reduce the statistical error affecting the estimate of thermal conductivity even for one-component systems: it can in fact decorrelate the finite-frequency power spectrum of non-diffusive fluxes (like the mass flux, or the adiabatic electronic flux in ab initio simulations) from the heat flux power spectrum, which will have its total power considerably reduced, and whose low-frequency portion will be easier to analyse [7]. The statistical tools for time-series analysis presented in this Section have been implemented in the open-source code SporTran, which is freely downloadable from the GitHub repository https://github.com/lorisercole/ sportran [34].

Ab initio heat transport in insulators
Until only a few years ago, it was thought that ab initio MD simulations were in general unsuitable to a GK theory of thermal transport, since the continuous electronic density makes any decomposition of the energy flux into local, atomic contributions fully arbitrary [35]. This consideration clashes with a reductionist picture whereby a fundamental description of the microscopic interactions should be in principle suitable to describe heat transport in the very general GK theory, as well. Once again, this apparent inconsistency stands on the misconception that the definition of microscopic fluxes must be unique, and it is thus solved thanks to the gauge-invariance principle. Apart from correcting such a misconception, the gauge-invariance principle proves to be also a rigorous mathematical tool to derive a welldefined expression (out of the infinitely many possibilities!) for the energy flux directly from DFT, with no ad hoc approximation tailored on the considered physical system [36]. The starting point is the standard DFT definition of the total energy in terms of the Kohn-Sham (KS) eigenvalues ε v , eigenfunctions φ v (r), and density n(r) = v |φ v (r)| 2 [37]: where e is the electron charge, XC [n](r) is a local exchange-correlation (XC) energy per particle defined by the relation XC [n](r)n(r)dr = E XC [n], the latter being the total XC energy of the system, and μ XC (r) = δEXC δn(r ) is the XC potential [in this Section and in Sect. 7 we drop the hat on top of classical observables to avoid confusion with quantum operators]. From this we can write a DFT energy density as [38] E DF T = e DF T (r)dr, where H KS is the instantaneous self-consistent Kohn-Sham Hamiltonian, and v H = e 2 dr n(r ) |r −r | is the Hartree potential. An explicit expression for the DFT energy flux, obtained by computing the first moment of the time derivative of the energy density in Eqs. (45)(46)(47)(48), results in a number of terms, some of which are either infinite or ill-defined in PBC, since the position operator is not periodic. Leveraging on gauge invariance and on a careful breakup and refactoring of the various harmful terms, as explained in Refs. [5,39], we can recast Eq. (49) in a form suitable to PBC, whose final expression is where Herev 0 is the bare, possibly non-local, (pseudo-)potential acting on the electrons and are the projections over the empty-state manifold of the action of the position operator over the vth occupied orbital, and of its adiabatic time derivative [40][41][42], respectively,P v andP c = 1 −P v being the projector operators over the occupied-and empty-states manifolds, respectively. Both these functions are well defined in PBC and can be computed, explicitly or implicitly, using standard density-functional perturbation theory [42]. These rather complicated formulae have been implemented in the open-source code QEHeat of the Quantum ESPRESSO project which has been publicly released [43].

Ab initio charge transport in ionic conductors
While in metals the current is carried by delocalised conduction electrons, in electronic insulators the electrons are bound to follow adiabatically the ionic motion and no charge transport can occur if the ion positions are frozen. Nonetheless, when ions are allowed to move, like in ionic liquids, charge can be displaced. Daily life examples range from simple salted water, to liquid electrolytes employed in Li-ion batteries, or to the molten salts (NaCl, KCl, etc.) used as heat exchangers in power plants. 1 Due to their large electronic bandgap, ionic liquids are in general transparent to visible light and possess a negligible fraction of "free", conduction electrons. When the quantum nature of the electrons is considered, a question arises about a proper definition for the charge flux, J (t), to employ in the GK expression for the electrical conductivity, σ: Any static partition of the instantaneous total charge to express J into atomic contributions is in fact totally arbitrary.
The solution comes from the modern theory of polarisation (MTP), which provides a definition for the polarisation P valid for extended systems [45][46][47]. Just like the electronic Hamiltonian and ground state, P depends on time through the nuclear coordinates only: we can thus apply the chain rule and write J (t) as a sum of atomic contributions where V i (t) is the atomic velocity of the ith atom and Z * i (t) is a time-dependent tensor whose entries, ∂R iβ , are the derivative of the cell polarisation along the Cartesian direction α with respect to the atomic displacement of atom i along β. The dynamical charges Z i are called "Born effective-charge tensors", and can be computed in perturbation theory [43], or by finite force differences when introducing a finite electric field E in accordance to the MTP [48]. Born charge tensors are in general strongly dependent on the atomic positions, and they display large fluctuations along a AIMD trajectory, even for strongly ionic systems [49]. For these reasons, the charge flux defined in Eq. (58) is in general fluctuating and does not vanish identically. Therefore, there is no apparent reason for the GK integral in Eq. (57) to be exactly zero. How come, then, that the electrical conductivity of, say, pure water is zero? And why, instead, under the same microscopic formalism, does a salted water solution have a nonvanishing σ? Another strange "coincidence" reported in the literature [50] is that by replacing in Eq. (58) the time-dependent Born charge tensors with the predefined constant integer charges-the oxidation numbers of the atoms-to define a new flux leads to the same GK integral, Eq. (57), that is obtained via the alternative definition J in Eq. (58). 2 It seems, therefore, that two main aspects must be understood to answer the fundamental questions raised above: first, the presence of integer numbers suggests some underlying quantisation in the charge transport process; second, the insensitivity of σ to the choice of one of the two different definition J = J hints at a manifestation of the gauge invariance principle of transport coefficients, described in Sect. 3. We analyse in detail these two aspects in what follows.

Quantisation of charge transport
In 1983, David Thouless showed that for a quantum system in PBC, with non-degenerate ground state evolving adiabatically under a cyclic, slowly varying Hamilto-nianĤ(0) =Ĥ(τ ), the total displaced dipole, Δμ is quantised, i.e. the time integral of the current over one cycle τ is equal to a triplet of integers, multiplied by the side L of the cell, which we shall assume cubic for simplicity [51]: with Q = (Q x , Q y , Q z ) ∈ Z 3 . In AIMD simulations, atomic trajectories are identified by paths in the nuclear configuration space (NCS). The electronic Hamiltonian, H(R(t)), depends parametrically upon time through the nuclear positions, at time t, R(t) = {R i (t)}, with i = 1, . . . , N at . A path C in NCS whose end points are one the the periodic image of the other can be thus considered as a cycle for the electronic Hamiltonian. Therefore, we can thus employ Thouless' theorem and show, under very general hypothesis, that the electric dipole displaced along C is itself partitioned into atomic contributions: where n i = (n x , n y , n z ) i is the triplet containing the number of cells spanned, along C, by atom i in x, y and z directions, and q S (i) are integer constants which only depend on the species S(i) of atom i, and are shown to coincide with the oxidation numbers suggested by chemical intuition [49]. This provides a quantum-mechanical definition of oxidation numbers where their integerness arises naturally (and not just as an approximation of some real charge), and which identifies them as intrinsically dynamical quantities [49,52].

Gauge invariance of electrical conductivity
We are now ready to combine the theory of quantisation of charge transport and the gauge-invariance principle of transport coefficients to answer the questions raised at beginning of this Section. Let us consider a physical path in the NCS from an initial configuration I to the configuration F , as a result, e.g. of an AIMD simulation. Then we elongate the path fictitiously up to the point I which is the replica (periodic image) of the initial point I sharing with the point F the same cell of the nuclear configuration space, as depicted by the dashed line in Fig. 5.
Due to the additivity of integrals, the electric dipole displaced along the physical path IF reads Since the open path I F entirely belongs to one cell, Δμ I F is a bounded quantity. Therefore, thanks to gauge-invariance, to evaluate σ we only need to consider By the same token, the electric dipole displaced from I to F by to the flux J (t) defined in Eq. (59) is Therefore, we can conclude that which, by comparison with Eq. (64), proves the equivalence of the electrical conductivities obtained via Eqs. (58) and (59). This is shown in Fig. 6 for an ab initio MD simulation of molten KCl. As explained in detail in Ref. [49], this result is grounded on the hypothesis, which we dubbed strong adiabaticity, that any closed paths in the NCS can be shrunk to a point without closing the electronic gap: this implies-see Eq. (61)-that charge transport can occur only through a net displacement of the ions, as it is typical of stoichiometric ionic conductors. The breach of strong adiabaticity may instead dictate a non-trivial charge-transport regime where charge may be adiabatically transported even in the absence of a net ionic displacement. As shown in Ref. [53] this non-trivial behaviour is intertwined with the presence, in nonstoichiometric electrolytes, of dissolved yet localised  58) and (59) share the same slope, and thus the same electrical conductivity. The difference J − J is instead non-diffusive (zero slope). The fits of the curves at asymptotic times are also displayed (dashed lines) electrons, whose displacement is to a large extent uncorrelated to that of the ions. By the same token discussed in Sect. 3.2, we remark that all the conclusions drawn in this Section are independent of the (macroscopic) size L of the system. In fact, even though all the derivation of Eq. (66) is done at finite size, the use of charge fluxes which are well defined in PBC ensures that the GK integrals of their correlation functions are well defined and non-vanishing identically, for any L.

Conclusions
To conclude, we believe that we managed to show how the invariance principles of transport coefficients can be employed, within the general Green-Kubo theory of linear response, to demystify some common misconceptions based on the groundless assumption that the microscopic conserved fluxes must be uniquely defined. We have further deployed the power of invariance principles in the construction of numerical tools for the statistical analysis of the time series of the fluxes, produced via equilibrium molecular dynamics simulations. These tools provide accurate values for the transport coefficients from the relatively short trajectories which are accessible to ab initio MD simulations. We also showed how to design an ab initio heat flux suitable to extended systems in PBC, from which the ab initio thermal conductivity can be computed without any further system-or phase-specific assumptions. Finally, we have applied the gauge invariance principle to the ab initio charge transport in ionic systems. We showed that each ion can be associated with a well-defined integer and time-independent charge, and the exact ab initio electrical conductivity can be obtained by replacing, with these integer charges, the time-dependent Born tensors, which enter the definition of the charge flux and whose calculation is a computationally expensive and quite abstruse task. In this way, we recover the classical (Faraday's) idea of atomic contributions to charge transport [54] and provided a theoretically sound definition to the concept of oxidation states in ionic liquid insulators. We are confident that the results here exposed will be a valid aid for both theorists and practitioners aiming at deeper insights and more efficient implementations about the calculation of transport coefficients from molecular dynamics simulations.

Data Availability Statement
The manuscript has associated data in a data repository. [Authors' comment: The data that support the plots and relevant results within this paper are available on the Materials Cloud platform [55] at Materials Cloud Archive 2021.112(2021), https://doi.org/ 10.24435/materialscloud:rp-cd.] Author contribution statement The authors contributed equally to all parts of this work.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/.

Appendix A: Variance on GK and HE formulas
To evaluate the statistical error affecting the GK or HE expressions of the transport coefficients, Eq. (14), we con- where X = GK or HE, Ttot = N is the total length of the time series of the flux, N the number of its terms, the sampling period, and ξ k are the set of independent stochastic variables introduced in Eq. (38). As the ξ k variables are independent and identically distributed, one has var (λX ) = 2 4T 2 tot N −1 k=0Θ T X (ω k ) 2 S(ω k ) 2 var (ξ) where we employed Eq. (10) and where the factor 2 in the first step accounts for the full correlation between S (ω) and S (−ω). This behaviour is shown in Fig. 7, which displays the theoretical estimate, Eq. (A2), for the variance on the GK integral, as well as the empirical variances for GK (blue) and HE (orange) integrals of the charge flux autocorrelation function, obtained via standard block analysis from the simulation of molten KCl already discussed in Sect. 2.
Notice that, to obtain the variance on the mean value λX , the variance of the process, which is independent of the number B of trajectories (or blocks) of length Ttot employed, must be further divided by B [56].