1 Introduction

In this paper, we discuss, focusing on recent developments, the Mass-Zero (MaZe) constrained dynamics and further extend it to a simple but interesting model of classical polarizable systems in constant external magnetic field. MaZe is a general simulation approach to study the motion of a set of physical degrees of freedom (dofs) whose evolution depends on parameters subject to given conditions. The method considers an extended system in which the parameters appear as (auxiliary) dynamical variables together with the original dofs and the conditions are interpreted as constraints. The coupled evolution equations for the overall constrained system are then conveniently obtained in the Lagrangian formalism. From these, the original parametric dynamics for the physical dofs is rigorously recovered by taking the limit of zero mass for the auxiliary variables. In practical implementations, use of the SHAKE algorithm enables symplectic and efficient numerical integration of the extended dynamical system.

The method of mass-zero constraints was originally introduced in the early 1980s to study the rotational–translational coupling in diatomic molecules [1]. Recently, it has undergone a new set of developments when adiabatic systems were identified as an important area where MaZe dynamics can provide an original formal approach and an effective integration algorithm [2,3,4]. In adiabatic systems, the substantial timescale separation of the motion of two sets of interacting degrees of freedom justifies adopting the Born–Oppenheimer approximation for the evolution. The timescale gap is typically due to the disparate masses of the two sets and full adiabatic separation is achieved in the limit of zero mass for the fast dofs. In the context of nuclear and electronic motion, for which the Born–Oppenheimer approximation was originally introduced, adiabaticity also requires the existence of a finite gap between the HOMO and LUMO electronic states. In the full adiabatic regime, evolution equations, typically of classical form, are given for the slow degrees of freedom. The forces on the slow variables, however, depend parametrically on the values of the fast variables. These values are obtained, for each configuration of the slow degrees of freedom along the trajectory, enforcing the condition that the interaction potential (a function of both sets) is at a minimum with respect to the fast dofs. In Molecular Dynamics (MD), a typical example of adiabatic dynamics is the evolution of ionic (slow) and electronic (fast) degrees of freedom in first principle calculations based on Kohn–Sham or orbital-free Density Functional Theory. Another important example is given by classical models of polarization in which electrons do not appear directly, but the dynamical system is extended to include sets of classical auxiliary variables of null mass mimicking different polarization effects.

Current methods adopted for the MD simulation of such systems combine standard propagation schemes for the slow variables—that we shall indicate as the ions for simplicity—with algorithms to find, or approximate, the minimum of the potential with respect to the fast dofs at each ionic configuration. Depending on the specific system, additional conditions, such as orthonormality or sum rules, may be imposed on the fast dofs, affecting the minimum search. Traditional schemes for finding the minimum include iterative methods, notably the conjugate-gradient approach [5, 6] adopted in Born–Oppenheimer MD. In Car–Parrinello MD, on the other hand, an extended system in which the auxiliary dofs are treated as dynamical variables with a small mass is defined [7, 8]. In this scheme, the minimum condition is approximately tracked, with a precision that improves with smaller mass for the auxiliary dofs [9,10,11,12], via the dynamics itself thus avoiding iterations. More recently, alternative ad hoc dynamics for the auxiliary variables like the so-called always stable predictor–corrector approach [13, 14] have also been employed. All these methods, however, suffer from practical or conceptual limitations. Conjugate-gradient minimization is guaranteed to converge only in the case of a quadratic function to be minimized, and, for the general minimization problems typically associated with realistic condensed-phase models, can be unstable [15] or expensive [16] to fully converge. Incomplete convergence of the iterative minimization in Born–Oppenheimer MD, also known as the self-consistent-field optimization, has been shown to cause energy transfer between the slow and fast dofs [17, 18], leading to energy drift in the ionic propagation and hindering access to long simulation timescales. Energy transfer, and the consequent violation of the adiabatic separation in the system, affects also Car–Parrinello propagation [5] due to the finite ratio of the masses associated with the fast and slow dofs. This pathology is often mitigated via thermostats that, however, may affect or, in the worst cases, compromise correct statistical sampling. Furthermore, the Car–Parrinello algorithm requires a very small timestep to integrate accurately the dynamics of the fast variables. The always stable predictor–corrector scheme is only approximately time-reversible [13, 14] leading again to energy drifts that are usually quenched via a Berendsen thermostat (thus raising questions on the ensemble sampled by the dynamics), and it contains system-dependent parameters that can only be determined by trial and error. An alternative and quite successful scheme, that combines an extended Lagrangian approach with efficient self-consistent minimization, was recently proposed to address these shortcomings in the so-called extended Lagrangian Born–Oppenheimer approach [19, 20]. The method is formally fully time-reversible and has been used in several interesting applications. The practical integration of the evolution equations for the auxiliary variables, however, requires, in particular for longer simulations, to dampen propagation of numerical noise that causes a divergence of the auxiliary dofs from the exact ground-state density [20, 21]. The modified Verlet algorithm used for this purpose breaks full-time reversibility of the propagation.

The MaZe approach avoids many of the difficulties described above. Adopting the framework of constrained MD [22], in combination with the SHAKE algorithm [23], MaZe enables to derive and numerically solve classical evolution equations for an extended system that rigorously enforces exact adiabatic propagation. Exploiting and adapting the formalism of Lagrange multipliers, the method can incorporate easily additional constraints that depend only on the auxiliary variables, such as electroneutrality in classical polarizable models or orthonormality in first principles calculations. The MaZe dynamical system is solved via a fully symplectic, time-reversible algorithm that guarantees stability of the evolution on the same timescale and with the same timestep size of standard MD for the physical dofs. The algorithm prevents, by construction, propagation of the error when imposing the constraints. Furthermore, the approach avoids standard self-consistent cycles for the minimization along the dynamics and uses iterations only to solve the equation of constraints, a process that usually has fast convergence, in particular in nonlinear problems, enabling to reach essentially the numerical precision limit at an affordable cost [2,3,4]. Importantly, rigorous sampling of the target probability for the physical dofs (which coincides with the one usually associated to Born-Oppenheimer dynamics) is also guaranteed [3] ensuring that not only the adiabatic evolution, but also the exact statistical mechanics of the system is obtained. In the context of adiabatic systems, MaZe has been used to simulate simple classical polarizable systems [2], and more recently for state-of-the-art classical modeling of electrode charges in electrochemical systems [4] (the method has also been implemented in MetalWalls [24], a high-performance community software in this area). The generalization to first principle MD based on orbital-free density functional theory was also derived and tested with very good results [3].

In the following, we first discuss the key aspects of MaZe summarizing recent work on the dynamical and statistical properties of the approach. For simplicity, the formalism will be presented using as reference application the adiabatic evolution of classical polarizable models. This choice is motivated also by the new MaZe development presented in the second part of the paper: the generalization of the approach for adiabatic propagation of classical polarizable models in external magnetic field. Although the model system considered in this work has some limitations (see detailed description in the following), this generalization is motivated by the problem of simulating ionic charge transport in systems subject to a magnetic field, with particular focus on the ionic Hall effect [25,26,27], an area that has attracted considerable interest to investigate the properties of superionic conductors [28, 29] and, more recently, to enhance the capacitance of batteries [30]; including the magnetic field in classical polarizable models requires, even with the simplified model adopted here, some nontrivial adaptations of the MaZe approach. First, due to the Lorentz force, the condition of null force on the fast degrees of freedom involves both the coordinates and the velocities of these particles, thus leading to a set of nonholonomic constraints associated with the MaZe dynamics. These constraints are, however, linear in the velocities, enabling to adapt the approach via a relatively standard generalization of the Lagrangian equations of motion for the system. Second, again due to the dependence of the constraint on the velocities, the standard SHAKE algorithm—not the idea at the basis of the approach—cannot be directly applied. While some methods for the numerical integration of systems subject to nonholonomic constraints exist [31, 32], they are not as consolidated as SHAKE and often rely on nonsymplectic algorithms. In this work, we then propose an appropriate integration algorithm and test its properties.

The paper is organized as follows. In Sect. 2, the derivation of the MaZe dynamical system and the proof of exact sampling of the Born–Oppenheimer probability density for the slow degrees of freedom are summarized. The presentation will be self-contained, also with the support of Appendix A, but we limit the proofs to their key steps, referring to previous work for more details. Our focus, in fact, will be to illustrate the most interesting formal and practical aspects of the approach. In Sect. 3, we then introduce the generalization of the MaZe framework to the case of classical polarizable simulations in constant magnetic field, together with the new algorithm for the solution of the nonholonomic constrained dynamics. We consider, for convenience and given the exploratory purposes of these first MaZe developments in the presence of magnetic field, the simplest model of classical polarization, i.e., the shell model [33], and neglect possible magnetization effects. Section 4 reports an illustrative calculation investigating the combined effect of polarization and of the magnetic field on ionic charge transport properties in liquid NaCl.

2 MaZe dynamics and statistical mechanics

As mentioned above, to simplify the presentation and tackle an interesting physical case, we illustrate the MaZe approach via its application to classical polarizable models. These models are commonly employed to simulate systems of theoretical and technological interest such as devices for electrochemical energy storage [34,35,36] in which large sizes and long timescale prevent direct calculation of polarization effects via the quantum treatment of the electronic density in first principles MD. In this area then, polarization effects are described by constructing empirical potentials that include sets of auxiliary variables that mimic changes in the electronic density. Because they represent electronic properties, these auxiliary variables are assumed to adapt instantaneously to the ionic configuration in the spirit of the Born–Oppenheimer approximation and are assigned a null mass. An early example of this type of models is the shell model [33, 37, 38], which accounts for dipole polarization. Potentials that take into account interactions due to quadrupoles [39] and changes in the ions size and shape [40, 41] have also been introduced. More recently, models for capacitors have been proposed that include the mutual polarization of the elements combining a multipole description of the electrolyte with the so-called fluctuating charge model [7, 42] for the electrodes.

To be more specific, let us indicate with \(\varvec{R} \in \mathbb {R}^{3N}\) the Cartesian coordinates of the N physical dofs in the system (ions), and with \(s \in \mathbb {R}^M\) the M adiabatically separated auxiliary variables. Depending on the specific polarization model, the s variables may represent positions (as in the shell model) or different types of degrees of freedom (e.g., dipoles or quadrupoles, or charges) and their physical dimensions and number vary accordingly. The two sets of variables interact via the potential \(V(\varvec{R}, s)\). The adiabatic dynamics of the system is obtained by imposing that the auxiliary variables satisfy, for all values of \(\varvec{R}\) along the trajectory, the condition

$$\begin{aligned} \frac{\partial V(\varvec{R}, s)}{\partial s_\alpha } = 0 \qquad \alpha = 1,\dots ,M. \end{aligned}$$
(1)

Additional conditions, such as the charge neutrality constraint for classical models of electrodes, may be associated with the auxiliary dofs. These conditions are typically expressed as

$$\begin{aligned} f_\iota (s) = 0 \quad (\iota = 1, \dots , C), \end{aligned}$$
(2)

where C is the number of the additional constraints that we shall assume to be, as it is often the case, functions of the s variables alone. Equation (2) implies that not all variations of the s are independent, and this must be accounted for in the search of the minimum of the potential. For example, in Born–Oppenheimer dynamics, the conjugate-gradient minimization is conducted via a constrained search, while in Car–Parrinello schemes, the additional constraints are added in the evolution equations derived from the Lagrangian. In the following, we indicate with \(\tilde{s}\) the values of the auxiliary variables satisfying both the minimum condition on the potential and the additional constraints, if they are present. Due to the dependence of the potential on \(\varvec{R}\), \(\tilde{s}=\tilde{s}(\varvec{R})\). In the adiabatic regime, then, the evolution of the physical variables is given by

$$\begin{aligned} m_i\ddot{\varvec{R}}_i = -\nabla _{\varvec{R}_i}V(\varvec{R}, s)\big |_{s=\tilde{s}}, \end{aligned}$$
(3)

where \(m_i\) is the mass of ion i. As discussed in the Introduction, current approaches for the numerical solution of the equation above have limitations that justify the development of alternative schemes. Starting from the next subsection, the MaZe approach is presented.

2.1 MaZe dynamical system

The key idea of the mass-zero constrained dynamics is to construct a Lagrangian that includes the s as dynamical variables and to interpret Eq. (1) as a set of holonomic constraints. In this section, MaZe is presented for the general case in which additional conditions must be satisfied by the fast dofs. In this case, the system is further extended to include also the Lagrange multipliers associated with these conditions as auxiliary variables. To set the stage, let us introduce the auxiliary function

$$\begin{aligned} W(\varvec{R}, s, \nu )\equiv V(\varvec{R}, s)+\sum _{\iota = 1}^C\nu _\iota f_\iota (s), \end{aligned}$$
(4)

where \(\nu = \{ \nu _1,...,\nu _C\}\) are Lagrange multipliers associated to the additional constraints. The solution for s and \(\nu \) satisfying Eqs. (1) and  (2) is then given by the stationary point \((\hat{s},\hat{\nu })\) of \(W(\varvec{R}, s, \nu )\) [43, 44]. This leads to the \(M+C\) conditions

$$\begin{aligned} \begin{aligned} \sigma _\alpha (\varvec{R}, s, \nu )&= \frac{\partial W(\varvec{R}, s, \nu )}{\partial s_\alpha } = 0 \,\,\,\, (\alpha =1,\dots ,M) \\ \sigma _{M+\iota }(\varvec{R}, s, \nu )&= \frac{\partial W(\varvec{R}, s, \nu )}{\partial \nu _\iota } = 0 \,\,\,\, (\iota =1,\dots ,C). \end{aligned} \end{aligned}$$
(5)

Note that the last set of equations above represents in fact the additional conditions of Eq. (2), now obtained as the result of an optimization problem in the space that includes the Lagrange multipliers \(\nu \) as additional variables. In the absence of additional conditions, on the other hand, \(W(\varvec{R}, s, \nu )\equiv V(\varvec{R}, s)\) and the M surviving conditions above reduce to Eq. (1). At this stage, a finite fictitious “mass” is assigned to both sets of auxiliary variables.Footnote 1 Indicating the fictitious mass for the s and \(\nu \) variables as \(\mu _s\) and \(\mu _{\nu }\), respectively, the Lagrangian for the extended system is defined as

$$\begin{aligned} L(\varvec{R}, \dot{\varvec{R}}, s, \dot{s}, \nu , \dot{\nu })= & {} \frac{1}{2}\sum _{i=1}^{N}m_i\dot{\varvec{R}}^{2}_{i} + \frac{1}{2}\sum _{\alpha =1}^M\mu _s \dot{s}^2_\alpha \nonumber \\&+ \frac{1}{2}\sum _{\iota =1}^C\mu _{\nu } \dot{\nu }^2_{\iota } - W(\varvec{R}, s, \nu ), \end{aligned}$$
(6)

From this, the constrained evolution equations are obtained as

$$\begin{aligned} \begin{aligned} m_i\ddot{\varvec{R}}_i&= -\nabla _{\varvec{R}_i}W(\varvec{R}, s, \nu ) - \sum _{\beta = 1}^{M+C} \lambda _{\beta } \nabla _{\varvec{R}_i}\sigma _{\beta }(\varvec{R}, s, \nu )\\ \mu _s\ddot{s}_\alpha&= -\frac{\partial W(\varvec{R}, s, \nu )}{\partial s_{\alpha }} - \sum _{\beta = 1}^{M+C} \lambda _{\beta } \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial s_{\alpha }}\\ \mu _{\nu }\ddot{\nu }_{\iota }&= -\frac{\partial W(\varvec{R}, s, \nu )}{\partial \nu _{\iota }} -\sum _{\beta =1}^{M+C}\lambda _{\beta } \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial \nu _\iota }. \end{aligned} \end{aligned}$$
(7)

The equations above can be simplified by observing that, in the first line, \(\nabla _{\varvec{R}_i}W(\varvec{R}, s, \nu ) =\nabla _{\varvec{R}_i}V(\varvec{R}, s)\), and that the forces acting on the auxiliary variables are null, because they coincide with the constraints. Thus, dividing both sides of the equations for the auxiliary variables by their masses

$$\begin{aligned} \begin{aligned} m_i\ddot{\varvec{R}}_i&= -\nabla _{\varvec{R}_i}V(\varvec{R}, s) - \sum _{\beta = 1}^{M+C} \lambda _{\beta } \nabla _{\varvec{R}_i}\sigma _{\beta }(\varvec{R}, s, \nu )\\ \ddot{s}_\alpha&= - \sum _{\beta = 1}^{M+C} \frac{\lambda _{\beta }}{\mu _s} \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial s_{\alpha }}\\ \ddot{\nu }_{\iota }&= -\sum _{\beta =1}^{M+C}\frac{\lambda _{\beta }}{\mu _\nu } \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial \nu _\iota }. \end{aligned} \end{aligned}$$
(8)

Let us now consider the limit of zero mass for both sets of auxiliary variables. For this limit to be well defined, it needs to be taken in a homogeneous way. We then set \(\mu _{\nu }\equiv \mu _s/{\kappa }\) with \(\kappa \) a nonzero constant of dimensions given by the ratio of the masses, so that the last equation in the system above becomes

$$\begin{aligned} \ddot{\nu }_{\iota } = -\sum _{\beta =1}^{M+C}\kappa \frac{\lambda _{\beta }}{\mu _s} \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial \nu _\iota }. \end{aligned}$$
(9)

We can now take the limit \(\mu _s\rightarrow 0\) in Eq. (8). In order for the auxiliary variables to have finite acceleration, the ratio \(\gamma _\beta = \lim _{\mu _s\rightarrow 0}\frac{\lambda _\beta }{\mu _s}\) must remain finite, implying that the Lagrange multipliers \(\lambda _\beta \) are proportional to \(\mu _s\). In the limit of zero mass for the auxiliary variables, then

$$\begin{aligned} \begin{aligned} m_i\ddot{\varvec{R}}_i&= -\nabla _{\varvec{R}_i}V(\varvec{R}, s), \\ \ddot{s}_\alpha&= -\sum _{\beta =1}^{M+C}\gamma _{\beta } \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial s_\alpha },\\ \ddot{\nu }_{\iota }&= -\sum _{\beta =1}^{M+C}\kappa \gamma _{\beta } \frac{\partial \sigma _{\beta }(\varvec{R}, s, \nu )}{\partial \nu _\iota }. \end{aligned} \end{aligned}$$
(10)

Equation (10) defines the mass-zero constrained dynamics and it enables to recognize most of the interesting properties of the approach mentioned in the Introduction. First, since the Lagrange multipliers \(\lambda _\beta \) go to zero with the auxiliary masses \(\mu _s\), the evolution of the physical variables does not depend directly on the constraints. Second, the dynamics of the s and \(\nu \), controlled only by the constraint forces, satisfy by construction all the conditions imposed on the system. This implies that these conditions are automatically fulfilled also in the first of Eqs. (10) which is then equivalent to Eq. (3). Thus, by rigorously enforcing the mass-zero limit for the auxiliary variables, the system above provides a classical evolution for all degrees of freedom that leads to the exact adiabatic dynamics for the physical ones. Third, the numerical integration of the first equation can be performed with any standard MD algorithms (e.g., Verlet) with a timestep determined only by the force acting on the physical dofs. In addition, at each timestep, the Lagrange multipliers \(\gamma _\alpha \), that appear as unknown, time-dependent parameters in the dynamical system, must be determined. This is done enforcing the constraint, \(\sigma _{\alpha }(\varvec{R}(t+dt), s(t+dt), \nu (t+dt))=0\), at the position predicted by the MD algorithm as described in Refs. [22, 23]. This approach prevents propagation of the error between values of the variables at different timesteps. In the current implementations of the approach, the constraints are satisfied via the SHAKE iterative algorithm, which was proven to be symplectic and time-reversible [45, 46]. Note that the homogeneous mass-zero limit has introduced an unknown scaling factor \(\kappa \) in the equations. The choice of the numerical value of this parameter depends on the specific system and is discussed more in detail in Refs. [3, 4], where it is also shown that MaZe results are very stable with respect to this choice.

To conclude this section, note that when no additional constraints are present, i.e., in the absence of the \(\nu \) variables, the MaZe system reduces to

$$\begin{aligned} \begin{aligned} m_i\ddot{\varvec{R}}_i&= -\nabla _{\varvec{R}_i}V(\varvec{R}, s), \\ \ddot{s}_\alpha&= -\sum _{\beta =1}^M\gamma _{\beta } \frac{\partial \sigma _{\beta }(\varvec{R}, s)}{\partial s_\alpha }. \end{aligned} \end{aligned}$$
(11)

This form of the evolution equations is appropriate, for example, to simulate the shell model and, in view of the specific application considered in the results section and to simplify the notation, we shall adopt it in what follows. In particular, in the next subsection, we shall prove Eq. (11) samples exactly the Born–Oppenheimer probability density for the physical variables, i.e., the last MaZe property mentioned in the Introduction. This is an interesting result, because the use of constraints may induce a nontrivial metric in the phase space of the system [47, 48] and require appropriate reweighting of statistical properties in the physical phase space. Furthermore, importantly, we shall show that approximate adiabatic separation, i.e., performing a dynamics with \(\mu \ne 0\), can induce a bias in the statistical properties of the system.

2.2 Statistical mechanics of the Mass-Zero constrained evolution

The discussion in this subsection summarizes the proof presented in Ref. [4] and is reported here for completeness and for the reader’s convenience. Let us start by reconsidering the extended system before the mass-zero limit is taken. In the absence of additional conditions, the Lagrangian is given by

$$\begin{aligned} L(\varvec{R}, \dot{\varvec{R}}, s, \dot{s}) = \frac{1}{2}\sum _{i=1}^{N}m_i\dot{\varvec{R}}^{2}_{i} + \frac{1}{2}\sum _{\alpha =1}^M\mu _s \dot{s}^2_\alpha - V(\varvec{R}, s). \end{aligned}$$
(12)

The statistical mechanics of the system is described more naturally using (at first) a convenient set of generalized coordinates and in the Hamiltonian formalism. Proceeding in analogy with Ref. [48], we then start by performing the change of variables

$$\begin{aligned} \begin{aligned} \varvec{R}_i&\mapsto \varvec{\rho }_i = \varvec{R}_i \\ s_\alpha&\mapsto \sigma _\alpha = \sigma _\alpha (\varvec{R}, s). \end{aligned} \end{aligned}$$
(13)

In the following, we shall use the notation \(\upsilon = (\varvec{\rho }, \sigma )\) where \(\varvec{\rho }=\{\varvec{\rho }_1,...,\varvec{\rho }_{N}\}\) and \(\sigma =\{\sigma _1,...,\sigma _M\}\) and observables expressed in the new variables will be denoted in calligraphic font. The Hamiltonian of the system can be obtained via standard Legendre transform of the Lagrangian \(\mathcal {L}(\upsilon ,\dot{\upsilon })=L\bigl (R(\upsilon ),s(\upsilon ),\dot{R}(\upsilon ,\dot{\upsilon }),\dot{s}(\upsilon ,\dot{\upsilon })\bigr )\), and is given by

$$\begin{aligned} \mathcal {H}(\upsilon , \pi ^{\upsilon }) = \frac{1}{2}\pi ^{\upsilon ^{\text {T}}} \mathbb {M}^{-1}(\upsilon )\pi ^{\upsilon } + \mathcal {V}(\upsilon ), \end{aligned}$$
(14)

where the momentum \(\pi ^{\upsilon }\) is

$$\begin{aligned} \begin{aligned}&\pi ^{\upsilon }_k = \frac{\partial \mathcal {L}(\upsilon , \dot{\upsilon })}{\partial \dot{\upsilon }_k} \\&\quad = {\left\{ \begin{array}{ll} \varvec{\pi }^{\rho }_i = \nabla _{\dot{\varvec{\rho }}_i}\mathcal {L}(\varvec{\rho }, \dot{\varvec{\rho }}, \sigma , \dot{\sigma })&{} {k = 1,\dots , 3N}\\ \pi ^{\sigma }_\alpha = \frac{\partial \mathcal {L}(\varvec{\rho }, \dot{\varvec{\rho }}, \sigma , \dot{\sigma })}{\partial \dot{\sigma }_\alpha }&{} {k = 3N{+}1,\dots , 3N{+}M} \end{array}\right. } \end{aligned} \end{aligned}$$
(15)

(\(i=1,\dots ,N\) and \(\alpha = 1,\dots ,M\)), and we have also introduced \(\mathbb {M}^{-1}(\upsilon )\), i.e., the inverse of the metric matrix

$$\begin{aligned} \begin{aligned} \mathbb {M}_{kk'} = \sum _{i=1}^{N}m_i\frac{\partial \varvec{R}_i}{\partial \upsilon _k}\cdot \frac{\partial \varvec{R}_i}{\partial \upsilon _{k'}} + \sum _{\alpha =1}^{M}\mu _s\frac{\partial s_\alpha }{\partial \upsilon _k}\frac{\partial s_\alpha }{\partial \upsilon _{k'}} \end{aligned} \end{aligned}$$
(16)

associated with the new variables. For future convenience, the metric matrix and its inverse can also be expressed in block form as

(17)

where \(\mathbb {A}\) and are \(3N\times 3N\) matrices, \(\mathbb {B}\) and \(\mathbb {E}\) are \(3N\times M\) matrices, and and \(\mathbb {Z}\) are \(M\times M\) matrices, whose expressions are given in Appendix A.1.

The average of an observable \(\mathcal {O}(\varvec{\rho }, \sigma , \varvec{\pi }^{\rho }, \pi ^{\sigma })\) in the constrained microcanonical ensemble is given by

$$\begin{aligned} \begin{aligned} \langle {\mathcal {O}}\rangle = \frac{1}{\mathcal {Z}}\int&\mathrm {d}^{3N}\rho \mathrm {d}^{3N}\pi ^{\rho }\mathrm {d}^M\sigma \mathrm {d}^M\pi ^{\sigma } \delta ^M(\sigma )\delta ^M(\pi ^{\sigma } - \tilde{\pi }^{\sigma })\\&\times \delta (\mathcal {H}(\varvec{\rho }, \sigma , \varvec{\pi }^{\rho }, \pi ^{\sigma })-E) \mathcal {O}(\varvec{\rho }, \sigma , \varvec{\pi }^{\rho }, \pi ^{\sigma }), \end{aligned} \end{aligned}$$
(18)

where \(\mathcal {Z}\) is the partition function. The delta functions in the equation above express the constant energy condition (second line) and the constraints (first line). Note that, in addition to the delta function associated with the holonomic constraints, \(\delta ^M(\sigma )\), the integrand contains a delta function involving the momenta \(\pi ^{\sigma }\). This delta originates from the fact that, in order for the constraints to be satisfied at all times, the additional condition \(\dot{\sigma }=0\) must hold. Using the relation \(\dot{\upsilon }={\mathbb {M}}^{-1}\pi ^{\upsilon }\), this implies (see also Appendix A.2) that, when the constraints are imposed, the momenta must satisfy

$$\begin{aligned} \pi ^{\sigma }=\tilde{\pi }^{\sigma } = -{\widetilde{\mathbb {Z}}}^{-1}{\widetilde{\mathbb {E}}}^{\text {T}}\cdot \varvec{\pi }^{\rho }, \end{aligned}$$
(19)

where the tildes indicate that all matrices are evaluated at \(\sigma =0\). We now move to determine the expression for the average after integration over the variables associated with the constraints. To that end, the integral over \(\pi ^{\sigma }\) is evaluated first, followed by the change of variables \(\sigma _\alpha \mapsto s_\alpha \), \(\varvec{\rho }_i \mapsto \varvec{R}_i\), and a last integration over the s variables. The last two steps are discussed more in detail in Ref. [3] and in Appendix A.2. Here, we report the result of these operations, which is given by

$$\begin{aligned} \begin{aligned} \langle {\mathcal {O}}\rangle =\frac{1}{\mathcal {Z}'}\int&\mathrm {d}^{3N} R\mathrm {d}^{3N}\pi ^{\rho } O(\varvec{R}, \tilde{s}, \varvec{\pi }^{\rho }, \tilde{\pi }^{\sigma })\\&\times \delta (H(\varvec{R}, \tilde{s}, \varvec{\pi }^{\rho }, \tilde{\pi }^{\sigma })-E). \end{aligned} \end{aligned}$$
(20)

In the equation above, \(\tilde{s}=\tilde{s}(\varvec{R})\) is such that \(\sigma (\varvec{R},\tilde{s})\equiv 0\) (we assume, as commonly done in the Born–Oppenheimer framework that this expression has, for any \(\varvec{R}\), a single root), and \(\tilde{\pi }^{\sigma }\) is defined in Eq. (19). The Hamiltonian is also evaluated on the hypersurface \(\sigma =0\), \(\pi ^{\sigma }=\tilde{\pi }^{\sigma }\) where the constrained motion takes place. Its explicit form is derived in Appendix A.3 and is equal to

$$\begin{aligned} \begin{aligned} H(\varvec{R}, \tilde{s}, \varvec{\pi }^{\rho }, \tilde{\pi }^{\sigma } )= \frac{1}{2} \varvec{\pi }^{\rho ^{\text {T}}}\widetilde{\mathbb {A}}^{-1}\varvec{\pi }^{\rho } + V(\varvec{R}, \tilde{s}). \end{aligned} \end{aligned}$$
(21)

Equation (20) defines the average of an observable with respect to a marginal probability where the constraints (or equivalently the auxiliary variables) have been integrated over. This marginal probability, however, still depends on the value of the mass, \(\mu _s\), associated with the auxiliary dofs. This is apparent in the definition of the mass matrix \(\widetilde{\mathbb {A}}\) (and its inverse) and therefore of the generalized momenta \(\varvec{\pi }^{\rho }\), and from the dependence of the observable on \(\tilde{\pi }^{\sigma }\). Indeed, from the definition in Appendix A.1, we have

$$\begin{aligned} \widetilde{\mathbb {A}}=\mathbb {D}+\mu _s\widetilde{\mathbb {R}}=\mathbb {D}\left[ \mathbb {1}+\mu _s\mathbb {D}^{-1}\widetilde{\mathbb {R}}\right] , \end{aligned}$$
(22)

where \(\mathbb {D}_{jj'}=m_j\delta _{jj'}\) and \(\widetilde{\mathbb {R}}_{jj'}=\sum _{\alpha =1}^M \frac{\partial s_{\alpha }}{\partial \varvec{\rho }_j}\cdot \frac{\partial s_{\alpha }}{\partial \varvec{\rho }_{j'}}\), so that

$$\begin{aligned} \widetilde{\mathbb {A}}^{-1}=\left[ \mathbb {1}+\mu _s\mathbb {D}^{-1}\widetilde{\mathbb {R}}\right] ^{-1}\mathbb {D}^{-1}. \end{aligned}$$
(23)

Furthermore, the relation \(\pi ^{\upsilon }={\mathbb {M}}\dot{\upsilon }\) implies, \(\varvec{\pi }^{\rho }=\mathbb {A}\cdot \dot{\varvec{\rho }}+\mathbb {B}\dot{\sigma }\) giving, on the constrained hypersurface

$$\begin{aligned} \varvec{\pi }^{\rho }=\widetilde{\mathbb {A}}\cdot \dot{\varvec{\rho }}=\widetilde{\mathbb {A}}\cdot \dot{\varvec{R}}, \end{aligned}$$
(24)

where in the last equality we used \(\dot{\varvec{\rho }}=\dot{\varvec{R}}\), as implied by the change of variable \(\varvec{R}\mapsto \varvec{\rho }\). Finally (see Appendix A.1), on the constrained hypersurface, we also have

(25)

that also carries a dependence on the mass \(\mu _s\) due to the definition of the matrices and \(\widetilde{\mathbb {B}}\). Let us now consider the limit \(\mu _s \rightarrow 0\). and \(\widetilde{\mathbb {B}}\) are proportional to \(\mu _s\) (see Appendix A) and therefore vanish in the limit, while \(\lim _{\mu _s\rightarrow 0} \widetilde{\mathbb {A}} = \widetilde{\mathbb {D}}\). In the zero auxiliary mass limit then, \(\tilde{\pi }^{\sigma }=0\) and the Hamiltonian of the system becomes

$$\begin{aligned} H(\varvec{R}, \tilde{s}, \varvec{\pi }^{R}, \tilde{\pi }^{\sigma } = 0)=\frac{1}{2}\varvec{\pi }^{R^{\text {T}}}\mathbb {D}^{-1}\varvec{\pi }^{R} + V(\varvec{R}, \tilde{s}) \end{aligned}$$
(26)

with \(\mathbb {D}^{-1}=\frac{1}{m_j}\delta _{jj'}\) and where we have used the fact that, from Eq. (24), in the null auxiliary mass limit, \(\varvec{\pi }^{\rho }=\mathbb {D}\dot{\varvec{R}}=\varvec{\pi }^R\).

Substituting in the expression for the average, we obtain

$$\begin{aligned} \begin{aligned}&\langle {\mathcal {O}}\rangle =\frac{1}{\mathcal {Z}'}\int \mathrm {d}^{3N} R\mathrm {d}^{3N}\pi ^{R}O(\varvec{R}, \tilde{s}, \varvec{\pi }^{R}, \tilde{\pi }^{\sigma }=0) \\&\quad \times \delta (H(\varvec{R}, \tilde{s}, \varvec{\pi }^{R}, \tilde{\pi }^{\sigma }=0)-E). \end{aligned} \end{aligned}$$
(27)

The result above implicitly defines the microcanonical marginal probability in the physical phase space in the full adiabatic limit. This definition is in agreement with the form usually assumed for the Born–Oppenheimer probability. The discussion above also indicates that the dynamical system rigorously samples this density only in the full \(\mu _s\rightarrow 0\) limit and that, for finite auxiliary masses, corrections to the mass matrix associated with the momenta would be required, as indicated by Eqs. (23) and (24).

3 Magnetic MaZe

In this section, we extend the MaZe formalism to treat the shell model [33] in constant external magnetic field. The shell model is one of the first attempts to represent polarization effects via empirical potentials, with specific focus in taking into account dipole polarization. This is described by assuming that the ion’s total charge is divided between a core (representing the nucleus) and a massless shell (representing the electronic charge density). Each core–shell pair is bound by a harmonic potential and feels electrostatic interactions with the other particles. The ions evolve according to full adiabatic dynamics, i.e., subject to a force computed with the auxiliary variables at the minimum of the potential. Although several refinements have been proposed, the shell model still represents a valid benchmark for classical polarizable potentials and was chosen in this work, focused on exploratory calculations for a new development of MaZe, due to its simplicity. Polarization effects are important to capture accurately features of ionic systems ranging from phonon dispersion curves to structural and transport properties [49]. In the following, we shall consider how they influence charge diffusion in the presence of an external magnetic field. The model we consider does not take into account magnetization effects and therefore identifies the magnetic induction field \(\varvec{B}\) and the applied external magnetic field, usually noted as \(\varvec{H}\). The generalization of the empirical Hamiltonian and of the integration algorithm that we describe in Sect. 3 to account for magnetization is nontrivial and beyond the developments presented in this work. To the best of our knowledge, however, this is the first time in which the effect of a magnetic field on the transport properties of a classical charged system is explored with any classical model of polarization and we consider it a first test on the way to more realistic simulations. Furthermore, in Sect. 4, we shall investigate a simple molecular liquid—molten sodium chloride—for which magnetization is likely to play a minor role.

Assigning a charge \(Q_i\) to core i and \(q_{\alpha }\) to the shell \(\alpha \), the MaZe dynamics for the system in magnetic field is conveniently obtained, in analogy with the discussion in Sect. 2.1, by first considering the Lagrangian

$$\begin{aligned} L(\varvec{R}, \dot{\varvec{R}}, \varvec{S},&\dot{\varvec{S}}&)= \frac{1}{2}\sum _{i=1}^{N}m_i\dot{\varvec{R}}^{2}_{i} + \frac{1}{2}\sum _{\alpha =1}^N \mu \dot{\varvec{s}}^2_{\alpha } \nonumber \\&- V(\varvec{R}, \varvec{S}) + \sum _{i=1}^{N} Q_i\dot{\varvec{R}}_i\cdot \varvec{A}(\varvec{R}_i) \nonumber \\&+ \sum _{\alpha =1}^N q_\alpha \dot{\varvec{s}}_{\alpha } \cdot \varvec{A}(\varvec{s}_{\alpha }), \end{aligned}$$
(28)

where a finite mass \(\mu \) has been (temporarily) associated with the shell variables. In the equation above, \(V(\varvec{R},\varvec{S})\) is the total interaction potential, whose form is detailed in Appendix B, and we have introduced the notation \(\varvec{R}=\{\varvec{R}_1,...,\varvec{R}_N\}\) (with \(\varvec{R}_i=\{R^x_i,R^y_i,R^z_i\}\)), and \(\varvec{S}=\{\varvec{s}_1,...,\varvec{s}_N\}\) (with \(\varvec{s}_{\alpha }=\{s^x_{\alpha },s^y_{\alpha },s^z_{\alpha }\}\)) for the 3N Cartesian coordinates of the cores and of the 3N shell variables, respectively. \(\varvec{A}(\varvec{r})\) is the vector potential associated to the magnetic field \(\varvec{B} = \varvec{\nabla }_{\varvec{r}} \times \varvec{A}(\varvec{r})\) at position \(\varvec{r}\). We shall consider a system in a constant magnetic field parallel to the z axis: \(\varvec{B} = (0, 0, B_z)\). In the Coulomb gauge (\(\varvec{\nabla }_{\varvec{r}} \cdot \varvec{A}(\varvec{r}) = 0\)), a valid choice for the vector potential is then \(\varvec{A}(\varvec{r}) = B_z/2(-y, x, 0)\). The dynamics of the system is defined as fully adiabatic: the shells are assumed to adapt instantaneously to the positions of the cores, so that the force on each shell variable is null

$$\begin{aligned} \begin{aligned} {\sigma }_{\alpha }^x (\varvec{R},\varvec{S},\dot{\varvec{S}})&= - \frac{\partial V(\varvec{R},\varvec{S})}{\partial s_{\alpha }^x} + q_{\alpha }B_z\dot{s}_{\alpha }^y=0 \\ {\sigma }_{\alpha }^y(\varvec{R},\varvec{S},\dot{\varvec{S}})&= - \frac{\partial V(\varvec{R},\varvec{S})}{\partial s_{\alpha }^y} - q_{\alpha }B_z\dot{s}_{\alpha }^x=0 \\ {\sigma }_{\alpha }^z (\varvec{R},\varvec{S})&= - \frac{\partial V(\varvec{R},\varvec{S})}{\partial s_{\alpha }^z} =0. \end{aligned} \end{aligned}$$
(29)

In the equations above, \(\alpha =1,...,N\) and we have written explicitly the conditions of zero force for the components on the xy plane, which include the Lorentz force, and the component along the z axis, i.e., parallel to the magnetic field. Equation (29) can still be interpreted a set of 3N constraints, but, for this system, the components of the force on the plane orthogonal to the field depend on the velocity and the corresponding constraints are therefore no longer holonomic (the \(\sigma _{\alpha }^z\), on the other hand, are holonomic). The linear dependence on the velocity of these constraints,Footnote 2 however, still enables to write the Lagrangian equations of motion. In fact, for systems with mixed holonomic and semiholonomic constraints, these equations can be expressed as [31, 32, 50,51,52,53,54]

$$\begin{aligned} \frac{d}{dt}\frac{\partial L}{\partial \dot{\xi }_{\alpha }^h} - \frac{\partial L}{\partial \xi _{\alpha }^h} = - \sum _{\beta =1}^N\sum _{l=x,y} \lambda _{\beta }^l \frac{\partial \sigma _{\beta }^l}{\partial \dot{\xi }_{\alpha }^h} - \sum _{\beta =1}^N \lambda _{\beta }^z \frac{\partial \sigma _{\beta }^z}{\partial \xi _{\alpha }^h} \end{aligned}$$
(30)

where we have indicated all the dynamical variables with the notation \(\mathbb {R}^{3N+3N} \ni \xi = (\varvec{R}, \varvec{S})\). Following the same steps described in Sect. 2.1, the MaZe dynamical system is derived by first obtaining the evolution equations for the system on the basis of Eq. (30), then rearranging the evolution equations for the shell variables exploiting the condition of null force as in Eq. (8). In the \(\mu \rightarrow 0\) limit, the resulting dynamical system then is

$$\begin{aligned} \begin{aligned} m_i \ddot{R}^h_i&= -\frac{\partial V(\varvec{R},\varvec{S})}{\partial R^h_i} + Q_i(\dot{\varvec{R}}_i \times \varvec{B})_h\\ \ddot{s}^h_{\alpha }&= - \sum _{\beta =1}^N\sum _{l=x,y} \gamma _{\beta }^l \frac{\partial \sigma _{\beta }^l}{\partial \dot{s}_{\alpha }^h} - \sum _{\beta =1}^N \gamma _{\beta }^z \frac{\partial \sigma _{\beta }^z}{\partial s_{\alpha }^h}, \end{aligned} \end{aligned}$$
(31)

where, as in the previous case, \(\gamma _{\beta }^h=\lim _{\mu \rightarrow 0}\lambda _{\beta }^h/\mu \).

3.1 The MaZe algorithm for the shell model

The numerical integration of Eqs. (31) must take into account two nontrivial features: the velocity dependence of the Lorentz force, which prevents direct use of standard integration algorithms (e.g., velocity Verlet), and the presence of nonholonomic constraints. These difficulties are solved combining a symplectic algorithm recently introduced to integrate the dynamics of ions in constant external magnetic field [55], with an adapted SHAKE algorithm to update the shell’s positions and velocities. To set the stage, we introduce the auxiliary dynamical system

$$\begin{aligned} \begin{aligned} \dot{R}_i^x&= \frac{P^x_i}{m_i} + \omega _iR^y_i \\ \dot{R}_i^y&= \frac{P^y_i}{m_i} - \omega _iR^x_i \\ \dot{R}_i^z&= \frac{P^z_i}{m_i} \\ \dot{s}_{\alpha }^x&= p_{\alpha }^x \\ \dot{s}_{\alpha }^y&= p_{\alpha }^y \\ \dot{s}_{\alpha }^z&= p_{\alpha }^z \end{aligned} \quad \quad \begin{aligned} \dot{P}_i^x&= -\frac{\partial V}{\partial R^x_i} + \omega _i(P^y_i - m_i\omega _iR^x_i) \\ \dot{P}_i^y&= -\frac{\partial V}{\partial R^y_i} - \omega _i(P^x_i + m_i\omega _iR^y_i) \\ \dot{P}_i^z&= -\frac{\partial V}{\partial R^z_i} \\ \dot{p}_{\alpha }^x&= G_{\alpha }^x \\ \dot{p}_{\alpha }^y&= G_{\alpha }^y \\ \dot{p}_{\alpha }^z&=G_{\alpha }^z, \end{aligned} \end{aligned}$$
(32)

where \(V \equiv V(\varvec{R},\varvec{S})\) and where we have introduced the notation

$$\begin{aligned} G_{\alpha }^h \equiv G_{\alpha }^h (\varvec{R},\varvec{S})= - \sum _{\beta =1}^N\sum _{l=x,y} \gamma _{\beta }^l \frac{\partial \sigma _{\beta }^l}{\partial \dot{s}_{\alpha }^h} - \sum _{\beta =1}^N \gamma _{\beta }^z \frac{\partial \sigma _{\beta }^z}{\partial s_{\alpha }^h}. \end{aligned}$$
(33)

Taking the time derivative of all positions, it is immediate to show that the system above is equivalent to Eq. (31). A convenient integration algorithm can now be obtained by exploiting the Liouvillian formalism and writing the single timestep evolution operator associated with Eq. (32) as

$$\begin{aligned} \mathcal {U}(\delta t) = e^{\mathrm {i}\delta t\mathcal {L}}, \end{aligned}$$
(34)

where the Liouvillian at the exponent is defined as

$$\begin{aligned} \mathrm {i}\mathcal {L}_X = \dot{\varvec{X}}\cdot \nabla _{\varvec{X}} \end{aligned}$$

with \(\mathrm {i}\) the imaginary unit and \(\varvec{X}=\{\varvec{R},\varvec{P},\varvec{S},\varvec{p}\}\), and where, for example, \(\varvec{P}=\{\varvec{P}_1,...,\varvec{P}_N\}\). To proceed, \(\mathcal {U}(\delta t)\) is approximated via the following Trotter splitting

$$\begin{aligned} \mathcal {U}(\delta t)\approx e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}}} e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{R}}} e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{p}}} e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{S}}} e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}}}. \end{aligned}$$
(35)

