scimba_torch.physical_models.temporal_pde.advection_diffusion_equation¶
Advection-reaction-diffusion equation.
Functions
|
Return a tensor of ones with shape (batch_size, 1). |
|
Return a tensor of zeros with shape (batch_size, spatial_dim, spatial_dim). |
|
Return a tensor of zeros with shape (batch_size, 1). |
|
Return a tensor of ones with shape (batch_size, spatial_dim). |
Classes
|
Class implementing the reaction, advection and diffusion coefficients. |
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:
t (
LabelTensor) – Temporal coordinate tensorx (
LabelTensor) – Spatial coordinate tensormu (
LabelTensor) – Parameter tensor
- 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:
x (
LabelTensor) – Spatial coordinate tensormu (
LabelTensor) – Parameter tensor
- 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:
t (
LabelTensor) – Temporal coordinate tensorx (
LabelTensor) – Spatial coordinate tensormu (
LabelTensor) – Parameter tensor
- 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:
t (
LabelTensor) – Temporal coordinate tensorx (
LabelTensor) – Spatial coordinate tensormu (
LabelTensor) – Parameter tensor
- 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:
FirstOrderTemporalPDEClass 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 functiona (
Callable) – Advection term functiond (
Callable) – Diffusion term functionf (
Callable) – Source term functionu0 (
Callable) – Initial condition functionconstant_advection (
bool) – Whether the advection term is constantconstant_diffusion (
bool) – Whether the diffusion term is constantzero_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:
w (
MultiLabelTensor) – State tensort (
LabelTensor) – Temporal coordinates tensorx (
LabelTensor) – Spatial coordinates tensormu (
LabelTensor) – Parameter tensor
- Return type:
Tensor- Returns:
The source term
- space_operator(w, t, x, mu)[source]¶
Compute the differential operator of the PDE, in space.
- Parameters:
w (
MultiLabelTensor) – State tensort (
LabelTensor) – Temporal coordinates tensorx (
LabelTensor) – Spatial coordinates tensormu (
LabelTensor) – Parameter tensor
- Return type:
Tensor- Returns:
The result of applying the operator to the state
- initial_condition(x, mu)[source]¶
Compute the initial condition.
- Parameters:
x (
LabelTensor) – Spatial coordinate tensormu (
LabelTensor) – Parameter tensor
- 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:
AdvectionReactionDiffusionadvection-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 problemr (
Callable) – Reaction term functiona (
Callable) – Advection term functiond (
Callable) – Diffusion term functionf (
Callable) – Source term functiong (
Callable) – Dirichlet boundary condition functionu0 (
Callable) – Initial condition functionconstant_advection (
bool) – Whether the advection term is constantconstant_diffusion (
bool) – Whether the diffusion term is constantzero_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:
w (
MultiLabelTensor) – State tensort (
LabelTensor) – Temporal coordinates tensorx (
LabelTensor) – Boundary coordinates tensorn (
LabelTensor) – Normal vector tensormu (
LabelTensor) – Parameter tensor
- 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:
w (
MultiLabelTensor) – State tensort (
LabelTensor) – Temporal coordinates tensorx (
LabelTensor) – Boundary coordinates tensorn (
LabelTensor) – Normal vector tensormu (
LabelTensor) – Parameter tensor
- Return type:
Tensor- Returns:
The boundary condition