| 1 |
#!/usr/bin/env python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# |
| 4 |
# Copyright (c) 2017, the cclib development team |
| 5 |
# |
| 6 |
# This file is part of cclib (http://cclib.github.io) and is distributed under |
| 7 |
# the terms of the BSD 3-Clause License. |
| 8 |
|
| 9 |
from __future__ import print_function |
| 10 |
import logging |
| 11 |
from argparse import ArgumentParser |
| 12 |
|
| 13 |
from cclib.io import ccread |
| 14 |
from cclib.method import CDA |
| 15 |
|
| 16 |
|
| 17 |
def main(): |
| 18 |
parser = ArgumentParser() |
| 19 |
parser.add_argument("file1", help="logfile containing the supermolecule") |
| 20 |
parser.add_argument("file2", help="logfile containing the first fragment") |
| 21 |
parser.add_argument("file3", help="logfile containing the second fragment") |
| 22 |
args = parser.parse_args() |
| 23 |
|
| 24 |
loglevel = logging.ERROR |
| 25 |
|
| 26 |
data1 = ccread(args.file1, loglevel=loglevel) |
| 27 |
data2 = ccread(args.file2, loglevel=loglevel) |
| 28 |
data3 = ccread(args.file3, loglevel=loglevel) |
| 29 |
|
| 30 |
fa = CDA(data1, None, loglevel) |
| 31 |
retval = fa.calculate([data2, data3]) |
| 32 |
|
| 33 |
if retval: |
| 34 |
|
| 35 |
print("Charge decomposition analysis of {}\n".format(args.file1)) |
| 36 |
|
| 37 |
if len(data1.homos) == 2: |
| 38 |
print("ALPHA SPIN:") |
| 39 |
print("===========") |
| 40 |
|
| 41 |
print(" MO# d b r s") |
| 42 |
print("-------------------------------------") |
| 43 |
|
| 44 |
for spin in range(len(data1.homos)): |
| 45 |
|
| 46 |
if spin == 1: |
| 47 |
print("\nBETA SPIN:") |
| 48 |
print("==========") |
| 49 |
|
| 50 |
for i in range(len(fa.donations[spin])): |
| 51 |
|
| 52 |
print("%4i: %7.3f %7.3f %7.3f %7.3f" % \ |
| 53 |
(i + 1, fa.donations[spin][i], |
| 54 |
fa.bdonations[spin][i], |
| 55 |
fa.repulsions[spin][i], |
| 56 |
fa.residuals[spin][i])) |
| 57 |
|
| 58 |
if i == data1.homos[spin]: |
| 59 |
print("------ HOMO - LUMO gap ------") |
| 60 |
|
| 61 |
|
| 62 |
print("-------------------------------------") |
| 63 |
print(" T: %7.3f %7.3f %7.3f %7.3f" % \ |
| 64 |
(fa.donations[spin].sum(), |
| 65 |
fa.bdonations[spin].sum(), |
| 66 |
fa.repulsions[spin].sum(), |
| 67 |
fa.residuals[spin].sum())) |
| 68 |
|
| 69 |
|
| 70 |
if __name__ == '__main__': |
| 71 |
main() |