{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:33:03.442062Z", "start_time": "2020-06-30T03:33:01.594274Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The autoreload extension is already loaded. To reload it, use:\n", " %reload_ext autoreload\n", " \n", " _ _ _____ _____ _____ \n", "| | | | ___/ ___|_ _| \n", "| | | | |__ \\ `--. | |_ __ _ _ \n", "| |/\\| | __| `--. \\ | | '_ \\| | | | \n", "\\ /\\ / |___/\\__/ / | | |_) | |_| | \n", " \\/ \\/\\____/\\____/ \\_/ .__/ \\__, | \n", " | | __/ | \n", " |_| |___/ \n", " \n", "WEST version : 4.1.0\n", "Today : 2020-06-29 22:33:03.328128\n" ] } ], "source": [ "from westpy import *\n", "\n", "def xyz2center(in_xyz,out_xyz,box_length=30):\n", " '''\n", " in_xyz: input xyz file in unit A\n", " out_xyz: output xyz file where coords are centered in simulation box. \n", " box_length: in unit Bohr\n", " '''\n", " from westpy.units import Angstrom\n", " import pandas as pd\n", " BOHR2A = 1.0 / Angstrom\n", " #convert box length 2 A:\n", " box_length *= BOHR2A\n", " #read in_xyz in unit A\n", " dict_atoms = {'element':[], 'x':[], 'y':[], 'z':[]}\n", " with open(in_xyz,'r') as f:\n", " n_atoms=int(f.readline())\n", " f.readline()\n", " for _ in range(n_atoms):\n", " element, x, y, z = f.readline().split()\n", " dict_atoms['element'].append(element.strip())\n", " dict_atoms['x'].append(float(x))\n", " dict_atoms['y'].append(float(y))\n", " dict_atoms['z'].append(float(z))\n", " assert(len(dict_atoms['x']) == n_atoms)\n", " df_atoms_centered=pd.DataFrame(dict_atoms)\n", " # shift in_xyz coords by [box_length/2,box_length/2,box_length/2]\n", " df_atoms_centered[['x','y','z']] -= df_atoms_centered[['x','y','z']].mean(axis=0)\n", " df_atoms_centered[['x','y','z']] += box_length/2.0\n", " # save to out_xyz\n", " xyz=str(len(df_atoms_centered))+'\\n\\n'\n", " for row in df_atoms_centered.values:\n", " xyz += \" \".join([str(e) for e in row]) + '\\n' \n", " with open(out_xyz,'w') as f:\n", " f.write(xyz)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Geometry.view() Si35H36 " ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:33:21.001332Z", "start_time": "2020-06-30T03:33:11.473346Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Downloaded file: si35h36.xyz , from url: https://journals.aps.org/prx/supplemental/10.1103/PhysRevX.6.041002/si35h36.xyz\n" ] }, { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#download xyz\n", "url = 'https://journals.aps.org/prx/supplemental/10.1103/PhysRevX.6.041002/si35h36.xyz'\n", "fname = 'si35h36.xyz'\n", "download(url=url, fname='si35h36.xyz')\n", "#center it to fit geom.setCell((box_length,0,0),(0,box_length,0),(0,0,box_length))\n", "box_length = 30 #Bohr\n", "center2box_fname = 'centered_si35h36.xyz' \n", "xyz2center(in_xyz=fname,out_xyz=center2box_fname,box_length=box_length)\n", "#creat geom\n", "geom = Geometry()\n", "geom.setCell((box_length,0,0),(0,box_length,0),(0,0,box_length))\n", "geom.addAtomsFromXYZFile(center2box_fname)\n", "geom.addSpecies( \"Si\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/Si_ONCV_PBE-1.2.upf\")\n", "geom.addSpecies( \"H\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/H_ONCV_PBE-1.2.upf\")\n", "geom.view()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:33:28.829407Z", "start_time": "2020-06-30T03:33:28.358677Z" } }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "geom.view(style='line')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:33:33.263955Z", "start_time": "2020-06-30T03:33:32.947704Z" } }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "geom.view(style='sphere')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:33:35.916789Z", "start_time": "2020-06-30T03:33:35.605968Z" } }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "geom.view(ix=2,iy=2,iz=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Geometry.view() HBN" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:45:12.638959Z", "start_time": "2020-06-30T03:45:12.323122Z" } }, "outputs": [], "source": [ "from westpy.units import Angstrom\n", "import numpy as np\n", "A2BOHR = Angstrom" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:45:48.928561Z", "start_time": "2020-06-30T03:45:48.461759Z" } }, "outputs": [], "source": [ "geom = Geometry()\n", "#define unit cell\n", "#>> ibrav = 4 ,\n", "#>> celldm(1) = 4.695926777902829 ,\n", "#>> celldm(3) = 8.048362859199854 ,\n", "# 4 Hexagonal and Trigonal P celldm(3)=c/a\n", "# v1 = a(1,0,0), v2 = a(-1/2,sqrt(3)/2,0), v3 = a(0,0,c/a)\n", "#https://materialsproject.org/materials/mp-984/\n", "celldm_1 = 2.51242804*A2BOHR #bohr\n", "celldm_3 = 7.70726501/2.0/2.512 #c/a\n", "geom.addSpecies( \"B\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/B_ONCV_PBE-1.2.upf\")\n", "geom.addSpecies( \"N\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/N_ONCV_PBE-1.2.upf\")\n", "geom.setCell(a1=(1,0,0), a2=(-1/2,np.sqrt(3)/2,0), a3=(0,0,celldm_3), units=celldm_1)\n", "geom.addFracCoordAtom('B', (1.0/3,2.0/3,0.5) )\n", "geom.addFracCoordAtom('N', (2.0/3,1.0/3,0.5) )" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:45:50.593250Z", "start_time": "2020-06-30T03:45:50.282429Z" } }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "geom.view(style='stick')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:45:54.460859Z", "start_time": "2020-06-30T03:45:54.155035Z" } }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "geom.view(style='line',ix=5,iy=5,iz=2)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "ExecuteTime": { "end_time": "2020-06-30T03:45:56.984028Z", "start_time": "2020-06-30T03:45:56.675204Z" } }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "geom.view(style='sphere',ix=2,iy=2,iz=1,width=400,height=400)" ] }, { "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.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }