pde_opt.numerics.equations

PDE equation classes.

class pde_opt.numerics.equations.BaseEquation[source]

Base class for time-dependent PDE equations.

Abstract base class for time-dependent PDE equations of the form

\[\frac{d}{dt} \text{state} = F(\text{state}, t)\]

where state is the state of the system and t is the time.

Subclasses should implement the rhs method, which returns the right hand side of the equation.

abstract rhs(state: State, t: float) State[source]

Right hand side of the equation.

class pde_opt.numerics.equations.AllenCahn2DPeriodic(domain: Domain, kappa: float, mu: Callable | equinox.Module, R: Callable | equinox.Module, derivs: str = 'fd')[source]

Allen-Cahn equation in 2D with periodic boundary conditions.

The Allen-Cahn equation describes phase transitions and interface dynamics. The equation is:

\[\frac{\partial u}{\partial t} = -R(u) \mu\]

where u is the concentration, R(u) is the reaction term, μ is the chemical potential, and κ is a parameter (the gradient energy coefficient). The chemical potential is given by:

\[\mu = \mu_h(u) - \kappa \nabla^2 u\]
domain: Domain

Domain of the equation

kappa: float

Gradient energy coefficient

mu: Callable | equinox.Module

Function for the chemical potential

R: Callable | equinox.Module

Function for the reaction term

derivs: str = 'fd'

Type of derivative computation

rhs(state, t)[source]

Right hand side of the equation.

rhs_fourier(state, t)[source]
rhs_fd(state, t)[source]
__init__(domain: Domain, kappa: float, mu: Callable | equinox.Module, R: Callable | equinox.Module, derivs: str = 'fd') None
class pde_opt.numerics.equations.AllenCahn2DSmoothedBoundary(domain: Domain, kappa: float, f: Callable | equinox.Module, mu: Callable | equinox.Module, R: Callable | equinox.Module, theta: Callable | equinox.Module, derivs: str = 'fd')[source]

Allen-Cahn equation with smoothed boundary method for arbitrary geometries.

This class implements the Allen-Cahn equation using the smoothed boundary method, which allows for complex domain geometries through a smooth level-set function ψ.

The equation is:

\[\frac{\partial u}{\partial t} = -R(u) \mu\]

where the chemical potential includes boundary effects:

\[\mu = \mu_h(u) - \frac{\kappa}{\psi} \nabla \cdot (\psi \nabla u) - \sqrt{\kappa} \frac{|\nabla \psi|}{\psi} \sqrt{2f} \cos(\theta)\]
domain: Domain

Domain of the equation

kappa: float

Gradient energy coefficient

f: Callable | equinox.Module

Function for the free energy density

mu: Callable | equinox.Module

Function for the chemical potential

R: Callable | equinox.Module

Function for the reaction term

theta: Callable | equinox.Module

Function for the contact angle

derivs: str = 'fd'

Type of derivative computation

rhs(state, t)[source]

Right hand side of the equation.

rhs_fd(state, t)[source]
__init__(domain: Domain, kappa: float, f: Callable | equinox.Module, mu: Callable | equinox.Module, R: Callable | equinox.Module, theta: Callable | equinox.Module, derivs: str = 'fd') None
class pde_opt.numerics.equations.CahnHilliard2DPeriodic(domain: Domain, kappa: float, mu: Callable | equinox.Module, D: Callable | equinox.Module, derivs: str = 'fd')[source]

Cahn–Hilliard equation in 2D with periodic boundary conditions.

The Cahn-Hilliard equation describes phase separation and coarsening dynamics. The equation is:

\[\frac{\partial u}{\partial t} = \nabla \cdot (D(u) \nabla \mu)\]

where u is the concentration, D(u) is the mobility, and μ is the chemical potential. The chemical potential is given by:

\[\mu = \mu_h(u) - \kappa \nabla^2 u\]
domain: Domain

Domain of the equation

kappa: float

Gradient energy coefficient

mu: Callable | equinox.Module

Function for the chemical potential

D: Callable | equinox.Module

Function for the mobility

derivs: str = 'fd'

Type of derivative computation

fft = None
ifft = None
fourier_symbol = None
rhs(state, t)[source]

Right hand side of the equation.

rhs_fourier(state, t)[source]
rhs_fd(state, t)[source]
__init__(domain: Domain, kappa: float, mu: Callable | equinox.Module, D: Callable | equinox.Module, derivs: str = 'fd') None
class pde_opt.numerics.equations.CahnHilliard3DPeriodic(domain: Domain, kappa: float, mu: Callable | equinox.Module, D: Callable | equinox.Module, derivs: str = 'fd')[source]

Cahn–Hilliard equation in 3D with periodic boundary conditions.

The Cahn-Hilliard equation describes phase separation and coarsening dynamics. The equation is:

\[\frac{\partial u}{\partial t} = \nabla \cdot (D(u) \nabla \mu)\]

where u is the concentration, D(u) is the mobility, and μ is the chemical potential. The chemical potential is given by:

\[\mu = \mu_h(u) - \kappa \nabla^2 u\]
domain: Domain

Domain of the equation

kappa: float

Gradient energy coefficient

mu: Callable | equinox.Module

Function for the chemical potential

D: Callable | equinox.Module

Function for the mobility

derivs: str = 'fd'

Type of derivative computation

fft = None
ifft = None
fourier_symbol = None
rhs(state, t)[source]

Right hand side of the equation.

rhs_fourier(state, t)[source]
rhs_fd(state, t)[source]
__init__(domain: Domain, kappa: float, mu: Callable | equinox.Module, D: Callable | equinox.Module, derivs: str = 'fd') None
class pde_opt.numerics.equations.CahnHilliard2DSmoothedBoundary(domain: Domain, kappa: float, f: Callable | equinox.Module, mu: Callable | equinox.Module, D: Callable | equinox.Module, theta: Callable | equinox.Module, flux: Callable | equinox.Module, derivs: str = 'fd')[source]

Cahn–Hilliard equation with smoothed boundary method for arbitrary geometries.

This class implements the Cahn-Hilliard equation using the smoothed boundary method, which allows for complex domain geometries through a smooth level-set function ψ.

The equation is:

\[\frac{\partial u}{\partial t} = \frac{1}{\psi} \nabla \cdot (\psi D(u) \nabla \mu) + \frac{|\nabla \psi|}{\psi} J_n\]

where the chemical potential includes boundary effects:

\[\mu = \mu_h(u) - \frac{\kappa}{\psi} \nabla \cdot (\psi \nabla u) - \sqrt{\kappa} \frac{|\nabla \psi|}{\psi} \sqrt{2f} \cos(\theta)\]
__init__(domain: Domain, kappa: float, f: Callable | equinox.Module, mu: Callable | equinox.Module, D: Callable | equinox.Module, theta: Callable | equinox.Module, flux: Callable | equinox.Module, derivs: str = 'fd') None
domain: Domain

Domain of the equation

kappa: float

Gradient energy coefficient

f: Callable | equinox.Module

Function for the free energy density

mu: Callable | equinox.Module

Function for the chemical potential

D: Callable | equinox.Module

Function for the mobility

theta: Callable | equinox.Module

Function for the contact angle

flux: Callable | equinox.Module

Function for the normal flux

derivs: str = 'fd'

Type of derivative computation

rhs(state, t)[source]

Right hand side of the equation.

rhs_fd(state, t)[source]
class pde_opt.numerics.equations.GPE2DTSControl(domain: Domain, k: float, e: float, lights: Callable, trap_factor: float = 1.0)[source]

Gross-Pitaevskii equation in 2D with time-splitting and control.

The Gross-Pitaevskii equation describes the dynamics of Bose-Einstein condensates. The equation is:

\[i\hbar \frac{\partial \psi}{\partial t} = \left[-\frac{\hbar^2}{2m}\nabla^2 + V(\mathbf{r}, t) + g|\psi|^2\right]\psi\]

where ψ is the wave function, V is the external potential, and g is the interaction strength. The external potential includes a harmonic trap and control field:

\[V(\mathbf{r}, t) = \frac{1}{2}m\omega^2\left[(1+\epsilon)x^2 + (1-\epsilon)y^2\right] + V_{control}(\mathbf{r}, t)\]
domain: Domain

Domain of the equation

k: float

Interaction strength parameter

e: float

Trap ellipticity parameter

lights: Callable

Function for the control field

trap_factor: float = 1.0

Scaling factor for the harmonic trap

fft = None
ifft = None
A_term = None
dx = None
A_terms(state, t)[source]

A terms of the equation.

B_terms(state, t)[source]

B terms of the equation.

rhs(state, t)[source]

Right hand side of the equation.

__init__(domain: Domain, k: float, e: float, lights: Callable, trap_factor: float = 1.0) None
class pde_opt.numerics.equations.GPE2DTSRot(domain: Domain, k: float, e: float, omega: float)[source]

Gross-Pitaevskii equation in 2D with time-splitting and rotation.

The Gross-Pitaevskii equation describes the dynamics of Bose-Einstein condensates. The equation is:

\[i\hbar \frac{\partial \psi}{\partial t} = \left[-\frac{\hbar^2}{2m}\nabla^2 + V(\mathbf{r}) + g|\psi|^2 - \Omega L_z\right]\psi\]

where ψ is the wave function, V is the external potential, g is the interaction strength, and Ω is the rotation frequency with L_z being the angular momentum operator. The external potential includes a harmonic trap:

\[V(\mathbf{r}) = \frac{1}{2}m\omega^2\left[(1+\epsilon)x^2 + (1-\epsilon)y^2\right]\]
domain: Domain

Domain of the equation

k: float

Interaction strength parameter

e: float

Trap ellipticity parameter

omega: float

Rotation frequency

A_terms(state_hat, t)[source]

A terms of the equation.

B_terms(state, t)[source]

B terms of the equation.

__init__(domain: Domain, k: float, e: float, omega: float) None

Modules

allen_cahn

This module contains various Allen-Cahn equation classes.

base_eq

This module contains the base equation classes for the PDEs.

cahn_hilliard

This module contains various Cahn-Hilliard equation classes.

gross_pitaevskii

This module contains various Gross-Pitaevskii equation classes.