scimba_torch.numerical_solvers.temporal_pde.pinns

Define the TemporalPinns class, which is a subclass of CollocationProjector.

It is designed to solve time-dependent partial differential equations (PDEs) using physics-informed neural networks (PINNs).

Classes

AnagramTemporalPinns(pde[, bc_type, ic_type])

A class extending TemporalPinns with Anagram preconditioning.

NaturalGradientTemporalPinns(pde[, bc_type, ...])

A class extending TemporalPinns with natural gradient preconditioning.

NystromNaturalGradientTemporalPinns(pde[, ...])

A class extending TemporalPinns with sketchy natural gradient preconditioning.

PreconditionedTemporalPinns(**kwargs)

A class extending TemporalPinns with preconditioning.

SketchyNaturalGradientTemporalPinns(pde[, ...])

A class extending TemporalPinns with sketchy natural gradient preconditioning.

TemporalPinns(pde[, bc_type, ic_type])

A class to solve time-dependent PDEs using Physics-Informed Neural Networks.

class TemporalPinns(pde, bc_type='strong', ic_type='strong', **kwargs)[source]

Bases: CollocationProjector

A class to solve time-dependent PDEs using Physics-Informed Neural Networks.

Parameters:
  • pde (TemporalPDE) – The time-dependent PDE to be solved

  • bc_type (str) – The type of boundary condition to be applied (“strong” or “weak”). (default: “strong”)

  • ic_type (str) – The type of initial condition to be applied (“strong” or “weak”). (default: “strong”)

  • **kwargs – Additional keyword arguments for customization.

Raises:

ValueError – when the lengths of in_weights or bc_weights of ic_weights does not match residual_size or bc_residual_size or ic_residual_size

get_dof(flag_scope='all', flag_format='list')[source]

Gets the parameters of the approximation space in use.

Parameters:
  • flag_scope (str) – Scope of the degrees of freedom to retrieve.

  • flag_format (str) – Format of the output, either “list” or “tensor”.

Return type:

Tensor | list

Returns:

Degrees of freedom in the specified format.

evaluate(t, x, mu)[source]

Evaluates the approximation at given points.

Parameters:
  • t (Tensor) – Input tensor for time coordinates.

  • x (Tensor) – Input tensor for spatial coordinates.

  • mu (Tensor) – Input tensor for parameters.

Return type:

MultiLabelTensor

Returns:

The evaluated solution.

sample_all_vars(**kwargs)[source]

Samples collocation points for the PDE, BCs, and initial conditions.

Parameters:

**kwargs (Any) – Additional keyword arguments for sampling.

Return type:

dict[str, tuple[LabelTensor, ...]]

Returns:

Dictionary of sampled tensors.

assembly_post_sampling(txmu, **kwargs)[source]

Assembles the system of equations post-sampling.

Parameters:
  • txmu (dict) – dictionary of sampled tensors.

  • **kwargs – Additional keyword arguments.

Return type:

tuple

Returns:

Tuple containing the assembled operator and right-hand side.

assembly(**kwargs)[source]

Assembles the system of equations for the PDE.

Assembles also weak boundary conditions if needed.

Parameters:

**kwargs (Any) – Additional keyword arguments.

Return type:

tuple

Returns:

Tuple containing the assembled operator and right-hand side.

class PreconditionedTemporalPinns(**kwargs)[source]

Bases: ABC

A class extending TemporalPinns with preconditioning.

Parameters:

**kwargs (Any) – Additional keyword arguments for customization.

Keyword Arguments:
  • default_lr (float) – The default learning rate used when linesearch fails. Default : 1e-2.

  • type_linesearch (str) – The linesearch algorithm: either “armijo” or “logarithmic_grid”. Default: “armijo”

  • data_linesearch (dict) – optional parameters for the linesearch. For logarithmic grid: “m” (nb nodes in the grid), “interval” (min max values of the grid), “log_basis” the logarithmic basis. For armijo: “n_step_max” (the max number of steps), “alpha” and “beta” (the alpha and beta parameters).

class NaturalGradientTemporalPinns(pde, bc_type='strong', ic_type='strong', **kwargs)[source]

Bases: TemporalPinns, PreconditionedTemporalPinns

A class extending TemporalPinns with natural gradient preconditioning.

Parameters:
  • pde (TemporalPDE) – The time-dependent PDE to be solved.

  • bc_type (str) – Type of boundary condition (“strong” or “weak”). Defaults to “strong”.

  • ic_type (str) – Type of initial condition (“strong” or “weak”). Defaults to “strong”.

  • **kwargs – Additional keyword arguments for customization.

Keyword Arguments:

ng_algo (str) – The algorithm for computing the natural gradient preconditioning matrix. Default : “ENG”.

Raises:

ValueError – value for ng_algo keyword argument is not correct.

class AnagramTemporalPinns(pde, bc_type='strong', ic_type='strong', **kwargs)[source]

Bases: TemporalPinns, PreconditionedTemporalPinns

A class extending TemporalPinns with Anagram preconditioning.

Parameters:
  • pde (TemporalPDE) – The time-dependent PDE to be solved.

  • bc_type (str) – Type of boundary condition (“strong” or “weak”). Defaults to “strong”.

  • ic_type (str) – Type of initial condition (“strong” or “weak”). Defaults to “strong”.

  • **kwargs – Additional keyword arguments for customization.

class SketchyNaturalGradientTemporalPinns(pde, bc_type='strong', ic_type='strong', **kwargs)[source]

Bases: TemporalPinns, PreconditionedTemporalPinns

A class extending TemporalPinns with sketchy natural gradient preconditioning.

Parameters:
  • pde (TemporalPDE) – The elliptic PDE to be solved, represented as an instance of StrongFormEllipticPDE or LinearOrder2PDE.

  • bc_type (str) – The type of boundary condition to be applied (“strong” or “weak”). (default: “strong”)

  • ic_type (str) – The type of initial condition to be applied (“strong” or “weak”). (default: “strong”)

  • **kwargs – Additional keyword arguments for customization.

class NystromNaturalGradientTemporalPinns(pde, bc_type='strong', ic_type='strong', **kwargs)[source]

Bases: TemporalPinns, PreconditionedTemporalPinns

A class extending TemporalPinns with sketchy natural gradient preconditioning.

Parameters:
  • pde (TemporalPDE) – The elliptic PDE to be solved, represented as an instance of StrongFormEllipticPDE or LinearOrder2PDE.

  • bc_type (str) – The type of boundary condition to be applied (“strong” or “weak”). (default: “strong”)

  • ic_type (str) – The type of initial condition to be applied (“strong” or “weak”). (default: “strong”)

  • **kwargs – Additional keyword arguments for customization.