aromatools 0.2.44__tar.gz → 0.2.45__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {aromatools-0.2.44 → aromatools-0.2.45}/PKG-INFO +1 -1
  2. aromatools-0.2.45/aromatools/aroelectronics/NImL.py +515 -0
  3. aromatools-0.2.45/aromatools/aroelectronics/mulliken_and_lowdin.py +891 -0
  4. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/reset_calc.py +0 -5
  5. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools.egg-info/PKG-INFO +1 -1
  6. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools.egg-info/SOURCES.txt +2 -0
  7. {aromatools-0.2.44 → aromatools-0.2.45}/pyproject.toml +1 -1
  8. {aromatools-0.2.44 → aromatools-0.2.45}/LICENSE +0 -0
  9. {aromatools-0.2.44 → aromatools-0.2.45}/README.md +0 -0
  10. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/__init__.py +0 -0
  11. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/arogeometric/__init__.py +0 -0
  12. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/arogeometric/__main__.py +0 -0
  13. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/arogeometric/arogeometric.py +0 -0
  14. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/__init__.py +0 -0
  15. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/__main__.py +0 -0
  16. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/amg_read_input.py +0 -0
  17. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/amg_write_inputs.py +0 -0
  18. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/aromagnetic.py +0 -0
  19. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/check_out.py +0 -0
  20. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/cube_to_vtk.py +0 -0
  21. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/get_cube.py +0 -0
  22. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/get_grid.py +0 -0
  23. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/get_mo.py +0 -0
  24. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/get_profile.py +0 -0
  25. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/get_results.py +0 -0
  26. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/insert_basis.py +0 -0
  27. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/make_input.py +0 -0
  28. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/parser_mo.py +0 -0
  29. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/predixy.py +0 -0
  30. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/pseudo_pi.py +0 -0
  31. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/sum_rest.py +0 -0
  32. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools/aromagnetic/tools.py +0 -0
  33. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools.egg-info/dependency_links.txt +0 -0
  34. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools.egg-info/entry_points.txt +0 -0
  35. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools.egg-info/requires.txt +0 -0
  36. {aromatools-0.2.44 → aromatools-0.2.45}/aromatools.egg-info/top_level.txt +0 -0
  37. {aromatools-0.2.44 → aromatools-0.2.45}/setup.cfg +0 -0
  38. {aromatools-0.2.44 → aromatools-0.2.45}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aromatools
3
- Version: 0.2.44
3
+ Version: 0.2.45
4
4
  Summary: Tools for aromaticity evaluation
5
5
  Author: Fernando Martínez-Villarino, Mesías Orozco-Ic, Gabriel Merino
6
6
  License-Expression: MIT
@@ -0,0 +1,515 @@
1
+ import sys
2
+ import numpy as np
3
+ import warnings
4
+ warnings.filterwarnings('ignore', category=RuntimeWarning, message='.*matmul.*')
5
+
6
+ from esipy.make_aoms import make_aoms
7
+ from esipy.indicators import compute_iring, sequential_mci, compute_pdi, compute_flu, compute_av1245
8
+ from esipy.tools import find_di, format_partition
9
+
10
+ # Ring search defaults taken from ESIpy
11
+ RING_MIN_LENGTH = 6
12
+ RING_MAX_LENGTH = 12
13
+ RING_THRESHOLD = 0.3 # minimum DI (electrons) for two atoms to be connected
14
+ MCI_MAX_RING_SIZE = 12 # ESIpy only computes the MCI for rings up to 12 atoms
15
+ PDI_RING_SIZE = 6 # ESIpy only computes the PDI for 6-membered rings
16
+ AV1245_MIN_RING_SIZE = 6 # ESIpy only computes AV1245/AVmin for rings of 6 atoms or more
17
+
18
+ PARTITION_NAMES = {'NAO': 'nao', 'IAO': 'iao', 'mate-LOWDIN': 'meta-lowdin'}
19
+ NOT_IMPLEMENTED_PARTITIONS = ('QTAIM', 'MULLIKEN', 'LOWDIN')
20
+
21
+ # ============================================================
22
+ # INPUT.txt and geometry
23
+ # ============================================================
24
+
25
+ def read_input(input_path):
26
+ data = {}
27
+
28
+ file = open(input_path, 'r')
29
+ lines = file.readlines()
30
+ file.close()
31
+
32
+ for line in lines:
33
+ hash_position = line.find('#')
34
+ if hash_position != -1:
35
+ line = line[:hash_position]
36
+
37
+ line = line.strip()
38
+
39
+ if line == '':
40
+ continue
41
+
42
+ words = line.split()
43
+ key = words[0]
44
+ value = ' '.join(words[1:])
45
+
46
+ data[key] = value
47
+
48
+ return data
49
+
50
+ def is_requested(input_data, key):
51
+ value = input_data.get(key, '').strip().upper()
52
+ return value == 'YES'
53
+
54
+ def read_lines(path):
55
+ try:
56
+ file = open(path, 'r')
57
+ except OSError:
58
+ sys.exit("Could not open '" + path + "'.")
59
+ lines = file.readlines()
60
+ file.close()
61
+ return lines
62
+
63
+ def read_xyz(xyz_path):
64
+ lines = read_lines(xyz_path)
65
+
66
+ number_of_atoms = int(lines[0].strip())
67
+
68
+ symbols = []
69
+ coordinates = []
70
+
71
+ for i in range(2, 2 + number_of_atoms):
72
+ parts = lines[i].split()
73
+ symbols.append(parts[0])
74
+ coordinates.append([float(parts[1]), float(parts[2]), float(parts[3])])
75
+
76
+ return symbols, coordinates
77
+
78
+ # ============================================================
79
+ # PySCF calculation
80
+ # ============================================================
81
+
82
+ def run_pyscf(input_data, symbols, coordinates, charge, multiplicity):
83
+ from pyscf import gto, dft
84
+
85
+ functional_basis = input_data['FUNCTIONAL/BASIS-SET'].split('/')
86
+ functional = functional_basis[0].replace('-', '').lower()
87
+ basis = functional_basis[1].lower()
88
+
89
+ atom_text = ''
90
+ for symbol, xyz in zip(symbols, coordinates):
91
+ atom_text = atom_text + symbol + ' ' + str(xyz[0]) + ' ' + str(xyz[1]) + ' ' + str(xyz[2]) + '\n'
92
+
93
+ mol = gto.Mole()
94
+ mol.atom = atom_text
95
+ mol.basis = basis
96
+ mol.charge = charge
97
+ mol.spin = multiplicity - 1
98
+ mol.build()
99
+
100
+ is_open_shell = multiplicity != 1
101
+ mf = dft.UKS(mol) if is_open_shell else dft.RKS(mol)
102
+ mf.xc = functional
103
+ mf.kernel()
104
+
105
+ return mol, mf, is_open_shell
106
+
107
+ # ============================================================
108
+ # Populations, charges and DI, straight from the AOM (works for any
109
+ # partition, not just NAO/IAO/meta-Lowdin -- it is the same formula ESIpy
110
+ # itself uses in rest.py/unrest.py's population analysis)
111
+ # ============================================================
112
+
113
+ def combine_channel_value(values, is_open_shell):
114
+ if is_open_shell:
115
+ return values[0] + values[1]
116
+ return 2 * values[0]
117
+
118
+ def combine_channel_list(lists, is_open_shell):
119
+ if is_open_shell:
120
+ return list(np.add(lists[0], lists[1]))
121
+ return [2 * v for v in lists[0]]
122
+
123
+ def charges_and_DI(mol, aoms_by_spin, is_open_shell):
124
+ natoms = mol.natm
125
+
126
+ N = np.array([combine_channel_value([np.trace(ch[A]) for ch in aoms_by_spin], is_open_shell)
127
+ for A in range(natoms)])
128
+ Z = np.array([mol.atom_charge(A) for A in range(natoms)])
129
+ charges = Z - N
130
+ # print(charges)
131
+
132
+ DI = np.zeros((natoms, natoms))
133
+ for A in range(natoms):
134
+ for B in range(A + 1, natoms):
135
+ value = combine_channel_value([find_di(ch, A + 1, B + 1) for ch in aoms_by_spin], is_open_shell)
136
+ DI[A][B] = value
137
+ DI[B][A] = value
138
+
139
+ return charges, DI
140
+
141
+ # ============================================================
142
+ # Ring detection (same algorithm as ESIpy, atoms are 1-indexed)
143
+ # ============================================================
144
+
145
+ def filter_connec(connec):
146
+ if len(connec) < 2:
147
+ return connec
148
+ filtered_connec = {}
149
+ for key, values in connec.items():
150
+ if len(values) > 1:
151
+ filtered_vals = [v for v in values if len(connec[v]) > 1]
152
+ if filtered_vals:
153
+ filtered_connec[key] = filtered_vals
154
+ return filtered_connec
155
+
156
+ def build_connectivity(DI, threshold):
157
+ natoms = len(DI)
158
+ connec = {i: [] for i in range(1, natoms + 1)}
159
+
160
+ for i in range(1, natoms):
161
+ for j in range(i + 1, natoms + 1):
162
+ if DI[i - 1][j - 1] >= threshold:
163
+ connec[i].append(j)
164
+ connec[j].append(i)
165
+
166
+ return filter_connec({k: v for k, v in connec.items() if v})
167
+
168
+ def find_middle_nodes(connec):
169
+ return [key for key, values in connec.items() if len(values) > 2]
170
+
171
+ def find_rings(connec, minlen, maxlen):
172
+ def dfs(start):
173
+ stack = [(start, [start])]
174
+ while stack:
175
+ v, path = stack.pop()
176
+ if len(path) > maxlen:
177
+ continue
178
+ if (len(path) >= minlen and start in connec.get(path[-1], [])
179
+ and path[1] < path[-1] and path[0] == start):
180
+ yield path
181
+ for next_atom in connec.get(v, []):
182
+ if next_atom not in path:
183
+ stack.append((next_atom, path + [next_atom]))
184
+
185
+ def unique(path, all_paths):
186
+ for shift in range(len(path)):
187
+ rotated = np.roll(path, shift).tolist()
188
+ if rotated in all_paths or rotated[::-1] in all_paths:
189
+ return False
190
+ return True
191
+
192
+ all_paths = []
193
+ starts = find_middle_nodes(connec)
194
+ if not starts:
195
+ starts = sorted(connec)
196
+ for start in starts:
197
+ for path in dfs(start):
198
+ if unique(path, all_paths):
199
+ all_paths.append(path)
200
+
201
+ return all_paths
202
+
203
+ def get_rings(input_data, DI):
204
+ ring_value = input_data.get('RING', '').strip()
205
+
206
+ if ring_value != '': # Manual
207
+ return [[int(number) for number in ring_value.split()]]
208
+
209
+ connec = build_connectivity(DI, RING_THRESHOLD) # Automatic, from the DIs
210
+ if not connec:
211
+ return []
212
+ return find_rings(connec, RING_MIN_LENGTH, RING_MAX_LENGTH)
213
+
214
+ # ============================================================
215
+ # Aromaticity indices (Iring, MCI, PDI, FLU, AV1245/AVmin)
216
+ # Identical logic to mulliken_lowdin.py -- see the comment there for why
217
+ # the closed/open-shell combination rules are what they are.
218
+ # ============================================================
219
+
220
+ def nth_root(value, n):
221
+ if value < 0:
222
+ return -(abs(value) ** (1.0 / n))
223
+ return value ** (1.0 / n)
224
+
225
+ def calc_iring_mci(aoms_by_spin, ring, partition, is_open_shell, want_iring, want_mci):
226
+ result = {}
227
+
228
+ if want_iring:
229
+ irings = [compute_iring(ring, aom) for aom in aoms_by_spin]
230
+ result['iring'] = combine_channel_value(irings, is_open_shell)
231
+ if is_open_shell:
232
+ result['iring_spin'] = irings
233
+
234
+ if want_mci:
235
+ if len(ring) > MCI_MAX_RING_SIZE:
236
+ result['mci'] = None
237
+ else:
238
+ mcis = [sequential_mci(ring, aom, partition) for aom in aoms_by_spin]
239
+ result['mci'] = combine_channel_value(mcis, is_open_shell)
240
+ if is_open_shell:
241
+ result['mci_spin'] = mcis
242
+
243
+ return result
244
+
245
+ def calc_pdi(aoms_by_spin, ring, is_open_shell):
246
+ if len(ring) != PDI_RING_SIZE:
247
+ return None
248
+
249
+ per_channel = [compute_pdi(ring, aom) for aom in aoms_by_spin] # (value, [DI_14, DI_25, DI_36])
250
+ values = [channel[0] for channel in per_channel]
251
+ lists = [channel[1] for channel in per_channel]
252
+
253
+ pdi = combine_channel_value(values, is_open_shell)
254
+ pdi_list = combine_channel_list(lists, is_open_shell)
255
+ return pdi, pdi_list
256
+
257
+ def calc_av1245(aoms_by_spin, ring, partition, is_open_shell):
258
+ if len(ring) < AV1245_MIN_RING_SIZE:
259
+ return None
260
+
261
+ per_channel = [compute_av1245(ring, aom, partition) for aom in aoms_by_spin] # (mean, avmin, products)
262
+ products_per_channel = [channel[2] for channel in per_channel]
263
+
264
+ products = combine_channel_list(products_per_channel, is_open_shell)
265
+ av1245 = float(np.mean(products))
266
+ avmin = min(products, key=abs)
267
+ return av1245, avmin, products
268
+
269
+ def calc_flu(aoms_by_spin, ring, molinfo, partition, is_open_shell, flurefs=None):
270
+ values = [compute_flu(ring, molinfo, aom, flurefs, partition) for aom in aoms_by_spin]
271
+ if any(value is None for value in values):
272
+ return None
273
+ if is_open_shell:
274
+ return values[0] + values[1]
275
+ return values[0]
276
+
277
+ # ============================================================
278
+ # Output files: {molecule_name}_{partition}_{criterion}.csv
279
+ # ============================================================
280
+
281
+ def atom_label(symbols, atom):
282
+ return symbols[atom - 1] + str(atom)
283
+
284
+ def ring_bonds(ring):
285
+ bonds = []
286
+ for i in range(len(ring)):
287
+ A = ring[i]
288
+ B = ring[(i + 1) % len(ring)]
289
+ bonds.append((A, B))
290
+ return bonds
291
+
292
+ def write_csv(molecule_name, partition, criterion, header, rows):
293
+ file_name = molecule_name + '_' + partition + '_' + criterion + '.csv'
294
+ file = open(file_name, 'w')
295
+
296
+ file.write(header + '\n')
297
+ for row in rows:
298
+ file.write(','.join(str(item) for item in row) + '\n')
299
+
300
+ file.close()
301
+ return file_name
302
+
303
+ def write_info_txt(molecule_name, mol, is_open_shell, charge, multiplicity, functional_basis,
304
+ output_files, skipped, rings_by_partition):
305
+ system_type = 'open-shell' if is_open_shell else 'closed-shell'
306
+ equations = 'UHF/UKS' if is_open_shell else 'RHF/RKS'
307
+
308
+ text = 'The ' + molecule_name + ' is ' + system_type + ', therefore, we use ' + equations + '.\n\n'
309
+ text = text + 'Program: PySCF\n'
310
+ text = text + 'Functional/basis-set: ' + functional_basis + '\n'
311
+ text = text + 'Charge: ' + str(charge) + '\n'
312
+ text = text + 'Multiplicity: ' + str(multiplicity) + '\n\n'
313
+
314
+ text = text + 'Rings found:\n'
315
+ for partition in rings_by_partition:
316
+ rings = rings_by_partition[partition]
317
+ if not rings:
318
+ text = text + ' ' + partition.capitalize() + ': none found (ring size ' + \
319
+ str(RING_MIN_LENGTH) + '-' + str(RING_MAX_LENGTH) + ', DI >= ' + str(RING_THRESHOLD) + \
320
+ '; set RING in INPUT.txt to give it manually)\n'
321
+ else:
322
+ for number, ring in enumerate(rings, start=1):
323
+ ring_text = '-'.join(str(atom) for atom in ring)
324
+ text = text + ' ' + partition.capitalize() + ' ring ' + str(number) + ': ' + ring_text + '\n'
325
+ text = text + '\n'
326
+
327
+ text = text + 'Output files:\n'
328
+ for file_name in output_files:
329
+ text = text + ' - ' + file_name + '\n'
330
+
331
+ if skipped:
332
+ text = text + '\nRequested but not implemented (skipped): ' + ', '.join(skipped) + '\n'
333
+
334
+ file = open('info.txt', 'w')
335
+ file.write(text)
336
+ file.close()
337
+ print(text)
338
+
339
+ # ============================================================
340
+ # MAIN PROGRAM
341
+ # ============================================================
342
+
343
+ def analyse_partition(partition, input_data, mol, mf, is_open_shell, molecule_name,
344
+ want_di, want_iring, want_mci, want_pdi, want_flu, want_av1245,
345
+ output_files, rings_by_partition):
346
+ symbols = [mol.atom_symbol(A) for A in range(mol.natm)]
347
+ molinfo = {'symbols': symbols}
348
+ print('=== ' + partition.capitalize() + ' partition ===')
349
+
350
+ aom = make_aoms(mol, mf, partition, myhf=None, save=None)
351
+ aoms_by_spin = aom if is_open_shell else [aom]
352
+
353
+ charges, DI = charges_and_DI(mol, aoms_by_spin, is_open_shell)
354
+
355
+ rows = []
356
+ for A in range(len(symbols)):
357
+ rows.append((symbols[A] + str(A + 1), charges[A]))
358
+ output_files.append(write_csv(molecule_name, partition, 'charges',
359
+ 'Atom,' + partition.capitalize() + ' charges', rows))
360
+
361
+ want_aromaticity = want_di or want_iring or want_mci or want_pdi or want_flu or want_av1245
362
+ if not want_aromaticity:
363
+ rings_by_partition[partition] = []
364
+ return
365
+
366
+ rings = get_rings(input_data, DI)
367
+ rings_by_partition[partition] = rings
368
+
369
+ if not rings:
370
+ print('No ring found (ring size ' + str(RING_MIN_LENGTH) + '-' + str(RING_MAX_LENGTH) +
371
+ ', DI >= ' + str(RING_THRESHOLD) + '). Set RING in INPUT.txt to give it manually.')
372
+ return
373
+
374
+ for number, ring in enumerate(rings, start=1):
375
+ print('Ring ' + str(number) + ': ' + '-'.join(str(atom) for atom in ring))
376
+
377
+ if want_di:
378
+ rows = []
379
+ for number, ring in enumerate(rings, start=1):
380
+ for A, B in ring_bonds(ring):
381
+ label = atom_label(symbols, A) + '-' + atom_label(symbols, B)
382
+ rows.append((number, label, DI[A - 1][B - 1]))
383
+ output_files.append(write_csv(molecule_name, partition, 'di',
384
+ 'Ring,Bond,delta(A,B)', rows))
385
+
386
+ spin_header = ',alpha,beta' if is_open_shell else ''
387
+ iring_rows, mci_rows, pdi_rows, flu_rows, av1245_rows = [], [], [], [], []
388
+
389
+ for number, ring in enumerate(rings, start=1):
390
+ ring_text = '-'.join(str(atom) for atom in ring)
391
+ n = len(ring)
392
+
393
+ result = calc_iring_mci(aoms_by_spin, ring, partition, is_open_shell, want_iring, want_mci)
394
+
395
+ if want_iring:
396
+ row = [number, ring_text, n, result['iring'], nth_root(result['iring'], n)]
397
+ if is_open_shell:
398
+ row = row + result['iring_spin']
399
+ iring_rows.append(row)
400
+ print('Iring ' + str(number) + ' = ' + str(round(result['iring'], 6)))
401
+
402
+ if want_mci:
403
+ if result['mci'] is None:
404
+ print('MCI ' + str(number) + ' skipped: ring size ' + str(n) +
405
+ ' > ' + str(MCI_MAX_RING_SIZE))
406
+ else:
407
+ row = [number, ring_text, n, result['mci'], nth_root(result['mci'], n)]
408
+ if is_open_shell:
409
+ row = row + result['mci_spin']
410
+ mci_rows.append(row)
411
+ print('MCI ' + str(number) + ' = ' + str(round(result['mci'], 6)))
412
+
413
+ if want_pdi:
414
+ pdi_result = calc_pdi(aoms_by_spin, ring, is_open_shell)
415
+ if pdi_result is None:
416
+ print('PDI ' + str(number) + ' skipped: ring size ' + str(n) +
417
+ ' != ' + str(PDI_RING_SIZE))
418
+ else:
419
+ pdi, pdi_list = pdi_result
420
+ for k, (A, B) in enumerate(((ring[0], ring[3]), (ring[1], ring[4]), (ring[2], ring[5]))):
421
+ label = atom_label(symbols, A) + '-' + atom_label(symbols, B)
422
+ pdi_rows.append([number, pdi, label, pdi_list[k]])
423
+ print('PDI ' + str(number) + ' = ' + str(round(pdi, 6)))
424
+
425
+ if want_flu:
426
+ flu = calc_flu(aoms_by_spin, ring, molinfo, partition, is_open_shell)
427
+ if flu is None:
428
+ print('FLU ' + str(number) + ' skipped: missing reference for a bond type in the ring')
429
+ else:
430
+ flu_rows.append([number, ring_text, n, flu])
431
+ print('FLU ' + str(number) + ' = ' + str(round(flu, 6)))
432
+
433
+ if want_av1245:
434
+ av_result = calc_av1245(aoms_by_spin, ring, partition, is_open_shell)
435
+ if av_result is None:
436
+ print('AV1245 ' + str(number) + ' skipped: ring size ' + str(n) +
437
+ ' < ' + str(AV1245_MIN_RING_SIZE))
438
+ else:
439
+ av1245, avmin, products = av_result
440
+ for k in range(n):
441
+ quadruplet = (ring[k % n], ring[(k + 1) % n], ring[(k + 3) % n], ring[(k + 4) % n])
442
+ label = '-'.join(atom_label(symbols, atom) for atom in quadruplet)
443
+ av1245_rows.append([number, av1245, avmin, label, products[k]])
444
+ print('AV1245 ' + str(number) + ' = ' + str(round(av1245, 6)) +
445
+ ' | AVmin ' + str(number) + ' = ' + str(round(avmin, 6)))
446
+
447
+ if want_iring:
448
+ output_files.append(write_csv(molecule_name, partition, 'iring',
449
+ 'Ring,Atoms,Size,Iring,Iring**(1/n)' + spin_header, iring_rows))
450
+ if want_mci:
451
+ output_files.append(write_csv(molecule_name, partition, 'mci',
452
+ 'Ring,Atoms,Size,MCI,MCI**(1/n)' + spin_header, mci_rows))
453
+ if want_pdi:
454
+ output_files.append(write_csv(molecule_name, partition, 'pdi',
455
+ 'Ring,PDI,Bond,DI', pdi_rows))
456
+ if want_flu:
457
+ output_files.append(write_csv(molecule_name, partition, 'flu',
458
+ 'Ring,Atoms,Size,FLU', flu_rows))
459
+ if want_av1245:
460
+ output_files.append(write_csv(molecule_name, partition, 'av1245',
461
+ 'Ring,AV1245,AVmin,Quadruplet,Value', av1245_rows))
462
+
463
+ def main():
464
+ input_path = sys.argv[1] if len(sys.argv) > 1 else 'INPUT.txt'
465
+ input_data = read_input(input_path)
466
+
467
+ program = input_data.get('PROGRAM', '').strip().upper()
468
+ if program not in ('', 'PYSCF'):
469
+ sys.exit("This script only supports PROGRAM = PySCF (found '" + program +
470
+ "'). Use mulliken_lowdin.py for Gaussian/ORCA (Mulliken/Lowdin only).")
471
+
472
+ partitions = [format_partition(PARTITION_NAMES[key]) for key in PARTITION_NAMES if is_requested(input_data, key)]
473
+ skipped = [key for key in NOT_IMPLEMENTED_PARTITIONS if is_requested(input_data, key)]
474
+
475
+ if not partitions:
476
+ print('None of NAO, IAO, mate-LOWDIN is set to YES in INPUT.txt; nothing to do.')
477
+ return
478
+ if skipped:
479
+ print('Not implemented in nao_iao_metalowdin.py, skipping: ' + ', '.join(skipped) +
480
+ ' (use mulliken_lowdin.py for Mulliken/Lowdin)')
481
+
482
+ for key in ('NAME_MOLECULE', 'FUNCTIONAL/BASIS-SET', 'CHARGE', 'MULTIPLICITY', 'MOLECULAR_COORDINARES'):
483
+ if key not in input_data:
484
+ sys.exit(key + ' is missing in INPUT.txt (required for PySCF).')
485
+
486
+ molecule_name = input_data['NAME_MOLECULE']
487
+ charge = int(input_data['CHARGE'])
488
+ multiplicity = int(input_data['MULTIPLICITY'])
489
+ symbols, coordinates = read_xyz(input_data['MOLECULAR_COORDINARES'])
490
+
491
+ want_di = is_requested(input_data, 'DI')
492
+ want_iring = is_requested(input_data, 'Iring')
493
+ want_mci = is_requested(input_data, 'MCI')
494
+ want_pdi = is_requested(input_data, 'PDI')
495
+ want_flu = is_requested(input_data, 'FLU')
496
+ want_av1245 = is_requested(input_data, 'AV1245')
497
+
498
+ mol, mf, is_open_shell = run_pyscf(input_data, symbols, coordinates, charge, multiplicity)
499
+
500
+ output_files = []
501
+ rings_by_partition = {}
502
+ for partition in partitions:
503
+ analyse_partition(partition, input_data, mol, mf, is_open_shell, molecule_name,
504
+ want_di, want_iring, want_mci, want_pdi, want_flu, want_av1245,
505
+ output_files, rings_by_partition)
506
+
507
+ write_info_txt(molecule_name, mol, is_open_shell, charge, multiplicity,
508
+ input_data['FUNCTIONAL/BASIS-SET'], output_files, skipped, rings_by_partition)
509
+
510
+
511
+ if __name__ == '__main__':
512
+ main()
513
+
514
+
515
+