Skip to content

PDE Weak Forms

weakforms

Weak form in UFL syntax for the Kolmogorov PDEs.

This module implements the weak forms for the Kolmogorov equations, which describe the PDEs governing stochastic process inference in SPIN. For a domain \(\Omega\subset\mathbb{R}^d\), drift vector \(\mathbf{b}(\mathbf{x})\), and squared diffusion \(\mathbf{\Sigma}(\mathbf{x})\), the Kolmogorov equations are based on the infinitesimal Generator of a process, defined as

\[ \mathcal{L} = \mathbf{b}(\mathbf{x})\cdot\nabla + \frac{1}{2}\mathbf{\Sigma}(\mathbf{x})\colon\nabla\nabla. \]

In SPIN, we consider the Kolmogorov forward, as well as backward equation. The forward equation, better known as Fokker-Planck equation, is defined in weak_form_fokker_planck. It governs the evolution of the law or distribution \(p: \Omega\times\mathbb{R}_+ \to \mathbb{R}_+\) of a process over space and time. On the other hand, the backward equation gives rise to a hierarchy of PDEs that governes the moments of the exit time or first passage time distribution of a process. The first passage time of a process \(\mathbf{X}_t\) is defined as

\[ \tau(\mathbf{x}) = \inf\{t\geq 0: X_t\notin\Omega | \mathbf{X}_0 = \mathbf{x}\}. \]

The respective weak forms are implemented in weak_form_mean_exit_time and weak_form_mean_exit_time_moments.

Functions:

Name Description
weak_form_mean_exit_time

UFL weak form for the mean exit time PDE.

weak_form_mean_exit_time_moments

UFL weak form for the PDE system yielding the first two moments of the exit time.

weak_form_fokker_planck

Weak form for the spatial contribution to the Fokker-Planck equation.

spin.core.weakforms.weak_form_mean_exit_time

weak_form_mean_exit_time(forward_variable: ufl.Argument | dl.Function, adjoint_variable: ufl.Argument | dl.Function, drift: ufl.Coefficient | ufl.tensors.ListTensor, squared_diffusion: ufl.tensors.ListTensor) -> ufl.Form

UFL weak form for the mean exit time PDE.

Given the definitions above, the PDE reads

\[ \begin{gather} \mathcal{L}\tau + 1 = 0, \quad \mathbf{x}\in\Omega, \\ \tau = 0, \quad \mathbf{x}\in\partial\Omega. \end{gather} \]

Forward and adjoint variables need to be defined on scalar function spaces, drift and diffusion are vector and matrix functions, respectively.

Parameters:

Name Type Description Default
forward_variable ufl.Argument | dl.Function

Forward or trial variable

required
adjoint_variable ufl.Argument | dl.Function

Adjoint or test variable

required
drift ufl.Coefficient | ufl.tensors.ListTensor

Drift vector function

required
squared_diffusion ufl.tensors.ListTensor

Diffusion tensor function

required

Returns:

Type Description
ufl.Form

ufl.Form: Resulting UFL form

spin.core.weakforms.weak_form_mean_exit_time_moments

weak_form_mean_exit_time_moments(forward_variable: ufl.Argument | dl.Function, adjoint_variable: ufl.Argument | dl.Function, drift: ufl.Coefficient | ufl.tensors.ListTensor, squared_diffusion: ufl.tensors.ListTensor) -> ufl.Form

UFL weak form for the PDE system yielding the first two exit time distribution moments.

Given the definitions above, the PDEs read

\[ \begin{gather} \mathcal{L}\tau_1 + 1 = 0, \quad \mathbf{x}\in\Omega, \\ \tau_1 = 0, \quad \mathbf{x}\in\partial\Omega, \end{gather} \]

and

\[ \begin{gather} \mathcal{L}\tau_2 + 2\tau_1 = 0, \quad \mathbf{x}\in\Omega, \\ \tau_2 = 0, \quad \mathbf{x}\in\partial\Omega. \end{gather} \]

Forward and adjoint variables need to be defined on vector function spaces for \(\tau = \text{vec}(\tau_1, \tau_2)\), drift and diffusion are a vector and matrix functions, respectively.

Parameters:

Name Type Description Default
forward_variable ufl.Argument | dl.Function

Forward or trial variable

required
adjoint_variable ufl.Argument | dl.Function

Adjoint or test variable

required
drift ufl.Coefficient | ufl.tensors.ListTensor

Drift vector function

required
squared_diffusion ufl.tensors.ListTensor

Diffusion tensor function

required

Returns:

Type Description
ufl.Form

ufl.Form: Resulting UFL form

spin.core.weakforms.weak_form_fokker_planck

weak_form_fokker_planck(forward_variable: ufl.Argument | dl.Function, adjoint_variable: ufl.Argument | dl.Function, drift: ufl.Coefficient | ufl.tensors.ListTensor, squared_diffusion: ufl.tensors.ListTensor) -> ufl.Form

Weak form for the spatial contribution to the Fokker-Planck equation.

Given the definitions above, the weak form defines the spatial contribution \(\mathcal{L}^*p\) of the time-dependent PDE

\[ \frac{\partial p}{\partial t} = \mathcal{L}^*p, \quad p(\mathbf{x},0) = p_0(\mathbf{x}), \]

Parameters:

Name Type Description Default
forward_variable ufl.Argument | dl.Function

Forward or trial variable

required
adjoint_variable ufl.Argument | dl.Function

Adjoint or test variable

required
drift ufl.Coefficient | ufl.tensors.ListTensor

Drift vector function

required
squared_diffusion ufl.tensors.ListTensor

Diffusion tensor function

required

Returns:

Type Description
ufl.Form

ufl.Form: Resulting UFL form