From dcac3a9ddbf4cec7e501fe48148523e4ea45763e Mon Sep 17 00:00:00 2001 From: GiovanniCanali Date: Tue, 28 Apr 2026 12:55:38 +0200 Subject: [PATCH] enhance problem formulation --- .../_src/problem/zoo/acoustic_wave_problem.py | 46 ++++++++++++++- pina/_src/problem/zoo/advection_problem.py | 36 ++++++++++- pina/_src/problem/zoo/allen_cahn_problem.py | 32 +++++++++- .../problem/zoo/diffusion_reaction_problem.py | 59 ++++++++++++++++++- pina/_src/problem/zoo/helmholtz_problem.py | 41 ++++++++++++- .../problem/zoo/inverse_poisson_problem.py | 30 +++++++++- pina/_src/problem/zoo/poisson_problem.py | 36 ++++++++++- 7 files changed, 263 insertions(+), 17 deletions(-) diff --git a/pina/_src/problem/zoo/acoustic_wave_problem.py b/pina/_src/problem/zoo/acoustic_wave_problem.py index 302702caa..f2f7cff8b 100644 --- a/pina/_src/problem/zoo/acoustic_wave_problem.py +++ b/pina/_src/problem/zoo/acoustic_wave_problem.py @@ -28,8 +28,50 @@ def initial_condition(input_, output_): class AcousticWaveProblem(TimeDependentProblem, SpatialProblem): r""" - Implementation of the acoustic wave problem in the spatial interval - :math:`[0, 1]` and temporal interval :math:`[0, 1]`. + Implementation of the one-dimensional acoustic wave problem on the + space-time domain :math:`\Omega\times T = [0, 1] \times [0, 1]`. + + The problem is governed by the acoustic wave equation + + .. math:: + + \frac{\partial^2 u}{\partial t^2} + = + c^2 \frac{\partial^2 u}{\partial x^2}, + + where :math:`u = u(x, t)` is the solution field and :math:`c > 0` is the + wave propagation speed. + + Homogeneous Dirichlet boundary conditions are imposed at the spatial + boundaries: + + .. math:: + + u(0, t) = u(1, t) = 0, \qquad t \in [0, 1]. + + The initial displacement is prescribed as + + .. math:: + + u(x, 0) = \sin(\pi x) + \frac{1}{2}\sin(4\pi x), + \qquad x \in [0, 1], + + together with zero initial velocity: + + .. math:: + + \frac{\partial u}{\partial t}(x, 0) = 0, + \qquad x \in [0, 1]. + + The analytical solution is given by + + .. math:: + + u(x, t) + = + \sin(\pi x)\cos(c\pi t) + + + \frac{1}{2}\sin(4\pi x)\cos(4c\pi t). .. seealso:: diff --git a/pina/_src/problem/zoo/advection_problem.py b/pina/_src/problem/zoo/advection_problem.py index b46eae737..113b36bee 100644 --- a/pina/_src/problem/zoo/advection_problem.py +++ b/pina/_src/problem/zoo/advection_problem.py @@ -24,9 +24,39 @@ def initial_condition(input_, output_): class AdvectionProblem(SpatialProblem, TimeDependentProblem): r""" - Implementation of the advection problem in the spatial interval - :math:`[0, 2 \pi]` and temporal interval :math:`[0, 1]` with periodic - boundary conditions. + Implementation of the one-dimensional advection problem on the space-time + domain :math:`\Omega\times T = [0, 2\pi] \times [0, 1]`. + + The problem is governed by the linear advection equation + + .. math:: + + \frac{\partial u}{\partial t} + + + c \frac{\partial u}{\partial x} + = + 0, + + where :math:`u = u(x, t)` is the solution field and :math:`c` is the + advection velocity. + + Periodic boundary conditions are imposed at the spatial boundaries: + + .. math:: + + u(0, t) = u(2\pi, t), \qquad t \in [0, 1]. + + The initial condition is prescribed as + + .. math:: + + u(x, 0) = \sin(x), \qquad x \in [0, 2\pi]. + + The analytical solution is given by + + .. math:: + + u(x, t) = \sin(x - ct). .. seealso:: diff --git a/pina/_src/problem/zoo/allen_cahn_problem.py b/pina/_src/problem/zoo/allen_cahn_problem.py index 5d80d8265..6a7126e68 100644 --- a/pina/_src/problem/zoo/allen_cahn_problem.py +++ b/pina/_src/problem/zoo/allen_cahn_problem.py @@ -26,9 +26,35 @@ def initial_condition(input_, output_): class AllenCahnProblem(TimeDependentProblem, SpatialProblem): r""" - Implementation of the Allen Cahn problem in the spatial interval - :math:`[-1, 1]` and temporal interval :math:`[0, 1]` with periodic - boundary conditions. + Implementation of the one-dimensional Allen-Cahn problem on the space-time + domain :math:`\Omega\times T = [-1, 1] \times [0, 1]`. + + The problem is governed by the Allen-Cahn equation + + .. math:: + + \frac{\partial u}{\partial t} + - + \alpha \frac{\partial^2 u}{\partial x^2} + + + \beta \left(u^3 - u\right) + = + 0, + + where :math:`u = u(x, t)` is the solution field, :math:`\alpha` is the + diffusion coefficient, and :math:`\beta` is the reaction coefficient. + + Periodic boundary conditions are imposed at the spatial boundaries: + + .. math:: + + u(-1, t) = u(1, t), \qquad t \in [0, 1]. + + The initial condition is prescribed as + + .. math:: + + u(x, 0) = x^2 \cos(\pi x), \qquad x \in [-1, 1]. .. seealso:: diff --git a/pina/_src/problem/zoo/diffusion_reaction_problem.py b/pina/_src/problem/zoo/diffusion_reaction_problem.py index 39de11dbc..7a5584ca5 100644 --- a/pina/_src/problem/zoo/diffusion_reaction_problem.py +++ b/pina/_src/problem/zoo/diffusion_reaction_problem.py @@ -35,8 +35,63 @@ def initial_condition(input_, output_): class DiffusionReactionProblem(TimeDependentProblem, SpatialProblem): r""" - Implementation of the diffusion-reaction problem in the spatial interval - :math:`[-\pi, \pi]` and temporal interval :math:`[0, 1]`. + Implementation of the one-dimensional diffusion-reaction problem on the + space-time domain :math:`\Omega\times T = [-\pi, \pi] \times [0, 1]`. + + The problem is governed by the forced diffusion-reaction equation + + .. math:: + + \frac{\partial u}{\partial t} + - + \alpha \frac{\partial^2 u}{\partial x^2} + = + f(x, t), + + where :math:`u = u(x, t)` is the solution field, :math:`\alpha` is the + diffusion coefficient, and :math:`f(x, t)` is a forcing term. + + Homogeneous Dirichlet boundary conditions are imposed at the spatial + boundaries: + + .. math:: + + u(-\pi, t) = u(\pi, t) = 0, \qquad t \in [0, 1]. + + The initial condition is prescribed as + + .. math:: + + u(x, 0) + = + \sin(x) + + + \frac{1}{2}\sin(2x) + + + \frac{1}{3}\sin(3x) + + + \frac{1}{4}\sin(4x) + + + \frac{1}{8}\sin(8x). + + The analytical solution is given by + + .. math:: + + u(x, t) + = + e^{-t} + \left( + \sin(x) + + + \frac{1}{2}\sin(2x) + + + \frac{1}{3}\sin(3x) + + + \frac{1}{4}\sin(4x) + + + \frac{1}{8}\sin(8x) + \right). .. seealso:: diff --git a/pina/_src/problem/zoo/helmholtz_problem.py b/pina/_src/problem/zoo/helmholtz_problem.py index 601e40b3a..9b11519aa 100644 --- a/pina/_src/problem/zoo/helmholtz_problem.py +++ b/pina/_src/problem/zoo/helmholtz_problem.py @@ -11,8 +11,45 @@ class HelmholtzProblem(SpatialProblem): r""" - Implementation of the Helmholtz problem in the square domain - :math:`[-1, 1] \times [-1, 1]`. + Implementation of the two-dimensional Helmholtz problem on the square domain + :math:`\Omega = [-1, 1] \times [-1, 1]`. + + The problem is governed by the forced Helmholtz equation + + .. math:: + + \Delta u + k u = f(x, y), + + where :math:`u = u(x, y)` is the solution field, :math:`k` is the squared + wavenumber, and :math:`f(x, y)` is a forcing term. + + Homogeneous Dirichlet boundary conditions are imposed on the boundary of + the domain: + + .. math:: + + u(x, y) = 0, \qquad (x, y) \in \partial \Omega. + + The analytical solution is given by + + .. math:: + + u(x, y) + = + \sin(\alpha_x \pi x) + \sin(\alpha_y \pi y), + + with forcing term + + .. math:: + + f(x, y) + = + \left[ + k - (\alpha_x^2 + \alpha_y^2)\pi^2 + \right] + \sin(\alpha_x \pi x) + \sin(\alpha_y \pi y). .. seealso:: diff --git a/pina/_src/problem/zoo/inverse_poisson_problem.py b/pina/_src/problem/zoo/inverse_poisson_problem.py index c16735408..8048944fe 100644 --- a/pina/_src/problem/zoo/inverse_poisson_problem.py +++ b/pina/_src/problem/zoo/inverse_poisson_problem.py @@ -74,9 +74,33 @@ def laplace_equation(input_, output_, params_): class InversePoisson2DSquareProblem(SpatialProblem, InverseProblem): r""" - Implementation of the inverse 2-dimensional Poisson problem in the square - domain :math:`[0, 1] \times [0, 1]`, with unknown parameter domain - :math:`[-1, 1] \times [-1, 1]`. + Implementation of the inverse two-dimensional Poisson problem on the square + domain :math:`\Omega = [-2, 2] \times [-2, 2]`, with unknown parameter + domain :math:`\Theta = [-1, 1] \times [-1, 1]`. + + The problem is governed by the parameterized Poisson equation + + .. math:: + + \Delta u + = + \exp\left( + -2(x - \mu_1)^2 + -2(y - \mu_2)^2 + \right), + + where :math:`u = u(x, y)` is the solution field and :math:`\mu_1, \mu_2` are + unknown parameters controlling the forcing term. + + Homogeneous Dirichlet boundary conditions are imposed on the boundary of the + domain: + + .. math:: + + u(x, y) = 0, \qquad (x, y) \in \partial \Omega. + + The inverse problem aims to infer the unknown parameters :math:`\mu_1` and + :math:`\mu_2` from solution data. The `"data"` condition is added only if the required files are downloaded successfully. diff --git a/pina/_src/problem/zoo/poisson_problem.py b/pina/_src/problem/zoo/poisson_problem.py index 50b80ad2d..34d86c6fb 100644 --- a/pina/_src/problem/zoo/poisson_problem.py +++ b/pina/_src/problem/zoo/poisson_problem.py @@ -26,8 +26,40 @@ def forcing_term(input_): class Poisson2DSquareProblem(SpatialProblem): r""" - Implementation of the 2-dimensional Poisson problem in the square domain - :math:`[0, 1] \times [0, 1]`. + Implementation of the two-dimensional Poisson problem on the square domain + :math:`\Omega = [0, 1] \times [0, 1]`. + + The problem is governed by the Poisson equation + + .. math:: + + \Delta u = f(x, y), + + where :math:`u = u(x, y)` is the solution field and :math:`f(x, y)` is the + forcing term. + + Homogeneous Dirichlet boundary conditions are imposed on the boundary of the + domain: + + .. math:: + + u(x, y) = 0, \qquad (x, y) \in \partial \Omega. + + The forcing term is given by + + .. math:: + + f(x, y) + = + 2\pi^2 \sin(\pi x)\sin(\pi y). + + The analytical solution is given by + + .. math:: + + u(x, y) + = + -\sin(\pi x)\sin(\pi y). :Example: