<commit_before>ANPHON: Theoretical background
==============================

.. |umulaut_u|   unicode:: U+00FC
.. |umulaut_o|   unicode:: U+00F6

Dynamical matrix
----------------

The dynamical matrix is given by

.. math::
    :label: dymat 

    D_{\mu\nu}(\kappa\kappa^{\prime};\boldsymbol{q}) = \frac{1}{\sqrt{M_{\kappa}M_{\kappa^{\prime}}}}
    \sum_{\ell^{\prime}}\Phi_{\mu\nu}(\ell\kappa;\ell^{\prime}\kappa^{\prime})\exp{\left[i\boldsymbol{q}\cdot(\boldsymbol{r}(\ell^{\prime})-\boldsymbol{r}(\ell))\right]},

where :math:`M_{\kappa}` is the atomic mass of atom :math:`\kappa`.
By diagonalizing the dynamical matrix, one can obtain :math:`m` (:math:`=3N_{\kappa}`) eigenvalues :math:`\omega_{\boldsymbol{q}j}^{2}`  (:math:`j = 1, 2, \dots, m`) and corresponding eigenvectors :math:`\boldsymbol{e}_{\boldsymbol{q}j}` for each :math:`\boldsymbol{q}` point.
Here, :math:`\boldsymbol{e}_{\boldsymbol{q}j}` is a column vector consisting of atomic polarization :math:`e_{\mu}(\kappa;\boldsymbol{q}j)`.
Let :math:`D(\boldsymbol{q})` denote a matrix form of equation :eq:`dymat`, the eigenvalues may be written as

.. math::
    :label: omega2

    \omega_{\boldsymbol{q}j}^{2} = (\boldsymbol{e}_{\boldsymbol{q}j}^{*})^{\mathrm{T}} D(\boldsymbol{q})\boldsymbol{e}_{\boldsymbol{q}j}.

Next, we introduce :math:`m\times m` matrices :math:`\Lambda` and :math:`W` which are defined as 
:math:`\Lambda(\boldsymbol{q}) = \mathrm{diag} (\omega_{\boldsymbol{q}1}^{2},\dots,\omega_{\boldsymbol{q}m}^{2})` and 
:math:`W(\boldsymbol{q}) = (\boldsymbol{e}_{\boldsymbol{q}1},\dots,\boldsymbol{e}_{\boldsymbol{q}m})`, respectively. 
Then, equation :eq:`omega2` can be denoted as 

.. math::
    
    \Lambda(\boldsymbol{q}) = W^{\dagger}(\boldsymbol{q})D(\boldsymbol{q})W(\boldsymbol{q}).


When one needs to capture the LO\-TO splitting near the zone-center by the supercell approach,
it is necessary to add the non\-analytic part of the dynamical matrix defined by

.. math::

    D_{\mu\nu}^{\mathrm{NA}}(\kappa\kappa^{\prime};\boldsymbol{q}) = \frac{1}{\sqrt{M_{\kappa}M_{\kappa^{\prime}}}}
    \frac{4\pi e^{2}}{\Omega} \frac{(Z_{\kappa}^{*}\boldsymbol{q})_{\mu}(Z_{\kappa^{\prime}}^{*}\boldsymbol{q})_{\nu}}{\boldsymbol{q}\cdot\epsilon^{\infty}\boldsymbol{q}},

where :math:`\Omega` is the volume of the primitive cell, :math:`Z_{\kappa}^{*}` is the Born effective charge tensor of atom :math:`\kappa`, 
and :math:`\epsilon^{\infty}` is the dielectric constant tensor, respectively.
In program *anphon*, either the Parlinski's way [1]_ or the mixed-space approach [2]_ can be used. 
In the Parlinski's approach (``NONANALYTIC = 1``), the total dynamical matrix is given by

.. math::

    D(\boldsymbol{q}) + D^{\textrm{NA}}(\boldsymbol{q})\exp{(-q^{2}/\sigma^{2})},

where :math:`\sigma` is a damping factor. 
:math:`\sigma` must be chosen carefully so that the non-analytic contribution
becomes negligible at Brillouin zone boundaries.
In the mixed-space approach (``NONANALYTIC = 2``), the total dynamical matrix is given by

.. math::

    D(\boldsymbol{q}) + D^{\textrm{NA}}(\boldsymbol{q})\frac{1}{N}\sum_{\ell^{\prime}}\exp{\left[i\boldsymbol{q}\cdot(\boldsymbol{r}(\ell^{\prime})-\boldsymbol{r}(\ell))\right]}.

