{ "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": "
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
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
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
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
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
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
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
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
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
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
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
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
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
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