## 2 Numerical Formulation of the Magneto-Quasi-Static Problem
The numerical model implemented in CARIDDI solves Equation (4) by applying [PERSON]'s method, starting from the following decomposition in edge elements, \(\mathbf{N}_{k}\), of the unknown current density, as follows:  
\[\mathbf{J}=\sum_{k}l_{k}\
abla\times\mathbf{N}_{k} \tag{5}\]  
By using (5) in (4), under the assumption of time-harmonic signals, the vector, \(\mathbf{I}\), of the unknown coefficients, \(l_{k}\), can be calculated by solving the following linear system:  
\[\left(\mathbf{R}+\mathbf{L}\frac{d}{dt}\right)\cdot\mathbf{I}=\mathbf{Z}\cdot \mathbf{I}=\mathbf{V}_{0} \tag{6}\]  
The resistance \(\mathbf{R}\) and inductance \(\mathbf{L}\) matrices in (6) are calculated by means of the following integrals in the conducting regions, \(V_{C}\):  
\[R_{\bar{\eta}}=\int_{V_{C}}\
abla\times\mathbf{N}_{i}(\mathbf{r})\cdot\sigma^ {-1}\
abla\times\mathbf{N}_{j}(\mathbf{r})d\mathbf{r} \tag{7}\]  
\[L_{\bar{\eta}}=\frac{\mu_{0}}{4\pi}\int_{V_{C}}\int_{V_{C}}\frac{\
abla\times \mathbf{N}_{i}(\mathbf{r})\cdot\
abla\times\mathbf{N}_{j}(\mathbf{r}^{\prime })}{|\mathbf{r}-\mathbf{r}^{\prime}|}dr\mathbf{d}\mathbf{r}^{\prime} \tag{8}\]  
whereas \(\mathbf{V}_{0}\) is a known vector that is computed from the external imposed sources, as follows:  
\[V_{0,k}=-\frac{d}{dt}\int_{V_{C}}\
abla\times\mathbf{N}_{k}(\mathbf{r})\cdot A _{s}(\mathbf{r},\mathbf{t})d\mathbf{r} \tag{9}\]Once the numerical problem (6) is solved, the flux density \(\mathbf{B}\) is obtained at any given position \(\mathbf{r}\) as \(\mathbf{B}=\mathbf{Q}\cdot\mathbf{I}\), where the generic entry of the matrix \(\mathbf{Q}\) is defined as follows:  
\[Q_{ki}=\frac{\mu_{0}}{4\pi}\int_{V_{C}}\frac{(\
abla xN_{k}(\mathbf{r^{\prime}} ))\times(\mathbf{r}_{i}-\mathbf{r^{\prime}})}{|\mathbf{r}_{i}-\mathbf{r^{ \prime}}|^{3}}d\mathbf{r^{\prime}}. \tag{10}\]  
The solution of the linear system (6) via a direct method requires a first step of matrix assembly, followed by a final step of matrix inversion. Specifically, the following four tasks may be identified:  
1. assembly of the known-terms vector, \(\mathbf{V}_{0}\);
2. assembly of the resistance and inductance matrices, \(\mathbf{R}\) and \(\mathbf{L}\);
3. assembly of the flux density matrix, \(\mathbf{Q}\);
4. inversion of the impedance matrix, \(\mathbf{Z}\), defined as in (6), via factorization and back substitution. In real-world applications such as those analyzed in this paper, related to fusion machines, the high computational burden requires the use of efficient parallel computing techniques, as discussed in the next section. In this paper, we focus on the parallelization of the assembly phase; whereas, the matrix inversion is here performed by using the best available routines, such as the Scalapack one [24]. The \"inversion phase\" (task (d)) is usually the most time consuming when using a direct solver, but it is worth noticing that in many practical cases also tasks (a)-(c) in the \"assembly phase\" can be very demanding of both CPU and RAM resources. Indeed, if we denote with \(N_{dof}\) the degrees of freedom of the numerical problem, the time required for the inversion (\(t_{i}\)) is proportional to \(N_{dof}^{3}\), \(t_{i}=k_{i}N_{dof}^{3}\); whereas, the assembly time (\(t_{a}\)) is proportional to \(N_{dof}^{2}\), i.e., \(t_{a}=k_{a}N_{dof}^{2}\). Following this consideration, one can be brought to affirm that the assembly time is lower than the inversion one. However, in many applications, the actual CPU-times for the two phases are comparable, since \(k_{i}\) depends only on the computational resources, whereas \(k_{a}\) depends on the accuracy. Indeed, there are some cases of practical interest among the MOS problems where the required accuracy imposes values of \(k_{a}\) that may lead to values of \(t_{a}\) comparable to, or even greater than, \(t_{i}\). This happens, for instance, when the density of the electrical current varies rapidly in space and in time and consequently a high accuracy in the evaluation of the inductance matrix is required.