In the equation above, we have separated, as commonly done [56], the differential operators acting on the coordinates \(\varvec{R}=\{\varvec{R}_1,...,\varvec{R}_N\}\) and momenta of the ions and the shells. Note that, in the exploratory calculations presented here, we have employed a mixed Trotter break up, which is symmetric for the cores’ momenta and simple for the shell variables and the cores’ positions. The overall error in the approximation of the propagator is then of order \(\delta t^2\). One more observation is necessary to proceed. Focusing on the physical dynamical variables, we have

$$\begin{aligned} \begin{aligned} \mathrm {i}\mathcal {L}_{\varvec{P}}&= \sum ^N_{i=1} \dot{P}_i^{x}\frac{\partial }{\partial P_i^x} + \sum ^N_{i=1} \dot{P}_i^{y}\frac{\partial }{\partial P_i^y} + \sum ^N_{i=1} \dot{P}_i^{z}\frac{\partial }{\partial P_i^z} \\&\equiv \mathrm {i}\mathcal {L}_{\varvec{P}^x} + \mathrm {i}\mathcal {L}_{\varvec{P}^y} + \mathrm {i}\mathcal {L}_{\varvec{P}^z} \\ \mathrm {i}\mathcal {L}_{\varvec{R}}&=\sum ^N_{i=1} \dot{R}_i^{x}\frac{\partial }{\partial R_i^x} + \sum ^N_{i=1} \dot{R}_i^{y}\frac{\partial }{\partial R_i^y} + \sum ^N_{i=1} \dot{R}_i^{z}\frac{\partial }{\partial R_i^z} \\&\equiv \mathrm {i}\mathcal {L}_{\varvec{R}^x} + \mathrm {i}\mathcal {L}_{\varvec{R}^y} + \mathrm {i}\mathcal {L}_{\varvec{R}^z}. \end{aligned} \end{aligned}$$
(36)

In the absence of an external magnetic field, the exponentials of the Liouvillians in Eq. (35) correspond to simple translation operators for the components of the momenta (\(e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}}}\)) and coordinates (\(e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{R}}}\)). Furthermore, always in the absence of an external magnetic field, the Liouvillians for the different Cartesian components of these variables commute among themselves so, for example, \(e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}}}=e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^x}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^y}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^z}}\) and the corresponding translations can be applied sequentially. Operating from left to right on the phase-space variables with the full set of translation operators, the velocity Verlet algorithm is recovered. When a (constant) magnetic field is present, however, the Liouvillians corresponding to the x and y components of the dynamical variables no longer commute. For example, by applying the commutator of the Liouvillians to a generic function of \(\varvec{X}\), it can be seen that

