| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# |
| 3 |
# Copyright (c) 2017, 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 GAMESS-UK output files""" |
| 9 |
|
| 10 |
|
| 11 |
import re |
| 12 |
|
| 13 |
import numpy |
| 14 |
|
| 15 |
from cclib.parser import logfileparser |
| 16 |
from cclib.parser import utils |
| 17 |
|
| 18 |
|
| 19 |
class GAMESSUK(logfileparser.Logfile): |
| 20 |
"""A GAMESS UK log file""" |
| 21 |
SCFRMS, SCFMAX, SCFENERGY = list(range(3)) # Used to index self.scftargets[] |
| 22 |
|
| 23 |
def __init__(self, *args, **kwargs): |
| 24 |
|
| 25 |
# Call the __init__ method of the superclass |
| 26 |
super(GAMESSUK, self).__init__(logname="GAMESSUK", *args, **kwargs) |
| 27 |
|
| 28 |
def __str__(self): |
| 29 |
"""Return a string representation of the object.""" |
| 30 |
return "GAMESS UK log file %s" % (self.filename) |
| 31 |
|
| 32 |
def __repr__(self): |
| 33 |
"""Return a representation of the object.""" |
| 34 |
return 'GAMESSUK("%s")' % (self.filename) |
| 35 |
|
| 36 |
def normalisesym(self, label): |
| 37 |
"""Use standard symmetry labels instead of GAMESS UK labels.""" |
| 38 |
label = label.replace("''", '"').replace("+", "").replace("-", "") |
| 39 |
ans = label[0].upper() + label[1:] |
| 40 |
return ans |
| 41 |
|
| 42 |
def before_parsing(self): |
| 43 |
|
| 44 |
# used for determining whether to add a second mosyms, etc. |
| 45 |
self.betamosyms = self.betamoenergies = self.betamocoeffs = False |
| 46 |
|
| 47 |
def extract(self, inputfile, line): |
| 48 |
"""Extract information from the file object inputfile.""" |
| 49 |
|
| 50 |
# Extract the version number and optionally the revision number. |
| 51 |
if "version" in line: |
| 52 |
search = re.search(r"\sversion\s*(\d\.\d)", line) |
| 53 |
if search: |
| 54 |
self.metadata["package_version"] = search.groups()[0] |
| 55 |
if "Revision" in line: |
| 56 |
revision = line.split()[1] |
| 57 |
# Don't add revision information to the main package version for now. |
| 58 |
# if "package_version" in self.metadata: |
| 59 |
# package_version = "{}.r{}".format(self.metadata["package_version"], |
| 60 |
# revision) |
| 61 |
# self.metadata["package_version"] = package_version |
| 62 |
|
| 63 |
if line[1:22] == "total number of atoms": |
| 64 |
natom = int(line.split()[-1]) |
| 65 |
self.set_attribute('natom', natom) |
| 66 |
|
| 67 |
if line[3:44] == "convergence threshold in optimization run": |
| 68 |
# Assuming that this is only found in the case of OPTXYZ |
| 69 |
# (i.e. an optimization in Cartesian coordinates) |
| 70 |
self.geotargets = [float(line.split()[-2])] |
| 71 |
|
| 72 |
if line[32:61] == "largest component of gradient": |
| 73 |
# This is the geotarget in the case of OPTXYZ |
| 74 |
if not hasattr(self, "geovalues"): |
| 75 |
self.geovalues = [] |
| 76 |
self.geovalues.append([float(line.split()[4])]) |
| 77 |
|
| 78 |
if line[37:49] == "convergence?": |
| 79 |
# Get the geovalues and geotargets for OPTIMIZE |
| 80 |
if not hasattr(self, "geovalues"): |
| 81 |
self.geovalues = [] |
| 82 |
self.geotargets = [] |
| 83 |
geotargets = [] |
| 84 |
geovalues = [] |
| 85 |
for i in range(4): |
| 86 |
temp = line.split() |
| 87 |
geovalues.append(float(temp[2])) |
| 88 |
if not self.geotargets: |
| 89 |
geotargets.append(float(temp[-2])) |
| 90 |
line = next(inputfile) |
| 91 |
self.geovalues.append(geovalues) |
| 92 |
if not self.geotargets: |
| 93 |
self.geotargets = geotargets |
| 94 |
|
| 95 |
# This is the only place coordinates are printed in single point calculations. Note that |
| 96 |
# in the following fragment, the basis set selection is not always printed: |
| 97 |
# |
| 98 |
# ****************** |
| 99 |
# molecular geometry |
| 100 |
# ****************** |
| 101 |
# |
| 102 |
# **************************************** |
| 103 |
# * basis selected is sto sto3g * |
| 104 |
# **************************************** |
| 105 |
# |
| 106 |
# ******************************************************************************* |
| 107 |
# * * |
| 108 |
# * atom atomic coordinates number of * |
| 109 |
# * charge x y z shells * |
| 110 |
# * * |
| 111 |
# ******************************************************************************* |
| 112 |
# * * |
| 113 |
# * * |
| 114 |
# * c 6.0 0.0000000 -2.6361501 0.0000000 2 * |
| 115 |
# * 1s 2sp * |
| 116 |
# * * |
| 117 |
# * * |
| 118 |
# * c 6.0 0.0000000 2.6361501 0.0000000 2 * |
| 119 |
# * 1s 2sp * |
| 120 |
# * * |
| 121 |
# ... |
| 122 |
# |
| 123 |
if line.strip() == "molecular geometry": |
| 124 |
|
| 125 |
self.updateprogress(inputfile, "Coordinates") |
| 126 |
|
| 127 |
self.skip_lines(inputfile, ['s', 'b', 's']) |
| 128 |
line = next(inputfile) |
| 129 |
if "basis selected is" in line: |
| 130 |
self.skip_lines(inputfile, ['s', 'b', 's', 's']) |
| 131 |
|
| 132 |
self.skip_lines(inputfile, ['header1', 'header2', 's', 's']) |
| 133 |
|
| 134 |
atomnos = [] |
| 135 |
atomcoords = [] |
| 136 |
line = next(inputfile) |
| 137 |
while line.strip(): |
| 138 |
line = next(inputfile) |
| 139 |
if line.strip()[1:10].strip() and list(set(line.strip())) != ['*']: |
| 140 |
atomcoords.append([utils.convertor(float(x), "bohr", "Angstrom") for x in line.split()[3:6]]) |
| 141 |
atomnos.append(int(round(float(line.split()[2])))) |
| 142 |
|
| 143 |
if not hasattr(self, "atomcoords"): |
| 144 |
self.atomcoords = [] |
| 145 |
self.atomcoords.append(atomcoords) |
| 146 |
self.set_attribute('atomnos', atomnos) |
| 147 |
|
| 148 |
# Each step of a geometry optimization will also print the coordinates: |
| 149 |
# |
| 150 |
# search 0 |
| 151 |
# ******************* |
| 152 |
# point 0 nuclear coordinates |
| 153 |
# ******************* |
| 154 |
# |
| 155 |
# x y z chg tag |
| 156 |
# ============================================================ |
| 157 |
# 0.0000000 -2.6361501 0.0000000 6.00 c |
| 158 |
# 0.0000000 2.6361501 0.0000000 6.00 c |
| 159 |
# .. |
| 160 |
# |
| 161 |
if line[40:59] == "nuclear coordinates": |
| 162 |
|
| 163 |
self.updateprogress(inputfile, "Coordinates") |
| 164 |
|
| 165 |
# We need not remember the first geometry in geometry optimizations, as this will |
| 166 |
# be already parsed from the "molecular geometry" section (see above). |
| 167 |
if not hasattr(self, 'firstnuccoords') or self.firstnuccoords: |
| 168 |
self.firstnuccoords = False |
| 169 |
return |
| 170 |
|
| 171 |
self.skip_lines(inputfile, ['s', 'b', 'colname', 'e']) |
| 172 |
|
| 173 |
atomcoords = [] |
| 174 |
atomnos = [] |
| 175 |
line = next(inputfile) |
| 176 |
while list(set(line.strip())) != ['=']: |
| 177 |
|
| 178 |
cols = line.split() |
| 179 |
atomcoords.append([utils.convertor(float(x), "bohr", "Angstrom") for x in cols[0:3]]) |
| 180 |
atomnos.append(int(float(cols[3]))) |
| 181 |
|
| 182 |
line = next(inputfile) |
| 183 |
|
| 184 |
if not hasattr(self, "atomcoords"): |
| 185 |
self.atomcoords = [] |
| 186 |
self.atomcoords.append(atomcoords) |
| 187 |
self.set_attribute('atomnos', atomnos) |
| 188 |
|
| 189 |
# This is printed when a geometry optimization succeeds, after the last gradient of the energy. |
| 190 |
if line[40:62] == "optimization converged": |
| 191 |
self.skip_line(inputfile, 's') |
| 192 |
if not hasattr(self, 'optdone'): |
| 193 |
self.optdone = [] |
| 194 |
self.optdone.append(len(self.geovalues)-1) |
| 195 |
|
| 196 |
# This is apparently printed when a geometry optimization is not converged but the job ends. |
| 197 |
if "minimisation not converging" in line: |
| 198 |
self.skip_line(inputfile, 's') |
| 199 |
self.optdone = [] |
| 200 |
|
| 201 |
if line[1:32] == "total number of basis functions": |
| 202 |
|
| 203 |
nbasis = int(line.split()[-1]) |
| 204 |
self.set_attribute('nbasis', nbasis) |
| 205 |
|
| 206 |
while line.find("charge of molecule") < 0: |
| 207 |
line = next(inputfile) |
| 208 |
|
| 209 |
charge = int(line.split()[-1]) |
| 210 |
self.set_attribute('charge', charge) |
| 211 |
|
| 212 |
mult = int(next(inputfile).split()[-1]) |
| 213 |
self.set_attribute('mult', mult) |
| 214 |
|
| 215 |
alpha = int(next(inputfile).split()[-1])-1 |
| 216 |
beta = int(next(inputfile).split()[-1])-1 |
| 217 |
if self.mult == 1: |
| 218 |
self.homos = numpy.array([alpha], "i") |
| 219 |
else: |
| 220 |
self.homos = numpy.array([alpha, beta], "i") |
| 221 |
|
| 222 |
if line[37:69] == "s-matrix over gaussian basis set": |
| 223 |
self.aooverlaps = numpy.zeros((self.nbasis, self.nbasis), "d") |
| 224 |
|
| 225 |
self.skip_lines(inputfile, ['d', 'b']) |
| 226 |
|
| 227 |
i = 0 |
| 228 |
while i < self.nbasis: |
| 229 |
self.updateprogress(inputfile, "Overlap") |
| 230 |
|
| 231 |
self.skip_lines(inputfile, ['b', 'b', 'header', 'b', 'b']) |
| 232 |
|
| 233 |
for j in range(self.nbasis): |
| 234 |
temp = list(map(float, next(inputfile).split()[1:])) |
| 235 |
self.aooverlaps[j, (0+i):(len(temp)+i)] = temp |
| 236 |
|
| 237 |
i += len(temp) |
| 238 |
|
| 239 |
if line[18:43] == 'EFFECTIVE CORE POTENTIALS': |
| 240 |
|
| 241 |
self.skip_line(inputfile, 'stars') |
| 242 |
|
| 243 |
self.coreelectrons = numpy.zeros(self.natom, 'i') |
| 244 |
line = next(inputfile) |
| 245 |
while line[15:46] != "*"*31: |
| 246 |
if line.find("for atoms ...") >= 0: |
| 247 |
atomindex = [] |
| 248 |
line = next(inputfile) |
| 249 |
while line.find("core charge") < 0: |
| 250 |
broken = line.split() |
| 251 |
atomindex.extend([int(x.split("-")[0]) for x in broken]) |
| 252 |
line = next(inputfile) |
| 253 |
charge = float(line.split()[4]) |
| 254 |
for idx in atomindex: |
| 255 |
self.coreelectrons[idx-1] = self.atomnos[idx-1] - charge |
| 256 |
line = next(inputfile) |
| 257 |
|
| 258 |
if line[3:27] == "Wavefunction convergence": |
| 259 |
self.scftarget = float(line.split()[-2]) |
| 260 |
self.scftargets = [] |
| 261 |
|
| 262 |
if line[11:22] == "normal mode": |
| 263 |
if not hasattr(self, "vibfreqs"): |
| 264 |
self.vibfreqs = [] |
| 265 |
self.vibirs = [] |
| 266 |
|
| 267 |
units = next(inputfile) |
| 268 |
xyz = next(inputfile) |
| 269 |
equals = next(inputfile) |
| 270 |
line = next(inputfile) |
| 271 |
while line != equals: |
| 272 |
temp = line.split() |
| 273 |
self.vibfreqs.append(float(temp[1])) |
| 274 |
self.vibirs.append(float(temp[-2])) |
| 275 |
line = next(inputfile) |
| 276 |
# Use the length of the vibdisps to figure out |
| 277 |
# how many rotations and translations to remove |
| 278 |
self.vibfreqs = self.vibfreqs[-len(self.vibdisps):] |
| 279 |
self.vibirs = self.vibirs[-len(self.vibdisps):] |
| 280 |
|
| 281 |
if line[44:73] == "normalised normal coordinates": |
| 282 |
|
| 283 |
self.skip_lines(inputfile, ['e', 'b', 'b']) |
| 284 |
|
| 285 |
self.vibdisps = [] |
| 286 |
freqnum = next(inputfile) |
| 287 |
while freqnum.find("=") < 0: |
| 288 |
|
| 289 |
self.skip_lines(inputfile, ['b', 'e', 'freqs', 'e', 'b', 'header', 'e']) |
| 290 |
|
| 291 |
p = [[] for x in range(9)] |
| 292 |
for i in range(len(self.atomnos)): |
| 293 |
brokenx = list(map(float, next(inputfile)[25:].split())) |
| 294 |
brokeny = list(map(float, next(inputfile)[25:].split())) |
| 295 |
brokenz = list(map(float, next(inputfile)[25:].split())) |
| 296 |
for j, x in enumerate(list(zip(brokenx, brokeny, brokenz))): |
| 297 |
p[j].append(x) |
| 298 |
self.vibdisps.extend(p) |
| 299 |
|
| 300 |
self.skip_lines(inputfile, ['b', 'b']) |
| 301 |
|
| 302 |
freqnum = next(inputfile) |
| 303 |
|
| 304 |
if line[26:36] == "raman data": |
| 305 |
self.vibramans = [] |
| 306 |
|
| 307 |
self.skip_lines(inputfile, ['s', 'b', 'header', 'b']) |
| 308 |
|
| 309 |
line = next(inputfile) |
| 310 |
while line[1] != "*": |
| 311 |
self.vibramans.append(float(line.split()[3])) |
| 312 |
self.skip_line(inputfile, 'blank') |
| 313 |
line = next(inputfile) |
| 314 |
# Use the length of the vibdisps to figure out |
| 315 |
# how many rotations and translations to remove |
| 316 |
self.vibramans = self.vibramans[-len(self.vibdisps):] |
| 317 |
|
| 318 |
if line[3:11] == "SCF TYPE": |
| 319 |
self.scftype = line.split()[-2] |
| 320 |
assert self.scftype in ['rhf', 'uhf', 'gvb'], "%s not one of 'rhf', 'uhf' or 'gvb'" % self.scftype |
| 321 |
|
| 322 |
if line[15:31] == "convergence data": |
| 323 |
if not hasattr(self, "scfvalues"): |
| 324 |
self.scfvalues = [] |
| 325 |
self.scftargets.append([self.scftarget]) # Assuming it does not change over time |
| 326 |
while line[1:10] != "="*9: |
| 327 |
line = next(inputfile) |
| 328 |
line = next(inputfile) |
| 329 |
tester = line.find("tester") # Can be in a different place depending |
| 330 |
assert tester >= 0 |
| 331 |
while line[1:10] != "="*9: # May be two or three lines (unres) |
| 332 |
line = next(inputfile) |
| 333 |
|
| 334 |
scfvalues = [] |
| 335 |
line = next(inputfile) |
| 336 |
while line.strip(): |
| 337 |
# e.g. **** recalulation of fock matrix on iteration 4 (examples/chap12/pyridine.out) |
| 338 |
if line[2:6] != "****": |
| 339 |
scfvalues.append([float(line[tester-5:tester+6])]) |
| 340 |
try: |
| 341 |
line = next(inputfile) |
| 342 |
except StopIteration: |
| 343 |
self.logger.warning('File terminated before end of last SCF! Last tester: {}'.format(line.split()[5])) |
| 344 |
break |
| 345 |
self.scfvalues.append(scfvalues) |
| 346 |
|
| 347 |
if line[10:22] == "total energy" and len(line.split()) == 3: |
| 348 |
if not hasattr(self, "scfenergies"): |
| 349 |
self.scfenergies = [] |
| 350 |
scfenergy = utils.convertor(float(line.split()[-1]), "hartree", "eV") |
| 351 |
self.scfenergies.append(scfenergy) |
| 352 |
|
| 353 |
# Total energies after Moller-Plesset corrections |
| 354 |
# Second order correction is always first, so its first occurance |
| 355 |
# triggers creation of mpenergies (list of lists of energies) |
| 356 |
# Further corrections are appended as found |
| 357 |
# Note: GAMESS-UK sometimes prints only the corrections, |
| 358 |
# so they must be added to the last value of scfenergies |
| 359 |
if line[10:32] == "mp2 correlation energy" or \ |
| 360 |
line[10:42] == "second order perturbation energy": |
| 361 |
if not hasattr(self, "mpenergies"): |
| 362 |
self.mpenergies = [] |
| 363 |
self.mpenergies.append([]) |
| 364 |
self.mp2correction = self.float(line.split()[-1]) |
| 365 |
self.mp2energy = self.scfenergies[-1] + self.mp2correction |
| 366 |
self.mpenergies[-1].append(utils.convertor(self.mp2energy, "hartree", "eV")) |
| 367 |
if line[10:41] == "third order perturbation energy": |
| 368 |
self.mp3correction = self.float(line.split()[-1]) |
| 369 |
self.mp3energy = self.mp2energy + self.mp3correction |
| 370 |
self.mpenergies[-1].append(utils.convertor(self.mp3energy, "hartree", "eV")) |
| 371 |
|
| 372 |
if line[40:59] == "molecular basis set": |
| 373 |
self.gbasis = [] |
| 374 |
line = next(inputfile) |
| 375 |
while line.find("contraction coefficients") < 0: |
| 376 |
line = next(inputfile) |
| 377 |
equals = next(inputfile) |
| 378 |
blank = next(inputfile) |
| 379 |
atomname = next(inputfile) |
| 380 |
basisregexp = re.compile("\d*(\D+)") # Get everything after any digits |
| 381 |
shellcounter = 1 |
| 382 |
while line != equals: |
| 383 |
gbasis = [] # Stores basis sets on one atom |
| 384 |
blank = next(inputfile) |
| 385 |
blank = next(inputfile) |
| 386 |
line = next(inputfile) |
| 387 |
shellno = int(line.split()[0]) |
| 388 |
shellgap = shellno - shellcounter |
| 389 |
shellsize = 0 |
| 390 |
while len(line.split()) != 1 and line != equals: |
| 391 |
if line.split(): |
| 392 |
shellsize += 1 |
| 393 |
coeff = {} |
| 394 |
# coefficients and symmetries for a block of rows |
| 395 |
while line.strip() and line != equals: |
| 396 |
temp = line.strip().split() |
| 397 |
# temp[1] may be either like (a) "1s" and "1sp", or (b) "s" and "sp" |
| 398 |
# See GAMESS-UK 7.0 distribution/examples/chap12/pyridine2_21m10r.out |
| 399 |
# for an example of the latter |
| 400 |
sym = basisregexp.match(temp[1]).groups()[0] |
| 401 |
assert sym in ['s', 'p', 'd', 'f', 'sp'], "'%s' not a recognized symmetry" % sym |
| 402 |
if sym == "sp": |
| 403 |
coeff.setdefault("S", []).append((float(temp[3]), float(temp[6]))) |
| 404 |
coeff.setdefault("P", []).append((float(temp[3]), float(temp[10]))) |
| 405 |
else: |
| 406 |
coeff.setdefault(sym.upper(), []).append((float(temp[3]), float(temp[6]))) |
| 407 |
line = next(inputfile) |
| 408 |
# either a blank or a continuation of the block |
| 409 |
if coeff: |
| 410 |
if sym == "sp": |
| 411 |
gbasis.append(('S', coeff['S'])) |
| 412 |
gbasis.append(('P', coeff['P'])) |
| 413 |
else: |
| 414 |
gbasis.append((sym.upper(), coeff[sym.upper()])) |
| 415 |
if line == equals: |
| 416 |
continue |
| 417 |
line = next(inputfile) |
| 418 |
# either the start of the next block or the start of a new atom or |
| 419 |
# the end of the basis function section (signified by a line of equals) |
| 420 |
numtoadd = 1 + (shellgap // shellsize) |
| 421 |
shellcounter = shellno + shellsize |
| 422 |
for x in range(numtoadd): |
| 423 |
self.gbasis.append(gbasis) |
| 424 |
|
| 425 |
if line[50:70] == "----- beta set -----": |
| 426 |
self.betamosyms = True |
| 427 |
self.betamoenergies = True |
| 428 |
self.betamocoeffs = True |
| 429 |
# betamosyms will be turned off in the next |
| 430 |
# SYMMETRY ASSIGNMENT section |
| 431 |
|
| 432 |
if line[31:50] == "SYMMETRY ASSIGNMENT": |
| 433 |
if not hasattr(self, "mosyms"): |
| 434 |
self.mosyms = [] |
| 435 |
|
| 436 |
multiple = {'a': 1, 'b': 1, 'e': 2, 't': 3, 'g': 4, 'h': 5} |
| 437 |
|
| 438 |
equals = next(inputfile) |
| 439 |
line = next(inputfile) |
| 440 |
while line != equals: # There may be one or two lines of title (compare mg10.out and duhf_1.out) |
| 441 |
line = next(inputfile) |
| 442 |
|
| 443 |
mosyms = [] |
| 444 |
line = next(inputfile) |
| 445 |
while line != equals: |
| 446 |
temp = line[25:30].strip() |
| 447 |
if temp[-1] == '?': |
| 448 |
# e.g. e? or t? or g? (see example/chap12/na7mg_uhf.out) |
| 449 |
# for two As, an A and an E, and two Es of the same energy respectively. |
| 450 |
t = line[91:].strip().split() |
| 451 |
for i in range(1, len(t), 2): |
| 452 |
for j in range(multiple[t[i][0]]): # add twice for 'e', etc. |
| 453 |
mosyms.append(self.normalisesym(t[i])) |
| 454 |
else: |
| 455 |
for j in range(multiple[temp[0]]): |
| 456 |
mosyms.append(self.normalisesym(temp)) # add twice for 'e', etc. |
| 457 |
line = next(inputfile) |
| 458 |
assert len(mosyms) == self.nmo, "mosyms: %d but nmo: %d" % (len(mosyms), self.nmo) |
| 459 |
if self.betamosyms: |
| 460 |
# Only append if beta (otherwise with IPRINT SCF |
| 461 |
# it will add mosyms for every step of a geo opt) |
| 462 |
self.mosyms.append(mosyms) |
| 463 |
self.betamosyms = False |
| 464 |
elif self.scftype == 'gvb': |
| 465 |
# gvb has alpha and beta orbitals but they are identical |
| 466 |
self.mosysms = [mosyms, mosyms] |
| 467 |
else: |
| 468 |
self.mosyms = [mosyms] |
| 469 |
|
| 470 |
if line[50:62] == "eigenvectors": |
| 471 |
# Mocoeffs...can get evalues from here too |
| 472 |
# (only if using FORMAT HIGH though will they all be present) |
| 473 |
if not hasattr(self, "mocoeffs"): |
| 474 |
self.aonames = [] |
| 475 |
aonames = [] |
| 476 |
minus = next(inputfile) |
| 477 |
|
| 478 |
mocoeffs = numpy.zeros((self.nmo, self.nbasis), "d") |
| 479 |
readatombasis = False |
| 480 |
if not hasattr(self, "atombasis"): |
| 481 |
self.atombasis = [] |
| 482 |
for i in range(self.natom): |
| 483 |
self.atombasis.append([]) |
| 484 |
readatombasis = True |
| 485 |
|
| 486 |
self.skip_lines(inputfile, ['b', 'b', 'evalues']) |
| 487 |
|
| 488 |
p = re.compile(r"\d+\s+(\d+)\s*(\w+) (\w+)") |
| 489 |
oldatomname = "DUMMY VALUE" |
| 490 |
|
| 491 |
mo = 0 |
| 492 |
while mo < self.nmo: |
| 493 |
self.updateprogress(inputfile, "Coefficients") |
| 494 |
|
| 495 |
self.skip_lines(inputfile, ['b', 'b', 'nums', 'b', 'b']) |
| 496 |
|
| 497 |
for basis in range(self.nbasis): |
| 498 |
line = next(inputfile) |
| 499 |
# Fill atombasis only first time around. |
| 500 |
if readatombasis: |
| 501 |
orbno = int(line[1:5])-1 |
| 502 |
atomno = int(line[6:9])-1 |
| 503 |
self.atombasis[atomno].append(orbno) |
| 504 |
if not self.aonames: |
| 505 |
pg = p.match(line[:18].strip()).groups() |
| 506 |
atomname = "%s%s%s" % (pg[1][0].upper(), pg[1][1:], pg[0]) |
| 507 |
if atomname != oldatomname: |
| 508 |
aonum = 1 |
| 509 |
oldatomname = atomname |
| 510 |
name = "%s_%d%s" % (atomname, aonum, pg[2].upper()) |
| 511 |
if name in aonames: |
| 512 |
aonum += 1 |
| 513 |
name = "%s_%d%s" % (atomname, aonum, pg[2].upper()) |
| 514 |
aonames.append(name) |
| 515 |
temp = list(map(float, line[19:].split())) |
| 516 |
mocoeffs[mo:(mo+len(temp)), basis] = temp |
| 517 |
# Fill atombasis only first time around. |
| 518 |
readatombasis = False |
| 519 |
if not self.aonames: |
| 520 |
self.aonames = aonames |
| 521 |
|
| 522 |
line = next(inputfile) # blank line |
| 523 |
while not line.strip(): |
| 524 |
line = next(inputfile) |
| 525 |
evalues = line |
| 526 |
if evalues[:17].strip(): # i.e. if these aren't evalues |
| 527 |
break # Not all the MOs are present |
| 528 |
mo += len(temp) |
| 529 |
mocoeffs = mocoeffs[0:(mo+len(temp)), :] # In case some aren't present |
| 530 |
if self.betamocoeffs: |
| 531 |
self.mocoeffs.append(mocoeffs) |
| 532 |
else: |
| 533 |
self.mocoeffs = [mocoeffs] |
| 534 |
|
| 535 |
if line[7:12] == "irrep": |
| 536 |
########## eigenvalues ########### |
| 537 |
# This section appears once at the start of a geo-opt and once at the end |
| 538 |
# unless IPRINT SCF is used (when it appears at every step in addition) |
| 539 |
if not hasattr(self, "moenergies"): |
| 540 |
self.moenergies = [] |
| 541 |
|
| 542 |
equals = next(inputfile) |
| 543 |
while equals[1:5] != "====": # May be one or two lines of title (compare duhf_1.out and mg10.out) |
| 544 |
equals = next(inputfile) |
| 545 |
|
| 546 |
moenergies = [] |
| 547 |
line = next(inputfile) |
| 548 |
if not line.strip(): # May be a blank line here (compare duhf_1.out and mg10.out) |
| 549 |
line = next(inputfile) |
| 550 |
|
| 551 |
while line.strip() and line != equals: # May end with a blank or equals |
| 552 |
temp = line.strip().split() |
| 553 |
moenergies.append(utils.convertor(float(temp[2]), "hartree", "eV")) |
| 554 |
line = next(inputfile) |
| 555 |
self.nmo = len(moenergies) |
| 556 |
if self.betamoenergies: |
| 557 |
self.moenergies.append(moenergies) |
| 558 |
self.betamoenergies = False |
| 559 |
elif self.scftype == 'gvb': |
| 560 |
self.moenergies = [moenergies, moenergies] |
| 561 |
else: |
| 562 |
self.moenergies = [moenergies] |
| 563 |
|
| 564 |
# The dipole moment is printed by default at the beginning of the wavefunction analysis, |
| 565 |
# but the value is in atomic units, so we need to convert to Debye. It seems pretty |
| 566 |
# evident that the reference point is the origin (0,0,0) which is also the center |
| 567 |
# of mass after reorientation at the beginning of the job, although this is not |
| 568 |
# stated anywhere (would be good to check). |
| 569 |
# |
| 570 |
# ********************* |
| 571 |
# wavefunction analysis |
| 572 |
# ********************* |
| 573 |
# |
| 574 |
# commence analysis at 24.61 seconds |
| 575 |
# |
| 576 |
# dipole moments |
| 577 |
# |
| 578 |
# |
| 579 |
# nuclear electronic total |
| 580 |
# |
| 581 |
# x 0.0000000 0.0000000 0.0000000 |
| 582 |
# y 0.0000000 0.0000000 0.0000000 |
| 583 |
# z 0.0000000 0.0000000 0.0000000 |
| 584 |
# |
| 585 |
if line.strip() == "dipole moments": |
| 586 |
|
| 587 |
# In older version there is only one blank line before the header, |
| 588 |
# and newer version there are two. |
| 589 |
self.skip_line(inputfile, 'blank') |
| 590 |
line = next(inputfile) |
| 591 |
if not line.strip(): |
| 592 |
line = next(inputfile) |
| 593 |
self.skip_line(inputfile, 'blank') |
| 594 |
|
| 595 |
dipole = [] |
| 596 |
for i in range(3): |
| 597 |
line = next(inputfile) |
| 598 |
dipole.append(float(line.split()[-1])) |
| 599 |
|
| 600 |
reference = [0.0, 0.0, 0.0] |
| 601 |
dipole = utils.convertor(numpy.array(dipole), "ebohr", "Debye") |
| 602 |
|
| 603 |
if not hasattr(self, 'moments'): |
| 604 |
self.moments = [reference, dipole] |
| 605 |
else: |
| 606 |
assert self.moments[1] == dipole |
| 607 |
|
| 608 |
# Net atomic charges are not printed at all, it seems, |
| 609 |
# but you can get at them from nuclear charges and |
| 610 |
# electron populations, which are printed like so: |
| 611 |
# |
| 612 |
# --------------------------------------- |
| 613 |
# mulliken and lowdin population analyses |
| 614 |
# --------------------------------------- |
| 615 |
# |
| 616 |
# ----- total gross population in aos ------ |
| 617 |
# |
| 618 |
# 1 1 c s 1.99066 1.98479 |
| 619 |
# 2 1 c s 1.14685 1.04816 |
| 620 |
# ... |
| 621 |
# |
| 622 |
# ----- total gross population on atoms ---- |
| 623 |
# |
| 624 |
# 1 c 6.0 6.00446 5.99625 |
| 625 |
# 2 c 6.0 6.00446 5.99625 |
| 626 |
# 3 c 6.0 6.07671 6.04399 |
| 627 |
# ... |
| 628 |
if line[10:49] == "mulliken and lowdin population analyses": |
| 629 |
|
| 630 |
if not hasattr(self, "atomcharges"): |
| 631 |
self.atomcharges = {} |
| 632 |
|
| 633 |
while not "total gross population on atoms" in line: |
| 634 |
line = next(inputfile) |
| 635 |
|
| 636 |
self.skip_line(inputfile, 'blank') |
| 637 |
|
| 638 |
line = next(inputfile) |
| 639 |
mulliken, lowdin = [], [] |
| 640 |
while line.strip(): |
| 641 |
nuclear = float(line.split()[2]) |
| 642 |
mulliken.append(nuclear - float(line.split()[3])) |
| 643 |
lowdin.append(nuclear - float(line.split()[4])) |
| 644 |
line = next(inputfile) |
| 645 |
|
| 646 |
self.atomcharges["mulliken"] = mulliken |
| 647 |
self.atomcharges["lowdin"] = lowdin |
| 648 |
|
| 649 |
# ----- spinfree UHF natural orbital occupations ----- |
| 650 |
# |
| 651 |
# 2.0000000 2.0000000 2.0000000 2.0000000 2.0000000 2.0000000 2.0000000 |
| 652 |
# |
| 653 |
# 2.0000000 2.0000000 2.0000000 2.0000000 2.0000000 1.9999997 1.9999997 |
| 654 |
# ... |
| 655 |
if "natural orbital occupations" in line: |
| 656 |
|
| 657 |
occupations = [] |
| 658 |
|
| 659 |
self.skip_line(inputfile, "blank") |
| 660 |
line = inputfile.next() |
| 661 |
|
| 662 |
while line.strip(): |
| 663 |
occupations += map(float, line.split()) |
| 664 |
|
| 665 |
self.skip_line(inputfile, "blank") |
| 666 |
line = inputfile.next() |
| 667 |
|
| 668 |
self.set_attribute('nooccnos', occupations) |
| 669 |
|
| 670 |
if line[:33] == ' end of G A M E S S program at': |
| 671 |
self.metadata['success'] = True |