-
Notifications
You must be signed in to change notification settings - Fork 105
/
jobs.html
328 lines (293 loc) · 33.4 KB
/
jobs.html
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
43
44
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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
188
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>custodian.vasp.jobs — custodian 0.4.3 documentation</title>
<link rel="stylesheet" href="../../../_static/proBlue.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '0.4.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../_static/doctools.js"></script>
<link rel="shortcut icon" href="../../../_static/favicon.ico"/>
<link rel="top" title="custodian 0.4.3 documentation" href="../../../index.html" />
<link rel="up" title="Module code" href="../../index.html" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39574369-1']);
_gaq.push(['_trackPageview']);
</script>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li><a href="../../../index.html">custodian 0.4.3 documentation</a> »</li>
<li><a href="../../index.html" accesskey="U">Module code</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>Source code for custodian.vasp.jobs</h1><div class="highlight"><pre>
<span class="c">#!/usr/bin/env python</span>
<span class="sd">"""</span>
<span class="sd">This module implements basic kinds of jobs for VASP runs.</span>
<span class="sd">"""</span>
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">division</span>
<span class="n">__author__</span> <span class="o">=</span> <span class="s">"Shyue Ping Ong"</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s">"0.1"</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s">"Shyue Ping Ong"</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s">"shyuep@gmail.com"</span>
<span class="n">__status__</span> <span class="o">=</span> <span class="s">"Beta"</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s">"2/4/13"</span>
<span class="kn">import</span> <span class="nn">subprocess</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">shutil</span>
<span class="kn">from</span> <span class="nn">pymatgen.util.io_utils</span> <span class="kn">import</span> <span class="n">zopen</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vaspio.vasp_input</span> <span class="kn">import</span> <span class="n">VaspInput</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.smartio</span> <span class="kn">import</span> <span class="n">read_structure</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vaspio_set</span> <span class="kn">import</span> <span class="n">MITVaspInputSet</span>
<span class="kn">from</span> <span class="nn">pymatgen.serializers.json_coders</span> <span class="kn">import</span> <span class="n">MSONable</span><span class="p">,</span> <span class="n">PMGJSONDecoder</span>
<span class="kn">from</span> <span class="nn">custodian.ansible.intepreter</span> <span class="kn">import</span> <span class="n">Modder</span>
<span class="kn">from</span> <span class="nn">custodian.ansible.actions</span> <span class="kn">import</span> <span class="n">FileActions</span><span class="p">,</span> <span class="n">DictActions</span>
<span class="kn">from</span> <span class="nn">custodian.custodian</span> <span class="kn">import</span> <span class="n">Job</span>
<span class="n">VASP_INPUT_FILES</span> <span class="o">=</span> <span class="p">{</span><span class="s">"INCAR"</span><span class="p">,</span> <span class="s">"POSCAR"</span><span class="p">,</span> <span class="s">"POTCAR"</span><span class="p">,</span> <span class="s">"KPOINTS"</span><span class="p">}</span>
<span class="n">VASP_OUTPUT_FILES</span> <span class="o">=</span> <span class="p">[</span><span class="s">'DOSCAR'</span><span class="p">,</span> <span class="s">'INCAR'</span><span class="p">,</span> <span class="s">'KPOINTS'</span><span class="p">,</span> <span class="s">'POSCAR'</span><span class="p">,</span> <span class="s">'PROCAR'</span><span class="p">,</span>
<span class="s">'vasprun.xml'</span><span class="p">,</span> <span class="s">'CHGCAR'</span><span class="p">,</span> <span class="s">'CHG'</span><span class="p">,</span> <span class="s">'EIGENVAL'</span><span class="p">,</span> <span class="s">'OSZICAR'</span><span class="p">,</span>
<span class="s">'WAVECAR'</span><span class="p">,</span> <span class="s">'CONTCAR'</span><span class="p">,</span> <span class="s">'IBZKPT'</span><span class="p">,</span> <span class="s">'OUTCAR'</span><span class="p">]</span>
<span class="k">class</span> <span class="nc">VaspJob</span><span class="p">(</span><span class="n">Job</span><span class="p">,</span> <span class="n">MSONable</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> A basic vasp job. Just runs whatever is in the directory. But conceivably</span>
<span class="sd"> can be a complex processing of inputs etc. with initialization.</span>
<span class="sd"> """</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vasp_command</span><span class="p">,</span> <span class="n">output_file</span><span class="o">=</span><span class="s">"vasp.out"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s">""</span><span class="p">,</span>
<span class="n">final</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">gzipped</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">backup</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
<span class="n">default_vasp_input_set</span><span class="o">=</span><span class="n">MITVaspInputSet</span><span class="p">(),</span>
<span class="n">settings_override</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> This constructor is necessarily complex due to the need for</span>
<span class="sd"> flexibility. For standard kinds of runs, it's often better to use one</span>
<span class="sd"> of the static constructors.</span>
<span class="sd"> Args:</span>
<span class="sd"> vasp_command:</span>
<span class="sd"> Command to run vasp as a list of args. For example,</span>
<span class="sd"> if you are using mpirun, it can be something like</span>
<span class="sd"> ["mpirun", "pvasp.5.2.11"]</span>
<span class="sd"> output_file:</span>
<span class="sd"> Name of file to direct standard out to. Defaults to vasp.out.</span>
<span class="sd"> suffix:</span>
<span class="sd"> A suffix to be appended to the final output. E.g.,</span>
<span class="sd"> to rename all VASP output from say vasp.out to</span>
<span class="sd"> vasp.out.relax1, provide ".relax1" as the suffix.</span>
<span class="sd"> final:</span>
<span class="sd"> Boolean indicating whether this is the final vasp job in a</span>
<span class="sd"> series. Defaults to True.</span>
<span class="sd"> backup:</span>
<span class="sd"> Boolean whether to backup the initial input files. If True,</span>
<span class="sd"> the INCAR, KPOINTS, POSCAR and POTCAR will be copied with a</span>
<span class="sd"> ".orig" appended. Defaults to True.</span>
<span class="sd"> gzipped:</span>
<span class="sd"> Whether to gzip the final output. Defaults to False.</span>
<span class="sd"> default_vasp_input_set:</span>
<span class="sd"> Species the default input set to use for directories that do</span>
<span class="sd"> not contain full set of VASP input files. For example,</span>
<span class="sd"> if a directory contains only a POSCAR or a cif,</span>
<span class="sd"> the vasp input set will be used to generate the necessary</span>
<span class="sd"> input files for the run. If the directory already</span>
<span class="sd"> contain a full set of VASP input files,</span>
<span class="sd"> this input is ignored. Defaults to the MITVaspInputSet.</span>
<span class="sd"> settings_override:</span>
<span class="sd"> An ansible style list of dict to override changes. For example,</span>
<span class="sd"> to set ISTART=1 for subsequent runs and to copy the CONTCAR</span>
<span class="sd"> to the POSCAR, you will provide::</span>
<span class="sd"> [{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}},</span>
<span class="sd"> {"filename": "CONTCAR",</span>
<span class="sd"> "action": {"_file_copy": {"dest": "POSCAR"}}}]</span>
<span class="sd"> """</span>
<span class="bp">self</span><span class="o">.</span><span class="n">vasp_command</span> <span class="o">=</span> <span class="n">vasp_command</span>
<span class="bp">self</span><span class="o">.</span><span class="n">output_file</span> <span class="o">=</span> <span class="n">output_file</span>
<span class="bp">self</span><span class="o">.</span><span class="n">final</span> <span class="o">=</span> <span class="n">final</span>
<span class="bp">self</span><span class="o">.</span><span class="n">backup</span> <span class="o">=</span> <span class="n">backup</span>
<span class="bp">self</span><span class="o">.</span><span class="n">gzipped</span> <span class="o">=</span> <span class="n">gzipped</span>
<span class="bp">self</span><span class="o">.</span><span class="n">default_vis</span> <span class="o">=</span> <span class="n">default_vasp_input_set</span>
<span class="bp">self</span><span class="o">.</span><span class="n">suffix</span> <span class="o">=</span> <span class="n">suffix</span>
<span class="bp">self</span><span class="o">.</span><span class="n">settings_override</span> <span class="o">=</span> <span class="n">settings_override</span>
<div class="viewcode-block" id="VaspJob.setup"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.setup">[docs]</a> <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">files</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="s">"."</span><span class="p">)</span>
<span class="n">num_structures</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">set</span><span class="p">(</span><span class="n">files</span><span class="p">)</span><span class="o">.</span><span class="n">issuperset</span><span class="p">(</span><span class="n">VASP_INPUT_FILES</span><span class="p">):</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">struct</span> <span class="o">=</span> <span class="n">read_structure</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="n">num_structures</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">except</span><span class="p">:</span>
<span class="k">pass</span>
<span class="k">if</span> <span class="n">num_structures</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s">"{} structures found. Unable to continue."</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">num_structures</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">default_vis</span><span class="o">.</span><span class="n">write_input</span><span class="p">(</span><span class="n">struct</span><span class="p">,</span> <span class="s">"."</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">backup</span><span class="p">:</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">VASP_INPUT_FILES</span><span class="p">:</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s">"{}.orig"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f</span><span class="p">))</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">settings_override</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">vi</span> <span class="o">=</span> <span class="n">VaspInput</span><span class="o">.</span><span class="n">from_directory</span><span class="p">(</span><span class="s">"."</span><span class="p">)</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">Modder</span><span class="p">([</span><span class="n">FileActions</span><span class="p">,</span> <span class="n">DictActions</span><span class="p">])</span>
<span class="n">modified</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">settings_override</span><span class="p">:</span>
<span class="k">if</span> <span class="s">"dict"</span> <span class="ow">in</span> <span class="n">a</span><span class="p">:</span>
<span class="n">modified</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="s">"dict"</span><span class="p">])</span>
<span class="n">vi</span><span class="p">[</span><span class="n">a</span><span class="p">[</span><span class="s">"dict"</span><span class="p">]]</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">modify_object</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="s">"action"</span><span class="p">],</span>
<span class="n">vi</span><span class="p">[</span><span class="n">a</span><span class="p">[</span><span class="s">"dict"</span><span class="p">]])</span>
<span class="k">elif</span> <span class="s">"filename"</span> <span class="ow">in</span> <span class="n">a</span><span class="p">:</span>
<span class="n">m</span><span class="o">.</span><span class="n">modify</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="s">"action"</span><span class="p">],</span> <span class="n">a</span><span class="p">[</span><span class="s">"filename"</span><span class="p">])</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">modified</span><span class="p">:</span>
<span class="n">vi</span><span class="p">[</span><span class="n">f</span><span class="p">]</span><span class="o">.</span><span class="n">write_file</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="VaspJob.run"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">output_file</span><span class="p">,</span> <span class="s">'w'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="k">return</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vasp_command</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">f</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="VaspJob.postprocess"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.postprocess">[docs]</a> <span class="k">def</span> <span class="nf">postprocess</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">VASP_OUTPUT_FILES</span> <span class="o">+</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">output_file</span><span class="p">]:</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">final</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">suffix</span> <span class="o">!=</span> <span class="s">""</span><span class="p">:</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">move</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s">"{}{}"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">suffix</span><span class="p">))</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">suffix</span> <span class="o">!=</span> <span class="s">""</span><span class="p">:</span>
<span class="n">shutil</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s">"{}{}"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">suffix</span><span class="p">))</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">gzipped</span><span class="p">:</span>
<span class="n">gzip_directory</span><span class="p">(</span><span class="s">"."</span><span class="p">)</span>
</div>
<span class="nd">@property</span>
<div class="viewcode-block" id="VaspJob.name"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.name">[docs]</a> <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="s">"Vasp Job"</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="VaspJob.double_relaxation_run"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.double_relaxation_run">[docs]</a> <span class="k">def</span> <span class="nf">double_relaxation_run</span><span class="p">(</span><span class="n">vasp_command</span><span class="p">,</span> <span class="n">gzipped</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Returns a list of two jobs corresponding to an AFLOW style double</span>
<span class="sd"> relaxation run.</span>
<span class="sd"> Args:</span>
<span class="sd"> vasp_command:</span>
<span class="sd"> Command to run vasp as a list of args. For example,</span>
<span class="sd"> if you are using mpirun, it can be something like</span>
<span class="sd"> ["mpirun", "pvasp.5.2.11"]</span>
<span class="sd"> Returns:</span>
<span class="sd"> List of two jobs corresponding to an AFLOW style run.</span>
<span class="sd"> """</span>
<span class="k">return</span> <span class="p">[</span><span class="n">VaspJob</span><span class="p">(</span><span class="n">vasp_command</span><span class="p">,</span> <span class="n">final</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s">".relax1"</span><span class="p">),</span>
<span class="n">VaspJob</span><span class="p">(</span>
<span class="n">vasp_command</span><span class="p">,</span> <span class="n">final</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">backup</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">suffix</span><span class="o">=</span><span class="s">".relax2"</span><span class="p">,</span> <span class="n">gzipped</span><span class="o">=</span><span class="n">gzipped</span><span class="p">,</span>
<span class="n">settings_override</span><span class="o">=</span><span class="p">[</span>
<span class="p">{</span><span class="s">"dict"</span><span class="p">:</span> <span class="s">"INCAR"</span><span class="p">,</span>
<span class="s">"action"</span><span class="p">:</span> <span class="p">{</span><span class="s">"_set"</span><span class="p">:</span> <span class="p">{</span><span class="s">"ISTART"</span><span class="p">:</span> <span class="mi">1</span><span class="p">}}},</span>
<span class="p">{</span><span class="s">"filename"</span><span class="p">:</span> <span class="s">"CONTCAR"</span><span class="p">,</span>
<span class="s">"action"</span><span class="p">:</span> <span class="p">{</span><span class="s">"_file_copy"</span><span class="p">:</span> <span class="p">{</span><span class="s">"dest"</span><span class="p">:</span> <span class="s">"POSCAR"</span><span class="p">}}}])]</span>
</div>
<span class="nd">@property</span>
<div class="viewcode-block" id="VaspJob.to_dict"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.to_dict">[docs]</a> <span class="k">def</span> <span class="nf">to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">d</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">vasp_command</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">vasp_command</span><span class="p">,</span>
<span class="n">output_file</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">output_file</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">suffix</span><span class="p">,</span>
<span class="n">final</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">final</span><span class="p">,</span> <span class="n">gzipped</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">gzipped</span><span class="p">,</span> <span class="n">backup</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">backup</span><span class="p">,</span>
<span class="n">default_vasp_input_set</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">default_vis</span><span class="o">.</span><span class="n">to_dict</span><span class="p">,</span>
<span class="n">settings_override</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">settings_override</span>
<span class="p">)</span>
<span class="n">d</span><span class="p">[</span><span class="s">"@module"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__module__</span>
<span class="n">d</span><span class="p">[</span><span class="s">"@class"</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span>
<span class="k">return</span> <span class="n">d</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="VaspJob.from_dict"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.VaspJob.from_dict">[docs]</a> <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="n">d</span><span class="p">):</span>
<span class="n">vis</span> <span class="o">=</span> <span class="n">PMGJSONDecoder</span><span class="p">()</span><span class="o">.</span><span class="n">process_decoded</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s">"default_vasp_input_set"</span><span class="p">])</span>
<span class="k">return</span> <span class="n">VaspJob</span><span class="p">(</span>
<span class="n">vasp_command</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"vasp_command"</span><span class="p">],</span> <span class="n">output_file</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"output_file"</span><span class="p">],</span>
<span class="n">suffix</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"suffix"</span><span class="p">],</span> <span class="n">final</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"final"</span><span class="p">],</span> <span class="n">gzipped</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"gzipped"</span><span class="p">],</span>
<span class="n">backup</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"backup"</span><span class="p">],</span> <span class="n">default_vasp_input_set</span><span class="o">=</span><span class="n">vis</span><span class="p">,</span>
<span class="n">settings_override</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s">"settings_override"</span><span class="p">])</span>
</div>
<div class="viewcode-block" id="gzip_directory"><a class="viewcode-back" href="../../../custodian.vasp.html#custodian.vasp.jobs.gzip_directory">[docs]</a><span class="k">def</span> <span class="nf">gzip_directory</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="sd">"""</span>
<span class="sd"> Gzips all files in a directory.</span>
<span class="sd"> Args:</span>
<span class="sd"> path:</span>
<span class="sd"> Path to directory.</span>
<span class="sd"> """</span>
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">f</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s">"gz"</span><span class="p">):</span>
<span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="s">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_in</span><span class="p">,</span> \
<span class="n">zopen</span><span class="p">(</span><span class="s">'{}.gz'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f</span><span class="p">),</span> <span class="s">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_out</span><span class="p">:</span>
<span class="n">f_out</span><span class="o">.</span><span class="n">writelines</span><span class="p">(</span><span class="n">f_in</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">f</span><span class="p">)</span></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li><a href="../../../index.html">custodian 0.4.3 documentation</a> »</li>
<li><a href="../../index.html" >Module code</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2013, Shyue Ping Ong.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b1.
</div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
</div>
</body>
</html>