Physics informed neural network for charged particles surrounded by
  conductive boundaries
In this paper, we developed a new PINN-based model to predict the potential
of point-charged particles surrounded by conductive walls. As a result of the
proposed physics-informed neural network model, the mean square error and R2
score are less than 7% and more than 90% for the corresponding example
simulation, respectively. Results have been compared with typical neural
networks and random forest as a standard machine learning algorithm. The R2
score of the random forest model was 70%, and a standard neural network could
not be trained well. Besides, computing time is significantly reduced compared
to the finite element solver.
Fatemeh Hafezianzade, Morad Biagooi, SeyedEhsan Nedaaee Oskoee
# Physics informed neural network for charged particles surrounded by conductive boundaries

###### Abstract

In this paper, we developed a new PINN-based model to predict the potential of point-charged particles surrounded by conductive walls. As a result of the proposed physics-informed neural network model, the mean square error and \(R^{2}\) score are less than 7% and more than 90% for the corresponding example simulation, respectively. Results have been compared with typical neural networks and random forest as a standard machine learning algorithm. The \(R^{2}\) score of the random forest model was 70%, and a standard neural network could not be trained well. Besides, computing time is significantly reduced compared to the finite element solver.

Poisson Laplace Physics-informed neural network charged particles Conductive boundaries supercapacitor

## 1 Introduction

Computational Electromagnetic Simulation (CES) plays a significant role in many areas of science and engineering, such as soft matter, electrical engineering, biomedical engineering and chemistry. In addition, it has numerous applications in industry. For example, it is one of the main tools in investigating and designing the process of supercapacitors, which are porous energy storage devices with many applications in industry, especially when high power consumption or transfer is neededMiller and Simon (2008). Here, studying the physical mechanisms arising from charge storage in supercapacitors is essential for further technological developmentSalanne et al. (2016); Simon and Gogotsi (2008).
Solving Maxwell's equation, especially the Poisson equation in this study, is an essential part of computational electromagnetic algorithmsJackson (1962). Solving the Poisson equation can help scientists to calculate the potential of electrical sources in any system. However, many difficulties arise in practice due to the long-range nature of electrical interactions. In particular, estimating the potential of point-charged components in an environment with conductive walls is challenging because of the induced charges presented on the boundaries.

Generally, there are two approaches to solving the Poisson equation: analytical solutionJackson (1962) and numerical methods. There are limited techniques for solving analytically, like image charges methods applicable for cases with regular geometries; however, there is no guarantee to achieve practical results. If, for example, a particle is placed in a cubic conductive container, the image charges method will produce an infinite series. On the other hand, numerical methods lead to approximate solutions based on discretizing space and/or time domains. One of the typical numerical methods is the Finite Element Method (FEM)Jin (2014) which discretizes the continuous partial differential equations (PDEs) and forms a linear set of algebraic equationS. et al. (1991). Nevertheless, even FEM fails in calculating the potential in a charged particle's position since the electrical potential is singular at the place of charges. There are a number of methods and algorithms that have been developed to address this problem, including Induced Charge MMM2D (ICMMM2D)Tyagi et al. (2007) for 2D, ELCICTyagi et al. (2008) for 2D + h, Induced Charge Computation (\(ICC*\) )Tyagi et al. (2010), Kesselheim et al. (2010), Arnold et al. (2013) for 3D periodicity, and a method introduced by Reed et al.Reed et al. (2007) have been developed. In addition, recently, there has been another algorithm named PLT. It was first demonstrated for a partially periodic system constrained between two metallic plates in Rostami et al. (2016), and then it was applied to CAVIAR Biagooi et al. (2020), a molecular dynamics simulation package for charged particles surrounded by non-trivial conductive boundaries. Numerical solving of these problems with the CAVIAR package is accurate; moreover, it took less time than \(ICC*\) Biagooi et al. (2020) but is still time and memory-consuming.

Recently another data-driven approach to solving the PDEs based on deep machine learning is also of great current interest. For instance, Shan et al. Shan et al. (2020) present a CNN to predict the electric potential with different excitations and permittivity distribution in 2D and 3D models. It is fast and efficient compared with FEMJin (2014). However, a couple of problems prevent it from utilizing as a Poisson solver in the MD simulation process; first, it could not work in the case of discrete density functions such as those of point charges, and second, it is a physics-free approach which makes it hard to consider boundary conditions. To overcome the first problem, one can use the PLT algorithm. Additionally, Raissi et al. introduced the physics-informed neural network (PINN) that the loss function defined by Raissi et al. (2019) is an excellent alternative to the conventional deep learning method because of the governing equations, boundary conditions, and initial conditions used in its definition.

In this paper, we applied a new PINN-based model to predict the potential of point-charged particles surrounded by conductive walls. We then compared the results with typical neural networks and random forests as a standard machine learning algorithm. For instance, we tried to implement these models for a charged particle in a spherical container. The reason for utilizing this simple example was that there is an exact solution to this problem through the analytical method, the image charges method. As a starting point, we used the PLT algorithm to transfer the Poisson equation into the Laplace equation with modified boundary conditions. Then we trained the model to solve the Laplacian equation with new boundary conditions. The input data is included the position in which we want to evaluate the potential on it and the modified boundary conditions; the output data is the corresponding electrical potential of that position.

## 2 Methods

