{ "cells": [ { "cell_type": "markdown", "id": "8b00fbd5", "metadata": {}, "source": [ "# Auxiliary Modules\n", "\n", "You can download source files to follow this tutorial from this [link](https://drive.google.com/file/d/1_gMT74f_1PqxQ8Um1-y_i11Y2tKg7-3f/view?usp=drivesdk) (26 GB).\n", "\n", "```{note}\n", "This is the same example set used in the **Hopping Parameter Extraction** or **Mean Square Displacement** section in `CLI Tutorial` documentation, or the **Hopping Parameter Extraction** section in `API Tutorial` documentation. If you have already completed that tutorial, you do not need to download the files again.\n", "```\n", "\n", "----\n", "\n", "This tutorial provides a brief overview of `VacHopPy`'s auxiliary modules. For more detailed information on each module and its parameters, please consult the `API Reference` documentation.\n", "\n", "First, navigate to the `Example3` directory you downloaded. For this tutorial, we will only use the `TRAJ_TiO2` directory and the `POSCAR_TiO2` file; other files in the directory can be ignored." ] }, { "cell_type": "code", "execution_count": 3, "id": "e030d1e4", "metadata": {}, "outputs": [], "source": [ "import os\n", "from vachoppy.core import Site\n", "\n", "path_traj = 'TRAJ_TiO2'\n", "path_structure = 'POSCAR_TiO2'\n", "if not os.path.exists(path_traj): print(f\"{path_traj} not found.\")\n", "if not os.path.exists(path_structure): print(f\"{path_structure} not found.\")" ] }, { "cell_type": "markdown", "id": "ae5ffffa", "metadata": {}, "source": [ "First, we'll create an instance of the `Site` class. This object will analyze the perfect structure to define the lattice framework for our analysis." ] }, { "cell_type": "code", "execution_count": 4, "id": "77f0fe8e", "metadata": {}, "outputs": [], "source": [ "site = Site(path_structure, 'O')" ] }, { "cell_type": "markdown", "id": "9b4cb238", "metadata": {}, "source": [ "---\n", "## The `Vibration` Module\n", "\n", "The `Vibration` module is dedicated to calculating the **atomic vibration frequency ($\\nu^*$)** from trajectory data. Unlike the `Calculator` function, this module is designed to operate on a **single HDF5 trajectory file**.\n", "\n", "Let's instantiate the `Vibration` class, providing it with the path to a single trajectory file and our pre-defined `site` object." ] }, { "cell_type": "code", "execution_count": 7, "id": "c6d37edb", "metadata": {}, "outputs": [], "source": [ "from vachoppy.vibration import Vibration\n", "\n", "path_traj_single = os.path.join(path_traj, 'TRAJ_2100K', 'TRAJ_O_01.h5')\n", "vib = Vibration(path_traj_single, site)" ] }, { "cell_type": "markdown", "id": "2dbcfbf9", "metadata": {}, "source": [ "To run the analysis, simply call the `.calculate()` method. This will perform the frequency calculation and print a summary of the results directly to the console." ] }, { "cell_type": "code", "execution_count": 11, "id": "3a2b8e9a", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6f2065981548428b9b1ec245db0c139c", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Compute Displacement: 0%| | 0/47 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "eef89c98611841f59c293d7c4cb0192a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Capture Vibrations : 0%| | 0/5000 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0ce8dc03133e49f2bdf816562a5edbca", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Compute Frequenciy : 0%| | 0/47 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "====================================================\n", " High-Frequency Filtering Results (IQR)\n", "====================================================\n", " - Cutoff Frequency : 32.14 THz\n", " - Removed Outlier Frequencies : 74 (out of 7521)\n", "====================================================\n", " Vibrational Analysis Results Summary\n", "====================================================\n", " - Mean Vibrational Amplitude (σ) : 0.191 Ang\n", " - Determined Site Radius (2 x σ) : 0.383 Ang\n", " - Total Vibrational Frequencies : 7447 found\n", " - Mean Vibrational Frequency : 13.324 THz\n", "====================================================\n", "\n", "Execution Time: 2.647 seconds\n", "Peak RAM Usage: 0.016 GB\n" ] } ], "source": [ "vib.calculate(verbose=True)" ] }, { "cell_type": "markdown", "id": "2f50f6b8", "metadata": {}, "source": [ "The summary provides key metrics, including the **mean vibrational frequency** and the determined **site radius**, which is calculated as twice the mean vibrational amplitude. \n", "\n", "You can further visualize the results using the `plot_frequencies()` and `plot_displacements()` methods to see the distribution of frequencies and atomic displacements, respectively." ] }, { "cell_type": "code", "execution_count": null, "id": "f81131c4", "metadata": {}, "outputs": [], "source": [ "vib.plot_frequencies()" ] }, { "cell_type": "markdown", "id": "f208a69f", "metadata": {}, "source": [ "Example output:\n", "\n", "