Debian Codegraph @

doc/sphinx/methods.rst

raw
1 .. index::
2 module: methods
3
4 Calculation methods
5 ===================
6
7 The following methods in cclib allow further analysis of calculation output.
8
9 .. _`methods in the development version`: methods_dev.html
10
11 .. index::
12 single: methods; C squared population analysis (CSPA)
13
14 C squared population analysis (CSPA)
15 ------------------------------------
16
17 **CSPA** can be used to determine and interpret the electron density of a molecule. The contribution of the a-th atomic orbital to the i-th molecular orbital can be written in terms of the molecular orbital coefficients:
18
19 .. math:: \Phi_{ai} = \frac{c^2_{ai}}{\sum_k c^2_{ki}}
20
21 The CSPA class available from cclib.method performs C-squared population analysis and can be used as follows:
22
23 .. code-block:: python
24
25 from cclib.io import ccread
26 from cclib.method import CSPA
27
28 data = ccread("mycalc.out")
29
30 m = CSPA(data)
31 m.calculate()
32
33 After the ``calculate()`` method is called, the following attributes are available:
34
35 * ``aoresults`` is a NumPy array[3] with spin, molecular orbital, and atomic/fragment orbitals as the axes (``aoresults[0][45][0]`` gives the contribution of the 1st atomic/fragment orbital to the 46th alpha/restricted molecular orbital)
36 * ``fragresults`` is a NumPy array[3] with spin, molecular orbital, and atoms as the axes (``atomresults[1][23][4]`` gives the contribution of the 5th atomic/fragment orbital to the 24th beta molecular orbital)
37 * ``fragcharges`` is a NumPy array[1] with the number of (partial) electrons in each atom (``atomcharges[2]`` gives the number of electrons on the 3rd atom)
38
39 Custom fragments
40 ~~~~~~~~~~~~~~~~
41
42 Calling the calculate method without an argument treats each atom as a fragment in the population analysis. An optional argument can be passed - a list of lists - containing the atomic orbital numbers to be included in each fragment. Calling with this additional argument is useful if one is more interested in the contributions of certain orbitals, such as metal d, to the molecular orbitals. For example:
43
44 .. code-block:: python
45
46 from cclib.io import ccread
47 from cclib.method import CSPA
48
49 data = ccread("mycalc.out")
50
51 m = CSPA(data)
52 m.calculate([[0, 1, 2, 3, 4], [5, 6], [7, 8, 9]]) # fragment one is made from basis functions 0 - 4
53 # fragment two is made from basis functions 5 & 6
54 # fragment three is made from basis functions 7 - 9
55
56 Custom progress
57 ~~~~~~~~~~~~~~~
58
59 The CSPA class also can take a progress class as an argument so that the progress of the calculation can be monitored:
60
61 .. code-block:: python
62
63 from cclib.method import CSPA
64 from cclib.parser import Gaussian
65 from cclib.progress import TextProgress
66
67 import logging
68
69 progress = TextProgress()
70 p = Gaussian("mycalc.out", logging.ERROR)
71 d = p.parse(progress)
72
73 m = CSPA(d, progress, logging.ERROR)
74 m.calculate()
75
76 .. index::
77 single: methods; Mulliken population analysis (MPA)
78
79 Mulliken population analysis (MPA)
80 ----------------------------------
81
82 MPA can be used to determine and interpret the electron density of a molecule. The contribution of the a-th atomic orbital to the i-th molecular orbital in this method is written in terms of the molecular orbital coefficients, c, and the overlap matrix, S:
83
84 .. math:: \Phi_{ai} = \sum_b c_{ai} c_{bi} S_{ab}
85
86 The MPA class available from cclib.method performs Mulliken population analysis and can be used as follows:
87
88 .. code-block:: python
89
90 import sys
91
92 from cclib.method import MPA
93 from cclib.parser import ccopen
94
95 d = ccopen(sys.argv[1]).parse()
96 m = MPA(d)
97 m.calculate()
98
99 After the calculate() method is called, the following attributes are available:
100
101 * ``aoresults``: a three dimensional array with spin, molecular orbital, and atomic orbitals as the axes, so that ``aoresults[0][45][0]`` gives the contribution of the 1st atomic orbital to the 46th alpha/restricted molecular orbital,
102 * ``fragresults``: a three dimensional array with spin, molecular orbital, and atoms as the axes, so that ``fragresults[1][23][4]`` gives the contribution of the 5th fragment orbitals to the 24th beta molecular orbital)
103 * ``fragcharges``: a vector with the number of (partial) electrons in each fragment, so that ``fragcharges[2]`` gives the number of electrons in the 3rd fragment.
104
105 Custom fragments
106 ~~~~~~~~~~~~~~~~
107
108 The calculate method chooses atoms as the fragments by default, and optionally accepts a list of lists containing the atomic orbital numbers (e.g. ``[[0, 1, 2], [3, 4, 5, 6], ...]``) of arbitrary fragments. Calling it in this way is useful if one is more interested in the contributions of groups of atoms or even certain orbitals or orbital groups, such as metal d, to the molecular orbitals. In this case, fragresults and fragcharges reflect the chosen groups of atomic orbitals instead of atoms.
109
110 Custom progress
111 ~~~~~~~~~~~~~~~
112
113 The Mulliken class also can take a progress class as an argument so that the progress of the calculation can be monitored:
114
115 .. code-block:: python
116
117 from cclib.method import MPA
118 from cclib.parser import ccopen
119 from cclib.progress import TextProgress
120 import logging
121
122 progress = TextProgress()
123 d = ccopen("mycalc.out", logging.ERROR).parse(progress)
124
125 m = MPA(d, progress, logging.ERROR)
126 m.calculate()
127
128 .. index::
129 single: methods; Löwdin Population Analysis
130
131 Löwdin Population Analysis
132 --------------------------
133
134 The LPA class available from cclib.method performs Löwdin population analysis and can be used as follows:
135
136 .. code-block:: python
137
138 import sys
139
140 from cclib.method import LPA
141 from cclib.parser import ccopen
142
143 d = ccopen(sys.argv[1]).parse()
144 m = LPA(d)
145 m.calculate()
146
147 ..
148 Overlap Population Analysis
149 ---------------------------
150
151 Density Matrix calculation
152 --------------------------
153
154 The Density class from cclib.method can be used to calculate the density matrix:
155
156 .. code-block:: python
157
158 from cclib.parser import ccopen
159 from cclib.method import Density
160
161 parser = ccopen("myfile.out")
162 data = parser.parse()
163
164 d = Density(data)
165 d.calculate()
166
167 After ``calculate()`` is called, the density attribute is available. It is simply a NumPy array with three axes. The first axis is for the spin contributions, and the second and third axes are for the density matrix, which follows the standard definition.
168
169 Mayer's Bond Orders
170 -------------------
171
172 This method calculates the Mayer's bond orders for a given molecule:
173
174 .. code-block:: python
175
176 import sys
177
178 from cclib.parser import ccopen
179 from cclib.method import MBO
180
181 parser = ccopen(sys.argv[1])
182 data = parser.parse()
183
184 d = MBO(data)
185 d.calculate()
186
187 After ``calculate()`` is called, the fragresults attribute is available, which is a NumPy array of rank 3. The first axis is for contributions of each spin to the MBO, while the second and third correspond to the indices of the atoms.
188
189 Charge Decomposition Analysis
190 -----------------------------
191
192 The Charge Decomposition Analysis (CDA) as developed by Gernot Frenking et al. is used to study the donor-acceptor interactions of a molecule in terms of two user-specified fragments.
193
194 The CDA class available from cclib.method performs this analysis:
195
196 .. code-block:: python
197
198 from cclib.io import ccopen
199 from cclib.method import CDA
200
201 molecule = ccopen("molecule.log")
202 frag1 = ccopen("fragment1.log")
203 frag2 = ccopen("fragment2.log")
204
205 # if using CDA from an interactive session, it's best
206 # to parse the files at the same time in case they aren't
207 # parsed immediately---go get a drink!
208
209 m = molecule.parse()
210 f1 = frag1.parse()
211 f2 = frag2.parse()
212
213 cda = CDA(m)
214 cda.calculate([f1, f2])
215
216 After ``calculate()`` finishes, there should be the donations, bdonations (back donation), and repulsions attributes to the cda instance. These attributes are simply lists of 1-dimensional NumPy arrays corresponding to the restricted or alpha/beta molecular orbitals of the entire molecule. Additionally, the CDA method involves transforming the atomic basis functions of the molecule into a basis using the molecular orbitals of the fragments so the attributes mocoeffs and fooverlaps are created and can be used in population analyses such as Mulliken or C-squared (see Fragment Analysis for more details).
217
218 There is also a script provided by cclib that performs the CDA from a command-line::
219
220 $ cda molecule.log fragment1.log fragment2.log
221 Charge decomposition analysis of molecule.log
222
223 MO# d b r
224 -----------------------------
225 1: -0.000 -0.000 -0.000
226 2: -0.000 0.002 0.000
227 3: -0.001 -0.000 0.000
228 4: -0.001 -0.026 -0.006
229 5: -0.006 0.082 0.230
230 6: -0.040 0.075 0.214
231 7: 0.001 -0.001 0.022
232 8: 0.001 -0.001 0.022
233 9: 0.054 0.342 -0.740
234 10: 0.087 -0.001 -0.039
235 11: 0.087 -0.001 -0.039
236 ------ HOMO - LUMO gap ------
237 12: 0.000 0.000 0.000
238 13: 0.000 0.000 0.000
239 ......
240
241 Notes
242 ~~~~~
243
244 * Only molecular orbitals with non-zero occupancy will have a non-zero value.
245 * The absolute values of the calculated terms have no physical meaning and only the relative magnitudes, especially for the donation and back donation terms, are of any real value (Frenking, et al.)
246 * The atom coordinates in molecules and fragments must be the same, which is usually accomplished with an argument in the QM program (the NoSymm keyword in Gaussian, for instance).
247 * The current implementation has some subtle differences than the code from the Frenking group. The CDA class in cclib follows the formula outlined in one of Frenking's CDA papers, but contains an extra factor of 2 to give results that agree with those from the original CDA program. It also doesn't include negligible terms (on the order of 10^-6) that result from overlap between MOs on the same fragment that appears to be included in the Frenking code. Contact atenderholt (at) gmail (dot) com for discussion and more information.
248
249 ..
250 Electron Density Calculation
251 ----------------------------