
Atomic Density Distribution (ADD)
==================================================
.. |Angstrom|   unicode:: U+00C5 

Formulation 
------------

To describe the distribution of guest molecules within the pore cavities, 
we used Gaussian convolution to obtain a smooth atomic density profile rather 
than using simple histograms of number of particles on grids. 
Generally, the atomic density is calculated by summing delta functions at each atomic position, 
as described in the equation below:

.. math::

   \rho (\vec{x}) = \frac{1}{T} \sum _ t ^ T 
   \biggl[ 
   \frac{1}{N} \sum_i^N \delta (\vec{u}_i^t)   
   \biggr]


where :math:`\vec{u}_i^t` is the position of atom :math:`i` in configuration at step :math:`t`. 
The summation of delta function centered at every atom (:math:`i=1\sim N`) 
was taken before averaging over :math:`T` steps across trajectory. 
Numerically, we replaced the delta function with a 
normalized 3D-Gaussian function centered at :math:`\vec{u}_i^t`. 

.. math::

   \rho (\vec{x}) = \frac{1}{T} \sum _ t ^ T 
   \biggl[ 
   \frac{1}{N} \sum _ i ^ N 
   \frac{1}{\sigma \sqrt{2\pi}} 
   \exp \biggl( 
   -\frac{(\vec{x}-\vec{u}_i^t)^2}{\sigma ^ 2}   
   \biggr)
   \biggr]


Assume that total population can be further sampled by the small population, 
in particular, the slow and fast waters as defined in the main text. 
For the sampling of density :math:`\rho ^ {\alpha} (\vec{x})`,
one can calculate from the equation below

.. math::

   \rho ^ {\alpha} (\vec{x}) = \frac{1}{T} \sum _ t ^ T 
   \biggl[ 
   \frac{1}{N} \sum _ i ^ N 
   \frac{1}{\sigma \sqrt{2\pi}} 
   \exp \biggl( 
   -\frac{(\vec{x}-\vec{u}_i^t)^2}{\sigma ^ 2}   
   \biggr)
   \times G ^ {\alpha} [\varepsilon _ {i \in \mathrm{mol}}]
   \biggr]


where :math:`G ^ {\alpha} [\varepsilon _ {i \in \mathrm{mol}}]` 
is the distribution of the small population :math:`\alpha` of interest 
represented in gaussian function form. 
For example, the weight of population is characterized by the norm of the velocities 
at the center of mass of molecule.



Input 
-------

* ``initstructure`` 
   Path to reference structure to project average atimic density in.

* ``trajformat``
   Format of trajjectory file. 

* ``trajstructures``
   A list pf paths to the trajectory 

* ``subfix``
   A subfix for output density file 

* ``verbosity``
   Verbosity of the standard output 

* ``outdir``
   A name of directory containing the results of the calculation 
   
* ``grid``
   Grid size for density calculation 

* ``supercellsize``
   Supercell size applied in trajectory 

* ``sigma``
   Gaussian sigma 

* ``interval``
   Sample snapshot every 

* ``lsymmetry``
   Use symmetry or not 

* ``lspglib``
   Use spglib library or not 

* ``symprec``
   Precision of the symmetry determination 

* ``molecules_per_unit_cell``
   Number of molecule per unit cell for normalization 

* ``int_ratio``
   Give isosiurface value at integrated value of 

* ``ldeconv``
   Deconcolute or not 

* ``derivative``
   Performe derivative of not 

* ``deconvparams``
   Deconvolution parameters in Gaussian function type 

* ``natomframe``
   Number of atoms to be skip 
   



Example 
--------


The averaged ADD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This exameple will show the very beginning part of the ADD, where all atoms of interest 
will be averaged. Here, the symmetrization is not included, therefore, at the equivalent positions, 
the distribution will not be gaurantee to the equivalent. However, 
if our sampling number is large enough, we expect the convergence approaching the symmetrized ADD. 

.. code-block:: yaml

   initstructure: ./data/calf-repeat.cif
   trajformat: traj
   trajstructures:
   - ./data/retrajectory.traj
   subfix: without
   verbosity: high
   outdir: ./output
   grid: [30,30,30]
   supercellsize: [1,1,1]
   sigma: [0.5,0.5,0.5]
   interval: 10
   lsymmetry: true
   lspglib: true
   symprec: 0.1
   molecules_per_unit_cell: 1
   int_ratio: [0.5]
   ldeconv: false
   derivative: [2,"z"]
   deconvparams:
   - [ 1.74261517e+03, -5.08653734e-01, -1.69961484e-02]
   - [ 2.26937431e+03, -4.66048546e-01,  2.11681681e-02]
   - [ 1.02870494e+03, -4.28871212e-01,  1.40403790e-02]
   natomframe: 44






