## 3 Physics-Informed GAN
### The Physics-Informed Loss Functions  
The loss function of cGAN is defined as:  
\[L_{\text{cGAN}}(G,D)=E_{x,y}[logD(x,y)]+E_{x,z}[log(1-D(x,G(x,z)))] \tag{4}\]  
where x is the input (c.f. the output of Step 1 in Figure 1), y is the ground truth (\(B_{FEM}\), c.f. the input of the discriminator \(\left(B_{x}^{*},B_{y}^{*}\right)\) in Figure 1), and z is the random noise vector [27]. G tries to minimize this objective against an adversarial D that tries to maximize it.  
Ideally, the generated magnetic field result \(B_{Pred}\) (c.f. the output of the generator \(\left(\hat{B}_{x}^{*},\hat{B}_{y}^{*}\right)\) in Figure 1) shall match the magnetic field \(B_{FEM}\) obtained using the FE method for each element. Hence, an \(L_{1}\) loss between the predicted result \(B_{Pred}\) and the given input image \(B_{FEM}\) is formulated based on the following equation:  
\[L_{1}=||B_{Pred}-B_{FEM}||\]  
Figure 1: Overview of novel DL approach for magnetic field approximation. A generator is trained to predict the magnetic field values.  
Nevertheless, in this paper, not only is a visually appealing result generated, but the generated magnetic field governed by [PERSON]'s equations is also generated. The proposed method is derived from the Maxwell equation system. At the same time, in order to meet the training requirements of GAN, some vectors are transformed into scalars through integration for gradient descent optimization. The first physical loss term is [PERSON]'s law for magnetism, which states that:  
\[L_{div}=\left|\sum|\
abla\cdot B_{Pred}|-\sum|\
abla\cdot B_{FEM}|\;\right| \tag{6}\]  
The loss function derived from [PERSON]'s circuital law can be simplified to:  
\[L_{curl}=\left|\sum|\
abla\times B_{Pred}|-\sum|\
abla\times B_{FEM}|\right| \tag{7}\]  
where \(B_{Pred}\) is the predicted magnetic field from generator G, and \(B_{FEM}\) is the ground truth obtained by the FE solution.  
The force is calculated using the Maxwell Stress Tensor (MST) method [29; 30; 31]. In the case of the MST, the divergence of the following tensor can be calculated using the following equation:  
\[T_{ij}=\frac{1}{\mu_{0}}\bigg{(}B_{i}B_{j}-\frac{1}{2}\delta_{ij}B^{2}\bigg{)} \tag{8}\]  
where \(B\) is the magnetic flux density, and \(\delta_{ij}\) is the Kronecker sign (\(\delta_{ij}\) = 1 if I = j; otherwise, \(\delta_{ij}\) = 0).  
The Maxwell Stress Tensor (MST) is performed by calculating the force using a surface integration on \(\Gamma\) over a \(D\) domain. The force vector and the loss of force are listed in the following:  
\[\begin{array}{rl}\textbf{F}&=\int\limits_{D}div\;T\;dv\\ &=\oint\limits_{\Gamma}\frac{1}{\mu_{0}}\bigg{(}(B\cdot n)B-\frac{1}{2}|B|^{2}n \bigg{)}ds\\ \\ L_{force}=\left|\sum\right|F_{pred}\Big{|}-\sum\right|F_{FEM}|\Big{|}\end{array} \tag{9}\]  
The vector \(n\) is the normal on the surface \(\Gamma\), \(F_{pred}\) stands for the force vector obtained by \(B_{Pred}\), and \(F_{FEM}\) stands for the force vector obtained by \(B_{FEM}\).  
The final loss function used during training is a scalar, which is formulated as follows:  
\[\begin{array}{rl}L=&\lambda_{cGAN}L_{cGAN}+\lambda_{1}L_{1}\\ &+\lambda_{div}L_{div}+\lambda_{curl}L_{curl}+\lambda_{force}L_{force}\end{array} \tag{10}\]  
where \(\lambda_{cGAN}\), \(\lambda_{1}\), \(\lambda_{div}\), \(\lambda_{curl}\), and \(\lambda_{force}\) are the penalty coefficients for each single loss function and define their relative importance.