This article aims to build a machine-learning model (ML-Model) to predict the potential of point-charged particles surrounded by conductive walls. The potential of charged particles is calculated by solving the Poisson equation, which can be written as Jackson (1962):

\[\nabla^{2}\phi=-\rho/\epsilon_{0}=-\sum_{i=1}^{N}q_{i}\delta(x-x_{q_{i}})/ \epsilon_{0}, \tag{1}\]

where \(\phi\) is the potential and \(\rho\) is a charge distribution. The first and straightforward ML-Model that jumps to mind is a model that includes \(x_{q}\) and \(x\) as an input, and \(\phi(x_{q},x)\) as an output. Here \(x_{q}\) is the position of point-charged particle, \(x\) is the position in which we want to calculate the potential on it, and \(\phi(x_{q},x)\) is the corresponding potential. So the number of input features depends on the number of charged particles; for instance, in 3 dimensions, if there is N charged particles, the input features have to be \(3+3\times N\). Therefore,
this kind of model could only predict the potential of fix number of charged particles. In many applications of this method, such as the molecular dynamic simulation, this number is not fixed and could even increase or decrease during the simulation. We use the PLT algorithm to transpose the Poisson equation into the Laplace equation with new boundary conditions to overcome this problem. This algorithm will be discussed in more detail in 2.1. So we can train a model which includes \(x\) and modified boundary conditions as input features and \(\phi(\phi_{b},x)\) as an output. We define the boundary conditions only on \(N_{b}\) fixed points on the boundary \(\{\phi_{1},\phi_{2},\ldots,\phi_{N_{b}}\}\). In this case, with the PLT algorithm, we can build a model with a fixed number of input features that can predict any charged particles' potential.

### Poisson to Laplace Transformation (PLT)

According to the PLT algorithm, the electrical potential is divided into two parts: singular potential (\(\phi_{si}\)) and smooth potential (\(\phi_{sm}\)); \(\phi(\vec{x})=\phi_{si}(\vec{x})+\phi_{sm}(\vec{x})\). It is important to note that the smooth part here is the solution of the Laplace equation with modified boundary conditions,

\[\nabla^{2}\phi_{sm}(\vec{x})=0, \tag{2}\]

Figure 1: Methodology flow chart, The blue part: Preparing the data, in which the reference data set is created based on the PLT algorithm. The red part: Training models process, first the reference set is split to train and test set, then RF, ANN, and PINN model were applied on the train set, after tuning the hyperparameters the best model were chose.
while \(\phi_{si}\) obeys the famous Columb laws

\[\phi_{si}(\vec{x})=\sum_{i=1}^{N}\frac{q_{i}}{4\pi\epsilon_{0}\|\vec{x}-\vec{x}_{ i}\|}. \tag{3}\]

It can be seen that the modified boundary condition for \(\phi_{sm}\) is represented by

\[\phi_{sm}\|_{\vec{x}_{bc}}=\phi\|_{\vec{x}_{bc}}-\phi_{si}\|_{\vec{x}_{bc}}, \tag{4}\]

where \(\phi\|_{\vec{x}_{bc}}\) corresponds to the initial electrical potential on the boundaries. Finally, with the PLT algorithm, we could transfer the Poisson to the Laplace equation with new modified boundary conditions, then train an ML-Model with these modified boundary conditions as an input parameter and the smooth potential as an output. Afterward with the summation of singular and predicted smooth potential, we can reach the total potential. Advantage of utilizing PLT algorithm is that it leads to having a fixed number of input data since the number of input data would be independent of the number of point-charged particles.

### Data Engineering

For training a highly accurate model, having a nice train set is crucial. In this work, the reference set is \(\Gamma=\left\{x^{i},y^{i},z^{i},\varphi_{bc}^{\vec{i}},\phi^{i}\right\}_{i=1}^ {N}\), where the input is concluded \(\{x,y,z,\vec{\varphi}_{bc}=\{\phi_{1},\phi_{2},...,\phi_{N_{b}}\}\}\) and \(\phi\) is the target. \(x,y,z\) is the coordinate of a point in the container on which we want to calculate their potential, \(\phi\) is the numeric value of the potential at this point, and \(\{\phi_{1},\phi_{2},...,\phi_{N_{b}}\}\) is the boundary condition on \(N_{b}\) points on the boundary. First, in the container, \(N_{p}\) positions are chosen to predict the potential in their situations. In fact, for each boundary condition, \(\{\phi_{1},\phi_{2},...,\phi_{N_{b}}\}\), there are \(N_{p}\) points that we want to calculate the potential at their positions. Then, the reference set could be created for \(N_{q}\) different boundary conditions. So the reference set consists of \(N=N_{q}\times N_{p}\) samples which could split to train and test set. In this case, our container is a sphere, we also set \(N_{p}=78\), \(N_{b}=26\), and \(N_{q}=100\). So, our reference consists of 100 different boundary conditions and for each boundary condition \(\{\phi_{1},\phi_{2},...,\phi_{26}\}\) there are 78 points in the sphere on which we want to calculate the potential on it. We use the solution of the image charges method (Eq.5) to calculate targets of the reference set:

\[\phi(\vec{x})=\frac{1}{4\pi\epsilon_{0}}\{\frac{q}{\|\vec{x}-\vec{x}_{q}\|}+ \frac{q^{\prime}}{\|\vec{x}-\vec{x_{q^{\prime}}}\|}\},\quad q^{\prime}=-\frac {rq}{a},\quad\vec{x_{q^{\prime}}}=\frac{a^{2}}{r}\frac{\vec{x}_{q}}{\|\vec{x}_ {q}\|}, \tag{5}\]

