## 2 Materials and Methods
### Implementation Using PINNs
#### 2.2.2 Neural Network Architecture  
The developed neural network model for constructing a one-dimensional computational grid based on the diffusion equation is a multilayer fully connected network implemented in PyTorch. The main goal of this architecture is to approximate the function \(s(x)\), which is the function governing adaptive grid node distribution, while ensuring compliance with the diffusion equation. The architecture of the neural network used in this study is shown in Figure 1. The model consists of an input layer, several hidden layers with sigmoid activation functions, and an output layer that approximates the target function. The diffusion equation is incorporated into the loss function, enabling the model to learn in a physically consistent manner. The total loss function is defined as  
\[\mathcal{L}=\lambda\mathcal{L}_{\mathcal{BC}}+(1-\lambda)\mathcal{L}_{ \mathcal{PDE}} \tag{3}\]  
where \(\lambda\in[0,1]\) is a weighting coefficient that controls the contribution of the boundary conditions and the differential equation to the total error. This formulation ensures the normalization of the total loss and provides an intuitive interpretation of the relative importance of each component. Neural Network Structure  
The network architecture consists of 10 hidden layers, each containing 5 neurons. The input to the network is the one-dimensional coordinate x, while the output is the value s(x), which defines the position of the computational grid nodes. The network layers are structured as follows:  
* Input layer: Accepts the one-dimensional value x and passes it to the first hidden layer. * Ten hidden layers: Each layer contains five neurons, fully connected. A sigmoid activation function is used to introduce nonlinearity into the model. * Output layer: Transforms the output values of the last hidden layer into a one-dimensional value s(x) without applying an activation function, as this is a regression task. Figure 1: Architecture of the PINN used to generate the adaptive grid. Weight Initialization Methods and Input Data Normalization  
The network weights are initialized randomly following a standard distribution. The input data x are normalized before being processed by the network, which improves convergence during training. Optimal Hyperparameters  
The model's hyperparameters include the following:  
* Number of hidden layers: 10;
* Activation function: Sigmoid;
* Optimizer: Adam;
* Learning rate: 0.01;
* Number of training iterations: 40,000. The selected parameters ensure a balance between prediction accuracy and computational efficiency. Implementation of the Diffusion Equation as Part of the Loss Function  
In this implementation, the diffusion equation is incorporated into the loss function, allowing the neural network model to satisfy physical constraints without explicitly constructing the grid. This is achieved by automatically differentiating the network's output data and minimizing deviations from the equation. The loss function consists of two components:  
1. _Constraint on the diffusion equation_. Using automatic differentiation in PyTorch, the first derivative \(s_{x}\) is computed and weighted by the function \(\omega(s)\). Then, the second derivative \(A_{x}\) is calculated, where \(A=s_{x}\cdot\omega(s)\), which should be equal to zero. This condition is incorporated into the loss function as follows:  
\[\mathcal{L_{PDE}}=||A_{x}||^{2} \tag{4}\]  
Here, \(\mathcal{L_{PDE}}\) represents the loss function associated with the diffusion equation. The value of \(\mathcal{L_{PDE}}\) quantifies the deviation of the neural network's output from the equation. A lower \(\mathcal{L_{PDE}}\) indicates a better approximation of the solution. 2. _Boundary Conditions_.