zincware/MDSuite

View on GitHub
examples/notebooks/NaCl_walkthrough.ipynb

Summary

Maintainability
Test Coverage
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f186b759",
   "metadata": {},
   "source": [
    "# Molten NaCl Example\n",
    "\n",
    "In this walkthrough we will look at a system of molten NaCl to see how MDSuite can be used for the analysis of real systems"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5f810d7",
   "metadata": {},
   "source": [
    "###  Library imports\n",
    "\n",
    "For this specific tutorial we will use our designate data server zinchub to load the data. This is the only import other than mdsuite required for any analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5dc4e981-a7ec-4c75-9962-c47895e4d032",
   "metadata": {},
   "outputs": [],
   "source": [
    "from zinchub import DataHub\n",
    "import mdsuite as mds"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7770d927",
   "metadata": {},
   "source": [
    "With the following two lines we download the data from zinchub."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3cf35074-6729-4ffc-9e46-b7b0088a02ca",
   "metadata": {},
   "outputs": [],
   "source": [
    "NaCl = DataHub(url=\"https://github.com/zincware/DataHub/tree/main/NaCl_gk_i_q\", tag=\"v0.1.0\")\n",
    "NaCl.get_file(path=\".\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c06178db",
   "metadata": {},
   "source": [
    "### Starting your project\n",
    "\n",
    "Now we can start an MDSuite project and add some data to it. Creating a project is as simple as calling the Project class with the name."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d64da139-7bd9-48e0-b808-0981facea3df",
   "metadata": {},
   "outputs": [],
   "source": [
    "project = mds.Project(\"NaCl_Example\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3dd39884",
   "metadata": {},
   "source": [
    "Now we can add an experiment to the project. In this case, we pass the downloaded data directly to this experiment rather than add it at a later stage."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb939f9c-9092-4144-b46b-b562ef1dc64f",
   "metadata": {},
   "outputs": [],
   "source": [
    "project.add_experiment(\n",
    "        name=\"NaCl_example_data\",\n",
    "        timestep=0.002,\n",
    "        temperature=1400.0,\n",
    "        units=\"metal\",\n",
    "        simulation_data=\"NaCl_gk_i_q.lammpstraj\",\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8eb5349",
   "metadata": {},
   "source": [
    "### System analysis\n",
    "\n",
    "Now we can start looking at the system and learning from it. Let's start with a radial distribution function to see the structure."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2d58da29",
   "metadata": {},
   "outputs": [],
   "source": [
    "project.run.RadialDistributionFunction(number_of_configurations=100, plot=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0293d3d0",
   "metadata": {},
   "source": [
    "This looks nice, but let's kick it up a notch and look at bond distributions with the angular distribution functions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4de242c",
   "metadata": {},
   "outputs": [],
   "source": [
    "project.run.EinsteinDiffusionCoefficients()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3bc18982",
   "metadata": {},
   "outputs": [],
   "source": [
    "project.run.EinsteinDiffusionCoefficients(species=[\"Na\"], data_range=50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "72481f26",
   "metadata": {},
   "outputs": [],
   "source": [
    "project.run.AngularDistributionFunction(number_of_configurations=50, plot=True, cutoff=3.6)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b1c70313",
   "metadata": {},
   "source": [
    "Finally, let's take a look at the Green-Kubo diffusion coefficients and ionic conductivity."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af1016db-732e-4911-8104-2fd956166646",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "project.run.GreenKuboDiffusionCoefficients(\n",
    "        data_range=102, plot=True, correlation_time=10\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a6cc2baa",
   "metadata": {},
   "outputs": [],
   "source": [
    "project.run.GreenKuboIonicConductivity(\n",
    "        data_range=300, plot=True, correlation_time=1\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dc2b4278",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}