$$\begin{aligned}{}[\mathrm {i}\mathcal {L}_{\varvec{R}^x},\mathrm {i}\mathcal {L}_{\varvec{R}^y}] = -\sum ^N_{i=1}\omega _i\left[ \dot{R}_i^{x}\frac{\partial }{\partial R_i^y} + \dot{R}_i^{y}\frac{\partial }{\partial R_i^x}\right] . \end{aligned}$$
(37)

A nonzero result is obtained also for \([\mathrm {i}\mathcal {L}_{\varvec{P}^x},\mathrm {i}\mathcal {L}_{\varvec{P}^y}]\), while the remaining commutators are zero. For this reason, two more Trotter break-ups become necessary to write the single-step propagator as a sequence of translations for the different variables. In particular, following Ref. [55], we choose the splitting:

$$\begin{aligned} \begin{aligned} e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}}} e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{R}}} e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}}} =&e^{\mathrm {i}\frac{\delta t}{4}\mathcal {L}_{\varvec{P}^y}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^x}}e^{\mathrm {i}\frac{\delta t}{4}\mathcal {L}_{\varvec{P}^y}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^z}}\\&e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{R}^y}}e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{R}^x}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{R}^y}}e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{R}^z}} \\&e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{p}}} e^{\mathrm {i}\delta t\mathcal {L}_{\varvec{S}}} \\&e^{\mathrm {i}\frac{\delta t}{4}\mathcal {L}_{\varvec{P}^y}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^x}}e^{\mathrm {i}\frac{\delta t}{4}\mathcal {L}_{\varvec{P}^y}}e^{\mathrm {i}\frac{\delta t}{2}\mathcal {L}_{\varvec{P}^z}}. \end{aligned} \end{aligned}$$
(38)

The actions of these operators can be directly translated into a set of instructions taking the system from time t to time \(t+\delta t\) and this is detailed in the insets in Fig. 1. In particular, the action of the momentum translations induced by the operators in the first line of the equation above corresponds to the “Update Core Momenta (1)” in the figure, while “Update Core Positions” shows the effect of the coordinates translations induced by the operators in the second line, and “Update Core Momenta (2)” derives from application of the operators in the last line. As indicated in the figure, the evaluation of the forces required to implement the second update of the core’s momenta (these forces depend on the shell variables at time \(t+\delta t\)) must be performed under the condition that the updated shell velocities and positions satisfy the constraints Eq. (29).

Fig. 1
figure 1

On the right: schematic flowchart of the main molecular dynamics loop for the propagation of the cores. The equations for the update of positions and momenta, derived in Ref. [55], are given in the boxes on the left. The update of the shell variables, red box in the main loop, is performed via the adapted SHAKE algorithm described in the last part of Sect. 3

These updated shell variables are determined via a straightforward generalization of the standard SHAKE algorithm (see also Refs. [31, 32]) that preserves the key conceptual steps of the method. After the update of the positions of the cores, and based on the propagators associated with \(\varvec{S}\) and \(\varvec{p}\) (which is equal to \(\dot{\varvec{S}}\)) in Eq. (38), the shell variables are advanced as

$$\begin{aligned} \begin{aligned} s_{\alpha }^h (t+\delta t)&= s_{\alpha }^h(t) + \delta t\dot{s}_{\alpha }^h(t) + \frac{\delta t^2}{2} \ddot{s}_{\alpha }^h(t) \\&= s_{\alpha }^h(t) + \delta t\dot{s}_{\alpha }^h(t) \, + \\&- \frac{\delta t^2}{2} \Bigl [\sum _{\beta =1}^N\sum _{l=x,y} \gamma _{\beta }^l \frac{\partial \sigma _{\beta }^l(t)}{\partial \dot{s}_{\alpha }^h} + \sum _{\beta =1}^N \gamma _{\beta }^z \frac{\partial \sigma _{\beta }^z(t)}{\partial s_{\alpha }^h} \Bigr ]\\&\equiv s_{\alpha }^{h}(t+\delta t;\varvec{\varGamma }) \end{aligned} \end{aligned}$$
(39)

and

$$\begin{aligned} \begin{aligned} \dot{s}_{\alpha }^h (t+\delta t)&= \dot{s}_{\alpha }^h(t) + \delta t\ddot{s}_{\alpha }^h(t) \\&= \dot{s}_{\alpha }^h(t) \, + \\&- \delta t\Bigl [\sum _{\beta =1}^N\sum _{l=x,y} \gamma _{\beta }^l \frac{\partial \sigma _{\beta }^l(t)}{\partial \dot{s}_{\alpha }^h} + \sum _{\beta =1}^N \gamma _{\beta }^z \frac{\partial \sigma _{\beta }^z(t)}{\partial s_{\alpha }^h} \Bigr ] \\&\equiv \dot{s}_{\alpha }^{h}(t+\delta t;\varvec{\varGamma }). \end{aligned} \end{aligned}$$
(40)

In the second and third line of Eqs. (39) and (40), we have used the form of the shell’s acceleration prescribed by the MaZe dynamical system, Eq. (31), and it must be noted that the constraint accelerations depend on time via the core and shell positions. Finally, the definitions in the fourth line of Eqs. (39) and (40) highlight the fact that the updated shell positions and velocities are a function of the Lagrange multipliers represented, for future convenience, as the 3N-dimensional vector

$$\begin{aligned} \varvec{\varGamma }=\{\gamma ^x_1, \gamma ^y_1,\gamma ^z_1,...,\gamma ^x_N,\gamma ^y_N,\gamma ^z_N\}. \end{aligned}$$

The value of \(\varvec{\varGamma }\), at this stage, is yet undetermined. Following the SHAKE strategy, these Lagrange multipliers are computed a posteriori imposing that the advanced shell positions and velocities satisfy the constraints at time \(t+\delta t\):

$$\begin{aligned} \begin{aligned} \sigma ^l_\alpha \bigl (\varvec{R}(t+\delta t), \varvec{S}(t+\delta t;\varvec{\varGamma }), \dot{\varvec{S}}(t+\delta t;\varvec{\varGamma })\bigr )&= 0 \\ \sigma ^z_\alpha \bigl (\varvec{R}(t+\delta t), \varvec{S}(t+\delta t;\varvec{\varGamma })\bigr )&= 0 \end{aligned} \end{aligned}$$
(41)

with, as usual, \(\alpha =1,...,N\) and \(l=x,y\). The expressions above are a system of nonlinear equations in the unknowns \(\varvec{\varGamma }\) that is conveniently solved using the SHAKE algorithm. This is an adapted Newton–Raphson method [44] in which the Lagrange multipliers are determined iteratively according to

$$\begin{aligned} \varvec{\varGamma }^{(n+1)}=\varvec{\varGamma }^{(n)} - \varvec{\eta }[\mathbb {J_d}(\varvec{S}^{(n)}, \dot{\varvec{S}}^{(n)})^{-1}] \varvec{\varSigma }(\varvec{S}^{(n)},\dot{\varvec{S}}^{(n)}), \end{aligned}$$
(42)

where the superscript (n) indicates the iteration step. In the equation above, the vector of parameters \(\varvec{\eta } = (\eta _x, \eta _y, \eta _z)\) was introduced. In standard SHAKE calculations, this vector is not present. However, following a common practice in minimization algorithms [57], it has been shown [58] that using a scaling factor to modulate the magnitude of the SHAKE update can improve convergence. As discussed more in detail in Sect. 4, for the particular problem considered in this paper, it proved useful to use a different scaling factor for the components of the constraints perpendicular and parallel to the field. This is due to the different nature (holonomic and semiholonomic) of the constraints shown in Eq. (29). In Eq. (42), we have also adopted the notation

$$\begin{aligned} \varvec{\varSigma }= \{\sigma ^x_1, \sigma ^y_1,\sigma ^z_1,...,\sigma ^x_N,\sigma ^y_N,\sigma ^z_N\} \end{aligned}$$

to define the vector of the constraints, and \(\mathbb {J_d}\) for the \(3N\times 3N\) diagonal matrix

$$\begin{aligned} \bigr [\mathbb {J_d}(\varvec{S}^{(n)}, \dot{\varvec{S}}^{(n)})\bigl ]_{ab}= & {} \frac{\partial \varSigma _a(\varvec{S}^{(n)}, \dot{\varvec{S}}^{(n)})}{\partial \varGamma _b}\delta _{ab} \nonumber \\= & {} \Bigl [\sum ^{3N}_{c=1}\frac{\partial \varSigma _a(\varvec{S}^{(n)}, \dot{\varvec{S}}^{(n)})}{\partial S_c} \frac{\partial S_c}{\partial \varGamma _b} \nonumber \\&+ \sum ^{3N}_{c=1} \frac{\partial \varSigma _a(\varvec{S}^{(n)}, \dot{\varvec{S}}^{(n)})}{\partial \dot{S}_c} \frac{\partial \dot{S}_c}{\partial \varGamma _b} \Bigr ]\delta _{ab}\nonumber \\ \end{aligned}$$
(43)

(i.e., the diagonal approximation of the Jacobian matrix of the standard Newton–Raphson method), with \(a,b=1,...,3N\). This matrix and the vector of the constraints are updated at each iteration step with the updated shell’s positions and velocities that are computed according to