where \(a\) is the conductive spherical shell radius and \(r\) is the distance of a point charge \(q\) from its center. The numeric value of potential is minimal (\(\sim 10^{-9}\)), which conducts to significant rounding error during computation; therefore, the potential of an electron in a \(1m\) distance of it, \(1.44\times 10^{-9}[V]\), is used as a unit

Figure 2: Schematic of the PLT method: a) the main system which had point charges inside of it b) the new system without any point charges and the boundaries were modified c) \(N_{b}\) points on the boundary are shown to be used as our model input.
to make equation 5 dimensionless. We randomly chose 5000 and 1000 samples from the reference set to create a train and test set. The train and test set have no samples in common. In addition, the best model could adequately predict the potential of test samples and samples with different boundary conditions from the train and test set. So to evaluate the model better, we prepare an extrapolation set that includes 1000 samples with 55 distinct boundary conditions.

### ML Algorithms

In this work, three different supervised learning methods have been used, and their regression accuracy, based on the metrics presented in 2.4, has been evaluated. Mainly, we stick to Physics-Informed Neural Networks (PINN, Raissi et al. (2019)), but to compare our results with other ML algorithms, we use Random Forest (RF, Breiman (2001)) and Artificial Neural Networks (ANN). All the models are briefly introduced, the hyperparameters are fine-tuned, and their performance is reported. Scikit-learn Pedregosa et al. (2011), Tensorflow Abadi (2016), Keras Chollet (2015), and NumPy Walt et al. (2011) are all the python libraries that have been used in this project.

#### 2.3.1 Random Forest(RF)

RF is one of the most popular machine learning algorithms in regression problems for many reasons, but in this project, this model has been chosen since

a) It is speedy to learn.

b) It is robust against over-fitting.

over-fitting is detected when the performance of train samples is perfect while the performance of test samples is poor. RF is an ensemble model in which an average of many uncorrelated trees determines the predicted potential for the target data set. Although each tree is a weak learner, they make a strong learner when many trees are grouped. The RF randomizes the trees by choosing a subset of training data and features for each tree. Here we use scikit-learn Pedregosa et al. (2011) RF implementation.

#### 2.3.2 Ann

Typical neural network architecture consists of the input layer, multiple hidden layers, and the output layer with several neurons in each layer. Totally:

* Input layer: The neurons in the input layer are the input features.
* Hidden layers: The value of every neuron in the hidden layers is a linear combination of the neurons in the previous layer followed by the implementation of an activation function(Eq.6); in most cases, the activation function is non-linear. \[a_{n}=\sigma_{l}\left(a_{n-1}\mathbf{w}_{n}+\mathbf{b}_{n}\right).\] (6) \(\mathbf{n}\) is the layer number, \(\mathbf{w}\) and \(\mathbf{b}\) are the model parameters, weights and bias respectively, and \(\sigma_{l}\) is the activation function based on Goodfellow et al. (2016).
* Output layer: The neurons in the output layer are the model targets and they are calculated with Eq.6 with linear activation function.
* Loss function: There is a function in all neural networks that must be minimized over the model parameters during the training stage via back-propagation, typically the loss function is the mean square error between the true and the predicted values. \[\text{Loss}(w)=MSE_{d}+\lambda\sum_{w}w^{2},\] (7) \[MSE_{d}=\frac{1}{N}\sum_{\text{i=1}}^{\text{N}}\left[\text{U}\left(\mathbf{ X}_{\text{i}},\mathbf{w}\right)-\text{T}_{\text{i}}\right]^{2}.\] (8)

U and T are the predicted output and true target values, respectively, X is the input data, and w is the parameter of neural networks, weights, and biases. The first sentence in Eq.7 is a mean square error, and
The second sentence exists to prevent over-fitting, namely \(L2\) regularizationa. K. Connect et al. (1992), that is used in order to reduce the effects of the large weights.

#### 2.3.3 PINN

PINNRAissi et al. (2019) enforces the Laplace equation, a physical law of the electromagnetic system, as a constraint on the neural network. This study proposes a PINN-based approach to solve the Laplace equation with changeable boundary conditions. Fig.3 shows a schematic of the neural network layout for this approach. PINN-based models are neural networks with modified \(loss\) functions:

\[\text{Loss}=\lambda_{1}MSE_{d}+\lambda_{2}MSE_{f}+\lambda_{3}MSE_{b}+\lambda_ {4}\sum_{w}w^{2}, \tag{9}\]

The first and the last term of Eq.9 are the same as typical neural networks in Eq.7. The second term corresponds to the governing physical equation, i.e., the is Laplace, and the third term corresponds to the boundary conditions;

\[MSE_{d}=\frac{1}{N_{d}}\sum_{i=1}^{N_{d}}\|u(\mathbf{x}_{d}^{i},\vec{\varphi}_ {d}^{i};w)-\phi_{d}^{i}\|^{2}, \tag{10}\]

\[MSE_{f}=\frac{1}{N_{f}}\sum_{i=1}^{N_{f}}\|f(\mathbf{x}_{f}^{i},u_{f}^{i};w) \|^{2}, \tag{11}\]

and

\[MSE_{b}=\frac{1}{N_{b}}\sum_{i=1}^{N_{b}}\|\mathcal{B}(\mathbf{x}_{b}^{i}, \vec{\varphi}_{b}^{i},u_{b}^{i};w)\|^{2}. \tag{12}\]

Here we define \(f\left(\mathbf{x},\mathrm{u};w\right)\)

\[\begin{split} f\left(\mathbf{x},\mathrm{u};w\right)& =0,\hskip 28.452756pt\mathrm{x}\in\Gamma_{f}\\ &=\nabla^{2}u\\ &=\frac{\partial^{2}u}{\partial x^{2}}+\frac{\partial^{2}u}{ \partial y^{2}}+\frac{\partial^{2}u}{\partial z^{2}}\\ &=\frac{\partial w}{\partial x}\frac{\partial}{\partial w}\left( \frac{\partial w}{\partial x}\frac{\partial u}{\partial w}\right)+\frac{ \partial w}{\partial y}\frac{\partial}{\partial w}\left(\frac{\partial w}{ \partial y}\frac{\partial u}{\partial w}\right)+\frac{\partial w}{\partial z} \frac{\partial}{\partial w}\left(\frac{\partial w}{\partial z}\frac{ \partial u}{\partial w}\right),\end{split} \tag{13}\]

with Dirichlet boundary conditions

\[\begin{split}\mathcal{B}\left(\mathbf{x},\vec{\varphi},u;w \right)&=0,\hskip 42.679134pt\mathrm{x}\in\Gamma_{b}\\ &=\sum_{j=1}^{26}(u(\mathbf{x}^{j},\vec{\varphi};w)-\varphi_{b} ^{j}).\end{split} \tag{14}\]

\(\lambda_{1},\lambda_{2},\lambda_{3}\) in Eq.9 correspond to the weight coefficients for the data contributions, Laplace equation, and boundary losses. We use the weight coefficient by motivating from the study of Kag et al. Kag et al. (2022). The last sentence is the \(L2\) regularizationa. K. Connect et al. (1992). Notice that the model with \(\lambda_{2}=\lambda_{3}=0.0\) is exactly a typical neural network described in the previous subsection.

### Evaluating Metrics

The performance evaluation of different algorithms for potential estimation depends on different metrics,

\[\Delta\phi=\phi_{True}-\phi_{Pred}, \tag{15}\]

\[\sigma=\sqrt{\frac{1}{n}\sum_{i=0}^{n-1}(\Delta\phi)^{2}}, \tag{16}\]
\[\text{R}^{2}=1-\frac{\sum_{i=1}^{n}\left(\phi_{\text{True}}-\phi_{\text{Pred}} \right)^{2}}{\sum_{i=1}^{n}\left(\phi_{\text{True}}-\bar{\phi}_{\text{True}} \right)^{2}}, \tag{17}\]

\[\text{MSE}=<(\Delta\phi)^{2}>. \tag{18}\]

Where \(\phi_{True}\) is the true potential, \(\phi_{Pred}\) is the predicted potential, and \(\bar{\phi}_{True}\) is the mean true potential of a given test sample. In this study we used scatter \(\sigma\), \(R^{2}\) score and \(MSE\) as our evaluating metrics.

## 3 Result

In this paper, we predict the smooth potential of a point-charged particle in a spherical conductive container. First, we set the train and test set with 5000 and 1000 samples (2.2), then we train our models to predict smooth potential. We can calculate total potential by summating smooth and singular potential (more detailed in 2.1). However, in this work, to compare our results with CAVIARBiagooi et al. (2020), we investigate the smooth potential.

### Random Forest

#### 3.1.1 hyperparameter for RF

We optimize over the only hyperparameter, the number of trees in the forest that influences the fitting of the random forest model. In Fig.4, we plot \(MSE\) (the left panel) and \(R^{2}\) score (the right one) as a function of the number of trees for the test set to determine the optimal hyperparameter, which we find 100 trees since progress after 100 trees are negligible. Afterward, we trained the RF model using 100 trees.

Figure 3: Physics-informed neural network scheme for solving Laplace equation with variable boundaries
#### 3.1.2 RF Prediction

Fig.5 is illustrated the RF model with 100 trees. It shows that prediction is acceptable when the numeric value of potential is less than 0.3 (\(\phi_{True}<0.3\)) while it could not predict precisely in the case of \(\phi_{True}>=0.3\). The graphs of Fig.5 compare the true potential \(\phi_{True}\) and RF model predicted potential \(\phi_{RF}\) for the train data set(left picture) and test data set(right image). The RF method is relatively fast; however, it works when the predicted potential is smooth and relatively small, it is not suitable in the case of point-charged particles (where a gradient of potential as well as its numeric value is high at the position of the charge). Furthermore, it fails to predict the potential near the boundaries since the gradient of the potential is considerable.

Figure 4: \(MSE\) (left), and \(R^{2}\) score (right) for 1000 different sample of Test set

Figure 5: Potential estimation of RF model: a) show the train data set with 5000 samples with scatter of \(\sigma=0.02\), b) show the test data set with 1000 samples with scatter of \(\sigma=0.07\). The dashed red line shows where the predicted potential equals the true potential. The pink-shaded region marks \(1\sigma\) scatter of potential errors.
### PINN based model and NN

