{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Welcome to exatomic\n", "\n", "This notebook demonstrates some basics of working with exatomic." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0.3.11'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import exatomic\n", "exatomic.__version__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Getting help in the **Jupyter notebook** is easy, just put a \"?\" after a class or function.\n", "- Don't forget to use **tab** to help with syntax completion" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "exatomic.Universe?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- The Universe object contains all of the information about a simulation, nuclear coordinates, orbitals, etc.\n", "- Data is stored in pandas **DataFrames** (see [pandas](http://pandas.pydata.org) for more information)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "uni = exatomic.Universe()\n", "uni" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Empty universes can be useful...but it is more interesting with data\n", "- Note that exatomic uses **Hartree atomic units**" ] }, { "cell_type": "code", "execution_count": 4, "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", "
framesymbolxyz
atom
00H0.00.0-0.34
10H0.00.00.34
\n", "
" ], "text/plain": [ "Atom(2, 5)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "atom = exatomic.Atom.from_dict({'x': [0.0, 0.0], 'y': [0.0, 0.0], 'z': [-0.34, 0.34],\n", " 'symbol': [\"H\", \"H\"], 'frame': [0, 0]})\n", "uni = exatomic.Universe(atom=atom)\n", "uni.atom" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- The **frame** column is how we track state (e.g. time, theory, etc.)\n", "- The simplest dataframe is the **frame** object which by default only contains the number of atoms" ] }, { "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", "
atom_count
frame
02
\n", "
" ], "text/plain": [ "Frame(1, 1)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "uni.frame # This was computed on-the-fly as we didn't instantiate it above" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Visualization of this simple universe can be accomplished directly in the notebook" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "899aa74a418341cf90c6cc921b3c39b3", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type UniverseWidget.

\n", "

\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "

\n", "

\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "

\n" ], "text/plain": [ "UniverseWidget(active_scene_indices=[0], children=(GUIBox(children=(Button(description=' Close', icon='trash', layout=Layout(width='98%'), style=ButtonStyle()), Button(description=' Clear', icon='bomb', layout=Layout(width='98%'), style=ButtonStyle()), Folder(children=(Button(description=' Active Scenes', icon='bars', layout=Layout(width='98%'), style=ButtonStyle()),), layout=Layout(align_items='flex-end', width='100%')), Folder(children=(Button(description=' Image', icon='save', layout=Layout(width='98%'), style=ButtonStyle()),), layout=Layout(align_items='flex-end', width='100%')), Folder(children=(Button(description=' Camera', icon='camera', layout=Layout(width='98%'), style=ButtonStyle()),), layout=Layout(align_items='flex-end', width='100%')), Button(description=' Fill', icon='adjust', layout=Layout(width='98%'), style=ButtonStyle()), Button(description=' Axis', icon='arrows-alt', layout=Layout(width='98%'), style=ButtonStyle()), Folder(children=(Button(description=' Animate', icon='play', layout=Layout(width='98%'), style=ButtonStyle()),), layout=Layout(align_items='flex-end', width='100%')), Folder(children=(Button(description=' Fields', icon='cube', layout=Layout(width='98%'), style=ButtonStyle()),), layout=Layout(align_items='flex-end', width='100%'))), layout=Layout(flex='0 0 240px')), VBox(children=(HBox(children=(UniverseScene(atom_c={0: '#9b9b9b'}, atom_l='[[\"H0\",\"H1\"]]', atom_r={0: 0.30235616}, atom_s='[[0,0]]', atom_x='[[0.0,0.0]]', atom_y='[[0.0,0.0]]', atom_z='[[-0.34,0.34]]', cont_lim=[-8, -1], imgname='name', layout=Layout(flex='1 1 auto', height='auto', min_height='500px'), two_b0='[[0]]', two_b1='[[1]]', uni=True),), layout=Layout(flex='1 1 auto', height='auto', width='auto')),), layout=Layout(flex='1 1 auto', height='auto', width='auto'))), layout=Layout(flex='1 1 auto', height='auto', width='auto'))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "exatomic.UniverseWidget(uni)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- In building the visualization, bonds were automatically computed\n", "- For small systems this is the default behavior, but for large systems it is not" ] }, { "cell_type": "code", "execution_count": 7, "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", "
atom0atom1drbond
two
0010.68True
\n", "
" ], "text/plain": [ "AtomTwo(1, 4)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "uni.atom_two" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Note again that distances are in **atomic units**" ] }, { "cell_type": "code", "execution_count": 8, "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", "
Hmass
molecule
022.015882
\n", "
" ], "text/plain": [ "Molecule(1, 2)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "uni.molecule" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Center of masses can also be computed" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "uni.compute_molecule_com()" ] }, { "cell_type": "code", "execution_count": 10, "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", "
Hmasscxcycz
molecule
022.0158820.00.00.0
\n", "
" ], "text/plain": [ "Molecule(1, 5)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "uni.molecule" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "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.6.4" } }, "nbformat": 4, "nbformat_minor": 4 }