Python library supporting Discrete Variational Formulations and training solutions with Collocation-based Robust Variational Physics Informed Neural Networks (DVF-CRVPINN)
Tomasz Służalec, Marcin Łoś, Askold Vilkha, Maciej Paszyński · 2026
Read Python library supporting Discrete Variational Formulations and training solutions with Collocation-based Robust Variational Physics Informed Neural Networks (DVF-CRVPINN) by Tomasz Służalec, Marcin Łoś, Askold Vilkha, Maciej Paszyński (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-15398.txt.
Introduction
Służalec and three colleagues present a Python library for solving partial differential equations with discrete variational formulations. Users define discrete domains, functions, inner products, and weak forms with Kronecker delta test functions, then train a discrete neural network with finite-difference derivatives. A Stokes-flow example plus a rigorous well-posedness and robustness proof show the loss tracks true error during training.
Catalog record
| CREATOR | Tomasz Służalec, Marcin Łoś, Askold Vilkha, Maciej Paszyński |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 53120 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2604.15398
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Python library supporting Discrete Variational Formulations and training solutions with Collocation-based Robust Variational Physics Informed Neural Networks (DVF-CRVPINN) Tomasz Służalec, Marcin Łoś, Askold Vilkha, Maciej Paszyński Abstract We explore the possibility of solving Partial Differential Equations (PDEs) using discrete weak formulations. We propose a programming environment for defining a discrete computational domain, introducing discrete functions defined over a set of points, constructing discrete inner products, and introducing discrete weak formulations employing Kronecker delta test functions. Building on this setup, we propose a discrete neural network representation, training the solution function defined over a discrete set of points and employing discrete finite difference derivatives in the automatic differentiation procedures. As a challenging computational model example, we focus on Stokes equations in two-dimensions, defined over a discrete set of points. We train the solution using the discrete weak residual and the Adamax algorithm with discrete automatic differentiation of the discrete gradients. Despite introducing the python environment, we also provide a rigorous mathematical formulation based on discrete weak formulations, proving the well-posedness and robustness of the loss function. The solution of the discrete weak formulations is based on neural network training employing a robust loss function that is related to the true error. In this way, we have a robust control of the numerical error during the training of the neural networks. Besides the Stokes formulation, we also explain the functionality of the proposed library using the Laplace problem formulation. 1 Introduction The rapid progress of deep learning over the last decade has had a profound impact on computational science, including the numerical solution of Partial Differential Equations (PDEs) (see, e.g., [ 9 ] , [ 30 ] , [ 17 ] , [ 7 ] ). Among the most influential developments are Physics-Informed Neural Networks (PINNs) [ [ 25 ] ], which embed physical constraints into neural network training by minimizing strong-form residuals evaluated at collocation points. PINNs have been applied to a wide range of problems, including fluid dynamics and Navier–Stokes equations [ 3 ] , [ 22 ] , [ 18 ] , [ 29 ] , [ 31 ] , wave propagation [ 26 ] , [ 21 ] , [ 6 ] , phase-field models [ 8 ] , biomechanics [ 1 ] , [ 16 ] , quantum mechanics [ 11 ] ], electrical engineering [ 24 ] , and inverse and uncertainty-aware problems [ 10 ] , [ 32 ] , [ 4 ] , [ 14 ] , [ 23 ] . Variational Physics-Informed Neural Networks (VPINNs) [ 12 ] were introduced as a weak-form alternative to classical PINNs, offering improved stability and accuracy. By constructing loss functions based on variational formulations, VPINNs have shown promising results for elliptic, parabolic, and transport-dominated problems [ 13 ] , [ 19 ] , [ 15 ] , as well as inverse problems [ 20 ] , [ 2 ] . Nevertheless, the original VPINN formulation lacks robustness at the discrete level. To address this issue, Robust VPINNs (RVPINNs) were proposed in [ 28 ] , introducing Gram-matrix-weighted norms that ensure stability and consistency between discrete and continuous formulations. Despite their theoretical appeal, existing RVPINN implementations rely on numerical integration and dense linear algebra, leading to prohibitive computational costs and memory requirements. The robust loss is defined as a Riesz representative of the residual, which practical implementation involves the inverse of the Gram matrix, namely, \displaystyle\mathcal{L}(\theta)=\left\|{Au_{\theta}-f}\right\|_{V^{\prime}}^{2}=R_{\theta}^{T}GR_{\theta}=\text{RES}\,(\theta)^{T}G^{-1}\,\text{RES}(\theta) (1) where R_{\theta}=G^{-1}\,\text{RES}(\theta) is a vector representing v\mapsto\left({Au-f},{v}\right)_{h} , \text{RES}(\theta)_{i}=\left({Au-f},{v_{i}}\right)_{h} is the weak residual vector, where v_{i} is the i -th basis function of V , following the VPINN formulation. This loss is robust, which means that the true error (the difference between the neural network solution and the exact solution) is bounded by the square root of the robust loss, up to the continuity and coercivity constants \frac{1}{\mu}\sqrt{\mathcal{L}(\theta)}\leq\left\|{u_{\theta}-u_{\text{exact}}}\right\|_{h}\leq\frac{1}{\alpha}\sqrt{\mathcal{L}(\theta)}. (2) As a precursor to the present study, the collocation-based robust variational framework was introduced and validated in two spatial dimensions in [ 33 ] . In that work, the CRVPINN methodology combined point-collocation with a Gram-matrix-weighted loss function and an LU-based solver strategy, leading to a substantial reduction in computational cost compared to classical RVPINNs while preserving robustness. The approach was successfully demonstrated on a range of two-dimensional problems, including Laplace, advection–diffusion, Stokes, stationary Navier–Stokes, and linear elasticity equations, showing that the collocation-based formulation provides an efficient and stable alternative to integration-based variational PINNs. In this paper, we introduce a programming framework for defining a discrete computational domain, incorporating discrete functions over a set of points, constructing discrete inner products, and formulating discrete weak problems using Kronecker delta test functions. Building on this foundation, we develop a discrete neural network representation in which the solution function is defined over discrete points and trained using finite-difference-based derivatives within automatic differentiation. As a challenging test case, we consider the two-dimensional Stokes equations on a discrete point set. The solution is obtained by minimizing a discrete weak residual using the Adam optimization algorithm, with gradients computed through discrete automatic differentiation. In addition to the Python implementation, we provide a rigorous mathematical framework based on discrete weak formulations, establishing the well-posedness and robustness of the loss function. The neural network is trained using a loss function closely related to the true error, ensuring reliable control of numerical accuracy throughout training. Figure 1 : The solution of the Laplace problem with manufactured solution solved using our framework on 30\times 30 grid. The Laplace problem has a continuity and coercivity constants equal to one, thus the convergence of trainig reviles the robust loss (equal to the true error). 2 Mathematical framework Following [ 33 ] , we consider the 2D unit square \Omega=(0,1)^{2} and a set of uniformly distributed collocation points \Omega_{h}\coloneq\{(ih,jh):0\leq i,j\leq N\}, (3) where h=1/N is the point spacing for some fixed grid size N . Our discrete formulations will be built using subspaces of the space of real functions on \Omega_{h} : D_{h}\coloneq\{u\colon\Omega_{h}\to\mathbb{R}\}\cong\mathbb{R}^{(N+1)^{2}} (4) which we endow with a scalar product and the induced norm: \left({u},{v}\right)_{h}\coloneq h^{2}\sum_{p\in\Omega_{h}}u(p)v(p),\qquad\left\|{u}\right\|_{h}^{2}\coloneq\left({u},{u}\right)_{h}. (5) Continuous derivatives will be approximated using finite difference operators given by \displaystyle\nabla_{+}u_{i,j}\coloneq \displaystyle\left(\nabla_{x+}u_{i,j},\nabla_{y+}u_{i,j}\right)\coloneq\left(\frac{u_{i+1,j}-u_{i,j}}{h},\frac{u_{i,j+1}-u_{i,j}}{h}\right) (6) \displaystyle\nabla_{-}u_{i,j}\coloneq \displaystyle\left(\nabla_{x-}u_{i,j},\nabla_{y-}u_{i,j}\right)\coloneq\left(\frac{u_{i,j}-u_{i-1,j}}{h},\frac{u_{i,j}-u_{i,j-1}}{h}\right) for these indices (i,j) where the right-hand side is defined, and zero otherwise. Here, u_{i,j} is a shorthand for u(ih,jh) . Using these, we can define a degenerate scalar product and a corresponding seminorm: \left({u},{v}\right)_{\nabla,h}\coloneq\left({\nabla_{x+}u},{\nabla_{x+}v}\right)_{h}+\left({\nabla_{y+}u},{\nabla_{y+}v}\right)_{h},\qquad\left\|{u}\right\|_{\nabla,h}^{2}\coloneq\left({u},{u}\right)_{\nabla,h}. (7) When restricted to the subspace D_{0,h}\coloneq\left\{u\in D_{h}:\left.u\right|_{\partial\Omega_{h}}=0\right\},\quad\partial\Omega_{h}\coloneq\partial\Omega\cap\Omega_{h} (8) of functions that vanish on the discrete boundary points, these two become a scalar product and a norm, respectively. The standard discrete Laplace operator \Delta u_{i,j}\approx\frac{1}{h^{2}}\left(u_{i,j+1}+u_{i,j-1}+u_{i+1,j}+u_{i-1,j}-4u_{i,j}\right) (9) corresponds to \Delta_{h}u=\nabla_{+}\cdot(\nabla_{-}u)=\nabla_{-}\cdot(\nabla_{+}u) . Let \tau_{\alpha}^{\pm} denote the shift operator in direction \alpha , that is \left(\tau_{x}^{+}u\right)_{ij}=\begin{cases}u_{i+1,j}&\text{for }i<N\\ 0&\text{for }i=N\end{cases}\quad\left(\tau_{x}^{-}u\right)_{ij}=\begin{cases}u_{i-1,j}&\text{for }i>0\\ 0&\text{for }i=0\end{cases}, (10) and similarly for \tau_{y}^{\pm} and \tau_{z}^{\pm} . Lemma 1 Shift operators \tau_{\alpha}^{+} and \tau_{\alpha}^{-} are adjoint, that is \left({\tau_{\alpha}^{+}u},{v}\right)_{h}=\left({u},{\tau_{\alpha}^{-}v}\right)_{h} for all u,v\in D_{h} . Proof We will prove it for \alpha=x ; for other directions, the proof is the same. Since the scalar product is bilinear, it is enough to consider the case when u is a basis function, that is, u=\delta^{ij} for some 0\leq i,j\leq N . If i=0 , then \tau_{x}^{+}\delta^{ij}\equiv 0 , so \left({\tau_{x}^{+}\delta^{ij}},{v}\right)_{h}=0 . On the other hand, \left(\tau_{x}^{-}v\right)_{ij}=0 , and consequently