The second term vanishes at commensurate :math:`\boldsymbol{q}` points other than :math:`\Gamma` point (:math:`\boldsymbol{q} = 0`).

To include the non-analytic term, one needs to set ``NONANALYTIC > 0`` and give appropriate ``BORNINFO`` and ``NA_SIGMA`` tags.


Group velocity
--------------

The group velocity of phonon mode :math:`\boldsymbol{q}j` is given by 

.. math::
    
    \boldsymbol{v}_{\boldsymbol{q}j} = \frac{\partial \omega_{\boldsymbol{q}j}}{\partial \boldsymbol{q}}.

To evaluate the group velocity numerically, we employ a central difference where
:math:`\boldsymbol{v}` may approximately be given by

.. math::

    \boldsymbol{v}_{\boldsymbol{q}j} \approx \frac{\omega_{\boldsymbol{q}+\Delta\boldsymbol{q}j} - \omega_{\boldsymbol{q}-\Delta\boldsymbol{q}j}}{2\Delta\boldsymbol{q}}.

If one needs to save the group velocities, please turn on the ``PRINTVEL``-tag.


Thermodynamics functions
------------------------

The specific heat at constant volume :math:`C_{\mathrm{v}}`, the internal energy :math:`U`, 
the vibrational entropy :math:`S`, and the Helmholtz free energy :math:`F` of individual harmonic oscillator are
given as follows:

.. math::
    :nowrap:
    
    \begin{align*}
     U &= \frac{1}{N_{q}}\sum_{\boldsymbol{q},j} \hbar\omega_{\boldsymbol{q}j} \left[\frac{1}{e^{\hbar\omega_{\boldsymbol{q}j}/kT} - 1} + \frac{1}{2}\right], \\
     C_{\mathrm{v}} &= \frac{k}{N_{q}}\sum_{\boldsymbol{q},j} \left(\frac{\hbar\omega_{\boldsymbol{q}j}}{2kT}\right)^{2} \mathrm{cosech}^{2}\left(\frac{\hbar\omega_{\boldsymbol{q}j}}{2kT}\right),\\
     S &= \frac{k}{N_{q}}\sum_{\boldsymbol{q},j} \left[\frac{\hbar\omega_{\boldsymbol{q}j}}{kT} \frac{1}{e^{\hbar\omega_{\boldsymbol{q}j}/kT} - 1} 
        - \log{\left( 1 - e^{-\hbar\omega_{\boldsymbol{q}j}/kT}\right)}\right], \\
     F &= \frac{1}{N_{q}}\sum_{\boldsymbol{q},j}\left[ \frac{\hbar\omega_{\boldsymbol{q}j}}{2} + kT\log{\left( 1 - e^{-\hbar\omega_{\boldsymbol{q}j}/kT}\right)} \right].
    \end{align*}

Here, :math:`k` is the Boltzmann constant. These quantities are saved in the ``PREFIX``.thermo file.

When the self-consistent phonon mode (``MODE = SCPH``) is selected, the anharmonic free-energy 
defined by the following equation will be calculated and saved in the ``PREFIX``.scph_thermo file:

.. math::
    :nowrap:
    
    \begin{align*}
     F^{\mathrm{SCP}} &= \frac{1}{N_{q}}\sum_{\boldsymbol{q},j}\left[ \frac{\hbar\Omega_{\boldsymbol{q}j}}{2} + kT\log{\left( 1 - e^{-\hbar\Omega_{\boldsymbol{q}j}/kT}\right)} \right] \\
     & - \frac{1}{N_{q}}\sum_{\boldsymbol{q},j}\left[ \Omega_{\boldsymbol{q}j}^{2} - (C_{\boldsymbol{q}}^{\dagger}\Lambda_{\boldsymbol{q}}^{(\mathrm{HA})}C_{\boldsymbol{q}})_{jj} \right]
     \times \frac{\hbar [1 + 2n_{\boldsymbol{q}j} ]}{2\Omega_{\boldsymbol{q}j}}.
    \end{align*}

Details of the derivation of the above expression can be found in Ref. [7]_.


Mean square displacement
------------------------

<commit_msg>Fix a typo in documentation<commit_after>ANPHON: Theoretical background
==============================

.. |umulaut_u|   unicode:: U+00FC
.. |umulaut_o|   unicode:: U+00F6

