{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

RESTful Tutorials

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will show here how to interact with the remote server where the `pw.x`, `wstat.x` and `wfreq.x` are already installed." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by importing WESTPy and generating a ground state input file for methane. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " \n", " _ _ _____ _____ _____ \n", "| | | | ___/ ___|_ _| \n", "| | | | |__ \\ `--. | |_ __ _ _ \n", "| |/\\| | __| `--. \\ | | '_ \\| | | | \n", "\\ /\\ / |___/\\__/ / | | |_) | |_| | \n", " \\/ \\/\\____/\\____/ \\_/ .__/ \\__, | \n", " | | __/ | \n", " |_| |___/ \n", " \n", "WEST version : 3.1.1\n", "Today : 2018-09-19 15:33:45.581889\n" ] } ], "source": [ "from westpy import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "geom = Geometry()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "geom.setCell((25,0,0),(0,25,0),(0,0,25))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "geom.addAtomsFromOnlineXYZ( \"http://www.west-code.org/doc/training/methane/CH4.xyz\" )" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "geom.addSpecies( \"C\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/C_ONCV_PBE-1.0.upf\")\n", "geom.addSpecies( \"H\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/H_ONCV_PBE-1.0.upf\")" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "gs = GroundState(geom,xc=\"PBE\",ecut=40.0)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Generated file: pw.in\n" ] } ], "source": [ "gs.generateInputPW()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now create a session on the remote server." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Check the inbox/spam folder of your email and click on the link to activate the session\n" ] } ], "source": [ "session = Session(\"your.email@domain.edu\")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'Active': 'True', 'Time Left': '59 minutes'}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "session.status()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requested to run executable pw on server imedevel.uchicago.edu\n", "Generated pw.out\n" ] } ], "source": [ "download = [\"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/C_ONCV_PBE-1.0.upf\",\"http://www.quantum-simulation.org/potentials/sg15_oncv/upf/H_ONCV_PBE-1.0.upf\"]\n", "pw_output = session.run(\"pw\",\"pw.in\",\"pw.out\",download,3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now generate the input for `wstat.x`." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "File written : wstat.in\n" ] } ], "source": [ "data = {}\n", "data[\"input_west\"] = {}\n", "data[\"input_west\"][\"qe_prefix\"] = \"calc\"\n", "data[\"input_west\"][\"west_prefix\"] = \"calc\"\n", "data[\"input_west\"][\"outdir\"] = \"./\"\n", "data[\"wstat_control\"] = {}\n", "data[\"wstat_control\"][\"wstat_calculation\"] = \"S\"\n", "data[\"wstat_control\"][\"n_pdep_eigen\"] = 5\n", "\n", "writeJsonFile(\"wstat.in\",data)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requested to run executable wstat on server imedevel.uchicago.edu\n", "Generated wstat.out\n" ] } ], "source": [ "wstat_output = session.run(\"wstat\",\"wstat.in\",\"wstat.out\",download,3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now generate the input for `wfreq.x`." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "File written : wfreq.in\n" ] } ], "source": [ "data[\"wfreq_control\"] = {}\n", "data[\"wfreq_control\"][\"wfreq_calculation\"] = \"XWGQ\"\n", "data[\"wfreq_control\"][\"n_pdep_eigen_to_use\"] = 5\n", "data[\"wfreq_control\"][\"qp_bandrange\"] = [1,5]\n", "data[\"wfreq_control\"][\"n_refreq\"] = 300\n", "data[\"wfreq_control\"][\"ecut_refreq\"] = 2.0\n", "\n", "writeJsonFile(\"wfreq.in\",data)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requested to run executable wfreq on server imedevel.uchicago.edu\n", "Generated wfreq.out\n" ] } ], "source": [ "wfreq_output = session.run(\"wfreq\",\"wfreq.in\",\"wfreq.out\",download,3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now stop the session." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'Success': 'Session removed and cleared'}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "session.stop()" ] }, { "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }