Tutorial
==========

.. |Angstrom|   unicode:: U+00C5 


In this tutorial, the molecular dynamics (MD) in 
metal organic framework named CALF-20 and water system 
will be used as an example. Note that, the trajectory ``alpha.4000`` 
was calculated without equilibration and sampled only 4000 steps with 1 fs of timestep. 
Therefore, the values obtained from present tutorial are not important. 
For more details, see [our CALF-20 paper].

.. figure:: ../data/images/frame.png
  :figwidth: 800px
  :width: 75%
  :alt: Alternative text
  :align: center

  **Figure 1** The example of CALF-20 structure with water loading will be used in this tutorial  

|
|

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

The input example for MSD calculation is shown in ``input.msd`` file. 
First, calculation mode is selected ``mode='msd'``, following by specifying a path to trajectory.
The important tags for averaging can specified by 
``mdstep``, ``bufferinterval``, ``nbuffer`` and ``nstepskip``. 
Here, buffer length is determined 
(``mdstep`` - ``nstepskip``) - ``nbuffer`` * ``bufferinterval``.
Time interval ``dt`` between neighnoring snapshots is 100 fs. 
For ``&msd`` namelist, the evaluation on the specified groups, only water molecules, will be done. 
For ecah group, a center of mass (COM) will be computed. 
Therefore, each group must contain only 1 water molecule. 
The projection of the displacement on 
the axis :math:`\vec{u}=(0,1,1)` will be obtained. 
Rather than specify the cartesian vector, 
we define the center of the first pore in fractional scale ``0.25 0.25 0.25`` as 
the beginning point and the center of the second pore ``0.25 0.50 0.50`` as the ending point. 
Therefore, a vector connecting between 2 pore centers will be a our reference axis. 


.. literalinclude:: ../data/examples/input.msd
   :caption: input.msd 
   :name: inputmsd


Here, when group of waters is specified, only water molecules will be calculated as shown in Figure below. 

.. figure:: ../data/images/group.png
  :figwidth: 800px
  :width: 60%
  :alt: Alternative text
  :align: center

  **Figure 2** The example of water groups used in MSD calculations
  

The execution is simple.


.. code-block:: shell 

    $ ./a.out intput.msd 


One can get the output files. 
        
* ``Total_xyz.dat`` contains the MSD decompsed in X, Y and Z axis 
* ``Total_sum.dat`` contains total MSD 
* ``Total_axis.dat`` contains the projected MSD on the specified axis 
* ``unwrap_trajectory.xsf`` contains the unwraped trajectory including all atoms 
* ``unwrap_groups.xsf`` contains the unwraped trajectory including only atoms in groups and their center of mass 
* ``unwrap_disp_*.xsf`` contains the trajcetory of center of mass used in each buffer 

The example MSD can be plotted as shown in following figure. 

.. figure:: ../data/images/msd_01.png
  :figwidth: 800px
  :width: 40%
  :alt: Alternative text
  :align: center

  **Figure 3** MSD calculated on center of mass of each water molecule 



The important aspect of ``unwrap_disp_*.xsf`` file is that it contains the velocity imformation as vectors. 
One can visualize and perform the further analysis using these vectors. 


.. figure:: ../data/images/com.png
  :figwidth: 800px
  :width: 60%
  :alt: Alternative text
  :align: center

  **Figure 4** The example of center of mass of each water group used in MSD calculations. 
  The vectors represent the velocity of each center of mass.





|


Intermittent bond autocorrelation
-----------------------------------


The input example for MSD calculation is shown in ``input.bond_correlation`` file. 
The first set ``mode='bond_correlation'`` following by specifying a path to dump file.
The important tags for averaging is specify by 
``mdstep``, ``bufferinterval``, ``nbuffer`` and ``nstepskip``. 
Time interval between neighnoring snapshots is 100 fs. 
For ``&bond_correlation`` namelist, the evaluation on whole atoms will be done.
In this tutorial, we are interested in the correlation of Zn-water bond. 
Thus, atomic index 5 for Zn and atomic index 7 for water oxygen will be focused. 
Here, the criteria for bond is 2.5 |Angstrom|


Input 
~~~~~~~~~

.. literalinclude:: ../data/examples/input.bond_correlation
   :caption: input.bond_correlation
   :name: inputbond_correlation


The execution is simple.

.. code-block::

    $ ./a.out input.bond_correlation


One can get the output files. 


* ``auto.bond`` contains bond autocorrelation function 


