Commit 3c39b2c5 authored by Marco Govoni's avatar Marco Govoni

Added RESTful tutorials

parent b900950f
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1>RESTful Tutorials</h1>"
]
},
{
"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.0\n",
"Today : 2018-09-19 15:02:57.396652\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(\"marco.outatime@gmail.com\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Active': 'True', 'Time Left': '49 minutes'}\n"
]
}
],
"source": [
"status = session.status()\n",
"print(status)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"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": 11,
"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": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requested to run executable wstat on server imedevel.uchicago.edu\n",
"Session Expired! Invalid Request sent, Please recreate session and recheck your input. \n",
"the JSON object must be str, bytes or bytearray, not dict\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": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"File written : wfreq.in\n"
]
}
],
"source": [
"data = {}\n",
"data[\"wfreq_control\"] = {}\n",
"data[\"wfreq_control\"][\"wfreq_calculation\"] = \"XWGQ\"\n",
"data[\"wfreq_control\"][\"n_pdep_eigen_to_use\"] = 50\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": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requested to run executable wfreq on server imedevel.uchicago.edu\n",
"Server failed with the following error \n",
" can only join an iterable\n"
]
}
],
"source": [
"wfreq_output = session.run(\"wfreq\",\"wfreq.in\",\"wfreq.out\",3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now stop the session."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment