Guide

Introduction to classical DFT

Classical density functional theory[1][2] is based on the functional minimization of the grand potential $\Omega[\rho]$ with respect to the density profile $\rho(\vec{r})$,

\[\frac{\delta \Omega[\rho]}{\delta \rho(\vec{r})} = 0.\]

Performing the functional derivative after writing out external, ideal and excess contributions of $\Omega[\rho]$ yields the DFT Euler-Lagrange equation

\[\rho(\vec{r}) = \exp\left(- \beta (V_\mathrm{ext}(\vec{r}) - \mu) + c_1(\vec{r}; [\rho]) \right),\]

where $V_\mathrm{ext}(\vec{r})$ denotes an external potential, $\mu$ is the chemical potential and $\beta = 1 / (k_B T)$ is the inverse of the temperature $T$ with Boltzmann's constant $k_B$.

The nontrivial effects of internal interactions are captured by the direct correlation function

\[c_1(\vec{r}; [\rho]) = - \beta \frac{\delta F_\mathrm{exc}[\rho]}{\delta \rho(\vec{r})},\]

which follows from the excess Helmholtz free energy functional $F_\mathrm{exc}[\rho]$ upon functional differentiation. Therefore, $c_1(\vec{r}; [\rho])$ is itself a functional of the density profile.

For practically all types of interacting particles, approximations of $c_1(\vec{r}; [\rho])$ (or equivalently of the generating functional $F_\mathrm{exc}[\rho]$) must be found in order to solve the DFT Euler-Lagrange equation. A well-studied system is the hard-sphere fluid, for which highly accurate approximations of $F_\mathrm{exc}[\rho]$ can be constructed.[3]

Basic usage

The main utility of ClassicalDFT is the solve function, which attempts to find the density profile that solves the DFT Euler-Lagrange equation.

For this, one has to specify the geometry of the problem, the functional which describes internal interactions as well as further relevant parameters of the system (external potential, chemical potential, inverse temperature).

In the following example, we select PlanarGeometry, where all quantities depend only on the $z$ coordinate, and choose implicit hard walls at the borders with boundary=:walls. To describe a confined hard sphere fluid, a RosenfeldFMTFunctional is constructed in this geometry, Vext within the box is set to zero, and typical values for temperature T and the chemical potential μ are chosen.

L, dz = 10, 1//100
geom = PlanarGeometry(L, dz; boundary=:walls)
functional = RosenfeldFMTFunctional(geom)
Vext(z) = 0
T, μ = 1.0, 3.0

We can pass this setup to the solve function, which performs the functional minimization and returns the resulting density profile ρ.

ρ = solve(functional, Vext, T; μ)
Note

The numerical details of the minimization can be controlled with further keyword arguments of solve.

To show further information during the minimization process, one can supply callbacks to solve. For example, the following prints the iteration count and residue $\Vert\Delta\rho\Vert_\infty$ and an interactive plot of the density profile is shown:

callbacks = [PrintInfoCallback(), PlotCallback()]
ρ = solve(functional, Vext, μ, β; callbacks)