By setting both \(\lambda_{2}\) and \(\lambda_{3}\) to zero in PINN-based model, one can get exactly NN model. Therefore we investigate both models together and report their reulsts at the same time in the following section.

#### 3.2.1 hyperparameter for PINN and NN

Unlike the RF model, we define several hyperparameters: a number of neurons, a number of layers, \(\lambda_{2}\), and \(\lambda_{3}\). To tune all hyperparameters, we train the model up to 100000 epochs, using the L-BFGS-B optimizerLiu and Nocedal [1989], until the model's tolerance reaches the level of machine epsilon. For all layers except the last one, we use a tanh activation function. Table 1 is reported the \(MSE\) between the predicted and the same potential for a different value of hyperparameters; \(\lambda_{2}=[0,0.1,0.2,0.3]\), \(\lambda_{3}=[0,0.1,0.2,0.3,0.4]\), number of hidden layers\(=[1,3,5,7]\) and number of neurons per hidden layer\(=[10,30,50]\) for 1000 samples of the test set. As shown in Table 1, we observe that a model with one hidden layer could not predict the potential well. Also, a model with ten neurons per layer could not work well. So, Table 2 and Table 3 reported the results for just \([3,5,7]\) layers as well as for \([30,50]\) neurons per layer. We chose \(\lambda_{4}=0.0001\) to prevent over-fitting.

#### 3.2.2 PINN and NN Prediction

In Contrast with Table 1, Table 2 is reported not only the \(MSE\) but also the \(R^{2}score\) of the test set. As can be seen in Table 2, the model with seven layers and 50 neurons per layer resulted better when \(\lambda_{2}\) and \(\lambda_{3}\) are \(0.3,0.3,\) or \(0.2,0.4\), respectively. When \(\lambda_{2}\) and \(\lambda_{3}\) are zero, a standard neural network, the model has not worked well; it is observed from Tabel 2 and Fig.4.

Both plots in Fig.6 compare the true and predicted potentials for the best-tuned NN and the best-tuned PINN model with 7 layers and 50 neurons per layer, \(\lambda_{2}=0.3\) and \(\lambda_{3}=0.3\)- on the train set. As can be seen, the NN model is not trained well, while the PINN-based model could predict the potential precisely with a scatter of 0.01. Although the PINN-based model predicts the train set well, aiming to clarify that over-fitting has not been accrued, we also evaluate the model on the test set, Fig.7.

Figure 6: Potential estimation of best-tuned (a) NN with scatter of \(\sigma=0.07\) and (b) PINN model on the 5000 samples of the train set with scatter of \(\sigma=0.01\). The dashed red line shows where the predicted potential equals the true potential. The pink-shaded region marks \(1\sigma\) scatter of potential errors.
Figure 7: Potential estimation of best-tuned PINN model on the 1000 samples of the test set with scatter of \(\sigma=0.02\), \(MSE=0.069\) and \(R^{2}score=0.851\). The dashed red line shows where the predicted potential equals the true potential. The pink-shaded region marks \(1\sigma\) scatter of potential errors.
\begin{table}
\begin{tabular}{c c||c c c|c c c} \hline \hline  & \multicolumn{4}{c}{\(MSE_{test}\)} & \multicolumn{4}{c}{\(MSE_{test}\)} \\ \cline{2-9} \(\lambda_{2}\) & \(\lambda_{3}\) & **Neurons=10** & **Neurons=30** & **Neurons=50** & **Neurons=10** & **Neurons=30** & **Neurons=50** \\ \hline \hline \multicolumn{9}{c}{**Num of hidden layer:1**} & \multicolumn{4}{c}{**Num of hidden layer:5**} \\ \hline \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.162 & 0.145 & 0.124 & **0.099** & 0.145 & **0.078** \\
0.0 & 0.2 & 0.191 & 0.212 & 0.132 & 0.136 & **0.062** & **0.072** \\  & 0.3 & 0.175 & 0.159 & 0.171 & 0.14 & **0.069** & 0.124 \\  & 0.4 & 0.24 & 0.171 & 0.18 & 0.191 & **0.064** & **0.076** \\ \hline  & 0.0 & 0.246 & 0.247 & 0.247 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.222 & 0.143 & 0.117 & 0.107 & 0.245 & 0.192 \\
0.1 & 0.2 & 0.201 & 0.165 & 0.129 & 0.243 & **0.079** & **0.062** \\  & 0.3 & 0.22 & 0.159 & 0.16 & 0.112 & **0.094** & **0.071** \\  & 0.4 & 0.249 & 0.177 & 0.243 & 0.205 & **0.088** & **0.07** \\ \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.158 & 0.144 & 0.154 & 0.235 & 0.161 & **0.083** \\
0.2 & 0.2 & 0.225 & 0.174 & 0.174 & 0.198 & **0.097** & **0.071** \\  & 0.3 & 0.223 & 0.143 & 0.158 & 0.192 & **0.081** & **0.075** \\  & 0.4 & 0.197 & 0.185 & 0.189 & 0.216 & **0.065** & 0.118 \\ \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.21 & 0.132 & 0.129 & 0.245 & **0.088** & **0.098** \\
0.3 & 0.2 & 0.199 & 0.139 & 0.157 & 0.209 & 0.117 & **0.065** \\  & 0.3 & 0.216 & 0.241 & 0.202 & 0.182 & 0.168 & **0.08** \\  & 0.4 & 0.225 & 0.182 & 0.196 & 0.239 & **0.083** & **0.097** \\ \hline  & \multicolumn{4}{c}{**Num of hidden layer:3**} & \multicolumn{4}{c}{**Num of hidden layer:7**} \\ \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.157 & 0.104 & **0.086** & 0.244 & 0.237 & 0.247 \\
0.0 & 0.2 & 0.151 & **0.088** & **0.086** & 0.238 & 0.087 & 0.105 \\  & 0.3 & 0.13 & **0.078** & **0.089** & 0.244 & **0.07** & **0.067** \\  & 0.4 & 0.202 & 0.173 & 0.102 & 0.188 & **0.068** & **0.063** \\ \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & **0.099** & **0.089** & 0.132 & 0.244 & 0.244 & 0.244 \\
0.1 & 0.2 & 0.198 & **0.093** & **0.077** & 0.23 & 0.221 & **0.069** \\  & 0.3 & 0.188 & **0.088** & **0.083** & 0.224 & 0.223 & **0.082** \\  & 0.4 & 0.262 & 0.104 & **0.079** & 0.213 & **0.072** & **0.074** \\ \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.119 & 0.146 & **0.082** & 0.244 & 0.244 & 0.245 \\
0.2 & 0.2 & 0.172 & 0.09 & **0.086** & 0.244 & 0.244 & **0.071** \\  & 0.3 & 0.179 & 0.084 & **0.085** & 0.225 & 0.251 & **0.08** \\  & 0.4 & 0.197 & 0.185 & **0.086** & 0.256 & 0.166 & **0.067** \\ \hline  & 0.0 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 & 0.246 \\  & 0.1 & 0.17 & 0.125 & **0.082** & 0.244 & 0.244 & 0.244 \\
0.3 & 0.2 & 0.199 & 0.117 & **0.096** & 0.244 & **0.083** & **0.08** \\  & 0.3 & 0.224 & 0.107 & **0.088** & 0.202 & 0.235 & **0.069** \\  & 0.4 & 0.199 & 0.222 & 0.152 & 0.236 & **0.097** & **0.075** \\ \hline \hline \end{tabular}
\end{table}
Table 1: \(MSE\) between the predicted and the exact potential \(\phi(x)\) for a different value of \(\lambda_{2}\), and \(\lambda_{3}\), and the different number of hidden layers, and neurons per hidden layer in PINN for 1000 different sample of the Test set. Here, \(\lambda_{4}=0.0001\) is fixed and \(\lambda_{1}=1-(\lambda_{2}+\lambda_{3}+\lambda_{4})\). In this table, the bold number means \(MSE<0.1\).
\begin{table}
\begin{tabular}{c c||c c c c c c} \hline \hline  & \multicolumn{3}{c}{\(Num_{layer}\)=3} & \multicolumn{3}{c}{\(Num_{layer}\)=5} & \multicolumn{3}{c}{\(Num_{layer}\)=7} \\ \cline{3-8} \(\lambda_{2}\) & \(\lambda_{3}\) & \(MSE\) & \(R^{2}\) & \(MSE\) & \(R^{2}\) & \(MSE\) & \(R^{2}\) \\ \hline \hline \multicolumn{8}{c}{\(Num_{neuron}\)=30} \\ \hline \hline \multirow{4}{*}{0.0} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.104 & 0.774 & 0.145 & 0.365 & 0.237 & -14.7 \\  & 0.2 & 0.088 & 0.85 & 0.062 & 0.889 & 0.087 & 0.807 \\  & 0.3 & 0.078 & 0.826 & 0.069 & 0.884 & **0.07** & **0.904** \\  & 0.4 & 0.173 & 0.551 & 0.064 & 0.863 & 0.068 & 0.868 \\ \hline \multirow{4}{*}{0.1} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.089 & 0.796 & 0.245 & -1478 & 0.244 & 0 \\  & 0.2 & 0.093 & 0.825 & 0.079 & 0.852 & 0.221 & -2.40 \\  & 0.3 & 0.088 & 0.793 & 0.094 & 0.714 & 0.223 & 0.094 \\  & 0.4 & 0.104 & 0.719 & 0.088 & 0.793 & 0.072 & 0.887 \\ \hline \multirow{4}{*}{0.2} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.146 & 0.64 & 0.161 & 0.566 & 0.244 & 0 \\  & 0.2 & 0.09 & 0.769 & 0.097 & 0.75 & 0.244 & -3167 \\  & 0.3 & 0.084 & 0.819 & 0.081 & 0.857 & 0.251 & -2.32 \\  & 0.4 & 0.185 & 0.521 & 0.065 & 0.874 & 0.166 & 0.07 \\ \hline \multirow{4}{*}{0.3} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.125 & 0.626 & 0.088 & 0.747 & 0.244 & 0 \\  & 0.2 & 0.117 & 0.666 & 0.117 & 0.689 & 0.083 & 0.863 \\  & 0.3 & 0.107 & 0.67 & 0.168 & 0.59 & 0.235 & 0 \\  & 0.4 & 0.222 & 0.25 & 0.083 & 0.837 & 0.097 & 0.804 \\ \hline \multicolumn{8}{c}{\(Num_{neuron}\)=50} \\ \hline \hline \multirow{4}{*}{0.0} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.086 & 0.832 & 0.078 & 0.865 & 0.247 & -254 \\  & 0.2 & 0.086 & 0.838 & 0.072 & 0.873 & 0.105 & 0.711 \\  & 0.3 & 0.089 & 0.767 & 0.124 & 0.66 & 0.067 & 0.875 \\  & 0.4 & 0.102 & 0.734 & 0.076 & 0.846 & 0.063 & 0.849 \\ \hline \multirow{4}{*}{0.1} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.132 & 0.64 & 0.192 & -0.48 & 0.244 & 0 \\  & 0.2 & 0.077 & 0.85 & 0.062 & 0.888 & 0.069 & 0.897 \\  & 0.3 & 0.083 & 0.837 & 0.071 & 0.895 & 0.082 & 0.774 \\  & 0.4 & 0.079 & 0.847 & 0.07 & 0.887 & 0.074 & 0.863 \\ \hline \multirow{4}{*}{0.2} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.082 & 0.756 & 0.083 & 0.859 & 0.245 & -1774 \\  & 0.2 & 0.086 & 0.796 & 0.071 & 0.88 & **0.071** & **0.908** \\  & 0.3 & 0.085 & 0.799 & 0.075 & 0.888 & 0.08 & 0.87 \\  & 0.4 & 0.086 & 0.8 & 0.118 & 0.727 & **0.067** & **0.902** \\ \hline \multirow{4}{*}{0.3} & 0.0 & 0.246 & 0 & 0.246 & 0 & 0.246 & 0 \\  & 0.1 & 0.082 & 0.75 & 0.098 & 0.753 & 0.244 & 0 \\ \cline{1-1}  & 0.2 & 0.096 & 0.777 & 0.065 & 0.894 & 0.08 & 0.798 \\ \cline{1-1}  & 0.3 & 0.088 & 0.785 & 0.08 & 0.834 & **0.069** & **0.902** \\ \cline{1-1}  & 0.4 & 0.152 & 0.557 & 0.097 & 0.818 & 0.075 & 0.867 \\ \hline \hline \end{tabular}
\end{table}
Table 2: \(MSE\), and \(R^{2}\) score between the predicted and the exact potential \(\phi(x)\) for a different value of \(\lambda_{2}\), and \(\lambda_{3}\), and the different number of hidden layers, and neurons per hidden layer in PINN for 1000 different samples of the Test set. Here, \(\lambda_{4}=0.0001\) is fixed and \(\lambda_{1}=1-(\lambda_{2}+\lambda_{3}+\lambda_{4})\). In this table bold numbers show cases with \(MSE<0.1\) and \(R^{2}score>0.9\).
\begin{table}
\begin{tabular}{l c||c c c c c c} \hline \hline  & \multicolumn{3}{c}{\(Num_{layer}\)=3} & \multicolumn{3}{c}{\(Num_{layer}\)=5} & \multicolumn{3}{c}{\(Num_{layer}\)=7} \\ \cline{2-7} \(\lambda_{2}\) & \(\lambda_{3}\) & \(MSE\) & \(R^{2}\) & \(MSE\) & \(R^{2}\) & \(MSE\) & \(R^{2}\) \\ \hline \hline \multicolumn{7}{c}{\(Num_{neuron}\)=30} \\ \hline \multirow{7}{*}{0.0} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.14 & 0.71 & 0.148 & 0.364 & 0.275 & -15.28 \\  & 0.2 & 0.118 & 0.764 & 0.077 & 0.847 & 0.126 & 0.646 \\  & 0.3 & 0.104 & 0.737 & 0.09 & 0.782 & 0.089 & 0.835 \\  & 0.4 & 0.208 & 0.587 & 0.072 & 0.842 & 0.083 & 0.822 \\ \hline \multirow{7}{*}{0.1} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.105 & 0.808 & 0.28 & -1801 & 0.28 & 0 \\  & 0.2 & 0.112 & 0.775 & 0.09 & 0.845 & 0.259 & -2.137 \\  & 0.3 & 0.105 & 0.793 & 0.123 & 0.697 & 0.264 & 0.07 \\  & 0.4 & 0.116 & 0.735 & 0.12 & 0.684 & 0.092 & 0.813 \\ \hline \multirow{7}{*}{0.2} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.183 & 0.601 & 0.201 & 0.484 & 0.28 & 0 \\  & 0.2 & 0.118 & 0.739 & 0.114 & 0.68 & 0.28 & -3620 \\  & 0.3 & 0.095 & 0.829 & 0.109 & 0.799 & 0.275 & -1.82 \\  & 0.4 & 0.209 & 0.586 & 0.078 & 0.851 & 0.205 & 0.183 \\ \hline \multirow{7}{*}{0.3} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.154 & 0.663 & 0.105 & 0.743 & 0.28 & 0 \\  & 0.2 & 0.13 & 0.74 & 0.139 & 0.688 & 0.109 & 0.725 \\  & 0.3 & 0.143 & 0.565 & 0.2 & 0.604 & 0.271 & 0.012 \\  & 0.4 & 0.269 & 0.356 & 0.158 & 0.364 & 0.118 & 0.726 \\ \hline \multicolumn{7}{c}{\(Num_{neuron}\)=50} \\ \hline \multirow{7}{*}{0.0} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0 & 0.281 & 0 \\  & 0.1 & 0.116 & 0.764 & 0.112 & 0.769 & 0.28 & -310 \\  & 0.2 & 0.1 & 0.837 & 0.092 & 0.829 & 0.135 & 0.598 \\  & 0.3 & 0.101 & 0.79 & 0.145 & 0.719 & 0.083 & 0.843 \\  & 0.4 & 0.117 & 0.706 & 0.096 & 0.801 & 0.106 & 0.662 \\ \hline \multirow{7}{*}{0.1} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.149 & 0.657 & 0.227 & -0.465 & 0.28 & 0 \\  & 0.2 & 0.121 & 0.658 & 0.077 & 0.832 & 0.09 & 0.824 \\  & 0.3 & 0.108 & 0.719 & 0.096 & 0.817 & 0.102 & 0.734 \\  & 0.4 & 0.117 & 0.716 & 0.085 & 0.843 & 0.093 & 0.842 \\ \hline \multirow{7}{*}{0.2} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.094 & 0.782 & 0.112 & 0.777 & 0.28 & -2164 \\  & 0.2 & 0.114 & 0.758 & 0.094 & 0.785 & 0.091 & 0.854 \\  & 0.3 & 0.101 & 0.762 & 0.093 & 0.818 & 0.104 & 0.771 \\  & 0.4 & 0.124 & 0.644 & 0.143 & 0.703 & 0.088 & 0.849 \\ \hline \multirow{7}{*}{0.3} & 0.0 & 0.281 & 0 & 0.281 & 0 & 0.281 & 0 \\  & 0.1 & 0.097 & 0.772 & 0.115 & 0.727 & 0.28 & 0 \\ \cline{1-1}  & 0.2 & 0.112 & 0.768 & 0.096 & 0.807 & 0.167 & 0.363 \\ \cline{1-1}  & 0.3 & 0.11 & 0.777 & 0.113 & 0.682 & **0.089** & **0.851** \\ \cline{1-1}  & 0.4 & 0.177 & 0.563 & 0.114 & 0.76 & 0.103 & 0.741 \\ \hline \hline \end{tabular}
\end{table}
Table 3: \(MSE\) and \(R^{2}\) score between the predicted and the exact potential \(\phi(x)\) for a different value of \(\lambda_{2}\), and \(\lambda_{3}\), and the different number of hidden layers, and neurons per hidden layer in PINN for 1000 different samples of the Extrapolate set. Here, \(\lambda_{4}=0.0001\) is fixed and \(\lambda_{1}=1-(\lambda_{2}+\lambda_{3}+\lambda_{4})\). In this table bold number shows the best hyperparameters for our PINN-based model.
### Comparison

