Skip to content

Commit 8a65b0b

Browse files
committed
include DFT guide in the documentation
1 parent 000047c commit 8a65b0b

File tree

3 files changed

+161
-63
lines changed

3 files changed

+161
-63
lines changed

docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,11 @@ recipes/index
131131
132132
rustguide/index
133133
rust_api
134+
```
135+
136+
```{toctree}
137+
:caption: Theory
138+
:hidden:
139+
140+
theory
134141
```

docs/theory.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

docs/theory.rst

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
Classical Density Functional Theory
2+
===================================
3+
4+
In this section, the implementation of the core expressions in classical density functional theory is explained.
5+
6+
Euler-Lagrange equation
7+
-----------------------
8+
9+
The fundamental expression in classical density functional theory is the relation between the grand potential :math:`\Omega` and the intrinsic Helmholtz energy :math:`F`.
10+
11+
.. math::
12+
13+
\Omega(T,\mu,[\rho(r)])=F(T,[\rho(r)])-\sum_i\int\rho_i(r)\left(\mu_i-V_i^\mathrm{ext}(r)\right)dr
14+
15+
What makes this expression so appealing is that the intrinsic Helmholtz energy does only depend on the temperature :math:`T` and the density profiles :math:`\rho_i(r)` of the system and not on the external potential :math:`V_i^\mathrm{ext}(r)`.
16+
17+
For a given temperature :math:`T`, chemical potentials :math:`\mu` and external potentials :math:`V^\mathrm{ext}(r)` the grand potential reaches a minimum at equilibrium. Mathematically this condition can be written as
18+
19+
.. math::
20+
21+
\left.\frac{\delta\Omega}{\delta\rho_i(r)}\right|_{T,\mu}=F_{\rho_i}(r)-\mu_i+V_i^{\mathrm{ext}}(r)=0\tag{1}
22+
23+
where :math:`F_{\rho_i}(r)=\left.\frac{\delta F}{\delta\rho_i(r)}\right|_T` is short for the functional derivative of the intrinsic Helmholtz energy. In this context, eq. (1) is commonly referred to as the Euler-Lagrange equation, an implicit nonlinear integral equation which needs to be solved for the density profiles of the system.
24+
25+
For a homogeneous (bulk) system, :math:`V^\mathrm{ext}(r)=0` and we get
26+
27+
.. math::
28+
29+
F_{\rho_i}^\mathrm{b}-\mu_i=0
30+
31+
which can be inserted into (1) to give
32+
33+
.. math::
34+
35+
F_{\rho_i}(r)=F_{\rho_i}^\mathrm{b}-V_i^\mathrm{ext}(r)\tag{2}
36+
37+
Spherical molecules
38+
-------------------
39+
40+
In the simplest case, the molecules under considerations can be described as spherical. Then the Helmholtz energy can be split in to an ideal and a residual part:
41+
42+
.. math::
43+
44+
\beta F=\sum_i\int\rho_i(r)\left(\ln\left(\rho_i(r)\Lambda_i^3\right)-1\right)dr+\beta F^\mathrm{res}
45+
The functional derivatives for an inhomogeneous and a bulk system follow as
46+
47+
.. math::
48+
49+
\beta F_{\rho_i}=\ln\left(\rho_i(r)\Lambda_i^3\right)+\beta F_{\rho_i}^\mathrm{res}
50+
51+
.. math::
52+
53+
\beta F_{\rho_i}^\mathrm{b}=\ln\left(\rho_i^\mathrm{b}\Lambda_i^3\right)+\beta F_{\rho_i}^\mathrm{b,res}
54+
55+
Using these expressions in eq. (2) and solving for the density results in
56+
57+
.. math::
58+
59+
\rho_i(r)=\rho_i^\mathrm{b}e^{\beta\left(F_{\rho_i}^\mathrm{b,res}-F_{\rho_i}^\mathrm{res}(r)-V_i^\mathrm{ext}(r)\right)}
60+
61+
which is the common form of the Euler-Lagrange equation for spherical molecules.
62+
63+
Homosegmented chains
64+
--------------------
65+
66+
For chain molecules that do not resolve individual segments (essentially the PC-SAFT Helmholtz energy functional) a chain contribution is introduced as
67+
68+
.. math::
69+
70+
\beta F^\mathrm{chain}=-\sum_i\int\rho_i(r)\left(m_i-1\right)\ln\left(\frac{y_{ii}\lambda_i(r)}{\rho_i(r)}\right)dr
71+
72+
Here, $m_i$ is the chain length, $y_{ii}$ the cavity correlation function at contact in the reference fluid, and $\lambda_i$ a weighted density.
73+
The presence of $\rho(r)$ in the logarithm poses numerical problems. Therefore, it is convenient to rearrange the expression as
74+
75+
.. math::
76+
77+
\beta F^\mathrm{chain}=\sum_i\int\rho_i(r)\left(m_i-1\right)\left(\ln\left(\rho_i(r)\Lambda_i^3\right)-1\right)dr\underbrace{-\sum_i\int\rho_i(r)\left(m_i-1\right)\left(\ln\left(y_{ii}\lambda_i(r)\Lambda_i^3\right)-1\right)dr}_{\beta\hat{F}^\mathrm{chain}}
78+
79+
Then the total Helmholtz energy
80+
81+
.. math::
82+
83+
\beta F=\sum_i\int\rho_i(r)\left(\ln\left(\rho_i(r)\Lambda_i^3\right)-1\right)dr+\beta F^\mathrm{chain}+\beta F^\mathrm{res}
84+
85+
can be rearranged to
86+
87+
.. math::
88+
89+
\beta F=\sum_i\int\rho_i(r)m_i\left(\ln\left(\rho_i(r)\Lambda_i^3\right)-1\right)dr+\underbrace{\beta\hat{F}^\mathrm{chain}+\beta F^\mathrm{res}}_{\beta\hat{F}^\mathrm{res}}
90+
91+
The functional derivatives are then similar to the spherical case
92+
93+
.. math::
94+
95+
\beta F_{\rho_i}=m_i\ln\left(\rho_i(r)\Lambda_i^3\right)+\beta\hat{F}_{\rho_i}^\mathrm{res}
96+
97+
.. math::
98+
99+
\beta F_{\rho_i}^\mathrm{b}=m_i\ln\left(\rho_i^\mathrm{b}\Lambda_i^3\right)+\beta\hat{F}_{\rho_i}^\mathrm{b,res}
100+
101+
and lead to a slightly modified Euler-Lagrange equation
102+
103+
.. math::
104+
105+
\rho_i(r)=\rho_i^\mathrm{b}e^{\frac{\beta}{m_i}\left(\hat F_{\rho_i}^\mathrm{b,res}-\hat F_{\rho_i}^\mathrm{res}(r)-V_i^\mathrm{ext}(r)\right)}
106+
107+
Heterosegmented chains
108+
----------------------
109+
110+
Thex expressions are more complex for models in which density profiles of individual segments are considered. A derivation is given in the appendix of ***. The resulting Euler-Lagrange equation is given as
111+
112+
.. math::
113+
114+
\rho_\alpha(r)=\Lambda_i^{-3}e^{\beta\left(\mu_i-\hat F_{\rho_\alpha}(r)-V_\alpha^\mathrm{ext}(r)\right)}\prod_{\alpha'}I_{\alpha\alpha'}(r)
115+
116+
with
117+
118+
.. math::
119+
120+
I_{\alpha\alpha'}(r)=\int e^{-\beta\left(F_{\rho_{\alpha'}}(r')+V_{\alpha'}^\mathrm{ext}(r')\right)}\left(\prod_{\alpha''\neq\alpha}I_{\alpha'\alpha''}(r)\right)\omega_\mathrm{chain}^{\alpha\alpha'}(r-r')dr
121+
122+
The index $\alpha$ is used for every segment on component $i$, $\alpha'$ refers to all segments bonded to segment $\alpha$ and $\alpha''$ to all segments bonded to $\alpha'$.
123+
For bulk systems the expressions simplify to
124+
125+
.. math::
126+
127+
\rho_\alpha^\mathrm{b}=\Lambda_i^{-3}e^{\beta\left(\mu_i-\sum_\gamma\hat F_{\rho_\gamma}^\mathrm{b,res}\right)}
128+
129+
which shows that, by construction, the density of every segment on a molecule is identical in a bulk system. The index $\gamma$ refers to all segments on moecule $i$. The expressions can be combined in a similar way as for the molecular DFT:
130+
131+
.. math::
132+
133+
\rho_\alpha(r)=\rho_\alpha^\mathrm{b}e^{\beta\left(\sum_\gamma\hat F_{\rho_\gamma}^\mathrm{b,res}-\hat F_{\rho_\alpha}^\mathrm{res}(r)-V_\alpha^\mathrm{ext}(r)\right)}\prod_{\alpha'}I_{\alpha\alpha'}(r)
134+
135+
At this point it can be numerically useful to redistribute the bulk contributions back into the bond integrals
136+
137+
.. math::
138+
139+
\rho_\alpha(r)=\rho_\alpha^\mathrm{b}e^{\beta\left(\hat F_{\rho_\alpha}^\mathrm{b,res}-\hat F_{\rho_\alpha}^\mathrm{res}(r)-V_\alpha^\mathrm{ext}(r)\right)}\prod_{\alpha'}I_{\alpha\alpha'}(r)
140+
141+
.. math::
142+
143+
I_{\alpha\alpha'}(r)=\int e^{\beta\left(\hat F_{\rho_{\alpha'}}^\mathrm{b,res}-\hat F_{\rho_{\alpha'}}^\mathrm{res}(r')-V_{\alpha'}^\mathrm{ext}(r')\right)}\left(\prod_{\alpha''\neq\alpha}I_{\alpha'\alpha''}(r)\right)\omega_\mathrm{chain}^{\alpha\alpha'}(r-r')dr
144+
145+
Combined expression
146+
-------------------
147+
148+
To avoid having multiple implementations of the central part of the DFT code, the different descriptions of molecules can be combined in a single version of the Euler-Lagrange equation:
149+
150+
.. math::
151+
152+
\rho_\alpha(r)=\rho_\alpha^\mathrm{b}e^{\frac{\beta}{m_\alpha}\left(\hat F_{\rho_\alpha}^\mathrm{b,res}-\hat F_{\rho_\alpha}^\mathrm{res}(r)-V_\alpha^\mathrm{ext}(r)\right)}\prod_{\alpha'}I_{\alpha\alpha'}(r)
153+
154+
If molecules consist of single (possibly non-spherical) segments, the Euler-Lagrange equation simplifies to that of the homosegmented chains shown above. For heterosegmented chains, the correct expression is obtained by setting $m_\alpha=1$.

0 commit comments

Comments
 (0)