$$\begin{aligned} \begin{aligned}&\varvec{S}^{(n+1)}=\varvec{S}^{(n)} + \delta t\dot{\varvec{S}}^{(n)} + \\&\quad - \frac{\delta t^2}{2} \Bigl [\sum _{\beta =1}^N\sum _{l=x,y} (\gamma _{\beta }^l)^{(n)} \nabla _{\dot{\varvec{S}}}\sigma _{\beta }^l(t) + \sum _{\beta =1}^N (\gamma _{\beta }^z)^{(n)} \nabla _{\varvec{S}}\sigma _{\beta }^z(t) \Bigr ] \\&\dot{\varvec{S}}^{(n+1)} =\dot{\varvec{S}}^{(n)} + \\&\quad - \delta t\Bigl [\sum _{\beta =1}^N\sum _{l=x,y} (\gamma _{\beta }^l)^{(n)} \nabla _{\dot{\varvec{S}}} \sigma _{\beta }^l(t) + \sum _{\beta =1}^N (\gamma _{\beta }^z)^{(n)} \nabla _{\varvec{S}}\sigma _{\beta }^z(t) \Bigr ]. \end{aligned} \end{aligned}$$
(44)

The algorithm in Eq. (42) can be initialized, for each timestep along the dynamics, with the null vector \(\varvec{\varGamma }^{(0)} = 0\) or, if it is available, with the value of the Lagrange multipliers computed at the previous timestep. The calculations presented in the following were performed using the sequential update of the components of the vector of constraints first proposed in [23]. The iteration process is stopped when the modulus of the largest constraint, i.e., \(\mathrm {max}_a |{\varSigma _a}|\), becomes smaller than a predefined tolerance, typically chosen as close to the numerical precision achievable on the computer.

4 Simulation setup and results

The algorithm detailed in the previous section is applied to compute static and transport properties in a shell model simulation of molten NaCl in external magnetic field. The simulated system contains 108 Na\(^+\) and 108 Cl\(^-\), placed in a cubic box of side \(L= 19.87\mathrm { {\AA }}\), corresponding to a density \(\rho = 1.3113\mathrm { g}\mathrm { cm^{-3}}\). In the presence of our vector potential, standard periodic boundary conditions can be preserved by imposing that images enter the box with their velocities [55]. This procedure ensures continuity of our Hamiltonian and of the relevant observables. The temperature of the system is set to \(T \approx 1350\mathrm { K}\). The specific form of the interatomic potential, \(V(\varvec{R},\varvec{S})\), is given in Appendix B, and it is similar to the one adopted in Ref. [38]. We present results for the polarizable system in the presence and in the absence of a constant magnetic field directed along the z axis. The intensity of the field is chosen, so that the magnitude of the Lorentz force on each particle is comparable to that of the forces originating from the other interparticle interactions. As in our previous work on the shell model [2], we do not use the method of Ewald sums in the simulations, but rather truncate all interactions at a cut-off radius \(r_c = 0.5L\). The truncation of the long-range forces, sometimes adopted in simulations of large systems or when accuracy on the energy is not critical [59,60,61], was enforced for convenience. Our calculations are intended as a proof-of-principle validation of the MaZe dynamics in magnetic field and, while qualitative trends in the observables will be described, we are not focused on a realistic description of the system. Note that incorporating Ewald sums in the algorithm does not pose a conceptual problem nor has a significant effect on the numerical cost of the approach, as shown in Ref. [4] where a state-of-the-art classical model of polarization was considered.

The simulations are initialized as follows. The Cl\(^-\) and Na\(^+\) cores are placed on the sites of a simple cubic lattice and then displaced by a small uniform random amount in all directions. Initial shell positions are then found via a conjugate-gradient minimization of the potential energy with respect to these degrees of freedom. Velocities for all the degrees of freedom are set to zero. After the calculation of the interatomic forces, the first half of the evolution algorithm is applied to the cores to compute \(\varvec{R}(\delta t)\) and \(\varvec{P}(\delta t/2)\). New values of the shell variables are determined by applying SHAKE starting from the shell positions found by the conjugate-gradient minimization at step zero. Finally, interatomic forces are computed for this new configuration and the second half of the evolution algorithm is applied to the cores to obtain \(\varvec{P}(\delta t)\). Note that, because the shell velocities are set to zero at initialization, this procedure ensures that constraints are satisfied at \(t=0\) both in the absence and in the presence of the magnetic field. MaZe integration as described in Sect. 2.1 (no magnetic field) and Sect. 3 (magnetic field present) is then started. The timestep for the standard MaZe simulations is set to \(\delta t=1\mathrm { fs}\), while for the runs with \(B_z\ne 0\), \(\delta t=0.25\mathrm { fs}\) (see below for a discussion of the reasons for the smaller timestep). Equilibration to the target temperature is achieved in all runs by simulating the system for \(5\mathrm { ps}\). During this equilibration, the velocities are rescaled if the temperature differs from the target more than \(10\%\). NVE runs of total length of \(10\mathrm { ps}\) are then performed to compute the properties reported in the following. A strict convergence criterion for the constraints is enforced in all runs by imposing that the maximum magnitude of the constraints is less than \(10^{-10}\) units of force. The relaxation parameter \(\varvec{\eta }\), see Eq. (42) and discussion in the previous section, is set to \(\varvec{\eta }=(1,1,1)\) for the calculations with \(B_z=0\) and to \(\varvec{\eta }=(0.33,0.33,1)\) when the magnetic field is present. While the value of \(\varvec{\eta }\) can be set via an automatic search and adapted during the run [58], here it was chosen via manual search by optimizing the number of iterations necessary to converge SHAKE for a typical configuration of the cores. Previous experience, confirmed by the simulations reported here, has shown that this is sufficient to provide a stable number of iterations along the whole trajectory. In Fig. 2, we show the convergence paths of the constraints in the presence (left panel) and absence (right panel) of the magnetic field for a few randomly chosen configurations along the trajectory of the cores. The figures show the magnitude of the largest constraint as a function of the number of SHAKE iterations. In agreement with previous calculations, the number of iterations needed to converge in MaZe calculations for fully holonomic constraints (no magnetic field) is very small and similar for different configurations. The path shows monotonic convergence, with a single slope on the semilogarithmic scale employed in the figure. This fast convergence is facilitated by the already small value of the largest constraint at the start of the iterative process, indicating that the provisional values for the shell positions are quite close to the minimizers of the potential. The convergence of MaZe for the mixed set of holonomic and semiholonomic constraints, on the other hand, is about four times slower. This may be related to the fact that the magnetic force results in larger nondiagonal terms in the Jacobian matrix of the Newton–Raphson procedure, implying that Eq. (43) provides a less effective approximant of its inverse. Furthermore, the value of the maximum constraint at the beginning of the minimization is now larger than in the holonomic case, indicating that our provisional shell positions and velocities at the zeroth iteration are farther from the final solution. This behavior is sensitive to the choice of the timestep \(\delta t\), with worse performance (and eventually lack of convergence) with larger timesteps. This suggests that the basin of convergence of SHAKE in the presence of semiholonomic constraints may be smaller than the one for standard applications, an issue that will be further investigated in future studies. Finally, the paths to convergence now present a double slope pattern: a fast initial decay is followed by a slower decrease. Closer inspection of the decrease of individual constraints suggests that this is due to the different speed of convergence of the holonomic and semiholonomic constraints, with the latter evolving faster toward the threshold. This is most likely also related to the different values for the components in the scaling vector \(\varvec{\eta }\). In spite of the differences in the convergence pattern, and of the need to further investigate the behavior of the new algorithm, this first implementation of SHAKE for mixed constraints performs well for the nontrivial interactions of the model.

Fig. 2
figure 2

Path to convergence of the maximum magnitude of the constraints for typical core configurations along the trajectory. In the right panel, results are shown for the polarizable model in the absence of external magnetic field. In the left panel, results for simulations with \(B_z\ne 0\) are reported. The value of the field is indicated in code units in this and in the following figures and it corresponds to \(B_z = 8.11 \cdot 10^6\) \(\mathrm { T}\) in SI units. This large value of \(\varvec{B}\) is not uncommon in molecular dynamics simulations of particle systems in external magnetic field (see, for example, Refs. [55, 62, 63])

Inspection of typical dynamical indicators and structural properties confirms the reliability of the MaZe approach for classical polarizable models in external magnetic field. In particular, the fluctuations of the total energy relative to the fluctuations of the potential energy along the trajectory of the cores are \(\Delta E/\Delta V \approx 2 \cdot 10^{-4}\), where, for example, \(\Delta E = \sqrt{\langle {E^2}\rangle -\langle {E}\rangle ^2}\). The stability of the new algorithm is visible also in the calculation of the instantaneous temperature of the cores. Figure 3 shows the fluctuations of this quantity in a \(10\mathrm { ps}\) simulation in the presence of the magnetic field, which are—again—perfectly compatible with typical results for classical simulations. As a test of the reliability of MaZe semiholonomic dynamics, we consider the radial distribution function of the ionic species as obtained in the simulation with and without external magnetic field. Results are shown in Fig. 4, where we report as symbols the output of the runs in the absence of the magnetic field and as solid lines that of the calculations with the magnetic field. The position and shape of the peaks for all g(R) are in good agreement with experimental results [64] and with previous calculations [2, 55] in spite of the somewhat crude treatment of the electrostatic interactions, of a different temperature (\(T\approx 1350\) K in this work and \(T\approx 1550\) K in Refs. [2, 55]) and of some differences in the parameters in the shell model detailed in Appendix B. Perhaps more importantly for our purposes, the curves and the symbols are superimposed. This provides strong validation for the MaZe algorithm presented in Sect. 3: it is in fact known (see, for example, Ref. [55]) that time-independent averages are not affected by the presence of the magnetic field. As shown by the results on a nontrivial observable, this property is respected by the MaZe algorithm.

