scimba_torch.numerical_solvers.pinn_preconditioners.energy_ng

Preconditioner for pinns.

Classes

EnergyNaturalGradientPreconditioner(space, ...)

Energy-based natural gradient preconditioner.

class EnergyNaturalGradientPreconditioner(space, pde, **kwargs)[source]

Bases: MatrixPreconditionerPinn

Energy-based natural gradient preconditioner.

Parameters:
Keyword Arguments:
  • matrix_regularization (float) – Regularization parameter for the preconditioning matrix (default: 1e-6).

  • adaptive_matrix_regularization (bool, default=False)

  • training (If True, adaptively adjusts the regularization parameter during)

  • Levenberg-Marquardt). ((à la)

  • parameter (If False, uses the fixed regularization)

  • matrix_regularization. (specified by)

  • adaptive_matrix_regularization_increase (float, default=10.0)

  • search (Factor by which to decrease the regularization parameter if the line)

  • size. (quickly succeeds in finding a suitable step)

  • adaptive_matrix_regularization_decrease (float, default=0.5)

  • search

  • size.

  • adaptive_matrix_regularization_min (float, default=1e-12)

  • adjustment. (Minimum value for the regularization parameter when using adaptive)

  • use_lstsq (bool) – Whether to use least squares solver for

  • (default (computing the preconditioner) – True).

  • inversion. (If False, uses direct matrix)

compute_preconditioning_matrix(labels, *args, **kwargs)[source]

Compute the preconditioning matrix using the main operator.

Parameters:
  • labels (Tensor) – The labels tensor.

  • *args (Tensor) – Additional arguments.

  • **kwargs – Additional keyword arguments.

Return type:

Tensor

Returns:

The preconditioning matrix.

compute_preconditioning_matrix_bc(labels, *args, **kwargs)[source]

Compute the boundary condition preconditioning matrix.

Parameters:
  • labels (Tensor) – The labels tensor.

  • *args (Tensor) – Additional arguments.

  • **kwargs – Additional keyword arguments.

Return type:

Tensor

Returns:

The boundary condition preconditioning matrix.

compute_preconditioning_matrix_ic(labels, *args, **kwargs)[source]

Compute the initial condition preconditioning matrix.

Parameters:
  • labels (Tensor) – The labels tensor.

  • *args (Tensor) – Additional arguments.

  • **kwargs – Additional keyword arguments.

Return type:

Tensor

Returns:

The initial condition preconditioning matrix.

compute_preconditioning_matrix_dl(*args, **kwargs)[source]

Computes the Gram matrix of the network for the given input tensors.

Parameters:
  • *args (Tensor) – Input tensors for computing the Gram matrix.

  • **kwargs – Additional keyword arguments.

Return type:

Tensor

Returns:

The computed Gram matrix.

compute_full_preconditioning_matrix(data, **kwargs)[source]

Compute the full preconditioning matrix.

Include contributions from the main operator, boundary conditions, and initial conditions.

Parameters:
  • data (tuple | dict) – Input data, either as a tuple or a dictionary.

  • **kwargs – Additional keyword arguments.

Return type:

Tensor

Returns:

The full preconditioning matrix.

update_matrix_regularization(n_steps, loss_has_decreased)[source]

Updates the regularization parameter for the preconditioning matrix.

This method adaptively adjusts the regularization parameter during training based on the number of line search steps taken and whether the loss has decreased.

Parameters:
  • n_steps (int) – The number of line search steps taken.

  • loss_has_decreased (bool) – Whether the loss has decreased after the line search.

reset_matrix_regularization()[source]

Resets the regularization parameter to its initial value.