We evaluate RF, NN, and PINN to estimate the potential of point-charged particles surrounded by conductive walls. According to Fig.6, NN was not trained well, while RF and PINN-based models could predict potential precisely. However, RF did not work well to estimate \(\phi_{True}>0.3\). Apart from this, the best model could estimate not only the potential of the train and the test sets but also the potential of point-charged particles that are not in the train or test set. So we evaluate the best tuned-PINN model and RF on the extrapolation samples; the results are reported in Table 3. As can be seen in Fig.8 PINN-based model could predict the potential of newly charged particles better than the RF model, where PINN could predict \(\phi_{True}>0.3\) by far better than RF.

### Generalization (Multi charged particles)

For generalization, we test the PINN-based model with \(\lambda_{2}=0.3\) and \(\lambda_{3}=0.3\) for the case of more than one charged particle surrounded with conductive boundaries. Since the Laplace equation is a linear function, we predict the potential of each charged particle and then calculate the total potential with a superposition of the corresponding predicted potential. After that, we report the \(MSE\) between the predicted smooth potential and the exact smooth solution, which is calculated by the image charges method. Fig.9 shows the relation between \(MSE\) and \(N\), the number of charged particles. As expected, the \(MSE\) is independent of the number of charged particles. Therefore, it leads to the fact that we can also use this method for problems with any desired particles.

