Public interface

Minimization

ClassicalDFT.solveFunction
solve(functional::AbstractFunctional, Vext::Union{Array,Function}, T::Number=1; <keyword arguments>)

Solve the DFT Euler-Lagrange equation

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

and return the density profile $\rho(\vec{r})$. The direct correlation function $c_1(\vec{r}; [\rho])$ is evaluated via the given functional, the external potential $V_\mathrm{ext}(\vec{r})$ is expected in Vext and $\beta = 1 / (k_B T)$ follows from the given temperature T. The prefactor $A$ is determined either from the chemical potential $\mu$ according to $A = \exp(\beta \mu)$ or from the target mean density $\rho_b$, in which case A sets the normalization of the density profile. Specify either μ or ρb as a keyword argument.

Note

Vext can be given as a discretized array or as a function. In both cases, compatibility with the geometry of the functional must be ensured.

Arguments

  • μ::Union{Number, Nothing}: Chemical potential
  • ρb::Union{Number, Nothing}: Mean density
  • solver::AbstractSolver=PicardIterationSolver(): Solve method
  • tol::Number=1e-5: Value of $\Vert \Delta \rho \Vert_\infty$ for which convergence is declared. $\Delta \rho$ is determined from the difference of right and left hand side of the DFT Euler-Lagrange equation.
  • maxiter::Integer=1000: Maximum number of iterations
  • callbacks::Vector{<:AbstractCallback}=AbstractCallback[]: Callbacks that are invoked in each iteration

See also Geometries, Functionals, Callbacks.

source
ClassicalDFT.PicardIterationSolverType
PicardIterationSolver(; α=0.05, adaptive=false, αmin=0.001)

Construct a solver that uses Picard iteration with mixing parameter α.

One iteration step has the form

$\rho \leftarrow (1 - \alpha) \rho + \alpha \rho_\mathrm{EL}$

where $\rho_\mathrm{EL}$ is determined by evaluating the right hand side of the DFT Euler-Lagrange equation with $\rho$.

If adaptive is true, the solver will reduce α based on the value of $\Vert \rho_\mathrm{EL} - \rho \Vert_\infty$ (but no lower than αmin) to ensure stability, especially during the first few iterations.

source

Geometries

ClassicalDFT.PlanarGeometryType
PlanarGeometry(L::Number, dz::Rational; boundary=:periodic, fftconv=true)

Construct a planar coordinate system with length L and discretization dz with boundary conditions boundary (one of :periodic, :walls).

fftconv determines if convolutions are evaluated in Fourier space. All quantities are assumed to depend only on the direction $z$ and to be integrated out over the lateral directions $x$ and $y$.

source
ClassicalDFT.SphericalGeometryType
SphericalGeometry(R::Number, dr::Rational, Rsolute::Number=1; boundary=:walls, fftconv=true)

Construct a spherical coordinate system with maximum radius R+Rsolute and discretization dr around a solute of radius Rsolute with boundary conditions boundary (one of :walls).

fftconv determines if convolutions are evaluated in Fourier space. All quantities are assumed to depend only on the radial distance $r$ and to be integrated out over the solid angle $\Omega$.

source

Functionals

Note

Constructors of functionals might add padding to the coordinates of the provided geometry. Therefore, use coordinates(geom) only after the construction of a functional with the geometry geom.

ClassicalDFT.CompositeFunctionalType
CompositeFunctional(geom::AbstractGeometry, functionals...)

Construct a functional that is a sum of other functionals in the geometry geom.

A popular example is the hard-sphere + mean-field functional $F_\mathrm{exc}[\rho] = F_\mathrm{exc}^\mathrm{HS}[\rho] + F_\mathrm{exc}^\mathrm{MF}[\rho]$.

The elements of functionals can be Type{<:AbstractFunctional}; in this case the respective functional is constructed with its default keyword arguments. Custom keyword arguments can be passed by providing a NamedTuple that contains the Type of the functional as the first element and suitable keyword arguments in the remaining entries.

Examples

# Pass only the type of the functional to use default keyword arguments
CompositeFunctional(geom, RosenfeldFMTFunctional, LennardJonesMeanFieldFunctional)

# Pass a NamedTuple to provide custom keyword arguments
CompositeFunctional(geom, RosenfeldFMTFunctional, (LennardJonesMeanFieldFunctional, rcut=3.0))
source

Fundamental measure theory

Mean-field

ClassicalDFT.LennardJonesMeanFieldFunctionalType
LennardJonesMeanFieldFunctional(geom::AbstractGeometry; rcut::Number=2.5)

Construct the Lennard-Jones mean-field functional in the geometry geom with a pair potential cutoff distance of rcut.

The Lennard-Jones pair potential has the form $\phi(r) = 4 (r^{-12} - r^{-6})$ for an inter-particle distance $r = \vert\vec{r} - \vec{r}'\vert < r_\mathrm{cut}$ and is $0$ for $r \geq r_\mathrm{cut}$.

source

Callbacks

ClassicalDFT.PlotCallbackType
PlotCallback(layout::Plotly.Layout=Plotly.Layout(); every::Int=1)

Show an interactive plot of the density profile.

every sets the interval in terms of the iteration count to update the plot.

source
ClassicalDFT.PrintInfoCallbackType
PrintInfoCallback(quantities::Vector{Symbol}=[:iteration, :Δρ]; every::Int=10)

Print various quantities during minimization.

Possible symbols are :iteration, :Δρ, . every sets the interval in terms of the iteration count to print output.

source