1 |
commit: 49e4b94f6aa24cd5a1c160094b8697ccef3a86cc |
2 |
Author: Tiziano Müller <dev-zero <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jul 1 12:27:33 2016 +0000 |
4 |
Commit: Tiziano Müller <dev-zero <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jul 1 12:27:33 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/dev/dev-zero.git/commit/?id=49e4b94f |
7 |
|
8 |
dev-python/ase-espresso: initial commit |
9 |
|
10 |
dev-python/ase-espresso/ase-espresso-9999.ebuild | 62 +++ |
11 |
.../ase-espresso-9999-basic-py3-support.patch | 551 +++++++++++++++++++++ |
12 |
.../ase-espresso-9999-espfilter-libexec.patch | 13 + |
13 |
3 files changed, 626 insertions(+) |
14 |
|
15 |
diff --git a/dev-python/ase-espresso/ase-espresso-9999.ebuild b/dev-python/ase-espresso/ase-espresso-9999.ebuild |
16 |
new file mode 100644 |
17 |
index 0000000..4187edd |
18 |
--- /dev/null |
19 |
+++ b/dev-python/ase-espresso/ase-espresso-9999.ebuild |
20 |
@@ -0,0 +1,62 @@ |
21 |
+# Copyright 1999-2016 Gentoo Foundation |
22 |
+# Distributed under the terms of the GNU General Public License v2 |
23 |
+# $Id$ |
24 |
+ |
25 |
+EAPI=6 |
26 |
+PYTHON_COMPAT=( python{2_7,3_4,3_5} ) |
27 |
+ |
28 |
+inherit python-r1 toolchain-funcs git-r3 |
29 |
+ |
30 |
+DESCRIPTION="Python ASE interface for Quantum Espresso" |
31 |
+HOMEPAGE="https://github.com/vossjo/ase-espresso/wiki" |
32 |
+EGIT_REPO_URI="https://github.com/vossjo/ase-espresso.git" |
33 |
+ |
34 |
+LICENSE="GPL-3" |
35 |
+SLOT="0" |
36 |
+KEYWORDS="~amd64" |
37 |
+IUSE="" |
38 |
+ |
39 |
+DEPEND="dev-python/ase[${PYTHON_USEDEP}]" |
40 |
+RDEPEND="${DEPEND}" |
41 |
+ |
42 |
+PATCHES=( |
43 |
+ "${FILESDIR}/${P}-espfilter-libexec.patch" |
44 |
+ "${FILESDIR}/${P}-basic-py3-support.patch" |
45 |
+) |
46 |
+ |
47 |
+src_prepare() { |
48 |
+ # remove b0rken forward-to-make |
49 |
+ rm setup.py |
50 |
+ |
51 |
+ default |
52 |
+} |
53 |
+ |
54 |
+src_configure() { |
55 |
+ sed -i \ |
56 |
+ -e "s|GITVERSION|${EGIT_VERSION}|" \ |
57 |
+ __init__.py || die |
58 |
+} |
59 |
+ |
60 |
+src_compile() { |
61 |
+ for e in cubecutperiodic espfilter ; do |
62 |
+ $(tc-getCC) ${LDFLAGS} ${CFLAGS} \ |
63 |
+ -o "c-src/${e}" "c-src/${e}.c" || die "building ${e} failed" |
64 |
+ done |
65 |
+} |
66 |
+ |
67 |
+src_install() { |
68 |
+ installation() { |
69 |
+ python_doexe pwlog2trajectory |
70 |
+ |
71 |
+ insinto "$(python_get_sitedir)/espresso" |
72 |
+ doins espsite.py.example.* *.py |
73 |
+ python_optimize |
74 |
+ } |
75 |
+ python_foreach_impl installation |
76 |
+ |
77 |
+ dobin c-src/cubecutperiodic |
78 |
+ exeinto /usr/libexec |
79 |
+ doexe c-src/espfilter |
80 |
+ |
81 |
+ dodoc README.md |
82 |
+} |
83 |
|
84 |
diff --git a/dev-python/ase-espresso/files/ase-espresso-9999-basic-py3-support.patch b/dev-python/ase-espresso/files/ase-espresso-9999-basic-py3-support.patch |
85 |
new file mode 100644 |
86 |
index 0000000..c5516f6 |
87 |
--- /dev/null |
88 |
+++ b/dev-python/ase-espresso/files/ase-espresso-9999-basic-py3-support.patch |
89 |
@@ -0,0 +1,551 @@ |
90 |
+diff --git a/__init__.py b/__init__.py |
91 |
+index 439a037..b181e54 100644 |
92 |
+--- a/__init__.py |
93 |
++++ b/__init__.py |
94 |
+@@ -10,10 +10,10 @@ gitver = 'GITVERSION' |
95 |
+ import os |
96 |
+ |
97 |
+ try: |
98 |
+- import espsite |
99 |
++ from . import espsite |
100 |
+ except ImportError: |
101 |
+- print '*** ase-espresso requires a site-specific espsite.py in PYTHONPATH.' |
102 |
+- print '*** You may use the espsite.py.example.* in the git checkout as templates.' |
103 |
++ print('*** ase-espresso requires a site-specific espsite.py in PYTHONPATH.') |
104 |
++ print('*** You may use the espsite.py.example.* in the git checkout as templates.') |
105 |
+ raise ImportError |
106 |
+ site = espsite.config() |
107 |
+ |
108 |
+@@ -21,10 +21,9 @@ from ase.calculators.general import Calculator |
109 |
+ import atexit |
110 |
+ import sys, string |
111 |
+ import numpy as np |
112 |
+-from types import FileType, StringType |
113 |
+-from constants import * |
114 |
+-from utils import * |
115 |
+-from subdirs import * |
116 |
++from .constants import * |
117 |
++from .utils import * |
118 |
++from .subdirs import * |
119 |
+ |
120 |
+ # ase controlled pw.x's register themselves here, so they can be |
121 |
+ # stopped automatically |
122 |
+@@ -394,7 +393,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
123 |
+ if type(kpts)==float or type(kpts)==int: |
124 |
+ from ase.calculators.calculator import kptdensity2monkhorstpack |
125 |
+ kpts = kptdensity2monkhorstpack(atoms, kpts) |
126 |
+- elif isinstance(kpts, StringType): |
127 |
++ elif isinstance(kpts, str): |
128 |
+ assert kpts == 'gamma' |
129 |
+ else: |
130 |
+ assert len(kpts) == 3 |
131 |
+@@ -594,11 +593,11 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
132 |
+ atoms.set_calculator(self) |
133 |
+ |
134 |
+ if hasattr(site, 'mpi_not_setup') and self.onlycreatepwinp is None: |
135 |
+- print '*** Without cluster-adjusted espsite.py, ase-espresso can only be used' |
136 |
+- print '*** to create input files for pw.x via the option onlycreatepwinp.' |
137 |
+- print '*** Otherwise, ase-espresso requires a site-specific espsite.py' |
138 |
+- print '*** in PYTHONPATH.' |
139 |
+- print '*** You may use the espsite.py.example.* in the git checkout as templates.' |
140 |
++ print('*** Without cluster-adjusted espsite.py, ase-espresso can only be used') |
141 |
++ print('*** to create input files for pw.x via the option onlycreatepwinp.') |
142 |
++ print('*** Otherwise, ase-espresso requires a site-specific espsite.py') |
143 |
++ print('*** in PYTHONPATH.') |
144 |
++ print('*** You may use the espsite.py.example.* in the git checkout as templates.') |
145 |
+ raise ImportError |
146 |
+ |
147 |
+ |
148 |
+@@ -621,7 +620,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
149 |
+ try: |
150 |
+ self.psppath = os.environ['ESP_PSP_PATH'] |
151 |
+ except: |
152 |
+- print 'Unable to find pseudopotential path. Consider setting ESP_PSP_PATH environment variable' |
153 |
++ print('Unable to find pseudopotential path. Consider setting ESP_PSP_PATH environment variable') |
154 |
+ raise |
155 |
+ if self.dipole is None: |
156 |
+ self.dipole = {'status':False} |
157 |
+@@ -631,7 +630,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
158 |
+ if self.convergence is None: |
159 |
+ self.conv_thr = 1e-6/rydberg |
160 |
+ else: |
161 |
+- if self.convergence.has_key('energy'): |
162 |
++ if 'energy' in self.convergence: |
163 |
+ self.conv_thr = self.convergence['energy']/rydberg |
164 |
+ else: |
165 |
+ self.conv_thr = 1e-6/rydberg |
166 |
+@@ -654,11 +653,11 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
167 |
+ self.log = self.txt |
168 |
+ self.scratch = mkscratch(self.localtmp, site) |
169 |
+ if self.output is not None: |
170 |
+- if self.output.has_key('removewf'): |
171 |
++ if 'removewf' in self.output: |
172 |
+ removewf = self.output['removewf'] |
173 |
+ else: |
174 |
+ removewf = True |
175 |
+- if self.output.has_key('removesave'): |
176 |
++ if 'removesave' in self.output: |
177 |
+ removesave = self.output['removesave'] |
178 |
+ else: |
179 |
+ removesave = False |
180 |
+@@ -741,7 +740,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
181 |
+ if type(self.U)==dict: |
182 |
+ Ulist = np.zeros(len(symbols), np.float) |
183 |
+ for i,s in enumerate(symbols): |
184 |
+- if self.U.has_key(s): |
185 |
++ if s in self.U: |
186 |
+ Ulist[i] = self.U[s] |
187 |
+ else: |
188 |
+ Ulist = list(self.U) |
189 |
+@@ -754,7 +753,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
190 |
+ if type(self.J)==dict: |
191 |
+ Jlist = np.zeros(len(symbols), np.float) |
192 |
+ for i,s in enumerate(symbols): |
193 |
+- if self.J.has_key(s): |
194 |
++ if s in self.J: |
195 |
+ Jlist[i] = self.J[s] |
196 |
+ else: |
197 |
+ Jlist = list(self.J) |
198 |
+@@ -767,7 +766,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
199 |
+ if type(self.U_alpha)==dict: |
200 |
+ U_alphalist = np.zeros(len(symbols), np.float) |
201 |
+ for i,s in enumerate(symbols): |
202 |
+- if self.U_alpha.has_key(s): |
203 |
++ if s in self.U_alpha: |
204 |
+ U_alphalist[i] = self.U_alpha[s] |
205 |
+ else: |
206 |
+ U_alphalist = list(self.U_alpha) |
207 |
+@@ -784,7 +783,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
208 |
+ symcounter[s] = 0 |
209 |
+ for i in range(len(symbols)): |
210 |
+ key = symbols[i]+'_m%.14eU%.14eJ%.14eUa%.14e' % (magmoms[i],Ulist[i],Jlist[i],U_alphalist[i]) |
211 |
+- if dic.has_key(key): |
212 |
++ if key in dic: |
213 |
+ self.specprops.append((dic[key][1],pos[i])) |
214 |
+ else: |
215 |
+ symcounter[symbols[i]] += 1 |
216 |
+@@ -825,7 +824,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
217 |
+ overridekpts=None, overridekptshift=None, overridenbands=None, |
218 |
+ suppressforcecalc=False, usetetrahedra=False): |
219 |
+ if self.atoms is None: |
220 |
+- raise ValueError, 'no atoms defined' |
221 |
++ raise ValueError('no atoms defined') |
222 |
+ if self.cancalc: |
223 |
+ fname = self.localtmp+'/'+filename |
224 |
+ #f = open(self.localtmp+'/pw.inp', 'w') |
225 |
+@@ -866,14 +865,14 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
226 |
+ if self.calcstress: |
227 |
+ print >>f, ' tstress=.true.,' |
228 |
+ if self.output is not None: |
229 |
+- if self.output.has_key('avoidio'): |
230 |
++ if 'avoidio' in self.output: |
231 |
+ if self.output['avoidio']: |
232 |
+ self.output['disk_io'] = 'none' |
233 |
+- if self.output.has_key('disk_io'): |
234 |
++ if 'disk_io' in self.output: |
235 |
+ if self.output['disk_io'] in ['high', 'low', 'none']: |
236 |
+ print >>f, ' disk_io=\''+self.output['disk_io']+'\',' |
237 |
+ |
238 |
+- if self.output.has_key('wf_collect'): |
239 |
++ if 'wf_collect' in self.output: |
240 |
+ if self.output['wf_collect']: |
241 |
+ print >>f, ' wf_collect=.true.,' |
242 |
+ if self.opt_algorithm!='ase3' or not self.cancalc: |
243 |
+@@ -941,7 +940,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
244 |
+ if self.tot_magnetization != 'hund': |
245 |
+ self.totmag = self.tot_magnetization |
246 |
+ else: |
247 |
+- from atomic_configs import hundmag |
248 |
++ from .atomic_configs import hundmag |
249 |
+ self.totmag = sum([hundmag(x) for x in self.atoms.get_chemical_symbols()]) |
250 |
+ print >>f, ' tot_magnetization='+num2str(self.totmag*inimagscale)+',' |
251 |
+ print >>f, ' ecutwfc='+num2str(self.pw/rydberg)+',' |
252 |
+@@ -1030,15 +1029,15 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
253 |
+ if dipfield or efield: |
254 |
+ print >>f, ' edir='+str(edir)+',' |
255 |
+ if dipfield: |
256 |
+- if self.dipole.has_key('emaxpos'): |
257 |
++ if 'emaxpos' in self.dipole: |
258 |
+ emaxpos = self.dipole['emaxpos'] |
259 |
+ else: |
260 |
+ emaxpos = self.find_max_empty_space(edir) |
261 |
+- if self.dipole.has_key('eopreg'): |
262 |
++ if 'eopreg' in self.dipole: |
263 |
+ eopreg = self.dipole['eopreg'] |
264 |
+ else: |
265 |
+ eopreg = 0.025 |
266 |
+- if self.dipole.has_key('eamp'): |
267 |
++ if 'eamp' in self.dipole: |
268 |
+ eamp = self.dipole['eamp'] |
269 |
+ else: |
270 |
+ eamp = 0.0 |
271 |
+@@ -1046,15 +1045,15 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
272 |
+ print >>f, ' eopreg='+num2str(eopreg)+',' |
273 |
+ print >>f, ' eamp='+num2str(eamp)+',' |
274 |
+ if efield: |
275 |
+- if self.field.has_key('emaxpos'): |
276 |
++ if 'emaxpos' in self.field: |
277 |
+ emaxpos = self.field['emaxpos'] |
278 |
+ else: |
279 |
+ emaxpos = 0.0 |
280 |
+- if self.field.has_key('eopreg'): |
281 |
++ if 'eopreg' in self.field: |
282 |
+ eopreg = self.field['eopreg'] |
283 |
+ else: |
284 |
+ eopreg = 0.0 |
285 |
+- if self.field.has_key('eamp'): |
286 |
++ if 'eamp' in self.field: |
287 |
+ eamp = self.field['eamp'] |
288 |
+ else: |
289 |
+ eamp = 0.0 |
290 |
+@@ -1367,7 +1366,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
291 |
+ ### closing PWscf input file ### |
292 |
+ f.close() |
293 |
+ if self.verbose == 'high': |
294 |
+- print '\nPWscf input file %s written\n' % fname |
295 |
++ print('\nPWscf input file %s written\n' % fname) |
296 |
+ |
297 |
+ def set_atoms(self, atoms): |
298 |
+ if self.atoms is None or not self.started: |
299 |
+@@ -1511,18 +1510,18 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
300 |
+ break |
301 |
+ if a[:20]==' convergence NOT': |
302 |
+ self.stop() |
303 |
+- raise RuntimeError, 'scf cycles did not converge\nincrease maximum number of steps and/or decreasing mixing' |
304 |
++ raise RuntimeError('scf cycles did not converge\nincrease maximum number of steps and/or decreasing mixing') |
305 |
+ elif a[:13]==' stopping': |
306 |
+ self.stop() |
307 |
+ self.checkerror() |
308 |
+ #if checkerror shouldn't find an error here, |
309 |
+ #throw this generic error |
310 |
+- raise RuntimeError, 'SCF calculation failed' |
311 |
++ raise RuntimeError('SCF calculation failed') |
312 |
+ elif a=='' and self.calcmode in ('ase3','relax','scf','vc-relax','vc-md','md'): |
313 |
+ self.checkerror() |
314 |
+ #if checkerror shouldn't find an error here, |
315 |
+ #throw this generic error |
316 |
+- raise RuntimeError, 'SCF calculation failed' |
317 |
++ raise RuntimeError('SCF calculation failed') |
318 |
+ self.atom_occ = atom_occ |
319 |
+ self.results['magmoms'] = magmoms |
320 |
+ if self.calcmode in ('ase3','relax','scf','vc-relax','vc-md','md','hund'): |
321 |
+@@ -1574,22 +1573,22 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
322 |
+ a = self.cout.readline() |
323 |
+ s.write(a) |
324 |
+ if not self.dontcalcforces: |
325 |
+- while a[:11]!=' Forces': |
326 |
+- a = self.cout.readline() |
327 |
+- s.write(a) |
328 |
+- s.flush() |
329 |
+- a = self.cout.readline() |
330 |
+- s.write(a) |
331 |
+- self.forces = np.empty((self.natoms,3), np.float) |
332 |
+- for i in range(self.natoms): |
333 |
+- a = self.cout.readline() |
334 |
+- while a.find('force')<0: |
335 |
+- s.write(a) |
336 |
+- a = self.cout.readline() |
337 |
+- s.write(a) |
338 |
+- forceinp = a.split() |
339 |
+- self.forces[i][:] = [float(x) for x in forceinp[len(forceinp)-3:]] |
340 |
+- self.forces *= rydberg_over_bohr |
341 |
++ while a[:11]!=' Forces': |
342 |
++ a = self.cout.readline() |
343 |
++ s.write(a) |
344 |
++ s.flush() |
345 |
++ a = self.cout.readline() |
346 |
++ s.write(a) |
347 |
++ self.forces = np.empty((self.natoms,3), np.float) |
348 |
++ for i in range(self.natoms): |
349 |
++ a = self.cout.readline() |
350 |
++ while a.find('force')<0: |
351 |
++ s.write(a) |
352 |
++ a = self.cout.readline() |
353 |
++ s.write(a) |
354 |
++ forceinp = a.split() |
355 |
++ self.forces[i][:] = [float(x) for x in forceinp[len(forceinp)-3:]] |
356 |
++ self.forces *= rydberg_over_bohr |
357 |
+ else: |
358 |
+ self.forces = None |
359 |
+ else: |
360 |
+@@ -1993,7 +1992,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
361 |
+ p.close() |
362 |
+ |
363 |
+ if len(s)!=3: |
364 |
+- raise RuntimeError, 'stress was not calculated\nconsider specifying calcstress or running a unit cell relaxation' |
365 |
++ raise RuntimeError('stress was not calculated\nconsider specifying calcstress or running a unit cell relaxation') |
366 |
+ |
367 |
+ stress = np.empty((3,3), np.float) |
368 |
+ for i in range(3): |
369 |
+@@ -2048,7 +2047,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
370 |
+ try: |
371 |
+ n = int(p.readline().split()[0].strip(':')) |
372 |
+ except: |
373 |
+- raise RuntimeError, 'Espresso executable doesn\'t seem to have been started.' |
374 |
++ raise RuntimeError('Espresso executable doesn\'t seem to have been started.') |
375 |
+ p.close() |
376 |
+ |
377 |
+ p = os.popen(('tail -n +%d ' % n)+self.log+' | grep -n %%%%%%%%%%%%%%%% |tail -2','r') |
378 |
+@@ -2074,7 +2073,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
379 |
+ msg = '' |
380 |
+ for e in err: |
381 |
+ msg += e |
382 |
+- raise RuntimeError, msg[:len(msg)-1] |
383 |
++ raise RuntimeError(msg[:len(msg)-1]) |
384 |
+ |
385 |
+ def relax_cell_and_atoms(self, |
386 |
+ cell_dynamics='bfgs', # {'none', 'sd', 'damp-pr', 'damp-w', 'bfgs'} |
387 |
+@@ -2186,9 +2185,9 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
388 |
+ |
389 |
+ def run_ppx(self, inp, log=None, inputpp=[], plot=[], |
390 |
+ output_format=5, iflag=3, piperead=False, parallel=True): |
391 |
+- if self.output.has_key('disk_io'): |
392 |
++ if 'disk_io' in self.output: |
393 |
+ if self.output['disk_io'] == 'none': |
394 |
+- print "run_ppx requires output['disk_io'] to be at least 'low' and avoidio=False" |
395 |
++ print("run_ppx requires output['disk_io'] to be at least 'low' and avoidio=False") |
396 |
+ self.stop() |
397 |
+ f = open(self.localtmp+'/'+inp, 'w') |
398 |
+ print >>f, '&INPUTPP\n prefix=\'calc\',\n outdir=\'.\',' |
399 |
+@@ -2229,7 +2228,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
400 |
+ efermi = float(p.readline().split()[-2]) |
401 |
+ p.close() |
402 |
+ except: |
403 |
+- raise RuntimeError, 'get_fermi_level called before DFT calculation was run' |
404 |
++ raise RuntimeError('get_fermi_level called before DFT calculation was run') |
405 |
+ return efermi |
406 |
+ |
407 |
+ |
408 |
+@@ -2349,7 +2348,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
409 |
+ else: |
410 |
+ #ncomponents = 2*j+1 +1 (latter for m summed up) |
411 |
+ ncomponents = int(2.*float(channel[jpos+2:]))+2 |
412 |
+- if not self.pdos[iatom].has_key(channel): |
413 |
++ if channel not in self.pdos[iatom]: |
414 |
+ self.pdos[iatom][channel] = np.zeros((ncomponents,npoints), np.float) |
415 |
+ first = True |
416 |
+ else: |
417 |
+@@ -2468,7 +2467,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
418 |
+ while a.find('<ATM')<0 and a!='': |
419 |
+ a = f.readline() |
420 |
+ if a=='': |
421 |
+- raise RuntimeError, 'no projections found' |
422 |
++ raise RuntimeError('no projections found') |
423 |
+ |
424 |
+ while True: |
425 |
+ while a.find('<ATM')<0 and a!='': |
426 |
+@@ -2570,7 +2569,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
427 |
+ f.write(x) |
428 |
+ x = stream.readline() |
429 |
+ if x=='': |
430 |
+- raise RuntimeError, 'error reading 3D data grid' |
431 |
++ raise RuntimeError('error reading 3D data grid') |
432 |
+ f.write(x) |
433 |
+ nx, ny, nz = [int(y) for y in stream.readline().split()] |
434 |
+ origin = np.array([float(y) for y in stream.readline().split()]) |
435 |
+@@ -2596,7 +2595,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
436 |
+ f.write(x) |
437 |
+ x = stream.readline() |
438 |
+ if x=='': |
439 |
+- raise RuntimeError, 'error reading 2D data grid' |
440 |
++ raise RuntimeError('error reading 2D data grid') |
441 |
+ f.write(x) |
442 |
+ nx, ny = [int(y) for y in stream.readline().split()] |
443 |
+ origin = np.array([float(y) for y in stream.readline().split()]) |
444 |
+@@ -2627,7 +2626,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
445 |
+ elif spin=='down' or spin==2: |
446 |
+ s = 2 |
447 |
+ else: |
448 |
+- raise ValueError, 'unknown spin component' |
449 |
++ raise ValueError('unknown spin component') |
450 |
+ |
451 |
+ p = self.run_ppx('charge.inp', |
452 |
+ inputpp=[['plot_num',0],['spin_component',s]], |
453 |
+@@ -2648,7 +2647,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
454 |
+ elif spin=='down' or spin==2: |
455 |
+ s = 2 |
456 |
+ else: |
457 |
+- raise ValueError, 'unknown spin component' |
458 |
++ raise ValueError('unknown spin component') |
459 |
+ |
460 |
+ self.run_ppx('charge.inp', |
461 |
+ inputpp=[['plot_num',0],['spin_component',s]], |
462 |
+@@ -2668,7 +2667,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
463 |
+ elif spin=='down' or spin==2: |
464 |
+ s = 2 |
465 |
+ else: |
466 |
+- raise ValueError, 'unknown spin component' |
467 |
++ raise ValueError('unknown spin component') |
468 |
+ |
469 |
+ p = self.run_ppx('totalpot.inp', |
470 |
+ inputpp=[['plot_num',1],['spin_component',s]], |
471 |
+@@ -2689,7 +2688,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
472 |
+ elif spin=='down' or spin==2: |
473 |
+ s = 2 |
474 |
+ else: |
475 |
+- raise ValueError, 'unknown spin component' |
476 |
++ raise ValueError('unknown spin component') |
477 |
+ |
478 |
+ self.run_ppx('totalpot.inp', |
479 |
+ inputpp=[['plot_num',1],['spin_component',s]], |
480 |
+@@ -2831,7 +2830,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
481 |
+ elif spin=='z': |
482 |
+ s = 3 |
483 |
+ else: |
484 |
+- raise ValueError, 'unknown spin component' |
485 |
++ raise ValueError('unknown spin component') |
486 |
+ if self.spinpol: |
487 |
+ p = os.popen('grep "number of k points=" '+self.log+'|tail -1|tr \'=\' \' \'', 'r') |
488 |
+ nkp = int(p.readline().split()[4]) |
489 |
+@@ -2870,7 +2869,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
490 |
+ elif spin=='z': |
491 |
+ s = 3 |
492 |
+ else: |
493 |
+- raise ValueError, 'unknown spin component' |
494 |
++ raise ValueError('unknown spin component') |
495 |
+ if self.spinpol: |
496 |
+ p = os.popen('grep "number of k points=" '+self.log+'|tail -1|tr \'=\' \' \'', 'r') |
497 |
+ nkp = int(p.readline().split()[4]) |
498 |
+@@ -2947,7 +2946,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
499 |
+ elif spin=='down' or spin==2: |
500 |
+ s = 2 |
501 |
+ else: |
502 |
+- raise ValueError, 'unknown spin component' |
503 |
++ raise ValueError('unknown spin component') |
504 |
+ |
505 |
+ inputpp=[['plot_num',10],['spin_component',s]] |
506 |
+ efermi = self.get_fermi_level() |
507 |
+@@ -2975,7 +2974,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
508 |
+ elif spin=='down' or spin==2: |
509 |
+ s = 2 |
510 |
+ else: |
511 |
+- raise ValueError, 'unknown spin component' |
512 |
++ raise ValueError('unknown spin component') |
513 |
+ |
514 |
+ inputpp=[['plot_num',10],['spin_component',s]] |
515 |
+ efermi = self.get_fermi_level() |
516 |
+@@ -3050,7 +3049,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
517 |
+ elif spin=='z': |
518 |
+ s = 3 |
519 |
+ else: |
520 |
+- raise ValueError, 'unknown spin component' |
521 |
++ raise ValueError('unknown spin component') |
522 |
+ p = self.run_ppx('noncollmag.inp', |
523 |
+ inputpp=[['plot_num',13],['spin_component',s]], |
524 |
+ piperead=True, parallel=False) |
525 |
+@@ -3072,7 +3071,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
526 |
+ elif spin=='z': |
527 |
+ s = 3 |
528 |
+ else: |
529 |
+- raise ValueError, 'unknown spin component' |
530 |
++ raise ValueError('unknown spin component') |
531 |
+ self.run_ppx('noncollmag.inp', |
532 |
+ inputpp=[['plot_num',13],['spin_component',s]], |
533 |
+ plot=[['fileout',self.topath(xsf)]], |
534 |
+@@ -3091,7 +3090,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
535 |
+ elif spin=='down' or spin==2: |
536 |
+ s = 2 |
537 |
+ else: |
538 |
+- raise ValueError, 'unknown spin component' |
539 |
++ raise ValueError('unknown spin component') |
540 |
+ |
541 |
+ p = self.run_ppx('aecharge.inp', |
542 |
+ inputpp=[['plot_num',17],['spin_component',s]], |
543 |
+@@ -3112,7 +3111,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
544 |
+ elif spin=='down' or spin==2: |
545 |
+ s = 2 |
546 |
+ else: |
547 |
+- raise ValueError, 'unknown spin component' |
548 |
++ raise ValueError('unknown spin component') |
549 |
+ |
550 |
+ self.run_ppx('aecharge.inp', |
551 |
+ inputpp=[['plot_num',17],['spin_component',s]], |
552 |
+@@ -3261,7 +3260,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
553 |
+ # if there's a dipole, we need to return 2 work functions - one for either direction away from the slab |
554 |
+ if self.dipole['status']: |
555 |
+ eopreg = 0.025 |
556 |
+- if self.dipole.has_key('eopreg'): |
557 |
++ if 'eopreg' in self.dipole: |
558 |
+ eopreg = self.dipole['eopreg'] |
559 |
+ # we use cell_length*eopreg*2.5 here since the work functions seem to converge at that distance rather than *1 or *2 |
560 |
+ vac_pos1 = (vacuum_pos - cell_length*eopreg*2.5) % cell_length |
561 |
+@@ -3306,7 +3305,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
562 |
+ |
563 |
+ |
564 |
+ def get_world(self): |
565 |
+- from worldstub import world |
566 |
++ from .worldstub import world |
567 |
+ return world(site.nprocs) |
568 |
+ |
569 |
+ |
570 |
+diff --git a/espsite.py b/espsite.py |
571 |
+index 68df03a..1ab90f7 100644 |
572 |
+--- a/espsite.py |
573 |
++++ b/espsite.py |
574 |
+@@ -9,7 +9,7 @@ class config: |
575 |
+ self.submitdir = '.' |
576 |
+ self.batch = False |
577 |
+ self.mpi_not_setup = True |
578 |
+- if not os.environ.has_key('ESP_PSP_PATH'): |
579 |
++ if 'ESP_PSP_PATH' not in os.environ: |
580 |
+ os.environ['ESP_PSP_PATH'] = '.' |
581 |
+ |
582 |
+ def do_perProcMpiExec(self, workdir, program): |
583 |
+diff --git a/multiespresso.py b/multiespresso.py |
584 |
+index 3be1d51..08b5daa 100644 |
585 |
+--- a/multiespresso.py |
586 |
++++ b/multiespresso.py |
587 |
+@@ -66,9 +66,9 @@ class multiespresso: |
588 |
+ a = self.calculators[i].cerr.readline() |
589 |
+ notdone |= (a!='' and a[:17]!='! total energy') |
590 |
+ if a[:13]==' stopping': |
591 |
+- raise RuntimeError, 'problem with calculator #%d' % i |
592 |
++ raise RuntimeError('problem with calculator #%d' % i) |
593 |
+ elif a[:20]==' convergence NOT': |
594 |
+- raise RuntimeError, 'calculator #%d did not converge' % i |
595 |
++ raise RuntimeError('calculator #%d did not converge' % i) |
596 |
+ elif a[1:17]!=' total energy': |
597 |
+ stderr.write(a) |
598 |
+ else: |
599 |
+@@ -85,7 +85,7 @@ class multiespresso: |
600 |
+ |
601 |
+ def set_images(self, images): |
602 |
+ if len(images)!=self.ncalc: |
603 |
+- raise ValueError, 'number of images (%d) doesn\'t match number of calculators (%d)' % (len(images),self.ncalc) |
604 |
++ raise ValueError('number of images (%d) doesn\'t match number of calculators (%d)' % (len(images),self.ncalc)) |
605 |
+ for i in range(self.ncalc): |
606 |
+ images[i].set_calculator(self.calculators[i]) |
607 |
+ self.images = images |
608 |
+diff --git a/subdirs.py b/subdirs.py |
609 |
+index 5b24a87..081ff2c 100644 |
610 |
+--- a/subdirs.py |
611 |
++++ b/subdirs.py |
612 |
+@@ -64,7 +64,7 @@ def cleanup(tmp, scratch, removewf, removesave, calc, site): |
613 |
+ os.chdir(tmp) |
614 |
+ os.system(pernodeexec + ' rm -r '+scratch+' 2>/dev/null') |
615 |
+ os.chdir(cdir) |
616 |
+- if hasattr(site, 'mpdshutdown') and not os.environ.has_key('QEASE_MPD_ISSHUTDOWN'): |
617 |
++ if hasattr(site, 'mpdshutdown') and 'QEASE_MPD_ISSHUTDOWN' not in os.environ: |
618 |
+ os.environ['QEASE_MPD_ISSHUTDOWN'] = 'yes' |
619 |
+ os.system(site.mpdshutdown) |
620 |
+ |
621 |
+diff --git a/utils.py b/utils.py |
622 |
+index d26c3d1..bbbf6c0 100644 |
623 |
+--- a/utils.py |
624 |
++++ b/utils.py |
625 |
+@@ -72,11 +72,11 @@ def convert_constraints(atoms): |
626 |
+ elif isinstance(d, constraints.FixInternals.FixDihedral): |
627 |
+ otherconstr.append("'torsional_angle' %d %d %d %d %s" % (d.indices[0]+1,d.indices[1]+1,d.indices[2]+1,d.indices[3]+1,num2str(np.arccos(d.angle)*180./np.pi))) |
628 |
+ else: |
629 |
+- raise NotImplementedError, 'constraint '+d.__name__+' from FixInternals not implemented\n' \ |
630 |
+- 'consider ase-based relaxation with this constraint instead' |
631 |
++ raise NotImplementedError('constraint '+d.__name__+' from FixInternals not implemented\n' \ |
632 |
++ 'consider ase-based relaxation with this constraint instead') |
633 |
+ else: |
634 |
+- raise NotImplementedError, 'constraint '+c.__name__+' not implemented\n' \ |
635 |
+- 'consider ase-based relaxation with this constraint instead' |
636 |
++ raise NotImplementedError('constraint '+c.__name__+' not implemented\n' \ |
637 |
++ 'consider ase-based relaxation with this constraint instead') |
638 |
+ return forcefilter,otherconstr |
639 |
+ else: |
640 |
+ return [],[] |
641 |
|
642 |
diff --git a/dev-python/ase-espresso/files/ase-espresso-9999-espfilter-libexec.patch b/dev-python/ase-espresso/files/ase-espresso-9999-espfilter-libexec.patch |
643 |
new file mode 100644 |
644 |
index 0000000..3d4c85d |
645 |
--- /dev/null |
646 |
+++ b/dev-python/ase-espresso/files/ase-espresso-9999-espfilter-libexec.patch |
647 |
@@ -0,0 +1,13 @@ |
648 |
+diff --git a/__init__.py b/__init__.py |
649 |
+index 439a037..1cb8d45 100644 |
650 |
+--- a/__init__.py |
651 |
++++ b/__init__.py |
652 |
+@@ -1701,7 +1701,7 @@ svn co --username anonymous http://qeforge.qe-forge.org/svn/q-e/branches/espress |
653 |
+ if not self.proclist: |
654 |
+ self.cinp, self.cout = site.do_perProcMpiExec(self.scratch,'pw.x '+self.parflags+' -in pw.inp') |
655 |
+ else: |
656 |
+- self.cinp, self.cout, self.cerr = site.do_perSpecProcMpiExec(self.mycpus,self.myncpus,self.scratch,'pw.x '+self.parflags+' -in pw.inp|'+self.mypath+'/espfilter '+str(self.natoms)+' '+self.log+'0') |
657 |
++ self.cinp, self.cout, self.cerr = site.do_perSpecProcMpiExec(self.mycpus,self.myncpus,self.scratch,'pw.x '+self.parflags+' -in pw.inp|/usr/libexec/espfilter '+str(self.natoms)+' '+self.log+'0') |
658 |
+ else: |
659 |
+ site.runonly_perProcMpiExec(self.scratch,' pw.x -in pw.inp >>'+self.log) |
660 |
+ os.system("sed s/occupations.*/occupations=\\'fixed\\',/ <"+self.localtmp+"/pw.inp | sed s/ELECTRONS/ELECTRONS\\\\n\ \ startingwfc=\\'file\\',\\\\n\ \ startingpot=\\'file\\',/ | sed s/conv_thr.*/conv_thr="+num2str(self.conv_thr)+",/ | sed s/tot_magnetization.*/tot_magnetization="+num2str(self.totmag)+",/ >"+self.localtmp+"/pw2.inp") |