Figure 8: Potential estimation of best-tuned (a) RF with scatter of \(\sigma=0.07\), and (b) PINN-based model with scatter of \(\sigma=0.02\) on the 1000 samples of the Extrapolation set. The dashed red line shows where the predicted potential equals the true potential. The pink-shaded region marks \(1\sigma\) scatter of potential errors.
## 4 Conclusion

In this study, we have trained a machine to predict the smooth potential of charged components surrounded by conductive boundaries. In this scene, the total potential could be easily calculated by the summation of predicted smooth potential with singular potential due to the PLT algorithm. The reference set consists of analytic solutions, the solution of the image charge method, which is split into a train set with 5000 samples and a test set with 1000 samples. To check the accuracy of our model, we set another data set called extrapolation set consisting of 1000 samples with different boundary conditions which were not in the train or even test set. Our main conclusion can be summarized as follows:

* We find that the PINN-based model trained better than RF and NN models. RF could not predict high potential; on the other hand, the NN could not be trained well at all.
* our PINN-based model could predict the potential of the test set with \(MSE=0.069\), \(R^{2}score=0.902\), and scatter \(\sigma=0.02\). It also could predict the potential of the extrapolation set with \(MSE=0.089\), \(R^{2}score=0.851\), and scatter \(\sigma=0.02\).
* Since the Laplace equation is a linear equation, the trained model could predict the potential of more than one charged particle by summating every particle's predicted potential. Besides, we show that the \(MSE\) of more than one particle is independent of a number of particles.
