Debian Codegraph @

cclib/parser/gaussianparser.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (c) 2018, the cclib development team
4 #
5 # This file is part of cclib (http://cclib.github.io) and is distributed under
6 # the terms of the BSD 3-Clause License.
7
8 """Parser for Gaussian output files"""
9
10
11 from __future__ import print_function
12 import re
13
14 import numpy
15
16 from cclib.parser import data
17 from cclib.parser import logfileparser
18 from cclib.parser import utils
19
20
21 class Gaussian(logfileparser.Logfile):
22 """A Gaussian 98/03 log file."""
23
24 def __init__(self, *args, **kwargs):
25
26 # Call the __init__ method of the superclass
27 super(Gaussian, self).__init__(logname="Gaussian", *args, **kwargs)
28
29 def __str__(self):
30 """Return a string representation of the object."""
31 return "Gaussian log file %s" % (self.filename)
32
33 def __repr__(self):
34 """Return a representation of the object."""
35 return 'Gaussian("%s")' % (self.filename)
36
37 def normalisesym(self, label):
38 """Use standard symmetry labels instead of Gaussian labels.
39
40 To normalise:
41 (1) If label is one of [SG, PI, PHI, DLTA], replace by [sigma, pi, phi, delta]
42 (2) replace any G or U by their lowercase equivalent
43 """
44 # note: DLT must come after DLTA
45 greek = [('SG', 'sigma'), ('PI', 'pi'), ('PHI', 'phi'),
46 ('DLTA', 'delta'), ('DLT', 'delta')]
47 for k, v in greek:
48 if label.startswith(k):
49 tmp = label[len(k):]
50 label = v
51 if tmp:
52 label = v + "." + tmp
53
54 ans = label.replace("U", "u").replace("G", "g")
55 return ans
56
57 def before_parsing(self):
58
59 # Used to index self.scftargets[].
60 SCFRMS, SCFMAX, SCFENERGY = list(range(3))
61
62 # Extract only well-formed numbers in scientific notation.
63 self.re_scinot = re.compile('(\w*)=\s*(-?\d\.\d{2}D[+-]\d{2})')
64 # Extract only well-formed numbers in traditional
65 # floating-point format.
66 self.re_float = re.compile('(\w*-?\w*)=\s*(-?\d+\.\d{10,})')
67
68 # Flag for identifying Coupled Cluster runs.
69 self.coupledcluster = False
70
71 # Fragment number for counterpoise or fragment guess calculations
72 # (normally zero).
73 self.counterpoise = 0
74
75 # Flag for identifying ONIOM calculations.
76 self.oniom = False
77
78 # Flag for identifying BOMD calculations.
79 # These calculations have a back-integration algorithm so that not all
80 # geometries should be kept.
81 # We also add a "time" attribute to the parser.
82 self.BOMD = False
83
84 # Do we have high-precision polarizabilities printed from a
85 # dedicated `polar` job? If so, avoid duplicate parsing.
86 self.hp_polarizabilities = False
87
88 def after_parsing(self):
89
90 # Correct the percent values in the etsecs in the case of
91 # a restricted calculation. The following has the
92 # effect of including each transition twice.
93 if hasattr(self, "etsecs") and len(self.homos) == 1:
94 new_etsecs = [[(x[0], x[1], x[2] * numpy.sqrt(2)) for x in etsec]
95 for etsec in self.etsecs]
96 self.etsecs = new_etsecs
97
98 if hasattr(self, "scanenergies"):
99 self.scancoords = []
100 self.scancoords = self.atomcoords
101
102 if (hasattr(self, 'enthalpy') and hasattr(self, 'temperature')
103 and hasattr(self, 'freeenergy')):
104 self.set_attribute('entropy', (self.enthalpy - self.freeenergy) / self.temperature)
105
106 # This bit is needed in order to trim coordinates that are printed a second time
107 # at the end of geometry optimizations. Note that we need to do this for both atomcoords
108 # and inputcoords. The reason is that normally a standard orientation is printed and that
109 # is what we parse into atomcoords, but inputcoords stores the input (unmodified) coordinates
110 # and that is copied over to atomcoords if no standard oritentation was printed, which happens
111 # for example for jobs with no symmetry. This last step, however, is now generic for all parsers.
112 # Perhaps then this part should also be generic code...
113 # Regression that tests this: Gaussian03/cyclopropenyl.rhf.g03.cut.log
114 if hasattr(self, 'optstatus') and len(self.optstatus) > 0:
115 last_point = len(self.optstatus) - 1
116 if hasattr(self, 'atomcoords'):
117 self.atomcoords = self.atomcoords[:last_point + 1]
118 if hasattr(self, 'inputcoords'):
119 self.inputcoords = self.inputcoords[:last_point + 1]
120
121 # If we parsed high-precision vibrational displacements, overwrite
122 # lower-precision displacements in self.vibdisps
123 if hasattr(self, 'vibdispshp'):
124 self.vibdisps = self.vibdispshp
125 del self.vibdispshp
126 if hasattr(self, 'time'):
127 self.time = [self.time[i] for i in sorted(self.time.keys())]
128 if hasattr(self, 'energies_BOMD'):
129 self.set_attribute('scfenergies',
130 [self.energies_BOMD[i] for i in sorted(self.energies_BOMD.keys())])
131 if hasattr(self, 'atomcoords_BOMD'):
132 self.atomcoords= \
133 [self.atomcoords_BOMD[i] for i in sorted(self.atomcoords_BOMD.keys())]
134
135 def extract(self, inputfile, line):
136 """Extract information from the file object inputfile."""
137
138 # Extract the version number: "Gaussian 09, Revision D.01"
139 # becomes "09revisionD.01".
140 if line.strip() == "Cite this work as:":
141 line = inputfile.next()
142 tokens = line.split()
143 self.metadata["package_version"] = ''.join([
144 tokens[1][:-1],
145 'revision',
146 tokens[-1][:-1],
147 ])
148
149 if line.strip().startswith("Link1: Proceeding to internal job step number"):
150 self.new_internal_job()
151
152 # This block contains some general information as well as coordinates,
153 # which could be parsed in the future:
154 #
155 # Symbolic Z-matrix:
156 # Charge = 0 Multiplicity = 1
157 # C 0.73465 0. 0.
158 # C 1.93465 0. 0.
159 # C
160 # ...
161 #
162 # It also lists fragments, if there are any, which is potentially valuable:
163 #
164 # Symbolic Z-matrix:
165 # Charge = 0 Multiplicity = 1 in supermolecule
166 # Charge = 0 Multiplicity = 1 in fragment 1.
167 # Charge = 0 Multiplicity = 1 in fragment 2.
168 # B(Fragment=1) 0.06457 -0.0279 0.01364
169 # H(Fragment=1) 0.03117 -0.02317 1.21604
170 # ...
171 #
172 # Note, however, that currently we only parse information for the whole system
173 # or supermolecule as Gaussian calls it.
174 if line.strip() == "Symbolic Z-matrix:":
175
176 self.updateprogress(inputfile, "Symbolic Z-matrix", self.fupdate)
177
178 line = inputfile.next()
179 while line.split()[0] == 'Charge':
180
181 # For the supermolecule, we can parse the charge and multicplicity.
182 regex = ".*=(.*)Mul.*=\s*-?(\d+).*"
183 match = re.match(regex, line)
184 assert match, "Something unusual about the line: '%s'" % line
185
186 self.set_attribute('charge', int(match.groups()[0]))
187 self.set_attribute('mult', int(match.groups()[1]))
188
189 if line.split()[-2] == "fragment":
190 self.nfragments = int(line.split()[-1].strip('.'))
191
192 if line.strip()[-13:] == "model system.":
193 self.nmodels = getattr(self, 'nmodels', 0) + 1
194
195 line = inputfile.next()
196
197 # The remaining part will allow us to get the atom count.
198 # When coordinates are given, there is a blank line at the end, but if
199 # there is a Z-matrix here, there will also be variables and we need to
200 # stop at those to get the right atom count.
201 # Also, in older versions there is bo blank line (G98 regressions),
202 # so we need to watch out for leaving the link.
203 natom = 0
204 while line.split() and not "Variables" in line and not "Leave Link" in line:
205 natom += 1
206 line = inputfile.next()
207 self.set_attribute('natom', natom)
208
209 # Continuing from above, there is not always a symbolic matrix, for example
210 # if the Z-matrix was in the input file. In such cases, try to match the
211 # line and get at the charge and multiplicity.
212 #
213 # Charge = 0 Multiplicity = 1 in supermolecule
214 # Charge = 0 Multiplicity = 1 in fragment 1.
215 # Charge = 0 Multiplicity = 1 in fragment 2.
216 if line[1:7] == 'Charge' and line.find("Multiplicity") >= 0:
217
218 self.updateprogress(inputfile, "Charge and Multiplicity", self.fupdate)
219
220 if line.split()[-1] == "supermolecule" or not "fragment" in line:
221
222 regex = ".*=(.*)Mul.*=\s*-?(\d+).*"
223 match = re.match(regex, line)
224 assert match, "Something unusual about the line: '%s'" % line
225
226 self.set_attribute('charge', int(match.groups()[0]))
227 self.set_attribute('mult', int(match.groups()[1]))
228
229 if line.split()[-2] == "fragment":
230 self.nfragments = int(line.split()[-1].strip('.'))
231
232 # Number of atoms is also explicitely printed after the above.
233 if line[1:8] == "NAtoms=":
234
235 self.updateprogress(inputfile, "Attributes", self.fupdate)
236
237 natom = int(re.search('NAtoms=\s*(\d+)', line).group(1))
238 self.set_attribute('natom', natom)
239
240 # Basis set name
241 if line[1:15] == "Standard basis":
242 self.metadata["basis_set"] = line.split()[2]
243
244 # Dipole moment
245 # e.g. from G09
246 # Dipole moment (field-independent basis, Debye):
247 # X= 0.0000 Y= 0.0000 Z= 0.0930
248 # e.g. from G03
249 # X= 0.0000 Y= 0.0000 Z= -1.6735 Tot= 1.6735
250 # need the "field independent" part - ONIOM and other calc use diff formats
251 if line[1:39] == "Dipole moment (field-independent basis":
252
253 self.updateprogress(inputfile, "Dipole and Higher Moments", self.fupdate)
254
255 self.reference = [0.0, 0.0, 0.0]
256 self.moments = [self.reference]
257
258 tokens = inputfile.next().split()
259 # split - dipole would need to be *huge* to fail a split
260 # and G03 and G09 use different spacing
261 if len(tokens) >= 6:
262 dipole = (float(tokens[1]), float(tokens[3]), float(tokens[5]))
263
264 if not hasattr(self, 'moments'):
265 self.moments = [self.reference, dipole]
266 else:
267 self.moments.append(dipole)
268
269 if line[1:43] == "Quadrupole moment (field-independent basis":
270 # e.g. (g09)
271 # Quadrupole moment (field-independent basis, Debye-Ang):
272 # XX= -6.1213 YY= -4.2950 ZZ= -5.4175
273 # XY= 0.0000 XZ= 0.0000 YZ= 0.0000
274 # or from g03
275 # XX= -6.1213 YY= -4.2950 ZZ= -5.4175
276 quadrupole = {}
277 for j in range(2): # two rows
278 line = inputfile.next()
279 if line[22] == '=': # g03 file
280 for i in (1, 18, 35):
281 quadrupole[line[i:i+4]] = float(line[i+5:i+16])
282 else:
283 for i in (1, 27, 53):
284 quadrupole[line[i:i+4]] = float(line[i+5:i+25])
285
286 lex = sorted(quadrupole.keys())
287 quadrupole = [quadrupole[key] for key in lex]
288
289 if not hasattr(self, 'moments') or len(self.moments) < 2:
290 self.logger.warning("Found quadrupole moments but no previous dipole")
291 self.reference = [0.0, 0.0, 0.0]
292 self.moments = [self.reference, None, quadrupole]
293 else:
294 if len(self.moments) == 2:
295 self.moments.append(quadrupole)
296 else:
297 assert self.moments[2] == quadrupole
298
299 if line[1:41] == "Octapole moment (field-independent basis":
300 # e.g.
301 # Octapole moment (field-independent basis, Debye-Ang**2):
302 # XXX= 0.0000 YYY= 0.0000 ZZZ= -0.1457 XYY= 0.0000
303 # XXY= 0.0000 XXZ= 0.0136 XZZ= 0.0000 YZZ= 0.0000
304 # YYZ= -0.5848 XYZ= 0.0000
305 octapole = {}
306 for j in range(2): # two rows
307 line = inputfile.next()
308 if line[22] == '=': # g03 file
309 for i in (1, 18, 35, 52):
310 octapole[line[i:i+4]] = float(line[i+5:i+16])
311 else:
312 for i in (1, 27, 53, 79):
313 octapole[line[i:i+4]] = float(line[i+5:i+25])
314
315 # last line only 2 moments
316 line = inputfile.next()
317 if line[22] == '=': # g03 file
318 for i in (1, 18):
319 octapole[line[i:i+4]] = float(line[i+5:i+16])
320 else:
321 for i in (1, 27):
322 octapole[line[i:i+4]] = float(line[i+5:i+25])
323
324 lex = sorted(octapole.keys())
325 octapole = [octapole[key] for key in lex]
326
327 if not hasattr(self, 'moments') or len(self.moments) < 3:
328 self.logger.warning("Found octapole moments but no previous dipole or quadrupole")
329 self.reference = [0.0, 0.0, 0.0]
330 self.moments = [self.reference, None, None, octapole]
331 else:
332 if len(self.moments) == 3:
333 self.moments.append(octapole)
334 else:
335 assert self.moments[3] == octapole
336
337 if line[1:20] == "Hexadecapole moment":
338 # e.g.
339 # Hexadecapole moment (field-independent basis, Debye-Ang**3):
340 # XXXX= -3.2614 YYYY= -6.8264 ZZZZ= -4.9965 XXXY= 0.0000
341 # XXXZ= 0.0000 YYYX= 0.0000 YYYZ= 0.0000 ZZZX= 0.0000
342 # ZZZY= 0.0000 XXYY= -1.8585 XXZZ= -1.4123 YYZZ= -1.7504
343 # XXYZ= 0.0000 YYXZ= 0.0000 ZZXY= 0.0000
344 hexadecapole = {}
345 # read three lines worth of 4 moments per line
346 for j in range(3):
347 line = inputfile.next()
348 if line[22] == '=': # g03 file
349 for i in (1, 18, 35, 52):
350 hexadecapole[line[i:i+4]] = float(line[i+5:i+16])
351 else:
352 for i in (1, 27, 53, 79):
353 hexadecapole[line[i:i+4]] = float(line[i+5:i+25])
354
355 # last line only 3 moments
356 line = inputfile.next()
357 if line[22] == '=': # g03 file
358 for i in (1, 18, 35):
359 hexadecapole[line[i:i+4]] = float(line[i+5:i+16])
360 else:
361 for i in (1, 27, 53):
362 hexadecapole[line[i:i+4]] = float(line[i+5:i+25])
363
364 lex = sorted(hexadecapole.keys())
365 hexadecapole = [hexadecapole[key] for key in lex]
366
367 if not hasattr(self, 'moments') or len(self.moments) < 4:
368 self.reference = [0.0, 0.0, 0.0]
369 self.moments = [self.reference, None, None, None, hexadecapole]
370 else:
371 if len(self.moments) == 4:
372 self.append_attribute("moments", hexadecapole)
373 else:
374 try:
375 numpy.testing.assert_equal(self.moments[4], hexadecapole)
376 except AssertionError:
377 self.logger.warning("Attribute hexadecapole changed value (%s -> %s)" % (self.moments[4], hexadecapole))
378 self.append_attribute("moments", hexadecapole)
379
380 # Catch message about completed optimization.
381 if line[1:23] == "Optimization completed":
382
383 if not hasattr(self, 'optdone'):
384 self.optdone = []
385 self.optdone.append(len(self.geovalues) - 1)
386
387 assert hasattr(self, "optstatus") and len(self.optstatus) > 0
388 self.optstatus[-1] += data.ccData.OPT_DONE
389
390 # Catch message about stopped optimization (not converged).
391 if line[1:21] == "Optimization stopped":
392
393 if not hasattr(self, "optdone"):
394 self.optdone = []
395
396 assert hasattr(self, "optstatus") and len(self.optstatus) > 0
397 self.optstatus[-1] += data.ccData.OPT_UNCONVERGED
398
399 # Extract the atomic numbers and coordinates from the input orientation,
400 # in the event the standard orientation isn't available.
401 # Don't extract from Input or Z-matrix orientation in a BOMD run, as only
402 # the final geometry should be kept but extract inputatoms.
403 if line.find("Input orientation") > -1 or line.find("Z-Matrix orientation") > -1:
404
405 # If this is a counterpoise calculation, this output means that
406 # the supermolecule is now being considered, so we can set:
407 self.counterpoise = 0
408
409 self.updateprogress(inputfile, "Attributes", self.cupdate)
410
411 if not self.BOMD and not hasattr(self, "inputcoords"):
412 self.inputcoords = []
413 self.inputatoms = []
414
415 self.skip_lines(inputfile, ['d', 'cols', 'cols', 'd'])
416
417 atomcoords = []
418 line = next(inputfile)
419 while list(set(line.strip())) != ["-"]:
420 broken = line.split()
421 self.inputatoms.append(int(broken[1]))
422 atomcoords.append(list(map(float, broken[3:6])))
423 line = next(inputfile)
424
425 if not self.BOMD: self.inputcoords.append(atomcoords)
426
427 self.set_attribute('atomnos', self.inputatoms)
428 self.set_attribute('natom', len(self.inputatoms))
429
430 if self.BOMD and line.startswith(' Summary information for step'):
431
432 # We keep time and energies_BOMD and coordinates in a dictionary
433 # because steps can be recalculated, and we need to overwite the
434 # previous data
435
436 broken = line.split()
437 step = int(broken[-1])
438 line = next(inputfile)
439 broken = line.split()
440 if not hasattr(self, "time"):
441 self.set_attribute('time', {step:float(broken[-1])})
442 else:
443 self.time[step] = float(broken[-1])
444
445 line = next(inputfile)
446 broken = line.split(';')[1].split()
447 ene = utils.convertor(self.float(broken[-1]), "hartree", "eV")
448 if not hasattr(self, "energies_BOMD"):
449 self.set_attribute('energies_BOMD', {step:ene})
450 else:
451 self.energies_BOMD[step] = ene
452
453 self.updateprogress(inputfile, "Attributes", self.cupdate)
454
455 if not hasattr(self, "atomcoords_BOMD"):
456 self.atomcoords_BOMD = {}
457 #self.inputatoms = []
458
459 self.skip_lines(inputfile, ['EKin', 'Angular', 'JX', 'Total', 'Total', 'Cartesian'])
460
461 atomcoords = []
462 line = next(inputfile)
463 while not "MW cartesian" in line:
464 broken = line.split()
465 atomcoords.append(list(map(self.float, (broken[3], broken[5], broken[7]))))
466 # self.inputatoms.append(int(broken[1]))
467 line = next(inputfile)
468
469 self.atomcoords_BOMD[step] = atomcoords
470
471 #self.set_attribute('atomnos', self.inputatoms)
472 #self.set_attribute('natom', len(self.inputatoms))
473
474
475 # Extract the atomic masses.
476 # Typical section:
477 # Isotopes and Nuclear Properties:
478 #(Nuclear quadrupole moments (NQMom) in fm**2, nuclear magnetic moments (NMagM)
479 # in nuclear magnetons)
480 #
481 # Atom 1 2 3 4 5 6 7 8 9 10
482 # IAtWgt= 12 12 12 12 12 1 1 1 12 12
483 # AtmWgt= 12.0000000 12.0000000 12.0000000 12.0000000 12.0000000 1.0078250 1.0078250 1.0078250 12.0000000 12.0000000
484 # NucSpn= 0 0 0 0 0 1 1 1 0 0
485 # AtZEff= -3.6000000 -3.6000000 -3.6000000 -3.6000000 -3.6000000 -1.0000000 -1.0000000 -1.0000000 -3.6000000 -3.6000000
486 # NQMom= 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
487 # NMagM= 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 2.7928460 2.7928460 2.7928460 0.0000000 0.0000000
488 # ... with blank lines dividing blocks of ten, and Leave Link 101 at the end.
489 # This is generally parsed before coordinates, so atomnos is not defined.
490 # Note that in Gaussian03 the comments are not there yet and the labels are different.
491 if line.strip() == "Isotopes and Nuclear Properties:":
492
493 if not hasattr(self, "atommasses"):
494 self.atommasses = []
495
496 line = next(inputfile)
497 while line[1:16] != "Leave Link 101":
498 if line[1:8] == "AtmWgt=":
499 self.atommasses.extend(list(map(float, line.split()[1:])))
500 line = next(inputfile)
501
502 # Extract the atomic numbers and coordinates of the atoms.
503 if line.strip() == "Standard orientation:":
504
505 self.updateprogress(inputfile, "Attributes", self.cupdate)
506
507 # If this is a counterpoise calculation, this output means that
508 # the supermolecule is now being considered, so we can set:
509 self.counterpoise = 0
510
511 if not hasattr(self, "atomcoords"):
512 self.atomcoords = []
513
514 self.skip_lines(inputfile, ['d', 'cols', 'cols', 'd'])
515
516 atomnos = []
517 atomcoords = []
518 line = next(inputfile)
519 while list(set(line.strip())) != ["-"]:
520 broken = line.split()
521 atomnos.append(int(broken[1]))
522 atomcoords.append(list(map(float, broken[-3:])))
523 line = next(inputfile)
524 self.atomcoords.append(atomcoords)
525
526 self.set_attribute('natom', len(atomnos))
527 self.set_attribute('atomnos', atomnos)
528
529 # This is a bit of a hack for regression Gaussian09/BH3_fragment_guess.pop_minimal.log
530 # to skip output for all fragments, assuming the supermolecule is always printed first.
531 # Eventually we want to make this more general, or even better parse the output for
532 # all fragment, but that will happen in a newer version of cclib.
533 if line[1:16] == "Fragment guess:" and getattr(self, 'nfragments', 0) > 1:
534 if not "full" in line:
535 inputfile.seek(0, 2)
536
537 # Another hack for regression Gaussian03/ortho_prod_prod_freq.log, which is an ONIOM job.
538 # Basically for now we stop parsing after the output for the real system, because
539 # currently we don't support changes in system size or fragments in cclib. When we do,
540 # we will want to parse the model systems, too, and that is what nmodels could track.
541 if "ONIOM: generating point" in line and line.strip()[-13:] == 'model system.' and getattr(self, 'nmodels', 0) > 0:
542 inputfile.seek(0, 2)
543
544 # With the gfinput keyword, the atomic basis set functios are:
545 #
546 # AO basis set in the form of general basis input (Overlap normalization):
547 # 1 0
548 # S 3 1.00 0.000000000000
549 # 0.7161683735D+02 0.1543289673D+00
550 # 0.1304509632D+02 0.5353281423D+00
551 # 0.3530512160D+01 0.4446345422D+00
552 # SP 3 1.00 0.000000000000
553 # 0.2941249355D+01 -0.9996722919D-01 0.1559162750D+00
554 # 0.6834830964D+00 0.3995128261D+00 0.6076837186D+00
555 # 0.2222899159D+00 0.7001154689D+00 0.3919573931D+00
556 # ****
557 # 2 0
558 # S 3 1.00 0.000000000000
559 # 0.7161683735D+02 0.1543289673D+00
560 # ...
561 #
562 # The same is also printed when the gfprint keyword is used, but the
563 # interstitial lines differ and there are no stars between atoms:
564 #
565 # AO basis set (Overlap normalization):
566 # Atom C1 Shell 1 S 3 bf 1 - 1 0.509245180608 -2.664678875191 0.000000000000
567 # 0.7161683735D+02 0.1543289673D+00
568 # 0.1304509632D+02 0.5353281423D+00
569 # 0.3530512160D+01 0.4446345422D+00
570 # Atom C1 Shell 2 SP 3 bf 2 - 5 0.509245180608 -2.664678875191 0.000000000000
571 # 0.2941249355D+01 -0.9996722919D-01 0.1559162750D+00
572 # ...
573
574 #ONIOM calculations result basis sets reported for atoms that are not in order of atom number which breaks this code (line 390 relies on atoms coming in order)
575 if line[1:13] == "AO basis set" and not self.oniom:
576
577 self.gbasis = []
578
579 # For counterpoise fragment calcualtions, skip these lines.
580 if self.counterpoise != 0:
581 return
582
583 atom_line = inputfile.next()
584 self.gfprint = atom_line.split()[0] == "Atom"
585 self.gfinput = not self.gfprint
586
587 # Note how the shell information is on a separate line for gfinput,
588 # whereas for gfprint it is on the same line as atom information.
589 if self.gfinput:
590 shell_line = inputfile.next()
591
592 shell = []
593 while len(self.gbasis) < self.natom:
594
595 if self.gfprint:
596 cols = atom_line.split()
597 subshells = cols[4]
598 ngauss = int(cols[5])
599 else:
600 cols = shell_line.split()
601 subshells = cols[0]
602 ngauss = int(cols[1])
603
604 parameters = []
605 for ig in range(ngauss):
606 line = inputfile.next()
607 parameters.append(list(map(self.float, line.split())))
608 for iss, ss in enumerate(subshells):
609 contractions = []
610 for param in parameters:
611 exponent = param[0]
612 coefficient = param[iss+1]
613 contractions.append((exponent, coefficient))
614 subshell = (ss, contractions)
615 shell.append(subshell)
616
617 if self.gfprint:
618 line = inputfile.next()
619 if line.split()[0] == "Atom":
620 atomnum = int(re.sub(r"\D", "", line.split()[1]))
621 if atomnum == len(self.gbasis) + 2:
622 self.gbasis.append(shell)
623 shell = []
624 atom_line = line
625 else:
626 self.gbasis.append(shell)
627 else:
628 line = inputfile.next()
629 if line.strip() == "****":
630 self.gbasis.append(shell)
631 shell = []
632 atom_line = inputfile.next()
633 shell_line = inputfile.next()
634 else:
635 shell_line = line
636
637 # Find the targets for SCF convergence (QM calcs).
638 # Not for BOMD as targets are not available in the summary
639 if not self.BOMD and line[1:44] == 'Requested convergence on RMS density matrix':
640
641 if not hasattr(self, "scftargets"):
642 self.scftargets = []
643 # The following can happen with ONIOM which are mixed SCF
644 # and semi-empirical
645 if type(self.scftargets) == type(numpy.array([])):
646 self.scftargets = []
647
648 scftargets = []
649 # The RMS density matrix.
650 scftargets.append(self.float(line.split('=')[1].split()[0]))
651 line = next(inputfile)
652 # The MAX density matrix.
653 scftargets.append(self.float(line.strip().split('=')[1][:-1]))
654 line = next(inputfile)
655 # For G03, there's also the energy (not for G98).
656 if line[1:10] == "Requested":
657 scftargets.append(self.float(line.strip().split('=')[1][:-1]))
658
659 self.scftargets.append(scftargets)
660
661 # Extract SCF convergence information (QM calcs).
662 if line[1:10] == 'Cycle 1':
663
664 if not hasattr(self, "scfvalues"):
665 self.scfvalues = []
666
667 scfvalues = []
668 line = next(inputfile)
669 while line.find("SCF Done") == -1:
670
671 self.updateprogress(inputfile, "QM convergence", self.fupdate)
672
673 if line.find(' E=') == 0:
674 self.logger.debug(line)
675
676 # RMSDP=3.74D-06 MaxDP=7.27D-05 DE=-1.73D-07 OVMax= 3.67D-05
677 # or
678 # RMSDP=1.13D-05 MaxDP=1.08D-04 OVMax= 1.66D-04
679 if line.find(" RMSDP") == 0:
680
681 # Fields of interest:
682 # RMSDP
683 # MaxDP
684 # (DE) -> Only add the energy if it's a target criteria
685
686 matches = self.re_scinot.findall(line)
687 matches = {
688 match[0]: self.float(match[1])
689 for match in matches
690 }
691 scfvalues_step = [
692 matches.get('RMSDP', numpy.nan),
693 matches.get('MaxDP', numpy.nan)
694 ]
695 if len(self.scftargets[0]) == 3:
696 scfvalues_step.append(matches.get('DE', numpy.nan))
697 scfvalues.append(scfvalues_step)
698
699 try:
700 line = next(inputfile)
701 # May be interupted by EOF.
702 except StopIteration:
703 self.logger.warning('File terminated before end of last SCF!')
704 break
705
706 self.scfvalues.append(scfvalues)
707
708 # Extract SCF convergence information (AM1, INDO and other semi-empirical calcs).
709 # The output (for AM1) looks like this:
710 # Ext34=T Pulay=F Camp-King=F BShift= 0.00D+00
711 # It= 1 PL= 0.103D+01 DiagD=T ESCF= 31.564733 Diff= 0.272D+02 RMSDP= 0.152D+00.
712 # It= 2 PL= 0.114D+00 DiagD=T ESCF= 7.265370 Diff=-0.243D+02 RMSDP= 0.589D-02.
713 # ...
714 # It= 11 PL= 0.184D-04 DiagD=F ESCF= 4.687669 Diff= 0.260D-05 RMSDP= 0.134D-05.
715 # It= 12 PL= 0.105D-04 DiagD=F ESCF= 4.687669 Diff=-0.686D-07 RMSDP= 0.215D-05.
716 # 4-point extrapolation.
717 # It= 13 PL= 0.110D-05 DiagD=F ESCF= 4.687669 Diff=-0.111D-06 RMSDP= 0.653D-07.
718 # Energy= 0.172272018655 NIter= 14.
719 if line[1:4] == 'It=':
720
721 scftargets = numpy.array([1E-7], "d") # This is the target value for the rms
722 scfvalues = [[]]
723
724 while line.find(" Energy") == -1:
725
726 self.updateprogress(inputfile, "AM1 Convergence")
727
728 if line[1:4] == "It=":
729 parts = line.strip().split()
730 scfvalues[0].append(self.float(parts[-1][:-1]))
731
732 line = next(inputfile)
733
734 # If an AM1 or INDO guess is used (Guess=INDO in the input, for example),
735 # this will be printed after a single iteration, so that is the line
736 # that should trigger a break from this loop. At least that's what we see
737 # for regression Gaussian/Gaussian09/guessIndo_modified_ALT.out
738 if line[:14] == " Initial guess":
739 break
740
741 # Attach the attributes to the object Only after the energy is found .
742 if line.find(" Energy") == 0:
743 self.scftargets = scftargets
744 self.scfvalues = scfvalues
745
746 # Note: this needs to follow the section where 'SCF Done' is used
747 # to terminate a loop when extracting SCF convergence information.
748 if not self.BOMD and line[1:9] == 'SCF Done':
749
750 t1 = line.split()[2]
751 if t1 == 'E(RHF)':
752 self.metadata["methods"].append("HF")
753 else:
754 self.metadata["methods"].append("DFT")
755 self.metadata["functional"] = t1[t1.index("(") + 2:t1.rindex(")")]
756
757 if not hasattr(self, "scfenergies"):
758 self.scfenergies = []
759
760 self.scfenergies.append(utils.convertor(self.float(line.split()[4]), "hartree", "eV"))
761 # gmagoon 5/27/09: added scfenergies reading for PM3 case
762 # Example line: " Energy= -0.077520562724 NIter= 14."
763 # See regression Gaussian03/QVGXLLKOCUKJST-UHFFFAOYAJmult3Fixed.out
764 if line[1:8] == 'Energy=':
765 if not hasattr(self, "scfenergies"):
766 self.scfenergies = []
767 self.scfenergies.append(utils.convertor(self.float(line.split()[1]), "hartree", "eV"))
768
769 # Total energies after Moller-Plesset corrections.
770 # Second order correction is always first, so its first occurance
771 # triggers creation of mpenergies (list of lists of energies).
772 # Further MP2 corrections are appended as found.
773 #
774 # Example MP2 output line:
775 # E2 = -0.9505918144D+00 EUMP2 = -0.28670924198852D+03
776 # Warning! this output line is subtly different for MP3/4/5 runs
777 if "EUMP2" in line[27:34]:
778 self.metadata["methods"].append("MP2")
779
780 if not hasattr(self, "mpenergies"):
781 self.mpenergies = []
782 self.mpenergies.append([])
783 mp2energy = self.float(line.split("=")[2])
784 self.mpenergies[-1].append(utils.convertor(mp2energy, "hartree", "eV"))
785
786 # Example MP3 output line:
787 # E3= -0.10518801D-01 EUMP3= -0.75012800924D+02
788 if line[34:39] == "EUMP3":
789 self.metadata["methods"].append("MP3")
790
791 mp3energy = self.float(line.split("=")[2])
792 self.mpenergies[-1].append(utils.convertor(mp3energy, "hartree", "eV"))
793
794 # Example MP4 output lines:
795 # E4(DQ)= -0.31002157D-02 UMP4(DQ)= -0.75015901139D+02
796 # E4(SDQ)= -0.32127241D-02 UMP4(SDQ)= -0.75016013648D+02
797 # E4(SDTQ)= -0.32671209D-02 UMP4(SDTQ)= -0.75016068045D+02
798 # Energy for most substitutions is used only (SDTQ by default)
799 if line[34:42] == "UMP4(DQ)":
800 self.metadata["methods"].append("MP4")
801
802 mp4energy = self.float(line.split("=")[2])
803 line = next(inputfile)
804 if line[34:43] == "UMP4(SDQ)":
805 mp4energy = self.float(line.split("=")[2])
806 line = next(inputfile)
807 if line[34:44] == "UMP4(SDTQ)":
808 mp4energy = self.float(line.split("=")[2])
809 self.mpenergies[-1].append(utils.convertor(mp4energy, "hartree", "eV"))
810
811 # Example MP5 output line:
812 # DEMP5 = -0.11048812312D-02 MP5 = -0.75017172926D+02
813 if line[29:32] == "MP5":
814 self.metadata["methods"].append("MP5")
815 mp5energy = self.float(line.split("=")[2])
816 self.mpenergies[-1].append(utils.convertor(mp5energy, "hartree", "eV"))
817
818 # Total energies after Coupled Cluster corrections.
819 # Second order MBPT energies (MP2) are also calculated for these runs,
820 # but the output is the same as when parsing for mpenergies.
821 # Read the consecutive correlated energies
822 # but append only the last one to ccenergies.
823 # Only the highest level energy is appended - ex. CCSD(T), not CCSD.
824 if line[1:10] == "DE(Corr)=" and line[27:35] == "E(CORR)=":
825 self.metadata["methods"].append("CCSD")
826 self.ccenergy = self.float(line.split()[3])
827 if line[1:10] == "T5(CCSD)=":
828 line = next(inputfile)
829 if line[1:9] == "CCSD(T)=":
830 self.metadata["methods"].append("CCSD-T")
831 self.ccenergy = self.float(line.split()[1])
832 if line[12:53] == "Population analysis using the SCF density":
833 if hasattr(self, "ccenergy"):
834 if not hasattr(self, "ccenergies"):
835 self.ccenergies = []
836 self.ccenergies.append(utils.convertor(self.ccenergy, "hartree", "eV"))
837 del self.ccenergy
838 # Find step number for current optimization/IRC
839 # Matches "Step number 123", "Pt XX Step number 123" and "PtXXX Step number 123"
840 if " Step number" in line:
841 step = int(line.split()[line.split().index('Step') + 2])
842 if not hasattr(self, "optstatus"):
843 self.optstatus = []
844 self.optstatus.append(data.ccData.OPT_UNKNOWN)
845 if step == 1:
846 self.optstatus[-1] += data.ccData.OPT_NEW
847
848 # Geometry convergence information.
849 if line[49:59] == 'Converged?':
850
851 if not hasattr(self, "geotargets"):
852 self.geovalues = []
853 self.geotargets = numpy.array([0.0, 0.0, 0.0, 0.0], "d")
854
855 newlist = [0]*4
856 for i in range(4):
857 line = next(inputfile)
858 self.logger.debug(line)
859 parts = line.split()
860 try:
861 value = self.float(parts[2])
862 except ValueError:
863 self.logger.error("Problem parsing the value for geometry optimisation: %s is not a number." % parts[2])
864 else:
865 newlist[i] = value
866 self.geotargets[i] = self.float(parts[3])
867
868 self.geovalues.append(newlist)
869
870 # Gradients.
871 # Read in the cartesian energy gradients (forces) from a block like this:
872 # -------------------------------------------------------------------
873 # Center Atomic Forces (Hartrees/Bohr)
874 # Number Number X Y Z
875 # -------------------------------------------------------------------
876 # 1 1 -0.012534744 -0.021754635 -0.008346094
877 # 2 6 0.018984731 0.032948887 -0.038003451
878 # 3 1 -0.002133484 -0.006226040 0.023174772
879 # 4 1 -0.004316502 -0.004968213 0.023174772
880 # -2 -0.001830728 -0.000743108 -0.000196625
881 # ------------------------------------------------------------------
882 #
883 # The "-2" line is for a dummy atom
884 #
885 # Then optimization is done in internal coordinates, Gaussian also
886 # print the forces in internal coordinates, which can be produced from
887 # the above. This block looks like this:
888 # Variable Old X -DE/DX Delta X Delta X Delta X New X
889 # (Linear) (Quad) (Total)
890 # ch 2.05980 0.01260 0.00000 0.01134 0.01134 2.07114
891 # hch 1.75406 0.09547 0.00000 0.24861 0.24861 2.00267
892 # hchh 2.09614 0.01261 0.00000 0.16875 0.16875 2.26489
893 # Item Value Threshold Converged?
894
895 # We could get the gradients in BOMD, but it is more complex because
896 # they are not in the summary, and they are not as relevant as for
897 # an optimization
898 if not self.BOMD and line[37:43] == "Forces":
899
900 if not hasattr(self, "grads"):
901 self.grads = []
902
903 self.skip_lines(inputfile, ['header', 'd'])
904
905 forces = []
906 line = next(inputfile)
907 while list(set(line.strip())) != ['-']:
908 tmpforces = []
909 for N in range(3): # Fx, Fy, Fz
910 force = line[23+N*15:38+N*15]
911 if force.startswith("*"):
912 force = "NaN"
913 tmpforces.append(float(force))
914 forces.append(tmpforces)
915 line = next(inputfile)
916 self.grads.append(forces)
917
918 #Extract PES scan data
919 #Summary of the potential surface scan:
920 # N A SCF
921 #---- --------- -----------
922 # 1 109.0000 -76.43373
923 # 2 119.0000 -76.43011
924 # 3 129.0000 -76.42311
925 # 4 139.0000 -76.41398
926 # 5 149.0000 -76.40420
927 # 6 159.0000 -76.39541
928 # 7 169.0000 -76.38916
929 # 8 179.0000 -76.38664
930 # 9 189.0000 -76.38833
931 # 10 199.0000 -76.39391
932 # 11 209.0000 -76.40231
933 #---- --------- -----------
934 if "Summary of the potential surface scan:" in line:
935
936 scanenergies = []
937 scanparm = []
938 colmnames = next(inputfile)
939 hyphens = next(inputfile)
940 line = next(inputfile)
941 while line != hyphens:
942 broken = line.split()
943 scanenergies.append(float(broken[-1]))
944 scanparm.append(map(float, broken[1:-1]))
945 line = next(inputfile)
946 if not hasattr(self, "scanenergies"):
947 self.scanenergies = []
948 self.scanenergies = scanenergies
949 if not hasattr(self, "scanparm"):
950 self.scanparm = []
951 self.scanparm = scanparm
952 if not hasattr(self, "scannames"):
953 self.scannames = colmnames.split()[1:-1]
954
955 # Orbital symmetries.
956 if line[1:20] == 'Orbital symmetries:' and not hasattr(self, "mosyms"):
957
958 # For counterpoise fragments, skip these lines.
959 if self.counterpoise != 0:
960 return
961
962 self.updateprogress(inputfile, "MO Symmetries", self.fupdate)
963
964 self.mosyms = [[]]
965 line = next(inputfile)
966 unres = False
967 if line.find("Alpha Orbitals") == 1:
968 unres = True
969 line = next(inputfile)
970 i = 0
971 while len(line) > 18 and line[17] == '(':
972 if line.find('Virtual') >= 0:
973 self.homos = [i - 1]
974 parts = line[17:].split()
975 for x in parts:
976 self.mosyms[0].append(self.normalisesym(x.strip('()')))
977 i += 1
978 line = next(inputfile)
979 if unres:
980 line = next(inputfile)
981 # Repeat with beta orbital information
982 i = 0
983 self.mosyms.append([])
984 while len(line) > 18 and line[17] == '(':
985 if line.find('Virtual') >= 0:
986 # Here we consider beta
987 # If there was also an alpha virtual orbital,
988 # we will store two indices in the array
989 # Otherwise there is no alpha virtual orbital,
990 # only beta virtual orbitals, and we initialize
991 # the array with one element. See the regression
992 # QVGXLLKOCUKJST-UHFFFAOYAJmult3Fixed.out
993 # donated by Gregory Magoon (gmagoon).
994 if (hasattr(self, "homos")):
995 # Extend the array to two elements
996 # 'HOMO' indexes the HOMO in the arrays
997 self.homos.append(i-1)
998 else:
999 # 'HOMO' indexes the HOMO in the arrays
1000 self.homos = [i - 1]
1001 parts = line[17:].split()
1002 for x in parts:
1003 self.mosyms[1].append(self.normalisesym(x.strip('()')))
1004 i += 1
1005 line = next(inputfile)
1006
1007 # Some calculations won't explicitely print the number of basis sets used,
1008 # and will occasionally drop some without warning. We can infer the number,
1009 # however, from the MO symmetries printed here. Specifically, this fixes
1010 # regression Gaussian/Gaussian09/dvb_sp_terse.log (#23 on github).
1011 self.set_attribute('nmo', len(self.mosyms[-1]))
1012
1013 # Alpha/Beta electron eigenvalues.
1014 if line[1:6] == "Alpha" and line.find("eigenvalues") >= 0:
1015
1016 # For counterpoise fragments, skip these lines.
1017 if self.counterpoise != 0:
1018 return
1019
1020 # For ONIOM calcs, ignore this section in order to bypass assertion failure.
1021 if self.oniom:
1022 return
1023
1024 self.updateprogress(inputfile, "Eigenvalues", self.fupdate)
1025 self.moenergies = [[]]
1026 HOMO = -2
1027
1028 while line.find('Alpha') == 1:
1029 if line.split()[1] == "virt." and HOMO == -2:
1030
1031 # If there aren't any symmetries, this is a good way to find the HOMO.
1032 HOMO = len(self.moenergies[0])-1
1033 self.homos = [HOMO]
1034
1035 # Convert to floats and append to moenergies, but sometimes Gaussian
1036 # doesn't print correctly so test for ValueError (bug 1756789).
1037 part = line[28:]
1038 i = 0
1039 while i*10+4 < len(part):
1040 s = part[i*10:(i+1)*10]
1041 try:
1042 x = self.float(s)
1043 except ValueError:
1044 x = numpy.nan
1045 self.moenergies[0].append(utils.convertor(x, "hartree", "eV"))
1046 i += 1
1047 line = next(inputfile)
1048
1049 # If, at this point, self.homos is unset, then there were not
1050 # any alpha virtual orbitals
1051 if not hasattr(self, "homos"):
1052 HOMO = len(self.moenergies[0])-1
1053 self.homos = [HOMO]
1054
1055 if line.find('Beta') == 2:
1056 self.moenergies.append([])
1057
1058 HOMO = -2
1059 while line.find('Beta') == 2:
1060 if line.split()[1] == "virt." and HOMO == -2:
1061
1062 # If there aren't any symmetries, this is a good way to find the HOMO.
1063 # Also, check for consistency if homos was already parsed.
1064 HOMO = len(self.moenergies[1])-1
1065 self.homos.append(HOMO)
1066
1067 part = line[28:]
1068 i = 0
1069 while i*10+4 < len(part):
1070 x = part[i*10:(i+1)*10]
1071 self.moenergies[1].append(utils.convertor(self.float(x), "hartree", "eV"))
1072 i += 1
1073 line = next(inputfile)
1074
1075 self.moenergies = [numpy.array(x, "d") for x in self.moenergies]
1076
1077 # Start of the IR/Raman frequency section.
1078 # Caution is advised here, as additional frequency blocks
1079 # can be printed by Gaussian (with slightly different formats),
1080 # often doubling the information printed.
1081 # See, for a non-standard exmaple, regression Gaussian98/test_H2.log
1082 # If either the Gaussian freq=hpmodes keyword or IOP(7/33=1) is used,
1083 # an extra frequency block with higher-precision vibdisps is
1084 # printed before the normal frequency block.
1085 # Note that the code parses only the vibsyms and vibdisps
1086 # from the high-precision block, but parses vibsyms, vibfreqs,
1087 # vibramans and vibirs from the normal block. vibsyms parsed
1088 # from the high-precision block are discarded and replaced by those
1089 # from the normal block while the high-precision vibdisps, if present,
1090 # are used to overwrite default-precision vibdisps at the end of the parse.
1091 if line[1:14] == "Harmonic freq": # This matches in both freq block types
1092
1093 self.updateprogress(inputfile, "Frequency Information", self.fupdate)
1094
1095 # The whole block should not have any blank lines.
1096 while line.strip() != "":
1097
1098 # The line with indices
1099 if line[1:15].strip() == "" and line[15:60].split()[0].isdigit():
1100 freqbase = int(line[15:60].split()[0])
1101 if freqbase == 1 and hasattr(self, 'vibsyms'):
1102 # we are coming accross duplicated information.
1103 # We might be be parsing a default-precision block having
1104 # already parsed (only) vibsyms and displacements from
1105 # the high-precision block, or might be encountering
1106 # a second low-precision block (see e.g. 25DMF_HRANH.log
1107 # regression).
1108 self.vibsyms = []
1109 if hasattr(self, "vibirs"):
1110 self.vibirs = []
1111 if hasattr(self, 'vibfreqs'):
1112 self.vibfreqs = []
1113 if hasattr(self, 'vibramans'):
1114 self.vibramans = []
1115 if hasattr(self, 'vibdisps'):
1116 self.vibdisps = []
1117
1118 # Lines with symmetries and symm. indices begin with whitespace.
1119 if line[1:15].strip() == "" and not line[15:60].split()[0].isdigit():
1120
1121 if not hasattr(self, 'vibsyms'):
1122 self.vibsyms = []
1123 syms = line.split()
1124 self.vibsyms.extend(syms)
1125
1126 if line[1:15] == "Frequencies --": # note: matches low-precision block, and
1127
1128 if not hasattr(self, 'vibfreqs'):
1129 self.vibfreqs = []
1130
1131 freqs = [self.float(f) for f in line[15:].split()]
1132 self.vibfreqs.extend(freqs)
1133
1134 if line[1:15] == "IR Inten --": # note: matches only low-precision block
1135
1136 if not hasattr(self, 'vibirs'):
1137 self.vibirs = []
1138
1139 irs = []
1140 for ir in line[15:].split():
1141 try:
1142 irs.append(self.float(ir))
1143 except ValueError:
1144 irs.append(self.float('nan'))
1145 self.vibirs.extend(irs)
1146
1147 if line[1:15] == "Raman Activ --": # note: matches only low-precision block
1148
1149 if not hasattr(self, 'vibramans'):
1150 self.vibramans = []
1151
1152 ramans = []
1153 for raman in line[15:].split():
1154 try:
1155 ramans.append(self.float(raman))
1156 except ValueError:
1157 ramans.append(self.float('nan'))
1158
1159 self.vibramans.extend(ramans)
1160
1161 # Block with (default-precision) displacements should start with this.
1162 # 1 2 3
1163 # A A A
1164 # Frequencies -- 370.7936 370.7987 618.0103
1165 # Red. masses -- 2.3022 2.3023 1.9355
1166 # Frc consts -- 0.1865 0.1865 0.4355
1167 # IR Inten -- 0.0000 0.0000 0.0000
1168 # Atom AN X Y Z X Y Z X Y Z
1169 # 1 6 0.00 0.00 -0.04 0.00 0.00 0.19 0.00 0.00 0.12
1170 # 2 6 0.00 0.00 0.19 0.00 0.00 -0.06 0.00 0.00 -0.12
1171
1172 if line.strip().split()[0:3] == ["Atom", "AN", "X"]:
1173 if not hasattr(self, 'vibdisps'):
1174 self.vibdisps = []
1175 disps = []
1176 for n in range(self.natom):
1177 line = next(inputfile)
1178 numbers = [float(s) for s in line[10:].split()]
1179 N = len(numbers) // 3
1180 if not disps:
1181 for n in range(N):
1182 disps.append([])
1183 for n in range(N):
1184 disps[n].append(numbers[3*n:3*n+3])
1185 self.vibdisps.extend(disps)
1186
1187 # Block with high-precision (freq=hpmodes) displacements should start with this.
1188 # 1 2 3 4 5
1189 # A A A A A
1190 # Frequencies --- 370.7936 370.7987 618.0103 647.7864 647.7895
1191 # Reduced masses --- 2.3022 2.3023 1.9355 6.4600 6.4600
1192 # Force constants --- 0.1865 0.1865 0.4355 1.5971 1.5972
1193 # IR Intensities --- 0.0000 0.0000 0.0000 0.0000 0.0000
1194 # Coord Atom Element:
1195 # 1 1 6 0.00000 0.00000 0.00000 -0.18677 0.05592
1196 # 2 1 6 0.00000 0.00000 0.00000 0.28440 0.21550
1197 # 3 1 6 -0.04497 0.19296 0.11859 0.00000 0.00000
1198 # 1 2 6 0.00000 0.00000 0.00000 0.03243 0.37351
1199 # 2 2 6 0.00000 0.00000 0.00000 0.14503 -0.06117
1200 # 3 2 6 0.18959 -0.05753 -0.11859 0.00000 0.00000
1201 if line.strip().split()[0:3] == ["Coord", "Atom", "Element:"]:
1202 # Wait until very end of parsing to assign vibdispshp to self.vibdisps
1203 # as otherwise the higher precision displacements will be overwritten
1204 # by low precision displacements which are printed further down file
1205 if not hasattr(self, 'vibdispshp'):
1206 self.vibdispshp = []
1207
1208 disps = []
1209 for n in range(3*self.natom):
1210 line = next(inputfile)
1211 numbers = [float(s) for s in line[16:].split()]
1212 atomindex = int(line[4:10])-1 # atom index, starting at zero
1213 numbermodes = len(numbers)
1214
1215 if not disps:
1216 for mode in range(numbermodes):
1217 # For each mode, make list of list [atom][coord_index]
1218 disps.append([[] for x in range(0, self.natom)])
1219 for mode in range(numbermodes):
1220 disps[mode][atomindex].append(numbers[mode])
1221 self.vibdispshp.extend(disps)
1222
1223 line = next(inputfile)
1224
1225 # Electronic transitions.
1226 if line[1:14] == "Excited State":
1227
1228 if not hasattr(self, "etenergies"):
1229 self.etenergies = []
1230 self.etoscs = []
1231 self.etsyms = []
1232 self.etsecs = []
1233
1234 # Need to deal with lines like:
1235 # (restricted calc)
1236 # Excited State 1: Singlet-BU 5.3351 eV 232.39 nm f=0.1695
1237 # (unrestricted calc) (first excited state is 2!)
1238 # Excited State 2: ?Spin -A 0.1222 eV 10148.75 nm f=0.0000
1239 # (Gaussian 09 ZINDO)
1240 # Excited State 1: Singlet-?Sym 2.5938 eV 478.01 nm f=0.0000 <S**2>=0.000
1241 p = re.compile(":(?P<sym>.*?)(?P<energy>-?\d*\.\d*) eV")
1242 groups = p.search(line).groups()
1243 self.etenergies.append(utils.convertor(self.float(groups[1]), "eV", "wavenumber"))
1244 self.etoscs.append(self.float(line.split("f=")[-1].split()[0]))
1245 self.etsyms.append(groups[0].strip())
1246
1247 line = next(inputfile)
1248
1249 p = re.compile("(\d+)")
1250 CIScontrib = []
1251 while line.find(" ->") >= 0: # This is a contribution to the transition
1252 parts = line.split("->")
1253 self.logger.debug(parts)
1254 # Has to deal with lines like:
1255 # 32 -> 38 0.04990
1256 # 35A -> 45A 0.01921
1257 frommoindex = 0 # For restricted or alpha unrestricted
1258 fromMO = parts[0].strip()
1259 if fromMO[-1] == "B":
1260 frommoindex = 1 # For beta unrestricted
1261 fromMO = int(p.match(fromMO).group())-1 # subtract 1 so that it is an index into moenergies
1262
1263 t = parts[1].split()
1264 tomoindex = 0
1265 toMO = t[0]
1266 if toMO[-1] == "B":
1267 tomoindex = 1
1268 toMO = int(p.match(toMO).group())-1 # subtract 1 so that it is an index into moenergies
1269
1270 percent = self.float(t[1])
1271 # For restricted calculations, the percentage will be corrected
1272 # after parsing (see after_parsing() above).
1273 CIScontrib.append([(fromMO, frommoindex), (toMO, tomoindex), percent])
1274 line = next(inputfile)
1275 self.etsecs.append(CIScontrib)
1276
1277 # Circular dichroism data (different for G03 vs G09)
1278 #
1279 # G03
1280 #
1281 # ## <0|r|b> * <b|rxdel|0> (Au), Rotatory Strengths (R) in
1282 # ## cgs (10**-40 erg-esu-cm/Gauss)
1283 # ## state X Y Z R(length)
1284 # ## 1 0.0006 0.0096 -0.0082 -0.4568
1285 # ## 2 0.0251 -0.0025 0.0002 -5.3846
1286 # ## 3 0.0168 0.4204 -0.3707 -15.6580
1287 # ## 4 0.0721 0.9196 -0.9775 -3.3553
1288 #
1289 # G09
1290 #
1291 # ## 1/2[<0|r|b>*<b|rxdel|0> + (<0|rxdel|b>*<b|r|0>)*]
1292 # ## Rotatory Strengths (R) in cgs (10**-40 erg-esu-cm/Gauss)
1293 # ## state XX YY ZZ R(length) R(au)
1294 # ## 1 -0.3893 -6.7546 5.7736 -0.4568 -0.0010
1295 # ## 2 -17.7437 1.7335 -0.1435 -5.3845 -0.0114
1296 # ## 3 -11.8655 -297.2604 262.1519 -15.6580 -0.0332
1297 if line[1:52] == "<0|r|b> * <b|rxdel|0> (Au), Rotatory Strengths (R)" or \
1298 line[1:50] == "1/2[<0|r|b>*<b|rxdel|0> + (<0|rxdel|b>*<b|r|0>)*]":
1299
1300 self.etrotats = []
1301
1302 self.skip_lines(inputfile, ['units'])
1303
1304 headers = next(inputfile)
1305 Ncolms = len(headers.split())
1306 line = next(inputfile)
1307 parts = line.strip().split()
1308 while len(parts) == Ncolms:
1309 try:
1310 R = self.float(parts[4])
1311 except ValueError:
1312 # nan or -nan if there is no first excited state
1313 # (for unrestricted calculations)
1314 pass
1315 else:
1316 self.etrotats.append(R)
1317 line = next(inputfile)
1318 temp = line.strip().split()
1319 parts = line.strip().split()
1320 self.etrotats = numpy.array(self.etrotats, "d")
1321
1322 # Number of basis sets functions.
1323 # Has to deal with lines like:
1324 # NBasis = 434 NAE= 97 NBE= 97 NFC= 34 NFV= 0
1325 # and...
1326 # NBasis = 148 MinDer = 0 MaxDer = 0
1327 # Although the former is in every file, it doesn't occur before
1328 # the overlap matrix is printed.
1329 if line[1:7] == "NBasis" or line[4:10] == "NBasis":
1330
1331 # For counterpoise fragment, skip these lines.
1332 if self.counterpoise != 0:
1333 return
1334
1335 # For ONIOM calcs, ignore this section in order to bypass assertion failure.
1336 if self.oniom:
1337 return
1338
1339 # If nbasis was already parsed, check if it changed. If it did, issue a warning.
1340 # In the future, we will probably want to have nbasis, as well as nmo below,
1341 # as a list so that we don't need to pick one value when it changes.
1342 nbasis = int(line.split('=')[1].split()[0])
1343 if hasattr(self, "nbasis"):
1344 try:
1345 assert nbasis == self.nbasis
1346 except AssertionError:
1347 self.logger.warning("Number of basis functions (nbasis) has changed from %i to %i" % (self.nbasis, nbasis))
1348 self.nbasis = nbasis
1349
1350 # Number of linearly-independent basis sets.
1351 if line[1:7] == "NBsUse":
1352
1353 # For counterpoise fragment, skip these lines.
1354 if self.counterpoise != 0:
1355 return
1356
1357 # For ONIOM calcs, ignore this section in order to bypass assertion failure.
1358 if self.oniom:
1359 return
1360
1361 nmo = int(line.split('=')[1].split()[0])
1362 self.set_attribute('nmo', nmo)
1363
1364 # For AM1 calculations, set nbasis by a second method,
1365 # as nmo may not always be explicitly stated.
1366 if line[7:22] == "basis functions, ":
1367
1368 nbasis = int(line.split()[0])
1369 self.set_attribute('nbasis', nbasis)
1370
1371 # Molecular orbital overlap matrix.
1372 # Has to deal with lines such as:
1373 # *** Overlap ***
1374 # ****** Overlap ******
1375 # Note that Gaussian sometimes drops basis functions,
1376 # causing the overlap matrix as parsed below to not be
1377 # symmetric (which is a problem for population analyses, etc.)
1378 if line[1:4] == "***" and (line[5:12] == "Overlap" or line[8:15] == "Overlap"):
1379
1380 # Ensure that this is the main calc and not a fragment
1381 if self.counterpoise != 0:
1382 return
1383
1384 self.aooverlaps = numpy.zeros((self.nbasis, self.nbasis), "d")
1385 # Overlap integrals for basis fn#1 are in aooverlaps[0]
1386 base = 0
1387 colmNames = next(inputfile)
1388 while base < self.nbasis:
1389
1390 self.updateprogress(inputfile, "Overlap", self.fupdate)
1391
1392 for i in range(self.nbasis-base): # Fewer lines this time
1393 line = next(inputfile)
1394 parts = line.split()
1395 for j in range(len(parts)-1): # Some lines are longer than others
1396 k = float(parts[j+1].replace("D", "E"))
1397 self.aooverlaps[base+j, i+base] = k
1398 self.aooverlaps[i+base, base+j] = k
1399 base += 5
1400 colmNames = next(inputfile)
1401 self.aooverlaps = numpy.array(self.aooverlaps, "d")
1402
1403 # Molecular orbital coefficients (mocoeffs).
1404 # Essentially only produced for SCF calculations.
1405 # This is also the place where aonames and atombasis are parsed.
1406 if line[5:35] == "Molecular Orbital Coefficients" or line[5:41] == "Alpha Molecular Orbital Coefficients" or line[5:40] == "Beta Molecular Orbital Coefficients":
1407
1408 # If counterpoise fragment, return without parsing orbital info
1409 if self.counterpoise != 0:
1410 return
1411 # Skip this for ONIOM calcs
1412 if self.oniom:
1413 return
1414
1415 if line[5:40] == "Beta Molecular Orbital Coefficients":
1416 beta = True
1417 if self.popregular:
1418 return
1419 # This was continue before refactoring the parsers.
1420 #continue # Not going to extract mocoeffs
1421 # Need to add an extra array to self.mocoeffs
1422 self.mocoeffs.append(numpy.zeros((self.nmo, self.nbasis), "d"))
1423 else:
1424 beta = False
1425 self.aonames = []
1426 self.atombasis = []
1427 mocoeffs = [numpy.zeros((self.nmo, self.nbasis), "d")]
1428
1429 base = 0
1430 self.popregular = False
1431 for base in range(0, self.nmo, 5):
1432
1433 self.updateprogress(inputfile, "Coefficients", self.fupdate)
1434
1435 colmNames = next(inputfile)
1436
1437 if not colmNames.split():
1438 self.logger.warning("Molecular coefficients header found but no coefficients.")
1439 break
1440
1441 if base == 0 and int(colmNames.split()[0]) != 1:
1442 # Implies that this is a POP=REGULAR calculation
1443 # and so, only aonames (not mocoeffs) will be extracted
1444 self.popregular = True
1445 symmetries = next(inputfile)
1446 eigenvalues = next(inputfile)
1447 for i in range(self.nbasis):
1448
1449 line = next(inputfile)
1450 if i == 0:
1451 # Find location of the start of the basis function name
1452 start_of_basis_fn_name = line.find(line.split()[3]) - 1
1453 if base == 0 and not beta: # Just do this the first time 'round
1454 parts = line[:start_of_basis_fn_name].split()
1455 if len(parts) > 1: # New atom
1456 if i > 0:
1457 self.atombasis.append(atombasis)
1458 atombasis = []
1459 atomname = "%s%s" % (parts[2], parts[1])
1460 orbital = line[start_of_basis_fn_name:20].strip()
1461 self.aonames.append("%s_%s" % (atomname, orbital))
1462 atombasis.append(i)
1463
1464 part = line[21:].replace("D", "E").rstrip()
1465 temp = []
1466 for j in range(0, len(part), 10):
1467 temp.append(float(part[j:j+10]))
1468 if beta:
1469 self.mocoeffs[1][base:base + len(part) // 10, i] = temp
1470 else:
1471 mocoeffs[0][base:base + len(part) // 10, i] = temp
1472
1473 if base == 0 and not beta: # Do the last update of atombasis
1474 self.atombasis.append(atombasis)
1475 if self.popregular:
1476 # We now have aonames, so no need to continue
1477 break
1478 if not self.popregular and not beta:
1479 self.mocoeffs = mocoeffs
1480
1481 # Natural orbital coefficients (nocoeffs) and occupation numbers (nooccnos),
1482 # which are respectively define the eigenvectors and eigenvalues of the
1483 # diagonalized one-electron density matrix. These orbitals are formed after
1484 # configuration interaction (CI) calculations, but not only. Similarly to mocoeffs,
1485 # we can parse and check aonames and atombasis here.
1486 #
1487 # Natural Orbital Coefficients:
1488 # 1 2 3 4 5
1489 # Eigenvalues -- 2.01580 2.00363 2.00000 2.00000 1.00000
1490 # 1 1 O 1S 0.00000 -0.15731 -0.28062 0.97330 0.00000
1491 # 2 2S 0.00000 0.75440 0.57746 0.07245 0.00000
1492 # ...
1493 #
1494 def natural_orbital_single_spin_parsing(inputfile, updateprogress_title):
1495 coeffs = numpy.zeros((self.nmo, self.nbasis), "d")
1496 occnos = []
1497 aonames = []
1498 atombasis = []
1499 for base in range(0, self.nmo, 5):
1500 self.updateprogress(inputfile, updateprogress_title, self.fupdate)
1501 colmNames = next(inputfile)
1502 eigenvalues = next(inputfile)
1503 occnos.extend(map(float, eigenvalues.split()[2:]))
1504 for i in range(self.nbasis):
1505 line = next(inputfile)
1506 # Just do this the first time 'round.
1507 if base == 0:
1508 # Changed below from :12 to :11 to deal with Elmar Neumann's example.
1509 parts = line[:11].split()
1510 # New atom.
1511 if len(parts) > 1:
1512 if i > 0:
1513 atombasis.append(basisonatom)
1514 basisonatom = []
1515 atomname = "%s%s" % (parts[2], parts[1])
1516 orbital = line[11:20].strip()
1517 aonames.append("%s_%s" % (atomname, orbital))
1518 basisonatom.append(i)
1519 part = line[21:].replace("D", "E").rstrip()
1520 temp = []
1521 for j in range(0, len(part), 10):
1522 temp.append(float(part[j:j+10]))
1523 coeffs[base:base + len(part) // 10, i] = temp
1524 # Do the last update of atombasis.
1525 if base == 0:
1526 atombasis.append(basisonatom)
1527 return occnos, coeffs, aonames, atombasis
1528
1529 if line[5:33] == "Natural Orbital Coefficients":
1530 updateprogress_title = "Natural orbitals"
1531 nooccnos, nocoeffs, aonames, atombasis = natural_orbital_single_spin_parsing(inputfile, updateprogress_title)
1532 self.set_attribute("nocoeffs", nocoeffs)
1533 self.set_attribute("nooccnos", nooccnos)
1534 self.set_attribute("atombasis", atombasis)
1535 self.set_attribute("aonames", aonames)
1536
1537 # Natural spin orbital coefficients (nsocoeffs) and occupation numbers (nsooccnos)
1538 # Parsed attributes are similar to the natural orbitals above except
1539 # the natural spin orbitals and occupation numbers are the eigenvalues
1540 # and eigenvectors of the one particles spin density matrices
1541 # Alpha Natural Orbital Coefficients:
1542 # 1 2 3 4 5
1543 # Eigenvalues -- 1.00000 1.00000 0.99615 0.99320 0.99107
1544 # 1 1 O 1S 0.70425 0.70600 -0.16844 -0.14996 -0.00000
1545 # 2 2S 0.01499 0.01209 0.36089 0.34940 -0.00000
1546 # ...
1547 # Beta Natural Orbital Coefficients:
1548 # 1 2 3 4 5
1549 # Eigenvalues -- 1.00000 1.00000 0.99429 0.98790 0.98506
1550 # 1 1 O 1S 0.70822 0.70798 -0.15316 -0.13458 0.00465
1551 # 2 2S 0.00521 0.00532 0.33837 0.33189 -0.01301
1552 # 3 3S -0.02542 -0.00841 0.28649 0.53224 0.18902
1553 # ...
1554
1555 if line[5:39] == "Alpha Natural Orbital Coefficients":
1556 updateprogress_title = "Natural Spin orbitals (alpha)"
1557 nsooccnos, nsocoeffs, aonames, atombasis = natural_orbital_single_spin_parsing(inputfile, updateprogress_title)
1558 if self.unified_no_nso:
1559 self.append_attribute("nocoeffs", nsocoeffs)
1560 self.append_attribute("nooccnos", nsooccnos)
1561 else:
1562 self.append_attribute("nsocoeffs", nsocoeffs)
1563 self.append_attribute("nsooccnos", nsooccnos)
1564 self.set_attribute("atombasis", atombasis)
1565 self.set_attribute("aonames", aonames)
1566 if line[5:38] == "Beta Natural Orbital Coefficients":
1567 updateprogress_title = "Natural Spin orbitals (beta)"
1568 nsooccnos, nsocoeffs, aonames, atombasis = natural_orbital_single_spin_parsing(inputfile, updateprogress_title)
1569 if self.unified_no_nso:
1570 self.append_attribute("nocoeffs", nsocoeffs)
1571 self.append_attribute("nooccnos", nsooccnos)
1572 else:
1573 self.append_attribute("nsocoeffs", nsocoeffs)
1574 self.append_attribute("nsooccnos", nsooccnos)
1575 self.set_attribute("atombasis", atombasis)
1576 self.set_attribute("aonames", aonames)
1577
1578 # For FREQ=Anharm, extract anharmonicity constants
1579 if line[1:40] == "X matrix of Anharmonic Constants (cm-1)":
1580 Nvibs = len(self.vibfreqs)
1581 self.vibanharms = numpy.zeros((Nvibs, Nvibs), "d")
1582
1583 base = 0
1584 colmNames = next(inputfile)
1585 while base < Nvibs:
1586
1587 for i in range(Nvibs-base): # Fewer lines this time
1588 line = next(inputfile)
1589 parts = line.split()
1590 for j in range(len(parts)-1): # Some lines are longer than others
1591 k = float(parts[j+1].replace("D", "E"))
1592 self.vibanharms[base+j, i+base] = k
1593 self.vibanharms[i+base, base+j] = k
1594 base += 5
1595 colmNames = next(inputfile)
1596
1597 # Pseudopotential charges.
1598 if line.find("Pseudopotential Parameters") > -1:
1599
1600 self.skip_lines(inputfile, ['e', 'label1', 'label2', 'e'])
1601
1602 line = next(inputfile)
1603 if line.find("Centers:") < 0:
1604 return
1605 # This was continue before parser refactoring.
1606 # continue
1607
1608 # Needs to handle code like the following:
1609 #
1610 # Center Atomic Valence Angular Power Coordinates
1611 # Number Number Electrons Momentum of R Exponent Coefficient X Y Z
1612 # ===================================================================================================================================
1613 # Centers: 1
1614 # Centers: 16
1615 # Centers: 21 24
1616 # Centers: 99100101102
1617 # 1 44 16 -4.012684 -0.696698 0.006750
1618 # F and up
1619 # 0 554.3796303 -0.05152700
1620 centers = []
1621 while line.find("Centers:") >= 0:
1622 temp = line[10:]
1623 for i in range(0, len(temp)-3, 3):
1624 centers.append(int(temp[i:i+3]))
1625 line = next(inputfile)
1626 centers.sort() # Not always in increasing order
1627
1628 self.coreelectrons = numpy.zeros(self.natom, "i")
1629
1630 for center in centers:
1631 front = line[:10].strip()
1632 while not (front and int(front) == center):
1633 line = next(inputfile)
1634 front = line[:10].strip()
1635 info = line.split()
1636 self.coreelectrons[center-1] = int(info[1]) - int(info[2])
1637 line = next(inputfile)
1638
1639 # This will be printed for counterpoise calcualtions only.
1640 # To prevent crashing, we need to know which fragment is being considered.
1641 # Other information is also printed in lines that start like this.
1642 if line[1:14] == 'Counterpoise:':
1643
1644 if line[42:50] == "fragment":
1645 self.counterpoise = int(line[51:54])
1646
1647 # This will be printed only during ONIOM calcs; use it to set a flag
1648 # that will allow assertion failures to be bypassed in the code.
1649 if line[1:7] == "ONIOM:":
1650 self.oniom = True
1651
1652 # This will be printed only during BOMD calcs;
1653 if line.startswith(" INPUT DATA FOR L118"):
1654 self.BOMD = True
1655
1656 # Atomic charges are straightforward to parse, although the header
1657 # has changed over time somewhat.
1658 #
1659 # Mulliken charges:
1660 # 1
1661 # 1 C -0.004513
1662 # 2 C -0.077156
1663 # ...
1664 # Sum of Mulliken charges = 0.00000
1665 # Mulliken charges with hydrogens summed into heavy atoms:
1666 # 1
1667 # 1 C -0.004513
1668 # 2 C 0.002063
1669 # ...
1670 #
1671 if line[1:25] == "Mulliken atomic charges:" or line[1:18] == "Mulliken charges:" or \
1672 line[1:23] == "Lowdin Atomic Charges:" or line[1:16] == "Lowdin charges:":
1673
1674 if not hasattr(self, "atomcharges"):
1675 self.atomcharges = {}
1676
1677 ones = next(inputfile)
1678
1679 charges = []
1680 nline = next(inputfile)
1681 while not "Sum of" in nline:
1682 charges.append(float(nline.split()[2]))
1683 nline = next(inputfile)
1684
1685 if "Mulliken" in line:
1686 self.atomcharges["mulliken"] = charges
1687 else:
1688 self.atomcharges["lowdin"] = charges
1689
1690 if line.strip() == "Natural Population":
1691 if not hasattr(self, 'atomcharges'):
1692 self.atomcharges = {}
1693 line1 = next(inputfile)
1694 line2 = next(inputfile)
1695 if line1.split()[0] == 'Natural' and line2.split()[2] == 'Charge':
1696 dashes = next(inputfile)
1697 charges = []
1698 for i in range(self.natom):
1699 nline = next(inputfile)
1700 charges.append(float(nline.split()[2]))
1701 self.atomcharges["natural"] = charges
1702
1703 #Extract Thermochemistry
1704 #Temperature 298.150 Kelvin. Pressure 1.00000 Atm.
1705 #Zero-point correction= 0.342233 (Hartree/
1706 #Thermal correction to Energy= 0.
1707 #Thermal correction to Enthalpy= 0.
1708 #Thermal correction to Gibbs Free Energy= 0.302940
1709 #Sum of electronic and zero-point Energies= -563.649744
1710 #Sum of electronic and thermal Energies= -563.636699
1711 #Sum of electronic and thermal Enthalpies= -563.635755
1712 #Sum of electronic and thermal Free Energies= -563.689037
1713 if "Sum of electronic and thermal Enthalpies" in line:
1714 self.set_attribute('enthalpy', float(line.split()[6]))
1715 if "Sum of electronic and thermal Free Energies=" in line:
1716 self.set_attribute('freeenergy', float(line.split()[7]))
1717 if line[1:13] == "Temperature ":
1718 self.set_attribute('temperature', float(line.split()[1]))
1719 self.set_attribute('pressure', float(line.split()[4]))
1720
1721 # Static polarizability (from `polar`), lower triangular
1722 # matrix.
1723 if line[1:26] == "SCF Polarizability for W=":
1724 self.hp_polarizabilities = True
1725 if not hasattr(self, 'polarizabilities'):
1726 self.polarizabilities = []
1727 polarizability = numpy.zeros(shape=(3, 3))
1728 self.skip_line(inputfile, 'directions')
1729 for i in range(3):
1730 line = next(inputfile)
1731 polarizability[i, :i+1] = [self.float(x) for x in line.split()[1:]]
1732
1733 polarizability = utils.symmetrize(polarizability, use_triangle='lower')
1734 self.polarizabilities.append(polarizability)
1735
1736 # Static polarizability (from `freq`), lower triangular matrix.
1737 if line[1:16] == "Polarizability=":
1738 self.hp_polarizabilities = True
1739 if not hasattr(self, 'polarizabilities'):
1740 self.polarizabilities = []
1741 polarizability = numpy.zeros(shape=(3, 3))
1742 polarizability_list = []
1743 polarizability_list.extend([line[16:31], line[31:46], line[46:61]])
1744 line = next(inputfile)
1745 polarizability_list.extend([line[16:31], line[31:46], line[46:61]])
1746 indices = numpy.tril_indices(3)
1747 polarizability[indices] = [self.float(x) for x in polarizability_list]
1748 polarizability = utils.symmetrize(polarizability, use_triangle='lower')
1749 self.polarizabilities.append(polarizability)
1750
1751 # Static polarizability, compressed into a single line from
1752 # terse printing.
1753 # Order is XX, YX, YY, ZX, ZY, ZZ (lower triangle).
1754 if line[2:23] == "Exact polarizability:":
1755 if not self.hp_polarizabilities:
1756 if not hasattr(self, 'polarizabilities'):
1757 self.polarizabilities = []
1758 polarizability = numpy.zeros(shape=(3, 3))
1759 indices = numpy.tril_indices(3)
1760 polarizability[indices] = [self.float(x) for x in
1761 [line[23:31], line[31:39], line[39:47], line[47:55], line[55:63], line[63:71]]]
1762 polarizability = utils.symmetrize(polarizability, use_triangle='lower')
1763 self.polarizabilities.append(polarizability)
1764
1765 # IRC Computation convergence checks.
1766 #
1767 # -------- Sample extract for IRC step --------
1768 #
1769 # IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC
1770 # ------------------------------------------------------------------------
1771 # INPUT DATA FOR L123
1772 # ------------------------------------------------------------------------
1773 # GENERAL PARAMETERS:
1774 # Follow reaction path in both directions.
1775 # Maximum points per path = 200
1776 # Step size = 0.100 bohr
1777 # Integration scheme = HPC
1778 # Redo corrector integration= Yes
1779 # DWI Weight Power = 2
1780 # DWI will use Hessian update vectors when possible.
1781 # Max correction cycles = 50
1782 # Initial Hessian = CalcFC
1783 # Hessian evaluation = Analytic every 5 predictor steps
1784 # = Analytic every 5 corrector steps
1785 # Hessian updating method = Bofill
1786 # ------------------------------------------------------------------------
1787 # IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC
1788 #
1789 # -------- Sample extract for converged step --------
1790 # IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC
1791 # Pt 1 Step number 1 out of a maximum of 50
1792 # Modified Bulirsch-Stoer Extrapolation Cycles:
1793 # EPS = 0.000010000000000
1794 # Maximum DWI energy std dev = 0.000000595 at pt 1
1795 # Maximum DWI gradient std dev = 0.135684493 at pt 2
1796 # CORRECTOR INTEGRATION CONVERGENCE:
1797 # Recorrection delta-x convergence threshold: 0.010000
1798 # Delta-x Convergence Met
1799 # Point Number: 1 Path Number: 1
1800 # CHANGE IN THE REACTION COORDINATE = 0.16730
1801 # NET REACTION COORDINATE UP TO THIS POINT = 0.16730
1802 # # OF POINTS ALONG THE PATH = 1
1803 # # OF STEPS = 1
1804 #
1805 # Calculating another point on the path.
1806 # IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC
1807 #
1808 # -------- Sample extract for unconverged intermediate step --------
1809 # IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC
1810 # Error in corrector energy = -0.0000457166
1811 # Magnitude of corrector gradient = 0.0140183779
1812 # Magnitude of analytic gradient = 0.0144021969
1813 # Magnitude of difference = 0.0078709968
1814 # Angle between gradients (degrees)= 32.1199
1815 # Pt 40 Step number 2 out of a maximum of 20
1816 # Modified Bulirsch-Stoer Extrapolation Cycles:
1817 # EPS = 0.000010000000000
1818 # Maximum DWI energy std dev = 0.000007300 at pt 31
1819 # Maximum DWI gradient std dev = 0.085197906 at pt 59
1820 # CORRECTOR INTEGRATION CONVERGENCE:
1821 # Recorrection delta-x convergence threshold: 0.010000
1822 # Delta-x Convergence NOT Met
1823 # IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC-IRC
1824 if line[1:20] == "INPUT DATA FOR L123": # First IRC step
1825 if not hasattr(self, "optstatus"):
1826 self.optstatus = []
1827 self.optstatus.append(data.ccData.OPT_NEW)
1828 if line[3:22] == "Delta-x Convergence":
1829 if line[23:30] == "NOT Met":
1830 self.optstatus[-1] += data.ccData.OPT_UNCONVERGED
1831 elif line[23:26] == "Met":
1832 self.optstatus[-1] += data.ccData.OPT_DONE
1833 if not hasattr(self, 'optdone'):
1834 self.optdone = []
1835 self.optdone.append(len(self.optstatus) - 1)
1836
1837 if line[:31] == ' Normal termination of Gaussian':
1838 self.metadata['success'] = True