The symmetrized ADD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This exameple will show the the symmetrization of ADD, where all atoms of interest 
will be duplicated by symmetry operators. Then, the ADD will fulfil crystal symmetry.  
One great advantage of this method is the reduction of the sampling number, 
since the equivalent positions will eventually give the equivalent density. 


The atomic-type decomposed ADD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this section, the atomic type decomposition will be demonstrated. 
The calculation will be done simply by the averaging on each atomic type found in 
the trajectory. By coloring the total ADD with atomic-type decomposed ADD, one can 
visualize the positions of each atomic type on the density surface. 


.. code-block:: yaml

   initstructure: ./data/calf-repeat.cif
   trajformat: traj
   trajstructures:
   - ./data/retrajectory.traj
   subfix: without
   verbosity: high
   outdir: ./output
   grid: [30,30,30]
   supercellsize: [1,1,1]
   sigma: [0.5,0.5,0.5]
   interval: 10
   lsymmetry: true
   lspglib: true
   symprec: 0.1
   molecules_per_unit_cell: 1
   int_ratio: [0.5]
   ldeconv: false
   derivative: [2,"z"]
   deconvparams:
   - [ 1.74261517e+03, -5.08653734e-01, -1.69961484e-02]
   - [ 2.26937431e+03, -4.66048546e-01,  2.11681681e-02]
   - [ 1.02870494e+03, -4.28871212e-01,  1.40403790e-02]
   natomframe: 44






The velocity-deconvoluted ADD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this section, the velocity-deconvoluted ADD will be demonstrated. 
The deconvoluation is done by the equation shown in the introduction. 
Therefore, the infornation of the labelling must be provided within the trajectory. 
And the population characterized by Gaussian function is required. 


.. code-block:: yaml

   initstructure: ./data/calf-repeat.cif
   trajformat: traj
   trajstructures:
   - ./data/retrajectory.traj
   subfix: without
   verbosity: high
   outdir: ./output
   grid: [30,30,30]
   supercellsize: [1,1,1]
   sigma: [0.5,0.5,0.5]
   interval: 10
   lsymmetry: true
   lspglib: true
   symprec: 0.1
   molecules_per_unit_cell: 1
   int_ratio: [0.5]
   ldeconv: false
   derivative: [2,"z"]
   deconvparams:
   - [ 1.74261517e+03, -5.08653734e-01, -1.69961484e-02]
   - [ 2.26937431e+03, -4.66048546e-01,  2.11681681e-02]
   - [ 1.02870494e+03, -4.28871212e-01,  1.40403790e-02]
   natomframe: 44






The energy-deconvoluted ADD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this section, the energy-deconvoluted ADD will be demonstrated. 
The deconvoluation is done by the equation shown in the introduction. 
Therefore, the infornation of the labelling must be provided within the trajectory. 
And the population characterized by Gaussian function is required. 









The derivative of ADD 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

One of the advantages of using Gaussian in ADD is the smoothness and differentiable property. 
The first and the second derivative of Gaussian function can be done simply analytically. 
Therefore, the derivative of ADD is acurate,
when compared to the numerical derivative in Histogram-like manner. 


.. code-block:: yaml

   initstructure: ./data/calf-repeat.cif
   trajformat: traj
   trajstructures:
   - ./data/retrajectory.traj
   subfix: without
   verbosity: high
   outdir: ./output
   grid: [30,30,30]
   supercellsize: [1,1,1]
   sigma: [0.5,0.5,0.5]
   interval: 10
   lsymmetry: true
   lspglib: true
   symprec: 0.1
   molecules_per_unit_cell: 1
   int_ratio: [0.5]
   ldeconv: false
   derivative: [2,"z"]
   deconvparams:
   - [ 1.74261517e+03, -5.08653734e-01, -1.69961484e-02]
   - [ 2.26937431e+03, -4.66048546e-01,  2.11681681e-02]
   - [ 1.02870494e+03, -4.28871212e-01,  1.40403790e-02]
   natomframe: 44









The ADD on fixed equivalent positions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By using symmetry operators, one can move the atoms from pore to pore, 
to fixed the positions of the averaging center. 
















.. * :ref:`genindex`
.. * :ref:`modindex`
.. * :ref:`search`
