## 2 Materials and Methods
### Implementation Using PINNs  
#### 2.2.1 Fundamental Principles of PINNs  
The PINN is a method that combines the capabilities of neural network modeling with physical laws. Unlike traditional neural networks, which rely solely on data, the PINN incorporates differential equations as additional constraints, allowing the model to account for physically justified dependencies during training. This approach is particularly useful in numerical modeling problems, where obtaining accurate and stable solutions requires integrating the knowledge of fundamental natural laws.  
One of the key advantages of the PINN is its ability to approximate solutions to differential equations without explicit domain discretization. This mitigates common numerical method challenges, including accuracy dependence on grid resolution and the need for explicit iterative schemes. Specifically, to construct an adaptive one-dimensional computational grid, the diffusion equation is incorporated into the neural network's loss function, ensuring a physically meaningful result.  
However, despite these advantages, the PINN method may exhibit a lower solution accuracy than traditional numerical methods. This is because minimizing the loss function does not always guarantee strict adherence to the original differential equation, especially in the presence of complex control functions with sharp variations. Additionally, the choice of hyperparameters, such as network architecture, learning rate, and loss function parameters, significantly impacts the final solution accuracy. In some cases, the PINN method may smooth out local grid features, leading to discrepancies compared to numerical methods.  
In the presented implementation, a PINN is applied to solve the one-dimensional diffusion equation, where the network is trained to ensure that its output values satisfy both the equation and the given boundary conditions. This is achieved by using automatic differentiation in PyTorch [[https://pytorch.org/](https://pytorch.org/)]([https://pytorch.org/](https://pytorch.org/)) (accessed on 11 April 2025), which allows for the direct computation of the derivatives of the network's output values and the minimization of the physics-informed loss function. This approach provides high flexibility in constructing computational grids and enables the generation of optimal node distributions.  
One possible way to improve the accuracy of the PINN method is to introduce an additional mapping of the reference domain, which allows for better control over the node distribution in the adaptive grid. Applying parametric transformations to input data or adjusting the weighting function can provide a more precise correspondence between the analytical solution and the predictions of the neural network model.  
To evaluate the effectiveness of different strategies for enforcing boundary conditions in PINNs, two neural network architectures are implemented in this study. The first architecture imposes Dirichlet boundary conditions via a penalty term in the loss function,while the second applies a hard constraint using a smooth mask function \(\phi(x)\) embedded into the output layer.