{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ADF parser API\n", "## Imports to get the resource files" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from vibrav.base import resource\n", "from vibrav.util.open_files import uncompress_file\n", "import os" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Uncompress the resource file to read." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "decomp = uncompress_file(resource('adf-ethane-ts-freq.t21.ascii.xz'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read the ASCII formatted ADF TAPE21 file" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from vibrav.adf import Tape21" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read the atom and frequency tables." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "ed = Tape21(decomp)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Parse the frequency data frame\n", "\n", "The `r_mass` column is calculated on the fly when parsing the mass-weighted normal modes with the formula,\n", "$$ \\mu_i = \\left(\\sum_k^{3N}l_{CARTk,i}^2\\right)^{-1} = \\left(\\sum_k^{3N}\\left(\\frac{l_{MWC k,i}}{\\sqrt{m_k}}\\right)^2\\right)^{-1} = N_i^2$$\n", "\n", "The reason that we must use the ASCII formatted TAPE21 file from ADF rather than the output is that ADF prints the non-mass-weighted normalized cartesians with three decimals of precision. Looking at the equation shown above the $l_{CARTk,i}$ matrix elements are indeed non-mass-weighted cartesian normal modes. However, they are not normalized and the information of the reduced masses can still be extracted.\n", "\n", "To calculate the reduced masses the program will need the latest developers version of both the [exa](https://github.com/exa-analytics/exa) and [exatomic](https://github.com/exa-analytics/exatomic) packages." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dxdydzfrequencyfreqdxr_masssymbollabelir_intframe
frequency
02.413489e-16-1.291217e-15-0.003898-239.03654701.008159C000
1-6.154398e-162.740316e-160.003898-239.03654701.008159C100
2-6.876806e-024.021443e-01-0.014579-239.03654701.008159H200
33.826512e-01-1.415172e-01-0.014579-239.03654701.008159H300
4-3.138831e-01-2.606270e-01-0.014579-239.03654701.008159H400
.................................
139-2.142217e-021.661105e-040.0025683044.853587171.100672H300
1402.947483e-01-3.633216e-01-0.1803263044.853587171.100672H400
1418.272322e-02-2.807390e-010.1128293044.853587171.100672H500
1421.433751e-011.971820e-010.0936303044.853587171.100672H600
1435.269408e-01-9.430460e-02-0.2064593044.853587171.100672H700
\n", "

144 rows × 10 columns

\n", "
" ], "text/plain": [ "Frequency(144, 10)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ed.parse_frequency(cart=True)\n", "ed.frequency" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Parse the atom data frame" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
symbolsetlabelxyzZframe
atom
0C000.0000000.0000001.4507156.00
1C110.0000000.000000-1.4507156.00
2H221.9059400.3463682.2244501.00
3H33-0.653007-1.8237772.2244501.00
4H44-1.2529331.4774092.2244501.00
5H55-0.6530071.823777-2.2244501.00
6H66-1.252933-1.477409-2.2244501.00
7H771.905940-0.346368-2.2244501.00
\n", "
" ], "text/plain": [ "Atom(8, 8)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ed.parse_atom()\n", "ed.atom" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Remove the uncompressed resource file" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "os.remove(decomp)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }