Coverage for cclib/scripts/cda.py : 17%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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.
9import logging
10from argparse import ArgumentParser
12from cclib.io import ccread
13from cclib.method import CDA
16def main():
17 parser = ArgumentParser()
18 parser.add_argument("file1", help="logfile containing the supermolecule")
19 parser.add_argument("file2", help="logfile containing the first fragment")
20 parser.add_argument("file3", help="logfile containing the second fragment")
21 args = parser.parse_args()
23 loglevel = logging.ERROR
25 data1 = ccread(args.file1, loglevel=loglevel)
26 data2 = ccread(args.file2, loglevel=loglevel)
27 data3 = ccread(args.file3, loglevel=loglevel)
29 fa = CDA(data1, None, loglevel)
30 retval = fa.calculate([data2, data3])
32 if retval:
34 print("Charge decomposition analysis of {}\n".format(args.file1))
36 if len(data1.homos) == 2:
37 print("ALPHA SPIN:")
38 print("===========")
40 print(" MO# d b r s")
41 print("-------------------------------------")
43 for spin in range(len(data1.homos)):
45 if spin == 1:
46 print("\nBETA SPIN:")
47 print("==========")
49 for i in range(len(fa.donations[spin])):
51 print("%4i: %7.3f %7.3f %7.3f %7.3f" % \
52 (i + 1, fa.donations[spin][i],
53 fa.bdonations[spin][i],
54 fa.repulsions[spin][i],
55 fa.residuals[spin][i]))
57 if i == data1.homos[spin]:
58 print("------ HOMO - LUMO gap ------")
61 print("-------------------------------------")
62 print(" T: %7.3f %7.3f %7.3f %7.3f" % \
63 (fa.donations[spin].sum(),
64 fa.bdonations[spin].sum(),
65 fa.repulsions[spin].sum(),
66 fa.residuals[spin].sum()))
69if __name__ == '__main__':
70 main()