Dynamical matrix
----------------

The dynamical matrix is given by

.. math::
    :label: dymat 

    D_{\mu\nu}(\kappa\kappa^{\prime};\boldsymbol{q}) = \frac{1}{\sqrt{M_{\kappa}M_{\kappa^{\prime}}}}
    \sum_{\ell^{\prime}}\Phi_{\mu\nu}(\ell\kappa;\ell^{\prime}\kappa^{\prime})\exp{\left[i\boldsymbol{q}\cdot(\boldsymbol{r}(\ell^{\prime})-\boldsymbol{r}(\ell))\right]},

where :math:`M_{\kappa}` is the atomic mass of atom :math:`\kappa`.
By diagonalizing the dynamical matrix, one can obtain :math:`m` (:math:`=3N_{\kappa}`) eigenvalues :math:`\omega_{\boldsymbol{q}j}^{2}`  (:math:`j = 1, 2, \dots, m`) and corresponding eigenvectors :math:`\boldsymbol{e}_{\boldsymbol{q}j}` for each :math:`\boldsymbol{q}` point.
Here, :math:`\boldsymbol{e}_{\boldsymbol{q}j}` is a column vector consisting of atomic polarization :math:`e_{\mu}(\kappa;\boldsymbol{q}j)`.
Let :math:`D(\boldsymbol{q})` denote a matrix form of equation :eq:`dymat`, the eigenvalues may be written as

.. math::
    :label: omega2

    \omega_{\boldsymbol{q}j}^{2} = (\boldsymbol{e}_{\boldsymbol{q}j}^{*})^{\mathrm{T}} D(\boldsymbol{q})\boldsymbol{e}_{\boldsymbol{q}j}.

Next, we introduce :math:`m\times m` matrices :math:`\Lambda` and :math:`W` which are defined as 
:math:`\Lambda(\boldsymbol{q}) = \mathrm{diag} (\omega_{\boldsymbol{q}1}^{2},\dots,\omega_{\boldsymbol{q}m}^{2})` and 
:math:`W(\boldsymbol{q}) = (\boldsymbol{e}_{\boldsymbol{q}1},\dots,\boldsymbol{e}_{\boldsymbol{q}m})`, respectively. 
Then, equation :eq:`omega2` can be denoted as 

.. math::
    
    \Lambda(\boldsymbol{q}) = W^{\dagger}(\boldsymbol{q})D(\boldsymbol{q})W(\boldsymbol{q}).


When one needs to capture the LO\-TO splitting near the zone-center by the supercell approach,
it is necessary to add the non\-analytic part of the dynamical matrix defined by

.. math::

    D_{\mu\nu}^{\mathrm{NA}}(\kappa\kappa^{\prime};\boldsymbol{q}) = \frac{1}{\sqrt{M_{\kappa}M_{\kappa^{\prime}}}}
    \frac{4\pi e^{2}}{\Omega} \frac{(Z_{\kappa}^{*}\boldsymbol{q})_{\mu}(Z_{\kappa^{\prime}}^{*}\boldsymbol{q})_{\nu}}{\boldsymbol{q}\cdot\epsilon^{\infty}\boldsymbol{q}},

where :math:`\Omega` is the volume of the primitive cell, :math:`Z_{\kappa}^{*}` is the Born effective charge tensor of atom :math:`\kappa`, 
and :math:`\epsilon^{\infty}` is the dielectric constant tensor, respectively.
In program *anphon*, either the Parlinski's way [1]_ or the mixed-space approach [2]_ can be used. 
In the Parlinski's approach (``NONANALYTIC = 1``), the total dynamical matrix is given by

.. math::

    D(\boldsymbol{q}) + D^{\textrm{NA}}(\boldsymbol{q})\exp{(-q^{2}/\sigma^{2})},

where :math:`\sigma` is a damping factor. 
:math:`\sigma` must be chosen carefully so that the non-analytic contribution
becomes negligible at Brillouin zone boundaries.
In the mixed-space approach (``NONANALYTIC = 2``), the total dynamical matrix is given by

.. math::

    D(\boldsymbol{q}) + D^{\textrm{NA}}(\boldsymbol{q})\frac{1}{N}\sum_{\ell^{\prime}}\exp{\left[i\boldsymbol{q}\cdot(\boldsymbol{r}(\ell^{\prime})-\boldsymbol{r}(\ell))\right]}.