Fig. 3
figure 3

Temperature fluctuations (yellow curve), running average (orange line), and final average (red line) along the core trajectory for a system of polarizable ions in magnetic field

Fig. 4
figure 4

Radial distribution function for the ionic species. Symbols indicate results for the simulations with no magnetic field, while solid lines refer to simulations with \(B_z\ne 0\)

We now move to the calculation of time-dependent statistical properties of the system. In this case, the presence of a magnetic field is expected to affect the results in nontrivial ways providing further and more interesting testing ground for our approach. We consider, in particular, the velocity correlation functions of the ionic species. In Figs. 5 and 6, we show results for the diagonal and off-diagonal correlations in the absence and presence of \(\varvec{B}\). Results for system in the absence of the magnetic field are reported in symbols (Na\(^+\) upper panel and Cl\(^-\) lower panel). In the insets, we also show the corresponding elements of the diffusion tensor. As expected, when \(B_z=0\), the three diagonal components of the velocity correlation function are equal for each species and show the characteristic initial decay followed by one or more minima before going to zero at longer times. For this system, the integral of the autocorrelation function of the velocity yields diffusion coefficients equal to \(D_{Na} = (1.78 \pm 0.08) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) and \(D_{Cl} = (1.51 \pm 0.06) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\), both obtained averaging the three components on the diagonal of the diffusion tensor. The error on the values of the diffusion is estimated from the off-diagonal components of the tensor for \(B_z = 0\). These off-diagonal components must be zero based on time-reversal symmetry arguments [65, 66], and the results of the simulation can be used to estimate the statistical noise in computing the integrals. All the results discussed above are compatible with previous studies [64] performed on the same system at zero magnetic field.

The presence of the magnetic field breaks the isotropy of space and this implies that the components of the correlation on the plane orthogonal to the field are now different from that in the direction parallel to it, and show an oscillatory behavior that reflects the rotatory motion induced by the Lorentz force. Consistently, the diffusion coefficients are also affected by the presence of the magnetic field. The observed reduction of their values is in fact a known phenomenon, the so-called magnetoresistance, which is commonly observed for the electrons in semiconductors in the presence of magnetic field and was also reported for ions in previous simulations [55, 62]. In particular, the diffusion coefficients are reduced to \(D^{\perp }_{Na} = (0.96 \pm 0.10) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\), \(D^{zz}_{Na} = (1.36 \pm 0.14) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) for the Sodium ions and to \(D^{\perp }_{Cl} = (0.91 \pm 0.07) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\), \(D^{zz}_{Cl} = (1.24 \pm 0.10) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) for the Chlorine ions, where \(D^{\perp } = (D^{xx} + D^{yy})/2\). The effect of the magnetic field is even more striking when considering the off-diagonal components of the velocity correlation functions. In Fig. 6, we present results for the xy and yx cross-correlations. In the absence of the field, time-reversal invariance leads to null values of these quantities. On the other hand, when \(B_z\ne 0\) a characteristic oscillatory pattern is observed. As detailed in Ref. [66], the antisymmetry of these two observables is dictated by their properties under generalized time-reversal symmetries and well reproduced by our simulations (all other off-diagonal components remain zero, for symmetry reasons). The behavior of the correlation function is reflected in the values obtained for the xy and yx components of the diffusion tensor, which are now equal to \(D^{xy}_{Na} = (0.46 \pm 0.14) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) and \(D^{yx}_{Na} = (-0.43 \pm 0.14) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) for Sodium and to \(D^{xy}_{Cl} = (-0.32 \pm 0.10) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) and \(D^{yx}_{Cl} = (0.32 \pm 0.10) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) for Chloride.

Fig. 5
figure 5

Autocorrelation functions of the Cartesian components of the velocity for Na\(^ +\) (upper panel) and Cl\(^-\) (lower panel) for polarizable shell model. Solid lines report results for \(B_z \ne 0\), while the symbols refer to the same system when no magnetic field is present. Diffusion coefficients, computed as time integrals of the correlation functions, are shown in the insets as a function of the total integration time

Fig. 6
figure 6

xy components of the velocity correlation tensor for Na\(^+\) (upper panel) and Cl\(^-\) (lower panel) for polarizable shell model. Solid lines report results for \(B_z \ne 0\), while the symbols refer to the same system when no magnetic field is present. Diffusion coefficients, computed as time integrals of the correlation functions, are shown in the insets as a function of the total integration time

Finally, it is interesting to explore the effects of polarization on the transport properties of this model of molten NaCl. To assess the relevance of these effects, we compare the elements of the diffusion tensor discussed above with those from a simulation of an unpolarized model of the system. The unpolarized (or rigid ion) model is defined by removing the shell variables from the electrostatic interactions, while keeping the remaining parameters of the potential for the cores as in our previous runs. Further details and the specific form of the interaction are also given in Appendix B. In Fig. 7, we show results for the diffusion coefficients of the polarized (solid curves) and rigid ions (symbols) simulations in the presence of the same magnetic field. The plot indicates that, for the rigid ion model, the diagonal components of the diffusion tensor (upper panel of the figure) are very similar for both species. The presence of polarization globally enhances transport in the system, but—due to the different polarizability of the two ions—leads to different values, in particular, of the component of the diffusion tensor parallel to the magnetic field. Similarly, the cross components of the diffusion for Na\(^+\) and Cl\(^-\) in the plane orthogonal to the magnetic field (bottom panel of the figure) are essentially identical for rigid ions, but polarization separates them. In particular, for the rigid ion case, we obtain values for the xy and yx components of the diffusion coefficients given by \(\bar{D}^{xy}_{Na} = (0.25 \pm 0.14) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) and \(\bar{D}^{yx}_{Na} = (-0.24 \pm 0.14) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) for Sodium and \(\bar{D}^{xy}_{Cl} = (-0.26 \pm 0.10) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) and \(\bar{D}^{yx}_{Cl} = (0.25 \pm 0.10) \cdot 10^{-4}\mathrm { cm^2}\mathrm { s^{-1}}\) for Chloride, where the symbol \(\bar{D}\) is used to indicate that the diffusion coefficient is computed for the rigid ion model, at difference with the notation D which indicates diffusion coefficient computed for the shell model.

This has an interesting implication for the detection of the ionic Hall effect in molted NaCl. In fact, the key indicator of this phenomenon, the Hall mobility, in the Nerst–Einstein approximation, is given by [62]

$$\begin{aligned} \mu _H = \frac{1}{B_z}\frac{D_{Na}^{xy}+D_{Cl}^{xy}}{D_{Na}^{\perp }+D_{Cl}^{\perp }}. \end{aligned}$$
(45)

When the off-diagonal components of the diffusion tensor of the two species are equal and opposite, as in previous more refined calculations on a rigid ion model for the system [55, 62] and, within errors, in the results shown in Fig. 7, the mobility is obviously null. In particular, the values of the diffusion coefficients obtained from the rigid ion simulations performed in this work yield a value for the Hall mobility given by \(\bar{\mu }_H \approx -0.9\cdot 10^{-5}\mathrm { cm^2}\mathrm { V^{-1}}\mathrm { s^{-1}}\). On the other hand, the diffusions obtained with the shell model result in \(\mu _H \approx 8.5\cdot 10^{-5}\mathrm { cm^2}\mathrm { V^{-1}}\mathrm { s^{-1}}\). While error bars (not reported) are still quite large with our level of statistics, the noticeably different values for these mobilities suggest that Hall effect is absent or hardly measurable for the rigid ion model but quite appreciable when polarization is accounted for. This observation needs to be confirmed via more accurate calculations, but it clearly underlines the relevance of polarization on observables affected by relatively subtle effects in transport processes.

Fig. 7
figure 7

Diagonal (upper panels) and off-diagonal, i.e., perpendicular to the magnetic field (lower panels), components of the diffusion tensor for a rigid ion (symbols), and a shell model (lines) system in magnetic field

5 Conclusions

In this paper, we described the MaZe dynamics for the simulation of systems where the evolution of a set of physical dofs depends on parameters subject to assigned conditions. Fully adiabatic dynamics, in first principle or classical polarizable models, is perhaps the most relevant example of such systems. The derivation of MaZe and of its key properties was presented, using the classical shell model for polarization as a reference case. MaZe exploits the Lagrangian formulation of classical mechanics to define an extended system in which the external parameters evolve as auxiliary dynamical variables of zero mass. These variables are subject to constraints that strictly enforce the conditions on the parameters for each configuration of the physical dofs in the evolution. The mass-zero value for the auxiliary variables results in rigorous fully adiabatic evolution for the physical dofs and, consequently, on exact statistical sampling of the associated probability density. From a numerical point of view, the integration of the constrained dynamics is efficiently performed using the SHAKE algorithm in its standard form for holonomic systems.

A new development extending this approach to the physically interesting case of the shell model in external magnetic field was also presented. Although the model we have chosen neglects magnetization effects, it is still nontrivial and represents an interesting extension of the MaZe framework. In this case, in fact, the presence of the Lorentz force requires to generalize the formalism and the associated algorithm to systems with constraints that depend linearly on the velocities. This generalization was described in the second part of the paper and used in illustrative calculations on a shell model of molten NaCl. These calculations demonstrate the effectiveness of the new algorithm and provide interesting qualitative information on the effect of polarization on ionic transport in magnetic field. In particular, we showed indications that—within the model adopted — polarization is critical to obtain a nonnull value of the Hall mobility for the system. Future work will consider extending MaZe to more general models for electric and magnetic interactions.