westpy_300.ipynb 7.12 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
 "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",
Marco Govoni's avatar
Marco Govoni committed
43
44
      "WEST version     :  3.1.1\n",
      "Today            :  2018-09-19 15:33:45.581889\n"
Marco Govoni's avatar
Marco Govoni committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
     ]
    }
   ],
   "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": [
Marco Govoni's avatar
Marco Govoni committed
137
    "session = Session(\"your.email@domain.edu\")"
Marco Govoni's avatar
Marco Govoni committed
138
139
140
141
   ]
  },
  {
   "cell_type": "code",
Marco Govoni's avatar
Marco Govoni committed
142
   "execution_count": 10,
Marco Govoni's avatar
Marco Govoni committed
143
144
145
   "metadata": {},
   "outputs": [
    {
Marco Govoni's avatar
Marco Govoni committed
146
147
148
149
150
151
152
153
     "data": {
      "text/plain": [
       "{'Active': 'True', 'Time Left': '59 minutes'}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
Marco Govoni's avatar
Marco Govoni committed
154
155
156
    }
   ],
   "source": [
Marco Govoni's avatar
Marco Govoni committed
157
    "session.status()"
Marco Govoni's avatar
Marco Govoni committed
158
159
160
161
   ]
  },
  {
   "cell_type": "code",
Marco Govoni's avatar
Marco Govoni committed
162
   "execution_count": 11,
Marco Govoni's avatar
Marco Govoni committed
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
   "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",
Marco Govoni's avatar
Marco Govoni committed
188
   "execution_count": 12,
Marco Govoni's avatar
Marco Govoni committed
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
   "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",
Marco Govoni's avatar
Marco Govoni committed
215
   "execution_count": 13,
Marco Govoni's avatar
Marco Govoni committed
216
217
218
219
220
221
222
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requested to run executable wstat on server imedevel.uchicago.edu\n",
Marco Govoni's avatar
Marco Govoni committed
223
      "Generated  wstat.out\n"
Marco Govoni's avatar
Marco Govoni committed
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
     ]
    }
   ],
   "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",
Marco Govoni's avatar
Marco Govoni committed
240
   "execution_count": 14,
Marco Govoni's avatar
Marco Govoni committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254
   "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",
Marco Govoni's avatar
Marco Govoni committed
255
    "data[\"wfreq_control\"][\"n_pdep_eigen_to_use\"] = 5\n",
Marco Govoni's avatar
Marco Govoni committed
256
257
258
259
260
261
262
263
264
    "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",
Marco Govoni's avatar
Marco Govoni committed
265
   "execution_count": 16,
Marco Govoni's avatar
Marco Govoni committed
266
267
268
269
270
271
272
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requested to run executable wfreq on server imedevel.uchicago.edu\n",
Marco Govoni's avatar
Marco Govoni committed
273
      "Generated  wfreq.out\n"
Marco Govoni's avatar
Marco Govoni committed
274
275
276
277
     ]
    }
   ],
   "source": [
Marco Govoni's avatar
Marco Govoni committed
278
    "wfreq_output = session.run(\"wfreq\",\"wfreq.in\",\"wfreq.out\",download,3)"
Marco Govoni's avatar
Marco Govoni committed
279
280
281
282
283
284
285
286
287
288
289
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now stop the session."
   ]
  },
  {
   "cell_type": "code",
Marco Govoni's avatar
Marco Govoni committed
290
   "execution_count": 17,
Marco Govoni's avatar
Marco Govoni committed
291
   "metadata": {},
Marco Govoni's avatar
Marco Govoni committed
292
293
294
295
296
297
298
299
300
301
302
303
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Success': 'Session removed and cleared'}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
Marco Govoni's avatar
Marco Govoni committed
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
   "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
}