Hide keyboard shortcuts

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. 

8 

9import logging 

10from argparse import ArgumentParser 

11 

12from cclib.io import ccread 

13from cclib.method import CDA 

14 

15 

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() 

22 

23 loglevel = logging.ERROR 

24 

25 data1 = ccread(args.file1, loglevel=loglevel) 

26 data2 = ccread(args.file2, loglevel=loglevel) 

27 data3 = ccread(args.file3, loglevel=loglevel) 

28 

29 fa = CDA(data1, None, loglevel) 

30 retval = fa.calculate([data2, data3]) 

31 

32 if retval: 

33 

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

35 

36 if len(data1.homos) == 2: 

37 print("ALPHA SPIN:") 

38 print("===========") 

39 

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

41 print("-------------------------------------") 

42 

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

44 

45 if spin == 1: 

46 print("\nBETA SPIN:") 

47 print("==========") 

48 

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

50 

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])) 

56 

57 if i == data1.homos[spin]: 

58 print("------ HOMO - LUMO gap ------") 

59 

60 

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())) 

67 

68 

69if __name__ == '__main__': 

70 main()