scimba_torch.physical_models.temporal_pde.advection_diffusion_equation

Advection-reaction-diffusion equation.

Functions

init_ones(x, mu)

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

matrix_zeros(t, x, mu)

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

scalar_zeros(t, x, mu)

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

vector_ones(t, x, mu)

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

Classes

AdvectionReactionDiffusion(space[, r, a, d, ...])

Class implementing the reaction, advection and diffusion coefficients.

AdvectionReactionDiffusionDirichletStrongForm(space)

advection-reaction-diffusion problem with Dirichlet BCs in strong form.

scalar_zeros(t, x, mu)[source]

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

Parameters:
Return type:

Tensor

Returns:

A tensor of zeros with shape (x.shape[0], 1)

init_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 (x.shape[0], 1)

vector_ones(t, x, mu)[source]

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

Parameters:
Return type:

Tensor

Returns:

A tensor of ones with shape (x.shape[0], x.shape[1])

matrix_zeros(t, x, mu)[source]

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

Parameters:
Return type:

Tensor

Returns:

A tensor of zeros with shape (x.shape[0], x.shape[1], x.shape[1])

class AdvectionReactionDiffusion(space, r=<function scalar_zeros>, a=<function vector_ones>, d=<function matrix_zeros>, f=<function scalar_zeros>, u0=<function init_ones>, constant_advection=False, constant_diffusion=False, zero_diffusion=False, **kwargs)[source]

Bases: FirstOrderTemporalPDE

Class implementing the reaction, advection and diffusion coefficients.

For an advection-reaction-diffusion problem in n space dimensions. In general, the PDE is given by:

\[r(t, x, \mu) u(t, x, \mu) + a(t, x, \mu) \cdot \nabla_x u(t, x, \mu) - \nabla_x \cdot (d(t, x, \mu) \nabla_x u(t, x, \mu)) = f(t, x, \mu)\]

By default, $r = 0$, \(a = \mathbb{1}_{\mathbb{R}^n}\), \(d = \mathbb{0}_{\mathcal{M}_n(\mathbb{R})}\), $f = 0$, and $u0 = 1$. The user can specify these functions as needed.

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

  • r (Callable) – Reaction term function

  • a (Callable) – Advection term function

  • d (Callable) – Diffusion term function

  • f (Callable) – Source term function

  • u0 (Callable) – Initial condition function

  • 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, t, x, mu)[source]

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

Parameters:
Return type:

Tensor

Returns:

The source term

space_operator(w, t, x, mu)[source]

Compute the differential operator of the PDE, in space.

Parameters:
Return type:

Tensor

Returns:

The result of applying the operator to the state

initial_condition(x, mu)[source]

Compute the initial condition.

Parameters:
Return type:

Tensor

Returns:

Initial condition tensor

class AdvectionReactionDiffusionDirichletStrongForm(space, r=<function scalar_zeros>, a=<function vector_ones>, d=<function matrix_zeros>, f=<function scalar_zeros>, g=<function scalar_zeros>, u0=<function init_ones>, constant_advection=False, constant_diffusion=False, zero_diffusion=False, **kwargs)[source]

Bases: AdvectionReactionDiffusion

advection-reaction-diffusion problem with Dirichlet BCs in strong form.

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

By default, $r = 0$, \(a = \mathbb{1}_{\mathbb{R}^n}\), \(d = \mathbb{0}_{\mathcal{M}_n(\mathbb{R})}\), $f = 0$, and $u0 = 1$. The user can specify these functions as needed.

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

  • r (Callable) – Reaction term function

  • a (Callable) – Advection term function

  • d (Callable) – Diffusion term function

  • f (Callable) – Source term function

  • g (Callable) – Dirichlet boundary condition function

  • u0 (Callable) – Initial condition function

  • 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

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

Compute the operator for the boundary conditions.

Parameters:
Return type:

Tensor

Returns:

The boundary operator applied to the state

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

Compute the RHS for the boundary conditions.

Parameters:
Return type:

Tensor

Returns:

The boundary condition