File: cda.py

package info (click to toggle)
cclib-data 1.6.2-2
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, sid
  • size: 87,912 kB
  • sloc: python: 16,440; sh: 131; makefile: 79; cpp: 31
file content (71 lines) | stat: -rw-r--r-- 2,200 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

from __future__ import print_function
import logging
from argparse import ArgumentParser

from cclib.io import ccread
from cclib.method import CDA


def main():
    parser = ArgumentParser()
    parser.add_argument("file1", help="logfile containing the supermolecule")
    parser.add_argument("file2", help="logfile containing the first fragment")
    parser.add_argument("file3", help="logfile containing the second fragment")
    args = parser.parse_args()

    loglevel = logging.ERROR

    data1 = ccread(args.file1, loglevel=loglevel)
    data2 = ccread(args.file2, loglevel=loglevel)
    data3 = ccread(args.file3, loglevel=loglevel)

    fa = CDA(data1, None, loglevel)
    retval = fa.calculate([data2, data3])

    if retval:

        print("Charge decomposition analysis of {}\n".format(args.file1))

        if len(data1.homos) == 2:
            print("ALPHA SPIN:")
            print("===========")

        print(" MO#      d       b       r       s")
        print("-------------------------------------")

        for spin in range(len(data1.homos)):

            if spin == 1:
                print("\nBETA SPIN:")
                print("==========")

            for i in range(len(fa.donations[spin])):

                print("%4i: %7.3f %7.3f %7.3f %7.3f" % \
                        (i + 1, fa.donations[spin][i],
                                fa.bdonations[spin][i],
                                fa.repulsions[spin][i],
                                fa.residuals[spin][i]))

                if i == data1.homos[spin]:
                    print("------ HOMO - LUMO gap ------")
                    

            print("-------------------------------------")
            print(" T:   %7.3f %7.3f %7.3f %7.3f" % \
                    (fa.donations[spin].sum(),
                        fa.bdonations[spin].sum(),
                        fa.repulsions[spin].sum(),
                        fa.residuals[spin].sum()))


if __name__ == '__main__':
    main()