pihnn.utils.compute_Lp_error#
- pihnn.utils.compute_Lp_error(triangulation, model, model_true, p=2)#
Compute and print to screen the approximated relative \(L^p\) error between a model and a reference solution. I.e.,
\[\frac{\|u_{NN}-u\|_{L^p(\Omega)}}{\|u\|_{L^p(\Omega)}} = \left(\frac{\int_{\Omega} |u_{NN}-u|^p}{\int_{\Omega} |u|^p} \right)^{1/p} \approx \left(\frac{\sum_{(x,y)\in \mathcal{T}} |u_{NN}(x,y)-u(x,y)|^p}{\sum_{(x,y)\in \mathcal{T}} |u(x,y)|^p} \right)^{1/p},\]where \(u\) denotes any of the variables of interest and \(\mathcal{T}\) is the set of points in the triangulation.
- Parameters:
triangulation (
matplotlib.tri.Triangulation
) – 2D mesh used for evaluating the model.model (
pihnn.nn.PIHNN
/pihnn.nn.DD_PIHNN
) – Neural network model.model_true (callable) – Reference solution. It must be a scalar function for Laplace and biharmonic problems whereas it must return the 3 components of the stress tensor when solving the linear elasticity problem.
p (int) – Exponent for the \(L^p\) error.
- Returns:
errors (list of float) - Approximated \(L^p\) error for each variable of interest.