The second term vanishes at commensurate :math:`\boldsymbol{q}` points other than :math:`\Gamma` point (:math:`\boldsymbol{q} = 0`).

To include the non-analytic term, one needs to set ``NONANALYTIC > 0`` and give appropriate ``BORNINFO`` and ``NA_SIGMA`` tags.


Group velocity
--------------

The group velocity of phonon mode :math:`\boldsymbol{q}j` is given by 

.. math::
    
    \boldsymbol{v}_{\boldsymbol{q}j} = \frac{\partial \omega_{\boldsymbol{q}j}}{\partial \boldsymbol{q}}.

To evaluate the group velocity numerically, we employ a central difference where
:math:`\boldsymbol{v}` may approximately be given by

.. math::

    \boldsymbol{v}_{\boldsymbol{q}j} \approx \frac{\omega_{\boldsymbol{q}+\Delta\boldsymbol{q}j} - \omega_{\boldsymbol{q}-\Delta\boldsymbol{q}j}}{2\Delta\boldsymbol{q}}.

If one needs to save the group velocities, please turn on the ``PRINTVEL``-tag.


Thermodynamics functions
------------------------

The specific heat at constant volume :math:`C_{\mathrm{v}}`, the internal energy :math:`U`, 
the vibrational entropy :math:`S`, and the Helmholtz free energy :math:`F` of individual harmonic oscillator are
given as follows:

.. math::
    :nowrap:
    
    \begin{align*}
     U &= \frac{1}{N_{q}}\sum_{\boldsymbol{q},j} \hbar\omega_{\boldsymbol{q}j} \left[\frac{1}{e^{\hbar\omega_{\boldsymbol{q}j}/kT} - 1} + \frac{1}{2}\right], \\
     C_{\mathrm{v}} &= \frac{k}{N_{q}}\sum_{\boldsymbol{q},j} \left(\frac{\hbar\omega_{\boldsymbol{q}j}}{2kT}\right)^{2} \mathrm{cosech}^{2}\left(\frac{\hbar\omega_{\boldsymbol{q}j}}{2kT}\right),\\
     S &= \frac{k}{N_{q}}\sum_{\boldsymbol{q},j} \left[\frac{\hbar\omega_{\boldsymbol{q}j}}{kT} \frac{1}{e^{\hbar\omega_{\boldsymbol{q}j}/kT} - 1} 
        - \log{\left( 1 - e^{-\hbar\omega_{\boldsymbol{q}j}/kT}\right)}\right], \\
     F &= \frac{1}{N_{q}}\sum_{\boldsymbol{q},j}\left[ \frac{\hbar\omega_{\boldsymbol{q}j}}{2} + kT\log{\left( 1 - e^{-\hbar\omega_{\boldsymbol{q}j}/kT}\right)} \right].
    \end{align*}

Here, :math:`k` is the Boltzmann constant. These quantities are saved in the ``PREFIX``.thermo file.

When the self-consistent phonon mode (``MODE = SCPH``) is selected, the anharmonic free-energy 
defined by the following equation will be calculated and saved in the ``PREFIX``.scph_thermo file:

.. math::
    :nowrap:
    
    \begin{align*}
     F^{\mathrm{SCP}} &= \frac{1}{N_{q}}\sum_{\boldsymbol{q},j}\left[ \frac{\hbar\Omega_{\boldsymbol{q}j}}{2} + kT\log{\left( 1 - e^{-\hbar\Omega_{\boldsymbol{q}j}/kT}\right)} \right] \\
     & - \frac{1}{4N_{q}}\sum_{\boldsymbol{q},j}\left[ \Omega_{\boldsymbol{q}j}^{2} - (C_{\boldsymbol{q}}^{\dagger}\Lambda_{\boldsymbol{q}}^{(\mathrm{HA})}C_{\boldsymbol{q}})_{jj} \right]
     \times \frac{\hbar [1 + 2n_{\boldsymbol{q}j} ]}{2\Omega_{\boldsymbol{q}j}}.
    \end{align*}

Details of the derivation of the above expression can be found in Ref. [7]_.


Mean square displacement
------------------------


{'fraction_non_alphanumeric': 0.22883072684547442, 'fraction_numerical': 0.008832347459687221, 'mean_word_length': 4.335927367055771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4657920', 'n_tokens_mistral': 4155, 'n_tokens_neox': 3959, 'n_words': 950}