scimba_torch.physical_models.elliptic_pde.advection_diffusion

Advection-reaction-diffusion problems in 1D and 2D.

Use Dirichlet boundary conditions in strong form.

Functions

matrix_zero(x, mu)

Return a tensor of zeros with shape (batch_size, 2, 2).

scalar_ones(x, mu)

Return a tensor of ones with shape (batch_size, 1).

scalar_zero(x, mu)

Return a tensor of zeros with shape (batch_size, 1).

vector_ones(x, mu)

Return a tensor of ones with shape (batch_size, 2).

Classes

AdvectionReactionDiffusion1DDirichletStrongForm(space)

1D advection-reaction-diffusion problem with strong Dirichlet BCs.

AdvectionReactionDiffusion2DDirichletStrongForm(space)

2D advection-reaction-diffusion problem with strong Dirichlet BCs.

scalar_zero(x, mu)[source]

Return a tensor of zeros with shape (batch_size, 1).

Parameters:
Return type:

Tensor

Returns:

A tensor of zeros with shape (batch_size, 1).

scalar_ones(x, mu)[source]

Return a tensor of ones with shape (batch_size, 1).

Parameters:
Return type:

Tensor

Returns:

A tensor of ones with shape (batch_size, 1).

vector_ones(x, mu)[source]

Return a tensor of ones with shape (batch_size, 2).

Parameters:
Return type:

Tensor

Returns:

A tensor of ones with shape (batch_size, 2).

matrix_zero(x, mu)[source]

Return a tensor of zeros with shape (batch_size, 2, 2).

Parameters:
Return type:

Tensor

Returns:

A tensor of zeros with shape (batch_size, 2, 2).

class AdvectionReactionDiffusion1DDirichletStrongForm(space, r=<function scalar_zero>, a=<function scalar_ones>, d=<function scalar_zero>, f=<function scalar_zero>, g=<function scalar_zero>, constant_advection=True, constant_diffusion=True, zero_diffusion=True, **kwargs)[source]

Bases: StrongFormEllipticPDE

1D advection-reaction-diffusion problem with strong Dirichlet BCs.

\[\begin{split}r(x, \mu) u(x, \mu) + a(x, \mu) \partial_x u(x, \mu) - \partial_x (d(x, \mu) \partial_x u(x, \mu)) & = f(x, \mu) \text{ in } \Omega, \\ u(x, \mu) & = g(x, \mu) \text{ on } \partial \Omega.\end{split}\]

By default, $r = 0$, $a = 1$, $d = 0$, $f = 0$, and $g = 0$. The user can specify these functions as needed.

Parameters:
  • space (AbstractApproxSpace) – The approximation space for the problem.

  • r (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the reaction term r(x, mu).

  • a (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the advection term a(x, mu).

  • d (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the advection term d(x, mu).

  • f (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the source term f(x, mu).

  • g (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the Dirichlet boundary condition g(x, mu).

  • constant_advection (bool) – Whether the advection term is constant.

  • constant_diffusion (bool) – Whether the diffusion term is constant.

  • zero_diffusion (bool) – Whether the diffusion term is zero.

  • **kwargs – Additional keyword arguments.

rhs(w, x, mu)[source]

Compute the right-hand side (RHS) of the PDE.

Parameters:
Return type:

Tensor

Returns:

The source term f(x, mu).

operator(w, x, mu)[source]

Compute the differential operator of the PDE.

Parameters:
Return type:

Tensor

Returns:

The result of applying the operator to the state.

bc_rhs(w, x, n, mu)[source]

Compute the RHS for the boundary conditions.

Parameters:
Return type:

Tensor

Returns:

The boundary condition g(x, mu).

bc_operator(w, x, n, mu)[source]

Compute the operator for the boundary conditions.

Parameters:
Return type:

Tensor

Returns:

The boundary operator applied to the state.

class AdvectionReactionDiffusion2DDirichletStrongForm(space, r=<function scalar_zero>, a=<function vector_ones>, d=<function matrix_zero>, f=<function scalar_zero>, g=<function scalar_zero>, constant_advection=True, constant_diffusion=True, zero_diffusion=True, **kwargs)[source]

Bases: StrongFormEllipticPDE

2D advection-reaction-diffusion problem with strong Dirichlet BCs.

\[\begin{split}r(x, \mu) u(x, \mu) + a(x, \mu) \cdot \nabla_x u(x, \mu) - \nabla_x \cdot (d(x, \mu) \nabla_x u(x, \mu)) & = f(x, \mu) \text{ in } \Omega, \\ u(x, \mu) & = g(x, \mu) \text{ on } \partial \Omega.\end{split}\]

By default, $r = 0$, $a = (1, 1)$, $d = [(0, 0), (0, 0)]$, $f = 0$, and $g = 0$. The user can specify these functions as needed.

Parameters:
  • space (AbstractApproxSpace) – The approximation space for the problem.

  • r (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the reaction term r(x, mu).

  • a (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the advection term a(x, mu).

  • d (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the advection term d(x, mu).

  • f (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the source term f(x, mu).

  • g (Callable[[LabelTensor, LabelTensor], Tensor]) – Callable representing the Dirichlet boundary condition g(x, mu).

  • constant_advection (bool) – Whether the advection term is constant.

  • constant_diffusion (bool) – Whether the diffusion term is constant.

  • zero_diffusion (bool) – Whether the diffusion term is zero.

  • **kwargs – Additional keyword arguments.

rhs(w, x, mu)[source]

Compute the right-hand side (RHS) of the PDE.

Parameters:
Return type:

Tensor

Returns:

The source term f(x, mu).

operator(w, x, mu)[source]

Compute the differential operator of the PDE.

Parameters:
Return type:

Tensor

Returns:

The result of applying the operator to the state.

bc_rhs(w, x, n, mu)[source]

Compute the RHS for the boundary conditions.

Parameters:
Return type:

Tensor

Returns:

The boundary condition g(x, mu).

bc_operator(w, x, n, mu)[source]

Compute the operator for the boundary conditions.

Parameters:
Return type:

Tensor

Returns:

The boundary operator applied to the state.