westpy_101.ipynb 6.11 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
2
3
4
5
6
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
7
    "This tutorial can be downloaded [link](http://greatfire.uchicago.edu/west-public/westpy/raw/master/doc/tutorials/westpy_101.ipynb)."
Marco Govoni's avatar
Marco Govoni committed
8
9
   ]
  },
10
11
12
13
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
14
    "# 1.1 Ground State Calculation with Qbox"
Marco Govoni's avatar
Marco Govoni committed
15
16
17
18
19
20
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
21
    "We are going to generate an input file for the [Qbox](http://qboxcode.org/) code. The code will compute the ground state electronic stucture for the methane molecule using Density Functional Theory. "
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 1: Load westpy"
   ]
  },
  {
   "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
50
51
      "WEST version     :  3.1.1\n",
      "Today            :  2018-09-19 15:21:57.535713\n"
52
53
54
55
56
57
58
59
60
61
62
     ]
    }
   ],
   "source": [
    "from westpy import *"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
63
    "## Step 2: Geometry"
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
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "geom = Geometry()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's define a cubic cell of edge 25 Bohr."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "geom.setCell((25,0,0),(0,25,0),(0,0,25))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We load the atomic positions from a XYZ file, available online. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
Marco Govoni's avatar
Marco Govoni committed
104
    "geom.addAtomsFromOnlineXYZ( \"http://www.west-code.org/doc/training/methane/CH4.xyz\" )"
105
106
107
108
109
110
111
112
113
114
115
116
117
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We associate pseudopotential files to each species."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
Marco Govoni's avatar
Marco Govoni committed
118
   "outputs": [],
119
   "source": [
120
121
    "geom.addSpecies( \"C\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml\")\n",
    "geom.addSpecies( \"H\", \"http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml\")"
122
123
124
125
126
127
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
128
    "## Step 3.1: Ground State"
Marco Govoni's avatar
Marco Govoni committed
129
130
131
132
133
134
135
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The ground state calculation is defined by the geometry, a choice of the exchange-correlation functional, and by setting an energy cutoff for the wavefunctions. "
136
137
138
139
   ]
  },
  {
   "cell_type": "code",
Marco Govoni's avatar
Marco Govoni committed
140
   "execution_count": 6,
141
   "metadata": {},
Marco Govoni's avatar
Marco Govoni committed
142
143
144
145
146
147
148
149
150
   "outputs": [],
   "source": [
    "gs = GroundState(geom,xc=\"PBE\",ecut=40.0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
151
    "We are now able to generate the input file for Qbox."
Marco Govoni's avatar
Marco Govoni committed
152
153
154
155
   ]
  },
  {
   "cell_type": "code",
Marco Govoni's avatar
Marco Govoni committed
156
   "execution_count": 7,
Marco Govoni's avatar
Marco Govoni committed
157
   "metadata": {},
Marco Govoni's avatar
Marco Govoni committed
158
159
160
161
162
163
164
165
166
167
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Generated file:  qbox.in\n"
     ]
    }
   ],
168
   "source": [
Marco Govoni's avatar
Marco Govoni committed
169
    "gs.generateInputQbox()"
170
171
172
173
174
175
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Marco Govoni's avatar
Marco Govoni committed
176
    "We can inspect the file qbox.in"
177
178
179
180
   ]
  },
  {
   "cell_type": "code",
181
   "execution_count": 8,
182
   "metadata": {},
Marco Govoni's avatar
Marco Govoni committed
183
184
185
186
187
188
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "set cell 25.0 0.0 0.0 0.0 25.0 0.0 0.0 0.0 25.0\n",
189
190
      "species Carbon http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml\n",
      "species Hydrogen http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml\n",
Marco Govoni's avatar
Marco Govoni committed
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
      "atom C1 Carbon 0.0 0.0 0.0\n",
      "atom H2 Hydrogen 1.185992116575257 -1.185803143962673 1.185992116575257\n",
      "atom H3 Hydrogen -1.185992116575257 1.185992116575257 1.185992116575257\n",
      "atom H4 Hydrogen -1.185992116575257 -1.185992116575257 -1.185992116575257\n",
      "atom H5 Hydrogen 1.185992116575257 1.185992116575257 -1.185992116575257\n",
      "set ecut 40.0\n",
      "set wf_dyn JD\n",
      "set xc PBE\n",
      "set scf_tol 1.e-8\n",
      "randomize_wf\n",
      "run -atomic_density 0 100 5\n",
      "save gs.xml\n",
      "\n"
     ]
    }
   ],
207
   "source": [
Marco Govoni's avatar
Marco Govoni committed
208
209
210
211
212
213
214
215
216
217
    "with open(\"qbox.in\",\"r\") as file :\n",
    "    data = file.read()\n",
    "    print(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can optionally also download the pseudopotentials files. "
218
   ]
Marco Govoni's avatar
Marco Govoni committed
219
220
221
  },
  {
   "cell_type": "code",
222
   "execution_count": 9,
Marco Govoni's avatar
Marco Govoni committed
223
   "metadata": {},
Marco Govoni's avatar
Marco Govoni committed
224
225
226
227
228
229
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloaded file:  C_ONCV_PBE-1.0.xml , from url:  http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml\n",
230
      "Downloaded file:  C_ONCV_PBE-1.0.xml , from url:  http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml\n"
Marco Govoni's avatar
Marco Govoni committed
231
232
233
     ]
    }
   ],
Marco Govoni's avatar
Marco Govoni committed
234
235
236
237
238
239
240
241
242
243
   "source": [
    "gs.downloadPseudopotentials()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
Marco Govoni's avatar
Marco Govoni committed
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
  }
 ],
 "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",
Marco Govoni's avatar
Marco Govoni committed
262
   "version": "3.7.0"
Marco Govoni's avatar
Marco Govoni committed
263
264
265
266
267
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}