scimba_torch.numerical_solvers.elliptic_pde.deep_ritz¶
Deep Ritz method for solving elliptic PDEs using deep learning.
Classes
|
A deep learning-based solver for elliptic PDEs using the Ritz method. |
|
A Deep Ritz solver for elliptic PDEs using natural gradient descent. |
- class DeepRitzElliptic(pde, bc_type='strong', **kwargs)[source]¶
Bases:
CollocationProjectorA deep learning-based solver for elliptic PDEs using the Ritz method.
The class inherits from AbstractNonlinearProjector and provides methods for assembling the PDE system and computing the metric matrix.
- Parameters:
pde (
RitzFormEllipticPDE|DivAGradUPDE) – The elliptic PDE to be solved, represented as an instance of RitzForm_EllipticPDE.bc_type (
str) – The type of boundary condition to be applied (“strong” or “weak”). (default: “strong”)**kwargs – Additional keyword arguments for losses and optimizers.
- get_dof(flag_scope='all', flag_format='list')[source]¶
Gets the degrees of freedom for the solver, including those from the PDE.
- Parameters:
flag_scope (
str) – Scope flag for getting degrees of freedom. (default: “all”)flag_format (
str) – Format flag for the degrees of freedom (“list” or “tensor”). (default: “list”)
- Returns:
The degrees of freedom tensor or list.
- evaluate(x, mu)[source]¶
Evaluates the solution at given spatial and parameter points.
- Parameters:
x (
Tensor) – Spatial points where the solution is evaluated.mu (
Tensor) – Parameter points where the solution is evaluated.
- Return type:
- Returns:
The evaluated solution as a MultiLabelTensor.
- metric_matrix(**kwargs)[source]¶
Placeholder method for computing the metric matrix.
- Parameters:
**kwargs (
Any) – Additional keyword arguments.- Returns:
The metric matrix.
- Return type:
torch.Tensor
- Raises:
NotImplementedError – This method must be implemented in subclasses.
- sample_all_vars(**kwargs)[source]¶
Samples all necessary variables for assembling the PDE system.
- Parameters:
**kwargs (
Any) –Additional keyword arguments including:
n_collocation: Number of collocation points for the PDE. Defaults to 1000.
n_bc_collocation: Number of collocation points for the boundary conditions. Defaults to 1000.
- Return type:
tuple- Returns:
A tuple containing sampled spatial points, parameter points, and, if applicable, boundary points and normals.
- assembly_post_sampling(xmu, **kwargs)[source]¶
Assembles the PDE system after sampling all necessary variables.
- Parameters:
xmu (
tuple) – A tuple containing sampled spatial points, parameter points, and, if applicable, boundary points and normals.**kwargs – Additional keyword arguments.
- Return type:
tuple- Returns:
A tuple containing the assembled system of equations (Lo, f).
- assembly(**kwargs)[source]¶
Assembles the system of equations for the PDE.
(and weak boundary conditions if needed).
- Parameters:
**kwargs (
Any) –Additional keyword arguments including:
n_collocation (int): Number of collocation points for the PDE. Defaults to 1000.
n_bc_collocation (int): Number of collocation points for the boundary conditions. Defaults to 1000.
- Return type:
tuple- Returns:
A tuple containing the assembled system of equations (Lo, f).
- class NaturalGradientDeepRitzElliptic(pde, bc_type='strong', **kwargs)[source]¶
Bases:
DeepRitzEllipticA Deep Ritz solver for elliptic PDEs using natural gradient descent.
- Parameters:
pde (
Laplacian2DDirichletRitzForm|DivAGradUPDE) – The elliptic PDE to be solved, represented as an instance of RitzForm_EllipticPDE.bc_type (
str) – The type of boundary condition to be applied (“strong” or “weak”). (default: “strong”)**kwargs – Additional keyword arguments for losses, optimizers, and preconditioners.