In this example, we calculated the antocorrelation function on 
:math:`O_F-H_w`, :math:`Zn_F-O_w` and :math:`O_w-O_w` as shown in figure below.
We can clearly see that waters :math:`O_w-O_w` are making cluster with long lifetime, 
while :math:`O_F-H_w` and :math:`Zn_F-O_w` interaction do not persist longer than 100 ps. 


.. figure:: ../data/images/lifetime_01.png
  :figwidth: 800px
  :width: 50%
  :alt: Alternative text
  :align: center

  **Figure 5** The bond autocorrelation function showing the lifetime of the bonds of interest 

|
|


Angle autocorrelation
-----------------------

The input example for MSD calculation is shown in ``input.angle_correlation`` file. 
The first set ``mode='angle_correlation'`` following by specifying a path to dump file.
The important tags for averaging is specify by 
``mdstep``, ``bufferinterval``, ``nbuffer`` and ``nstepskip``. 
Time interval between neighnoring snapshots is 100 fs. 
For ``&angle_correlation`` namelist, the evaluation on the specified groups will be done. 
For ecah group, five atoms for 2 planes definition are required. 
The first atomic index represent the center atoms. The second and the third are the definition of 
plane A, while the forth and the fifth are the definition of plane B.
Note that, the order second to fifth will be count the clockwise direction around the center (first atom). 
The specification required an external script to control. 

In this tutorial we are focusing on the openess of the Zn metal node in CALF-20 where the first plane 
is defined by the O-Zn-O plane (O is oxalate oxygen), 
while the second plane is defined by the N-Zn-N plane (N is triazole nitrogen). 


.. figure:: ../data/images/nodes.png
  :figwidth: 800px
  :width: 60%
  :alt: Alternative text
  :align: center

  **Figure 6** The molecular groups specified by atomic index below the namelist. 
  The vectors operators will be computed within each node. 
  The vectors shown in this figure is an example of normal vector of O-Zn-O plane. 
  

.. figure:: ../data/images/angle_2.png
  :figwidth: 800px
  :width: 40%
  :alt: Alternative text
  :align: center

  **Figure 7** The molecular group specified by atomic index below the namelist. 
  The vectors operators will be computed within each node. 
  The vectors shown in this figure is an example of normal vector of O-Zn-O plane. 


Input 
~~~~~~~~~~~~~~~~~~~~~~

.. literalinclude:: ../data/examples/input.angle_correlation
   :caption: input.angle_correlation
   :name: inputangle_correlation


The execution is simple.

.. code-block:: shell 

    $ ./a.out input.angle_correlation



|

.. figure:: ../data/images/angle_03.png
  :figwidth: 800px
  :width: 50%
  :alt: Alternative text
  :align: center

  **Figure 8** The geometry index of ecah node as a function of time 


.. figure:: ../data/images/angle_02.png
  :figwidth: 800px
  :width: 50%
  :alt: Alternative text
  :align: center

  **Figure 9** The angle measured by 2 different schemes as a a function of time 


.. figure:: ../data/images/angle_01.png
  :figwidth: 800px
  :width: 50%
  :alt: Alternative text
  :align: center

  **Figure 10** The autocorrelation function for each parameters (2 geometry indices and 2 
  angle scheme)


|


Dipole-derivative autocorrelation
----------------------------------



Input 
~~~~~~~~~~~~~~~~~~~~~~


.. literalinclude:: ../data/examples/input.dipole_correlation
   :caption: input.dipole_correlation
   :name: inputdipole_correlation


The execution is simple.

.. code-block:: shell 

    $ ./a.out input.dipole_correlation




.. figure:: ../data/images/ir_01.png
  :figwidth: 800px
  :width: 95%
  :alt: Alternative text
  :align: center

  **Figure 11** The IR spectra of water loaded CALF-20, where the concentration 
  is ranging from 0 - 1.0 H2O/unit cell (u.c.)


|


Velocity autocorrelation
----------------------------------



Input 
~~~~~~~~~~~~~~~~~~~~~~

The input is resemble to the dipole correlation calculation, 
therefore, the example is not provided here. 
The execution is simple.

.. code-block:: shell 

    $ ./a.out input.velocity_correlation




.. figure:: ../data/images/ir_01.png
  :figwidth: 800px
  :width: 95%
  :alt: Alternative text
  :align: center

  **Figure 11** The IR spectra of water loaded CALF-20, where the concentration 
  is ranging from 0 - 1.0 H2O/unit cell (u.c.)


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