parser_gaussian.py 82.8 KB
Newer Older
1
2
3
4
from __future__ import division
from builtins import str
from builtins import range
from builtins import object
5
import setup_paths
6
from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM
7
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
8
from nomadcore.caching_backend import CachingLevel
9
from nomadcore.unit_conversion.unit_conversion import convert_unit
10
11
import os, sys, json, logging
import numpy as np
12
import ase
13
14
15
16
17
18
19
import re

############################################################
# This is the parser for the output file of Gaussian.
############################################################

logger = logging.getLogger("nomad.GaussianParser")
20

Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
21
# description of the output
22
23
24
mainFileDescription = SM(
    name = 'root',
    weak = True,
25
    forwardMatch = True, 
26
27
28
    startReStr = "",
    subMatchers = [
        SM(name = 'newRun',
29
30
           startReStr = r"\s*Cite this work as:",
#           endReStr = r"\s*Normal termination of Gaussian",
31
32
33
           repeats = True,
           required = True,
           forwardMatch = True,
34
35
           fixedStartValues={ 'program_name': 'Gaussian', 'program_basis_set_type': 'gaussians' },
           sections   = ['section_run'],
36
37
           subMatchers = [
               SM(name = 'header',
38
39
                  startReStr = r"\s*Cite this work as:",
                  forwardMatch = True,
40
41
42
43
                  subMatchers = [
                      SM(r"\s*Cite this work as:"),
                      SM(r"\s*Gaussian [0-9]+, Revision [A-Za-z0-9.]*,"),
                      SM(r"\s\*\*\*\*\*\*\*\*\*\*\*\**"),
44
                      SM(r"\s*Gaussian\s*(?P<program_version>[0-9]+):\s*(?P<x_gaussian_program_implementation>[A-Za-z0-9-.]+)\s*(?P<x_gaussian_program_release_date>[0-9][0-9]?\-[A-Z][a-z][a-z]\-[0-9]+)"),
45
                      SM(r"\s*(?P<x_gaussian_program_execution_date>[0-9][0-9]?\-[A-Z][a-z][a-z]\-[0-9]+)"),
46
                      ]
47
             ),
48
49
50
51
52
               SM(name = 'globalparams',
                  startReStr = r"\s*%\w*=",
                  subFlags = SM.SubFlags.Unordered,
                  forwardMatch = True,
                  subMatchers = [
53
54
55
                      SM(r"\s*%[Cc]hk=(?P<x_gaussian_chk_file>[A-Za-z0-9.]*)"),
                      SM(r"\s*%[Mm]em=(?P<x_gaussian_memory>[A-Za-z0-9.]*)"),
                      SM(r"\s*%[Nn][Pp]roc=(?P<x_gaussian_number_of_processors>[A-Za-z0-9.]*)")
56
                      ]
57
58
59
60
61
62
63
64
65
             ),
               SM (name = 'SectionMethod',
               sections = ['section_method'],
                   startReStr = r"\s*#",
                   forwardMatch = True,
                   subMatchers = [
                       SM(r"\s*(?P<x_gaussian_settings>([a-zA-Z0-9-/=(),#*+:]*\s*)+)"),
                       SM(r"\s*(?P<x_gaussian_settings>([a-zA-Z0-9-/=(),#*+:]*\s*)+)")
                       ]
66
             ),
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
67
               SM(name = 'charge_multiplicity_cell',
68
               sections = ['section_system'],
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
69
		  startReStr = r"\s*Charge =",
70
                  endReStr = r"\s*Leave Link  101\s*",
71
                  subFlags = SM.SubFlags.Unordered,
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
72
73
                  forwardMatch = True,
                  subMatchers = [
74
                      SM(r"\s*Charge =\s*(?P<x_gaussian_total_charge>[-+0-9]*) Multiplicity =\s*(?P<x_gaussian_spin_target_multiplicity>[0-9]*)"),
75
                      SM(r"\s*(Tv|Tv\s*[0]|TV|TV\s*[0])\s*(?P<x_gaussian_geometry_lattice_vector_x>[0-9.]*)\s+(?P<x_gaussian_geometry_lattice_vector_y>[0-9.]*)\s+(?P<x_gaussian_geometry_lattice_vector_z>[0-9.]*)", repeats = True),
76
77
78
79
80
81
82
83
84
85
86
87
                      SM(r"\s*AtmWgt=\s+(?P<x_gaussian_atomic_masses>[0-9.]+(\s+[0-9.]+)(\s+[0-9.]+)?(\s+[0-9.]+)?(\s+[0-9.]+)?(\s+[0-9.]+)?(\s+[0-9.]+)?(\s+[0-9.]+)?(\s+[0-9.]+)?(\s+[0-9.]+)?)", repeats = True)
                      ]
             ),
            SM (name = 'SingleConfigurationCalculationWithSystemDescription',
                startReStr = "\s*Standard orientation:",
                repeats = False,
                forwardMatch = True,
                subMatchers = [
                SM (name = 'SingleConfigurationCalculation',
                  startReStr = "\s*Standard orientation:",
                  repeats = True,
                  forwardMatch = True,
88
                  sections = ['section_single_configuration_calculation'],
89
90
91
                  subMatchers = [
                  SM(name = 'geometry',
                   sections  = ['x_gaussian_section_geometry'],
92
                   startReStr = r"\s*Standard orientation:",
93
                   endReStr = r"\s*Rotational constants",
94
                      subMatchers = [
95
                      SM(r"\s+[0-9]+\s+(?P<x_gaussian_atomic_number>[0-9]+)\s+[0-9]+\s+(?P<x_gaussian_atom_x_coord__angstrom>[-+0-9EeDd.]+)\s+(?P<x_gaussian_atom_y_coord__angstrom>[-+0-9EeDd.]+)\s+(?P<x_gaussian_atom_z_coord__angstrom>[-+0-9EeDd.]+)",repeats = True),
96
97
98
99
                      SM(r"\s*Rotational constants")
                    ]
                ),
                    SM(name = 'TotalEnergyScfGaussian',
100
                    sections  = ['section_scf_iteration'],
101
                    startReStr = r"\s*Cycle\s+[0-9]+",
102
                    endReStr = r"\s*Leave Link  502\s*",
103
104
105
106
                    forwardMatch = True,
                    repeats = True, 
                    subMatchers = [
                    SM(r"\s*Cycle\s+[0-9]+"),
107
108
109
110
                    SM(r"\s*E=\s*(?P<energy_total_scf_iteration__hartree>[-+0-9.]+)\s*Delta-E=\s*(?P<x_gaussian_delta_energy_total_scf_iteration__hartree>[-+0-9.]+)"),
                    SM(r"\s*(?P<x_gaussian_single_configuration_calculation_converged>SCF Done):\s*[(),A-Za-z0-9-]+\s*=\s*(?P<x_gaussian_energy_total__hartree>[-+0-9.]+)"),
                     SM(r"\s*NFock=\s*[0-9]+\s*Conv=(?P<x_gaussian_energy_error__hartree>[-+0-9EeDd.]+)\s*"),
                     SM(r"\s*KE=\s*(?P<x_gaussian_electronic_kinetic_energy__hartree>[-+0-9EeDd.]+)\s*"),
111
112
113
114
                    ]
                ), 
                    SM(name = 'RealSpinValue',
                    sections  = ['x_gaussian_section_real_spin_squared'],
115
                    startReStr = r"\s*Annihilation of the first spin contaminant",
116
                    forwardMatch = True,
117
                    repeats = True,
118
119
                    subMatchers = [
                     SM(r"\s*Annihilation of the first spin contaminant"),
120
                     SM(r"\s*[A-Z][*][*][0-9]\s*before annihilation\s*(?P<spin_S2>[0-9.]+),\s*after\s*(?P<x_gaussian_after_annihilation_spin_S2>[0-9.]+)")
121
122
                     ]
                ),
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
                    SM(name = 'PerturbationEnergies',
                    sections = ['x_gaussian_section_moller_plesset'],
                    startReStr = r"\s*E2 =\s*",
                    forwardMatch = True,
                    subMatchers = [
                     SM(r"\s*E2 =\s*(?P<x_gaussian_mp2_correction_energy__hartree>[-+0-9EeDd.]+)\s*EUMP2 =\s*(?P<x_gaussian_mp2_energy__hartree>[-+0-9EeDd.]+)"),
                     SM(r"\s*E3=\s*(?P<x_gaussian_mp3_correction_energy__hartree>[-+0-9EeDd.]+)\s*EUMP3=\s*(?P<x_gaussian_mp3_energy__hartree>[-+0-9EeDd.]+)\s*"),
                     SM(r"\s*E4\(DQ\)=\s*(?P<x_gaussian_mp4dq_correction_energy__hartree>[-+0-9EeDd.]+)\s*UMP4\(DQ\)=\s*(?P<x_gaussian_mp4dq_energy__hartree>[-+0-9EeDd.]+)\s*"),
                     SM(r"\s*E4\(SDQ\)=\s*(?P<x_gaussian_mp4sdq_correction_energy__hartree>[-+0-9EeDd.]+)\s*UMP4\(SDQ\)=\s*(?P<x_gaussian_mp4sdq_energy__hartree>[-+0-9EeDd.]+)"),
                     SM(r"\s*E4\(SDTQ\)=\s*(?P<x_gaussian_mp4sdtq_correction_energy__hartree>[-+0-9EeDd.]+)\s*UMP4\(SDTQ\)=\s*(?P<x_gaussian_mp4sdtq_energy__hartree>[-+0-9EeDd.]+)"),
                     SM(r"\s*DEMP5 =\s*(?P<x_gaussian_mp5_correction_energy__hartree>[-+0-9EeDd.]+)\s*MP5 =\s*(?P<x_gaussian_mp5_energy__hartree>[-+0-9EeDd.]+)"),
                     ]
                ),
                    SM(name = 'CoupledClusterEnergies',
                    sections = ['x_gaussian_section_coupled_cluster'],
                    startReStr = r"\s*CCSD\(T\)\s*",
                    endReStr = r"\s*Population analysis using the SCF density",
                    forwardMatch = True,
                    subMatchers = [
                     SM(r"\s*DE\(Corr\)=\s*(?P<x_gaussian_ccsd_correction_energy__hartree>[-+0-9EeDd.]+)\s*E\(CORR\)=\s*(?P<x_gaussian_ccsd_energy__hartree>[-+0-9EeDd.]+)", repeats = True),
                     SM(r"\s*CCSD\(T\)=\s*(?P<x_gaussian_ccsdt_energy__hartree>[-+0-9EeDd.]+)"),
                     ]
                ),
                    SM(name = 'QuadraticCIEnergies',
                    sections = ['x_gaussian_section_quadratic_ci'],
                    startReStr = r"\s*Quadratic Configuration Interaction\s*",
                    endReStr = r"\s*Population analysis using the SCF density",
                    forwardMatch = True,
                    subMatchers = [
                     SM(r"\s*DE\(Z\)=\s*(?P<x_gaussian_qcisd_correction_energy__hartree>[-+0-9EeDd.]+)\s*E\(Z\)=\s*(?P<x_gaussian_qcisd_energy__hartree>[-+0-9EeDd.]+)", repeats = True),
                     SM(r"\s*DE\(Corr\)=\s*(?P<x_gaussian_qcisd_correction_energy__hartree>[-+0-9EeDd.]+)\s*E\(CORR\)=\s*(?P<x_gaussian_qcisd_energy__hartree>[-+0-9EeDd.]+)", repeats = True),
                     SM(r"\s*QCISD\(T\)=\s*(?P<x_gaussian_qcisdt_energy__hartree>[-+0-9EeDd.]+)"),
                     SM(r"\s*DE5\s*=\s*(?P<x_gaussian_qcisdtq_correction_energy__hartree>[-+0-9EeDd.]+)\s*QCISD\(TQ\)\s*=\s*(?P<x_gaussian_qcisdtq_energy__hartree>[-+0-9EeDd.]+)", repeats = True),
                     ]
                ),
                    SM(name = 'CIEnergies',
                    sections = ['x_gaussian_section_ci'],
                    startReStr = r"\s*Configuration Interaction\s*",
                    endReStr = r"\s*Population analysis using the SCF density",
                    forwardMatch = True,
                    subMatchers = [
                     SM(r"\s*DE\(CI\)=\s*(?P<x_gaussian_ci_correction_energy__hartree>[-+0-9EeDd.]+)\s*E\(CI\)=\s*(?P<x_gaussian_ci_energy__hartree>[-+0-9EeDd.]+)", repeats = True),
                     ]
                ),
                    SM(name = 'SemiempiricalEnergies',
                    sections = ['x_gaussian_section_semiempirical'],
                    startReStr = r"\s*[-A-Z0-9]+\s*calculation of energy[a-zA-Z,. ]+\s*",
                    endReStr = r"\s*Population analysis using the SCF density",
                    forwardMatch = True,
                    subMatchers = [
                     SM(r"\s*(?P<x_gaussian_semiempirical_method>[-A-Z0-9]+\s*calculation of energy[a-zA-Z,. ]+)"),
                     SM(r"\s*It=\s*[0-9]+\s*PL=\s*[-+0-9EeDd.]+\s*DiagD=[A-Z]\s*ESCF=\s*(?P<x_gaussian_semiempirical_energy>[-+0-9.]+)\s*", repeats = True),
                     SM(r"\s*Energy=\s*(?P<x_gaussian_semiempirical_energy_converged>[-+0-9EeDd.]+)"),
                     ]
                ),
                    SM(name = 'MolecularMechanicsEnergies',
                    sections = ['x_gaussian_section_molmech'],
                    startReStr = r"\s*[-A-Z0-9]+\s*calculation of energy[a-zA-Z,. ]+\s*",
                    forwardMatch = False,
                    repeats = True,
                    subMatchers = [
                     SM(r"\s*(?P<x_gaussian_molmech_method>[a-zA-Z0-9]+\s*calculation of energy[a-z,. ]+)"),
                     SM(r"\s*Energy=\s*(?P<x_gaussian_molmech_energy>[-+0-9EeDd.]+)\s*NIter=\s*[0-9.]"),
                     ]
                ),
                  SM(name = 'ExcitedStates',
                   sections  = ['x_gaussian_section_excited_initial'],
                   startReStr = r"\s*Excitation energies and oscillator strengths",
                   forwardMatch = False,
                   repeats = True,
                   subMatchers = [
                    SM(name = 'ExcitedStates',
                    sections = ['x_gaussian_section_excited'],
                    startReStr = r"\s*Excited State\s*",
                    forwardMatch = True,
                    repeats = True,
                    subMatchers = [
                     SM(r"\s*Excited State\s*(?P<x_gaussian_excited_state_number>[0-9]+):\s*[-+0-9A-Za-z.\?]+\s*(?P<x_gaussian_excited_energy__eV>[0-9.]+)\s*eV\s*[0-9.]+\s*nm\s*f=(?P<x_gaussian_excited_oscstrength>[0-9.]+)\s*<[A-Z][*][*][0-9]>=(?P<x_gaussian_excited_spin_squared>[0-9.]+)"),
                     SM(r"\s*(?P<x_gaussian_excited_transition>[0-9A-Z]+\s*->\s*[0-9A-Z]+\s*[-+0-9.]+)", repeats = True),
                     SM(r"\s*This state for optimization|\r?\n"),
                     ]
                    )
                   ]
               ),  
                  SM(name = 'CASSCFStates',
                   sections = ['x_gaussian_section_casscf'],
                   startReStr = r"\s*EIGENVALUES AND\s*",
210
                   forwardMatch = True,
211
                   repeats = False,
212
                   subMatchers = [
213
214
215
216
                    SM(r"\s*EIGENVALUES AND\s*"),
                    SM(r"\s*\(\s*[0-9]+\)\s*EIGENVALUE\s*(?P<x_gaussian_casscf_energy__hartree>[-+0-9.]+)", repeats = True),
                   ]
               ),
217
                  SM(name = 'Geometry_optimization',
218
                  sections  = ['x_gaussian_section_geometry_optimization_info'],
219
                  startReStr = r"\s*Optimization completed.",
220
                  forwardMatch = True,
221
                  subMatchers = [
222
                  SM(r"\s*(?P<x_gaussian_geometry_optimization_converged>Optimization completed)"),
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
                  SM(r"\s*(?P<x_gaussian_geometry_optimization_converged>Optimization stopped)"),
                  SM(r"\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[-+0-9EeDd.]+\s+[-+0-9EeDd.]+\s+[-+0-9EeDd.]+",repeats = True),
                  SM(r"\s*Distance matrix|\s*Rotational constants|\s*Stoichiometry")
                    ]
               ),
                SM(name = 'Orbital symmetries',
                sections = ['x_gaussian_section_orbital_symmetries'],
                startReStr = r"\s+Population analysis",
                subFlags = SM.SubFlags.Sequenced,
                subMatchers = [
                      SM(r"\s*Orbital symmetries"), 
                      SM(r"\s*Alpha Orbitals"),
                      SM(r"\s*Occupied\s+(?P<x_gaussian_alpha_occ_symmetry_values>\((.+)\))?"),
                      SM(r"\s+(?P<x_gaussian_alpha_occ_symmetry_values>\((.+)\)?)", repeats = True),
                      SM(r"\s*Virtual\s+(?P<x_gaussian_alpha_vir_symmetry_values>\((.+)\))?"),
                      SM(r"\s+(?P<x_gaussian_alpha_vir_symmetry_values>\((.+)\)?)", repeats = True),
                      SM(r"\s*Beta Orbitals"),
                      SM(r"\s*Occupied\s+(?P<x_gaussian_beta_occ_symmetry_values>\((.+)\))?"),
                      SM(r"\s+(?P<x_gaussian_beta_occ_symmetry_values>\((.+)\)?)", repeats = True),
                      SM(r"\s*Virtual\s+(?P<x_gaussian_beta_vir_symmetry_values>\((.+)\))?"),
                      SM(r"\s+(?P<x_gaussian_beta_vir_symmetry_values>\((.+)\)?)", repeats = True),
                      ]
             ),
                SM(name = 'Electronicstatesymmetry',
                sections = ['x_gaussian_section_symmetry'],
                startReStr = r"\s*The electronic state is",
                forwardMatch = True,
                subMatchers = [
251
                      SM(r"\s*The electronic state is\s*(?P<x_gaussian_elstate_symmetry>[A-Z0-9-']+)[.]")
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
                      ]
             ),
                SM(name = 'Eigenvalues',
                sections = ['x_gaussian_section_eigenvalues'],
                startReStr = r"\s*Alpha  occ. eigenvalues --",
                forwardMatch = True,
                subFlags = SM.SubFlags.Sequenced,
                subMatchers = [
                      SM(r"\s*Alpha  occ. eigenvalues --\s+(?P<x_gaussian_alpha_occ_eigenvalues_values>(.+)?)", repeats = True), 
                      SM(r"\s*Alpha virt. eigenvalues --\s+(?P<x_gaussian_alpha_vir_eigenvalues_values>(.+)?)", repeats = True),
                      SM(r"\s*Beta  occ. eigenvalues --\s+(?P<x_gaussian_beta_occ_eigenvalues_values>(.+)?)", repeats = True),
                      SM(r"\s*Beta virt. eigenvalues --\s+(?P<x_gaussian_beta_vir_eigenvalues_values>(.+)?)", repeats = True),
                      SM(r"\s*- Condensed to atoms (all electrons)"),
                      ]
             ),
                SM(name = 'Multipoles',
                  sections = ['x_gaussian_section_molecular_multipoles'],
269
270
                  startReStr = r"\s*Electronic spatial extent",
                  forwardMatch = False,
271
                  subMatchers = [
272
                      SM(r"\s*Charge=(?P<charge>\s*[-0-9.]+)"),
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
                      SM(r"\s*Dipole moment "), 
                      SM(r"\s+\w+=\s+(?P<dipole_moment_x>[-+0-9EeDd.]+)\s+\w+=\s+(?P<dipole_moment_y>[-+0-9EeDd.]+)\s+\w+=\s+(?P<dipole_moment_z>[-+0-9EeDd.]+)"),
                      SM(r"\s*Quadrupole moment"), 
                      SM(r"\s+\w+=\s+(?P<quadrupole_moment_xx>[0-9-.]+)\s+\w+=\s+(?P<quadrupole_moment_yy>[0-9-.]+)\s+\w+=\s+(?P<quadrupole_moment_zz>[0-9-.]+)"), 
                      SM(r"\s+\w+=\s+(?P<quadrupole_moment_xy>[0-9-.]+)\s+\w+=\s+(?P<quadrupole_moment_xz>[0-9-.]+)\s+\w+=\s+(?P<quadrupole_moment_yz>[0-9-.]+)"),
                      SM(r"\s*Traceless Quadrupole moment"),
                      SM(r"\s+\w+=\s+[0-9-.]+\s+\w+=\s+[0-9-.]+\s+\w+=\s+[0-9-.]+"),
                      SM(r"\s+\w+=\s+[0-9-.]+\s+\w+=\s+[0-9-.]+\s+\w+=\s+[0-9-.]+"),
                      SM(r"\s*Octapole moment"),
                      SM(r"\s+\w+=\s+(?P<octapole_moment_xxx>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_yyy>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_zzz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_xyy>[-+0-9EeDd.]+)"),
                      SM(r"\s+\w+=\s+(?P<octapole_moment_xxy>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_xxz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_xzz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_yzz>[-+0-9EeDd.]+)"),
                      SM(r"\s+\w+=\s+(?P<octapole_moment_yyz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<octapole_moment_xyz>[-+0-9EeDd.]+)"),
                      SM(r"\s*Hexadecapole moment"),
                      SM(r"\s+\w+=\s+(?P<hexadecapole_moment_xxxx>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_yyyy>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_zzzz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_xxxy>[-+0-9EeDd.]+)"),
                      SM(r"\s+\w+=\s+(?P<hexadecapole_moment_xxxz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_yyyx>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_yyyz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_zzzx>[-+0-9EeDd.]+)"),
                      SM(r"\s+\w+=\s+(?P<hexadecapole_moment_zzzy>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_xxyy>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_xxzz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_yyzz>[-+0-9EeDd.]+)"),
                      SM(r"\s+\w+=\s+(?P<hexadecapole_moment_xxyz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_yyxz>[-+0-9EeDd.]+)\s+\w+=\s+(?P<hexadecapole_moment_zzxy>[-+0-9EeDd.]+)")
                      ]
             ),    
292
293
294
295
296
297
298
299
300
301
                   SM(name = 'ForcesGaussian',
                   sections  = ['x_gaussian_section_atom_forces'],
                   startReStr = "\s*Center\s+Atomic\s+Forces ",
                   forwardMatch = True,
                   subMatchers = [
                    SM(r"\s*Center\s+Atomic\s+Forces "),
                    SM(r"\s+[0-9]+\s+[0-9]+\s+(?P<x_gaussian_atom_x_force__hartree_bohr_1>[-+0-9EeDd.]+)\s+(?P<x_gaussian_atom_y_force__hartree_bohr_1>[-+0-9EeDd.]+)\s+(?P<x_gaussian_atom_z_force__hartree_bohr_1>[-+0-9EeDd.]+)",repeats = True),
                    SM(r"\s*Cartesian Forces:\s+")
                    ]
                ),
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
                     SM (name = 'Frequencies',
                     sections = ['x_gaussian_section_frequencies'],
                     startReStr = r"\s*Frequencies --",
                     endReStr = r"\s*- Thermochemistry -",
                     forwardMatch = True,
                     repeats = True,
                     subFlags = SM.SubFlags.Unordered,
                     subMatchers = [
                          SM(r"\s*Frequencies --\s+(?P<x_gaussian_frequency_values>([-]?[0-9]+\.\d*)\s*([-]?[-0-9]+\.\d*)?\s*([-]?[-0-9]+\.\d*)?)", repeats = True),
                          SM(r"\s*Red. masses --\s+(?P<x_gaussian_reduced_masses>(.+))", repeats = True),
                          SM(r"\s*[0-9]+\s*[0-9]+\s*(?P<x_gaussian_normal_modes>([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+)\s*([-0-9.]+))", repeats = True),
                          SM(r"\s*[0-9]+\s*([0-9]+)?\s*([0-9]+)?"),
                      ]
             ),
                SM(name = 'Thermochemistry',
                sections = ['x_gaussian_section_thermochem'],
                startReStr = r"\s*Temperature",
319
320
                forwardMatch = True,
                subMatchers = [
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
                      SM(r"\s*Temperature\s*(?P<x_gaussian_temperature>[0-9.]+)\s*Kelvin.\s*Pressure\s*(?P<x_gaussian_pressure__atmosphere>[0-9.]+)\s*Atm."),
                      SM(r"\s*Principal axes and moments of inertia in atomic units:"),
                      SM(r"\s*Eigenvalues --\s*(?P<x_gaussian_moment_of_inertia_X__amu_angstrom_angstrom>[0-9.]+)\s*(?P<x_gaussian_moment_of_inertia_Y__amu_angstrom_angstrom>[0-9.]+)\s*(?P<x_gaussian_moment_of_inertia_Z__amu_angstrom_angstrom>[0-9.]+)"),
                      SM(r"\s*Zero-point correction=\s*(?P<x_gaussian_zero_point_energy__hartree>[0-9.]+)"),
                      SM(r"\s*Thermal correction to Energy=\s*(?P<x_gaussian_thermal_correction_energy__hartree>[0-9.]+)"),
                      SM(r"\s*Thermal correction to Enthalpy=\s*(?P<x_gaussian_thermal_correction_enthalpy__hartree>[0-9.]+)"),
                      SM(r"\s*Thermal correction to Gibbs Free Energy=\s*(?P<x_gaussian_thermal_correction_free_energy__hartree>[0-9.]+)"), 
                      ]
             ),       
                SM(name = 'Forceconstantmatrix',
                sections = ['x_gaussian_section_force_constant_matrix'],
                startReStr = r"\s*Force constants in Cartesian coordinates",
                forwardMatch = True,
                subMatchers = [
                      SM(r"\s*Force constants in Cartesian coordinates"),
                      SM(r"\s*[0-9]+\s*(?P<x_gaussian_force_constants>(\-?\d+\.\d*[-+D0-9]+)\s*(\-?\d+\.\d*[-+D0-9]+)?\s*(\-?\d+\.\d*[-+D0-9]+)?\s*(\-?\d+\.\d*[-+D0-9]+)?\s*(\-?\d+\.\d*[-+D0-9]+)?)", repeats = True),
                      SM(r"\s*Force constants in internal coordinates")
338
                      ]
339
340
341
342
343
344
345
346
347
348
349
350
             ),
                SM(name = 'CompositeModelEnergies',
                sections = ['x_gaussian_section_models'],
                startReStr = r"\s*Diagonal vibrational polarizability\s*",
                forwardMatch = False,
                repeats = True,
                subMatchers = [
                 SM(r"\s*G1 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*G2 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*G2MP2 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*G3 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*G3MP2 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
351
352
                 SM(r"\s*G4 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*G4MP2 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
353
354
355
356
357
358
359
360
                 SM(r"\s*CBS-4 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*CBS-q Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*CBS-Q Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*CBS-QB3 Energy=\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*W1U   Electronic Energy\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*W1RO  Electronic Energy\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                 SM(r"\s*W1BD  Electronic Energy\s*(?P<x_gaussian_model_energy__hartree>[-+0-9.]+)"),
                       ]
361
362
363
364
365
366
367
368
             ),
                SM(name = 'run times',
                  sections = ['x_gaussian_section_times'],
                  startReStr = r"\s*Job cpu time:",
                  forwardMatch = True,
                  subMatchers = [
                      SM(r"\s*Job cpu time:\s*(?P<x_gaussian_program_cpu_time>\s*[0-9]+\s*[a-z]+\s*[0-9]+\s*[a-z]+\s*[0-9]+\s*[a-z]+\s*[0-9.]+\s*[a-z]+)"),
                      SM(r"\s*Normal termination of Gaussian\s*[0-9]+\s* at \s*(?P<x_gaussian_program_termination_date>[A-Za-z]+\s*[A-Za-z]+\s*[0-9]+\s*[0-9:]+\s*[0-9]+)"),
369
                      ]
370
371
372
373
374
375
             )
          ])
        ])
      ])
    ])

376
377
378
379
380
381
382
383
384
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/gaussian.nomadmetainfo.json
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/gaussian.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)

parserInfo = {
  "name": "parser_gaussian",
  "version": "1.0"
}

385
class GaussianParserContext(object):
386
387
388
389
390
391
392
393
394
395
396
397
      """Context for parsing Gaussian output file.

        This class keeps tracks of several Gaussian settings to adjust the parsing to them.
        The onClose_ functions allow processing and writing of cached values after a section is closed.
        They take the following arguments:
        backend: Class that takes care of writing and caching of metadata.
        gIndex: Index of the section that is closed.
        section: The cached values and sections that were found in the section that is closed.
      """
      def __init__(self):
        # dictionary of energy values, which are tracked between SCF iterations and written after convergence
        self.totalEnergyList = {
398
399
400
                                'x_gaussian_electronic_kinetic_energy': None,
                                'x_gaussian_energy_electrostatic': None,
                                'x_gaussian_energy_error': None,
401
                               }
402

403
404
405
406
407
408
      def initialize_values(self):
        """Initializes the values of certain variables.

        This allows a consistent setting and resetting of the variables,
        when the parsing starts and when a section_run closes.
        """
409
410
        self.secMethodIndex = None
        self.secSystemDescriptionIndex = None
411
412
        # start with -1 since zeroth iteration is the initialization
        self.scfIterNr = -1
413
        self.singleConfCalcs = []
414
        self.scfConvergence = False
415
        self.geoConvergence = False
416
        self.scfenergyconverged = 0.0
417
418
419
        self.scfkineticenergyconverged = 0.0
        self.scfelectrostaticenergy = 0.0
        self.periodicCalc = False
420
421

      def startedParsing(self, path, parser):
422
        self.parser = parser
423
424
        # save metadata
        self.metaInfoEnv = self.parser.parserBuilder.metaInfoEnv
425
426
        # allows to reset values if the same superContext is used to parse different files
        self.initialize_values()
427

428
429
430
431
432
433
      def onClose_section_run(self, backend, gIndex, section):
          """Trigger called when section_run is closed.

          Write convergence of geometry optimization.
          Variables are reset to ensure clean start for new run.
          """
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
434
435
          global sampling_method
          sampling_method = ""
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
          # write geometry optimization convergence
          gIndexTmp = backend.openSection('section_frame_sequence')
          backend.addValue('geometry_optimization_converged', self.geoConvergence)
          backend.closeSection('section_frame_sequence', gIndexTmp)
          # frame sequence
          if self.geoConvergence:
              sampling_method = "geometry_optimization"
          elif len(self.singleConfCalcs) > 1:
              pass # to do
          else:
              return
          samplingGIndex = backend.openSection("section_sampling_method")
          backend.addValue("sampling_method", sampling_method)
          backend.closeSection("section_sampling_method", samplingGIndex)
          frameSequenceGIndex = backend.openSection("section_frame_sequence")
          backend.addValue("frame_sequence_to_sampling_ref", samplingGIndex)
          backend.addArrayValues("frame_sequence_local_frames_ref", np.asarray(self.singleConfCalcs))
          backend.closeSection("section_frame_sequence", frameSequenceGIndex)
          # reset all variables
          self.initialize_values()

457
458
459
      def onClose_x_gaussian_section_geometry(self, backend, gIndex, section):
        xCoord = section["x_gaussian_atom_x_coord"]
        yCoord = section["x_gaussian_atom_y_coord"]
460
461
        zCoord = section["x_gaussian_atom_z_coord"]
        numbers = section["x_gaussian_atomic_number"]
462
        atom_coords = np.zeros((len(xCoord),3), dtype=float)
463
        atom_numbers = np.zeros(len(xCoord), dtype=int)
464
        atomic_symbols = np.empty((len(xCoord)), dtype=object)
465
        for i in range(len(xCoord)):
466
467
468
469
470
471
           atom_coords[i,0] = xCoord[i]
           atom_coords[i,1] = yCoord[i]
           atom_coords[i,2] = zCoord[i]
        for i in range(len(xCoord)):
          atom_numbers[i] = numbers[i]
          atomic_symbols[i] = ase.data.chemical_symbols[atom_numbers[i]]
472
473
474
475
        gIndexTmp = backend.openSection("section_system")
        backend.addArrayValues("atom_labels", atomic_symbols)
        backend.addArrayValues("atom_positions", atom_coords)
        backend.closeSection("section_system", gIndexTmp)
476
477
478
479
480
481
482
483
484
485

      def onClose_x_gaussian_section_atom_forces(self, backend, gIndex, section):
        xForce = section["x_gaussian_atom_x_force"]
        yForce = section["x_gaussian_atom_y_force"]
        zForce = section["x_gaussian_atom_z_force"]
        atom_forces = np.zeros((len(xForce),3), dtype=float)
        for i in range(len(xForce)):
           atom_forces[i,0] = xForce[i]
           atom_forces[i,1] = yForce[i]
           atom_forces[i,2] = zForce[i]
486
        backend.addArrayValues("atom_forces_raw", atom_forces)
487

488
489
      def onOpen_section_single_configuration_calculation(self, backend, gIndex, section):
          self.singleConfCalcs.append(gIndex)
490

491
      def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
492
493
494
495
496
        """Trigger called when section_single_configuration_calculation is closed.
         Write number of SCF iterations and convergence.
         Check for convergence of geometry optimization.
        """
        # write SCF convergence and reset
497
        backend.addValue('single_configuration_calculation_converged', self.scfConvergence)
498
499
500
        self.scfConvergence = False
        # start with -1 since zeroth iteration is the initialization
        self.scfIterNr = -1
501
502
503
504
505
506
507
508
509
510
511
        # write the references to section_method and section_system
        backend.addValue('single_configuration_to_calculation_method_ref', self.secMethodIndex)
        backend.addValue('single_configuration_calculation_to_system_ref', self.secSystemDescriptionIndex)

      def onClose_x_gaussian_section_geometry_optimization_info(self, backend, gIndex, section):
        # check for geometry optimization convergence
        if section['x_gaussian_geometry_optimization_converged'] is not None:
           if section['x_gaussian_geometry_optimization_converged'] == ['Optimization completed']:
              self.geoConvergence = True
           elif section['x_gaussian_geometry_optimization_converged'] == ['Optimization stopped']:
              self.geoConvergence = False
512

513
      def onClose_section_scf_iteration(self, backend, gIndex, section):
514
515
516
517
        # count number of SCF iterations
        self.scfIterNr += 1
        # check for SCF convergence
        if section['x_gaussian_single_configuration_calculation_converged'] is not None:
518
519
520
521
522
523
           self.scfConvergence = True
           if section['x_gaussian_energy_total']:
              if section['x_gaussian_electronic_kinetic_energy']:
                 self.scfkineticenergyconverged = float(str(section['x_gaussian_electronic_kinetic_energy']).replace("[","").replace("]","").replace("D","E"))
                 self.scfelectrostaticenergy = self.scfenergyconverged - self.scfkineticenergyconverged
                 backend.addValue('x_gaussian_energy_electrostatic', self.scfelectrostaticenergy)
524
525
526
527

      def onClose_x_gaussian_section_eigenvalues(self, backend, gIndex, section):
          eigenenergies = str(section["x_gaussian_alpha_occ_eigenvalues_values"])
          eigenen1 = []
528
          energy = [float(f) for f in eigenenergies[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace(" ."," 0.").replace(" -."," -0.").split()]
529
          eigenen1 = np.append(eigenen1, energy)
530
531
532
533
534
          if(section["x_gaussian_beta_occ_eigenvalues_values"]):
             occoccupationsalp = np.ones(len(eigenen1), dtype=float)
          else:
             occoccupationsalp = 2.0 * np.ones(len(eigenen1), dtype=float)

535
536
          eigenenergies = str(section["x_gaussian_alpha_vir_eigenvalues_values"])
          eigenen2 = []
537
          energy = [float(f) for f in eigenenergies[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace(" ."," 0.").replace(" -."," -0.").split()]
538
539
540
541
          eigenen2 = np.append(eigenen2, energy)
          viroccupationsalp = np.zeros(len(eigenen2), dtype=float)
          eigenencon = np.zeros(len(eigenen1) + len(eigenen2))
          eigenencon = np.concatenate((eigenen1,eigenen2), axis=0)
542
          eigenencon = convert_unit(eigenencon, "hartree", "J")
543
544
545
546
          occupcon = np.concatenate((occoccupationsalp, viroccupationsalp), axis=0)
          backend.addArrayValues("x_gaussian_alpha_eigenvalues", eigenencon)
          backend.addArrayValues("x_gaussian_alpha_occupations", occupcon)

547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
          if(section["x_gaussian_beta_occ_eigenvalues_values"]):
             eigenenergies = str(section["x_gaussian_beta_occ_eigenvalues_values"])
             eigenen1 = []
             energy = [float(f) for f in eigenenergies[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace(" ."," 0.").replace(" -."," -0.").split()]
             eigenen1 = np.append(eigenen1, energy)
             occoccupationsbet = np.ones(len(eigenen1), dtype=float)
             eigenenergies = str(section["x_gaussian_beta_vir_eigenvalues_values"])
             eigenen2 = []
             energy = [float(f) for f in eigenenergies[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace(" ."," 0.").replace(" -."," -0.").split()]
             eigenen2 = np.append(eigenen2, energy)
             viroccupationsbet = np.zeros(len(eigenen2), dtype=float)
             eigenencon = np.zeros(len(eigenen1) + len(eigenen2))
             eigenencon = np.concatenate((eigenen1,eigenen2), axis=0)
             eigenencon = convert_unit(eigenencon, "hartree", "J")
             occupcon = np.concatenate((occoccupationsbet, viroccupationsbet), axis=0)
             backend.addArrayValues("x_gaussian_beta_eigenvalues", eigenencon)
             backend.addArrayValues("x_gaussian_beta_occupations", occupcon)
564
565
566
567

      def onClose_x_gaussian_section_orbital_symmetries(self, backend, gIndex, section):
          symoccalpha = str(section["x_gaussian_alpha_occ_symmetry_values"])
          symviralpha = str(section["x_gaussian_alpha_vir_symmetry_values"])
568
569
570
571
          if(section["x_gaussian_beta_occ_symmetry_values"]):
             symoccbeta = str(section["x_gaussian_beta_occ_symmetry_values"])
             symvirbeta = str(section["x_gaussian_beta_vir_symmetry_values"])

572
          symmetry = [str(f) for f in symoccalpha[1:].replace(",","").replace("(","").replace(")","").replace("]","").replace("'A","A").replace("\\'","'").replace("A''","A'").replace("'E","E").replace("G'","G").replace("\"A'\"","A'").split()]
573
574
          sym1 = []
          sym1 = np.append(sym1, symmetry)  
575
          symmetry = [str(f) for f in symviralpha[1:].replace(",","").replace("(","").replace(")","").replace("]","").replace("'A","A").replace("\\'","'").replace("A''","A'").replace("\"A'\"","A'").replace("'E","E").replace("G'","G").split()]
576
577
578
579
          sym2 = []
          sym2 = np.append(sym2, symmetry)
          symmetrycon = np.concatenate((sym1, sym2), axis=0)
          backend.addArrayValues("x_gaussian_alpha_symmetries", symmetrycon) 
580
581

          if(section["x_gaussian_beta_occ_symmetry_values"]):
582
             symmetry = [str(f) for f in symoccbeta[1:].replace(",","").replace("(","").replace(")","").replace("]","").replace("'A","A").replace("\\'","'").replace("A''","A'").replace("\"A'\"","A'").replace("'E","E").replace("G'","G").split()]
583
584
             sym1 = []
             sym1 = np.append(sym1, symmetry)
585
             symmetry = [str(f) for f in symvirbeta[1:].replace(",","").replace("(","").replace(")","").replace("]","").replace("'A","A").replace("\\'","'").replace("A''","A'").replace("\"A'\"","A'").replace("'E","E").replace("G'","G").split()]
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
             sym2 = []
             sym2 = np.append(sym2, symmetry)
             symmetrycon = np.concatenate((sym1, sym2), axis=0)
             backend.addArrayValues("x_gaussian_beta_symmetries", symmetrycon)

      def onClose_x_gaussian_section_molecular_multipoles(self, backend, gIndex, section):
          if(section["quadrupole_moment_xx"]):
             x_gaussian_number_of_lm_molecular_multipoles = 35
          else:
             x_gaussian_number_of_lm_molecular_multipoles = 4

          x_gaussian_molecular_multipole_m_kind = 'polynomial'

          char = str(section["charge"])
          cha = str([char])
          charge = [float(f) for f in cha[1:].replace("-."," -0.").replace("'."," 0.").replace("'","").replace("[","").replace("]","").replace(",","").replace('"','').split()]

Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
603
604
605
606
607
608
609
          if(section["dipole_moment_x"]):
            dipx = section["dipole_moment_x"]
            dipy = section["dipole_moment_y"]
            dipz = section["dipole_moment_z"]
            dip = str([dipx, dipy, dipz])
            dipoles = [float(f) for f in dip[1:].replace("-."," -0.").replace("'."," 0.").replace("'","").replace("[","").replace("]","").replace(",","").split()]
            dipoles = convert_unit(dipoles, "debye", "coulomb * meter")
610

Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
611
612
613
614
615
616
617
618
619
620
          if(section["quadrupole_moment_xx"]):
            quadxx = section["quadrupole_moment_xx"]
            quadxy = section["quadrupole_moment_xy"]
            quadyy = section["quadrupole_moment_yy"]
            quadxz = section["quadrupole_moment_xz"]
            quadyz = section["quadrupole_moment_yz"]
            quadzz = section["quadrupole_moment_zz"]
            quad = str([quadxx, quadxy, quadyy, quadxz, quadyz, quadzz])
            quadrupoles = [float(f) for f in quad[1:].replace("-."," -0.").replace("'."," 0.").replace("'","").replace("[","").replace("]","").replace(",","").split()] 
            quadrupoles = convert_unit(quadrupoles, "debye * angstrom", "coulomb * meter**2")
621
622

          if(section["octapole_moment_xxx"]):
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
623
624
625
626
627
628
629
630
631
632
633
634
635
            octaxxx = section["octapole_moment_xxx"]
            octayyy = section["octapole_moment_yyy"]
            octazzz = section["octapole_moment_zzz"]
            octaxyy = section["octapole_moment_xyy"]
            octaxxy = section["octapole_moment_xxy"]
            octaxxz = section["octapole_moment_xxz"]
            octaxzz = section["octapole_moment_xzz"]
            octayzz = section["octapole_moment_yzz"]
            octayyz = section["octapole_moment_yyz"]
            octaxyz = section["octapole_moment_xyz"]
            octa = str([octaxxx, octayyy, octazzz, octaxyy, octaxxy, octaxxz, octaxzz, octayzz, octayyz, octaxyz])
            octapoles = [float(f) for f in octa[1:].replace("-."," -0.").replace("'."," 0.").replace("'","").replace("[","").replace("]","").replace(",","").split()]
            octapoles = convert_unit(octapoles, "debye * angstrom**2", "coulomb * meter**3")
636
637

          if(section["hexadecapole_moment_xxxx"]):
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
            hexadecaxxxx = section["hexadecapole_moment_xxxx"]
            hexadecayyyy = section["hexadecapole_moment_yyyy"]
            hexadecazzzz = section["hexadecapole_moment_zzzz"]
            hexadecaxxxy = section["hexadecapole_moment_xxxy"]
            hexadecaxxxz = section["hexadecapole_moment_xxxz"]
            hexadecayyyx = section["hexadecapole_moment_yyyx"]
            hexadecayyyz = section["hexadecapole_moment_yyyz"]
            hexadecazzzx = section["hexadecapole_moment_zzzx"]
            hexadecazzzy = section["hexadecapole_moment_zzzy"]
            hexadecaxxyy = section["hexadecapole_moment_xxyy"]
            hexadecaxxzz = section["hexadecapole_moment_xxzz"]
            hexadecayyzz = section["hexadecapole_moment_yyzz"]
            hexadecaxxyz = section["hexadecapole_moment_xxyz"]
            hexadecayyxz = section["hexadecapole_moment_yyxz"]
            hexadecazzxy = section["hexadecapole_moment_zzxy"]
            hexa = str([hexadecaxxxx, hexadecayyyy, hexadecazzzz, hexadecaxxxy, hexadecaxxxz, hexadecayyyx, hexadecayyyz,
            hexadecazzzx, hexadecazzzy, hexadecaxxyy, hexadecaxxzz, hexadecayyzz, hexadecaxxyz, hexadecayyxz, hexadecazzxy])
            hexadecapoles = [float(f) for f in hexa[1:].replace("-."," -0.").replace("'."," 0.").replace("'","").replace("[","").replace("]","").replace(",","").split()]
            hexadecapoles = convert_unit(hexadecapoles, "debye * angstrom**3", "coulomb * meter**4")
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691

          if(section["quadrupole_moment_xx"]):
             multipoles = np.hstack((charge, dipoles, quadrupoles, octapoles, hexadecapoles))
          else:
             multipoles = np.hstack((charge, dipoles)) 

          x_gaussian_molecular_multipole_values = np.resize(multipoles, (x_gaussian_number_of_lm_molecular_multipoles))

          backend.addArrayValues("x_gaussian_molecular_multipole_values", x_gaussian_molecular_multipole_values)
          backend.addValue("x_gaussian_molecular_multipole_m_kind", x_gaussian_molecular_multipole_m_kind)

      def onClose_x_gaussian_section_frequencies(self, backend, gIndex, section):
          frequencies = str(section["x_gaussian_frequency_values"])
          vibfreqs = []
          freqs = [float(f) for f in frequencies[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace("\\n","").replace(" ."," 0.").replace(" -."," -0.").split()]
          vibfreqs = np.append(vibfreqs, freqs)
          vibfreqs = convert_unit(vibfreqs, "inversecm", "J")
          backend.addArrayValues("x_gaussian_frequencies", vibfreqs)

          masses = str(section["x_gaussian_reduced_masses"])
          vibreducedmasses = []
          reduced = [float(f) for f in masses[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace(" ."," 0.").split()]
          vibreducedmasses = np.append(vibreducedmasses, reduced)
          vibreducedmasses = convert_unit(vibreducedmasses, "amu", "kilogram")
          backend.addArrayValues("x_gaussian_red_masses", vibreducedmasses)

          vibnormalmodes = []
          vibdisps = str(section["x_gaussian_normal_modes"])
          disps = [float(s) for s in vibdisps[1:].replace("'","").replace(",","").replace("]","").replace("one","").replace("\\n","").replace(" ."," 0.").replace(" -."," -0.").split()]
          dispsnew = np.zeros(len(disps), dtype = float)

#  Reorder disps 

          if len(vibfreqs) % 3 == 0:
             k = 0
692
             for p in range(0,len(vibfreqs) // 3):
693
                M = int(len(disps)/len(vibfreqs)) * (p+1) 
694
                for m in range(3):
695
                  for n in range(M - int(len(disps) / len(vibfreqs)),M,3):
696
697
698
699
700
701
                    for l in range(3):
                      dispsnew[k] = disps[3*(n + m) + l]
                      k = k + 1
          elif len(vibfreqs) % 3 != 0:
             k = 0
             for p in range(len(vibfreqs)-1,0,-3):
702
                M = (len(disps) - int(len(disps) / len(vibfreqs))) // p
703
                for m in range(3):
704
                  for n in range(M - int(len(disps) / len(vibfreqs)),M,3):
705
706
707
                    for l in range(3):
                      dispsnew[k] = disps[3*(n + m) + l]
                      k = k + 1
708
             for m in range(int(len(disps) / len(vibfreqs))):
709
710
711
712
                   dispsnew[k] = disps[k]
                   k = k + 1

          vibnormalmodes = np.append(vibnormalmodes, dispsnew)
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
713
714
715
716
          if len(vibfreqs) != 0:
            natoms = int(len(disps) / len(vibfreqs) / 3)
            vibnormalmodes = np.reshape(vibnormalmodes,(len(vibfreqs),natoms,3))
            backend.addArrayValues("x_gaussian_normal_mode_values", vibnormalmodes)
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770

      def onClose_x_gaussian_section_force_constant_matrix(self, backend, gIndex, section):

          forcecnstvalues = []
          forceconst = str(section["x_gaussian_force_constants"])
          numbers = [float(s) for s in forceconst[1:].replace("'","").replace(",","").replace("]","").replace("\\n","").replace("D","E").replace(" ."," 0.").replace(" -."," -0.").split()]
          length = len(numbers)
          dim = int(((1 + 8 * length)**0.5 - 1) / 2) 
          cartforceconst = np.zeros([dim, dim])
          forcecnstvalues = np.append(forcecnstvalues, numbers) 
          if dim > 6:
             l = 0
             for i in range(0,5):
                for k in range(0,i+1):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
             for i in range(5,dim):
                for k in range(0,5):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
             for i in range(5,dim-2): 
                for k in range(5,i+1):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
             for i in range(dim-2,dim):
                for k in range(5,dim-2):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
             for i in range(dim-2,dim):
                for k in range(i,dim):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
          elif dim == 6:
             l = 0
             for i in range(0,5):
                for k in range(0,i+1):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
             for i in range(5,dim):
                for k in range(0,5):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
             for i in range(dim,dim):
                for k in range(i,dim):
                   l = l + 1
                   cartforceconst[i,k] = forcecnstvalues[l-1]
 
          for i in range(0,dim):
             for k in range(i+1,dim):
                 cartforceconst[i,k] = cartforceconst[k,i]

          cartforceconst = convert_unit(cartforceconst, "forceAu / bohr", "J / (meter**2)")

          backend.addArrayValues("x_gaussian_force_constant_values", cartforceconst) 
771

772
773
774
775
      def onOpen_section_method(self, backend, gIndex, section):
        # keep track of the latest method section
        self.secMethodIndex = gIndex

776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
      def onClose_section_method(self, backend, gIndex, section):
        # handling of xc functional
        # two functions to convert hybrid_xc_coeff to the correct weight
        def GGA_weight(x):
          return 1.0 - x
        def HF_weight(x):
          return x
       # TODO vdW functionals and double-hybrid functionals
       # Dictionary for conversion of xc functional name in aims to metadata format.
       # The individual x and c components of the functional are given as dictionaries.
       # Possible keys of such a dictionary are 'name', 'weight', and 'convert'.
       # If 'weight' is not given it is not written.
       # With 'convert', a funtion is specified how hybrid_xc_coeff is converted to the correct weight for this xc component.
        xcDict = {
              'S':           [{'name': 'LDA_X'}],
              'XA':	     [{'name': 'X_ALPHA'}],
              'VWN5':        [{'name': 'LDA_C_VWN'}],
              'VWN':         [{'name': 'LDA_C_VWN_3'}],
              'LSDA':        [{'name': 'LDA_X'}, {'name': 'LDA_C_VWN'}], 
              'B':           [{'name': 'GGA_X_B88'}],
              'BLYP':        [{'name': 'GGA_C_LYP'}, {'name': 'GGA_X_B88'}],
              'PBE':         [{'name': 'GGA_C_PBE'}],
              'PBEPBE':      [{'name': 'GGA_C_PBE'}, {'name': 'GGA_X_PBE'}],
              'PBEH':        [{'name': 'GGA_X_PBEH'}],
              'WPBEH':       [{'name': 'GGA_X_WPBEH'}],
              'PW91PW91':    [{'name': 'GGA_C_PW91'}, {'name': 'GGA_X_PW91'}],
              'M06L':        [{'name': 'MGGA_C_M06_L'}, {'name': 'MGGA_X_M06_L'}],
              'M11L':        [{'name': 'MGGA_C_M11_L'}, {'name': 'MGGA_X_M11_L'}],
              'SOGGA11':     [{'name': 'GGA_XC_SOGGA11'}],
              'MN12L':       [{'name': 'GGA_XC_MN12L'}],
              'N12':         [{'name': 'GGA_C_N12'}, {'name': 'GGA_X_N12'}],
              'VSXC':        [{'name': 'GGA_XC_VSXC'}],
              'HCTH93':      [{'name': 'GGA_XC_HCTH_93'}],
              'HCTH147':     [{'name': 'GGA_XC_HCTH_147'}],
              'HCTH407':     [{'name': 'GGA_XC_HCTH_407'}],
              'HCTH':        [{'name': 'GGA_XC_HCTH_407'}],
              'B97D':        [{'name': 'GGA_XC_B97D'}],
              'B97D3':       [{'name': 'GGA_XC_B97D3'}],
              'MPW':         [{'name': 'GGA_X_MPW'}],
              'G96':         [{'name': 'GGA_X_G96'}],
              'O':           [{'name': 'GGA_X_O'}],
              'BRX':         [{'name': 'GGA_X_BRX'}],
              'PKZB':        [{'name': 'GGA_C_PKZB'}, {'name': 'GGA_X_PKZB'}],
              'PL':          [{'name': 'GGA_C_PL'}],
              'P86':         [{'name': 'GGA_C_P86'}],
              'B95':         [{'name': 'GGA_C_B95'}],
              'KCIS':        [{'name': 'GGA_C_KCIS'}],
              'BRC':         [{'name': 'GGA_C_BRC'}],
              'VP86':        [{'name': 'GGA_C_VP86'}],
              'V5LYP':       [{'name': 'GGA_C_V5LYP'}],
              'tHCTH':       [{'name': 'MGGA_XC_TAU_HCTH'}],
              'TPSSTPSS':    [{'name': 'MGGA_C_TPSS'}, {'name': 'MGGA_X_TPSS'}],
              'B3LYP':       [{'name': 'HYB_GGA_XC_B3LYP'}], 
              'B3PW91':      [{'name': 'HYB_GGA_XC_B3PW91'}],
              'B3P86':       [{'name': 'HYB_GGA_XC_B3P86'}], 
              'B1B95':       [{'name': 'HYB_GGA_XC_B1B95'}],
              'MPW1PW91':    [{'name': 'HYB_GGA_XC_MPW1PW91'}],
              'MPW1LYP':     [{'name': 'HYB_GGA_XC_MPW1LYP'}],
              'MPW1PBE':     [{'name': 'HYB_GGA_XC_MPW1PBE'}],
              'MPW3PBE':     [{'name': 'HYB_GGA_XC_MPW3PBE'}],
              'B98':         [{'name': 'HYB_GGA_XC_B98'}],
              'B971':        [{'name': 'HYB_GGA_XC_B971'}],
              'B972':        [{'name': 'HYB_GGA_XC_B972'}],
              'O3LYP':       [{'name': 'HYB_GGA_XC_O3LYP'}], 
              'TPSSh':       [{'name': 'HYB_GGA_XC_TPSSh'}],
              'BMK':         [{'name': 'HYB_GGA_XC_BMK'}],
              'X3LYP':       [{'name': 'HYB_GGA_XC_X3LYP'}],
              'tHCTHhyb':    [{'name': 'HYB_GGA_XC_tHCTHHYB'}],
              'BHANDH':      [{'name': 'HYB_GGA_XC_BHANDH'}],
              'BHANDHLYP':   [{'name': 'HYB_GGA_XC_BHANDHLYP'}],
              'APF':         [{'name': 'HYB_GGA_XC_APF'}],
              'APFD':        [{'name': 'HYB_GGA_XC_APFD'}],
              'B97D':        [{'name': 'HYB_GGA_XC_B97D'}],
              'RHF':         [{'name': 'RHF_X'}],
              'UHF':         [{'name': 'UHF_X'}],
              'ROHF':        [{'name': 'ROHF_X'}],
              'OHSE2PBE':    [{'name': 'HYB_GGA_XC_HSE03'}],
              'HSEH1PBE':    [{'name': 'HYB_GGA_XC_HSE06'}],
              'OHSE1PBE':    [{'name': 'HYB_GGA_XC_HSEOLD'}],
              'PBEH1PBE':    [{'name': 'HYB_GGA_XC_PBEh1PBE'}],
              'PBE1PBE':     [{'name': 'GGA_C_PBE'}, {'name': 'GGA_X_PBE', 'weight': 0.75, 'convert': GGA_weight}, {'name': 'HF_X', 'weight': 0.25, 'convert': HF_weight}],
              'M05':         [{'name': 'HYB_MGGA_XC_M05'}],
              'M052X':       [{'name': 'HYB_MGGA_XC_M05_2X'}],
              'M06':         [{'name': 'HYB_MGGA_XC_M06'}],
              'M062X':       [{'name': 'HYB_MGGA_XC_M06_2X'}],
              'M06HF':       [{'name': 'HYB_MGGA_XC_M06_HF'}],
              'M11':         [{'name': 'HYB_MGGA_XC_M11'}],
              'SOGGAX11':    [{'name': 'HYB_MGGA_XC_SOGGA11_X'}],
              'MN12SX':      [{'name': 'HYB_MGGA_XC_MN12_SX'}],
              'N12SX':       [{'name': 'HYB_MGGA_XC_N12_SX'}],
              'LC-WPBE':     [{'name': 'LC-WPBE'}],
              'CAM-B3LYP':   [{'name': 'CAM-B3LYP'}],
              'WB97':        [{'name': 'WB97'}],
              'WB97X':       [{'name': 'WB97X'}],
              'WB97XD':      [{'name': 'WB97XD'}],
              'HISSBPBE':    [{'name': 'HISSBPBE'}],
              'B2PLYP':      [{'name': 'B2PLYP'}],
              'MPW2PLYP':    [{'name': 'MPW2PLYP'}],
              'B2PLYPD':     [{'name': 'B2PLYPD'}],
              'MPW2PLYPD':   [{'name': 'MPW2PLYPD'}],
              'B97D3':       [{'name': 'B97D3'}], 
              'B2PLYPD3':    [{'name': 'B2PLYPD3'}],
              'MPW2PLYPD3':  [{'name': 'MPW2PLYPD3'}],
              'LC-':         [{'name': 'Long-range corrected'}],
             }

        methodDict = {
              'AMBER':     [{'name': 'Amber'}],
              'DREIDING':  [{'name': 'Dreiding'}],
              'UFF':       [{'name': 'UFF'}],
              'AM1':       [{'name': 'AM1'}],
              'PM3':       [{'name': 'PM3'}],
              'PM3MM':     [{'name': 'PM3MM'}],
889
              'PM3D3':     [{'name': 'PM3D3'}],
890
891
892
893
894
895
896
              'PM6':       [{'name': 'PM6'}],
              'PDDG':      [{'name': 'PDDG'}],
              'CNDO':      [{'name': 'CNDO'}],
              'INDO':      [{'name': 'INDO'}],
              'MINDO':     [{'name': 'MINDO'}],
              'MINDO3':    [{'name': 'MINDO3'}],
              'ZINDO':     [{'name': 'ZINDO'}],
897
898
              'HUCKEL':    [{'name': 'HUCKEL'}],
              'EXTENDEDHUCKEL':    [{'name': 'HUCKEL'}],
899
900
901
902
903
904
905
906
907
908
              'ONIOM':     [{'name': 'ONIOM'}],
              'RHF':       [{'name': 'RHF'}],
              'UHF':       [{'name': 'UHF'}],
              'ROHF':      [{'name': 'ROHF'}],
              'GVB':       [{'name': 'GVB'}],
              'DFT':       [{'name': 'DFT'}],
              'CID':       [{'name': 'CID'}],
              'CISD':      [{'name': 'CISD'}],
              'CIS':       [{'name': 'CIS'}],
              'BD':        [{'name': 'BD'}],
909
              'BD(T)':     [{'name': 'BD(T)'}],
910
911
912
913
              'CCD':       [{'name': 'CCD'}],
              'CCSD':      [{'name': 'CCSD'}],
              'EOMCCSD':   [{'name': 'EOMCCSD'}],
              'QCISD':     [{'name': 'QCISD'}],
914
915
916
              'CCSD(T)':   [{'name': 'CCSD(T)'}],
              'QCISD(T)':  [{'name': 'QCISD(T)'}],
              'QCISD(TQ)': [{'name': 'QCISD(TQ)'}],
917
918
919
              'MP2':       [{'name': 'MP2'}],
              'MP3':       [{'name': 'MP3'}],
              'MP4':       [{'name': 'MP4'}],
920
921
922
923
924
925
              'MP4DQ':     [{'name': 'MP4DQ'}],
              'MP4(DQ)':   [{'name': 'MP4DQ'}],
              'MP4SDQ':    [{'name': 'MP4SDQ'}],
              'MP4(SDQ)':  [{'name': 'MP4SDQ'}],
              'MP4SDTQ':   [{'name': 'MP4SDTQ'}],
              'MP4(SDTQ)': [{'name': 'MP4SDTQ'}],
926
927
928
929
930
931
932
933
934
935
936
937
              'MP5':       [{'name': 'MP5'}],
              'CAS':       [{'name': 'CASSCF'}],
              'CASSCF':    [{'name': 'CASSCF'}],
              'G1':        [{'name': 'G1'}],
              'G2':        [{'name': 'G2'}],
              'G2MP2':     [{'name': 'G2MP2'}],
              'G3':        [{'name': 'G3'}],
              'G3MP2':     [{'name': 'G3MP2'}],
              'G3B3':      [{'name': 'G3B3'}],
              'G3MP2B3':   [{'name': 'G3MP2B3'}],
              'G4':        [{'name': 'G4'}],
              'G4MP2':     [{'name': 'G4MP2'}],
938
939
              'CBSEXTRAP':   [{'name': 'CBSExtrapolate'}],
              'CBSEXTRAPOLATE':   [{'name': 'CBSExtrapolate'}],
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
              'CBS-4M':    [{'name': 'CBS-4M'}],
              'CBS-4O':    [{'name': 'CBS-4O'}],
              'CBS-QB3':   [{'name': 'CBS-QB3'}],
              'CBS-QB3O':  [{'name': 'CBS-QB3O'}],
              'CBS-APNO':  [{'name': 'CBS-APNO'}],
              'W1U':       [{'name': 'W1U'}],
              'W1BD':      [{'name': 'W1BD'}],
              'W1RO':      [{'name': 'W1RO'}],
             }

        basissetDict = {
              'STO-3G':      [{'name': 'STO-3G'}],
              '3-21G':       [{'name': '3-21G'}],
              '6-21G':       [{'name': '6-21G'}],
              '4-31G':       [{'name': '4-31G'}],
              '6-31G':       [{'name': '6-31G'}],
              '6-311G':      [{'name': '6-311G'}],
              'D95V':        [{'name': 'D95V'}],
              'D95':         [{'name': 'D95'}],
              'CC-PVDZ':     [{'name': 'cc-pVDZ'}],
              'CC-PVTZ':     [{'name': 'cc-pVTZ'}],
              'CC-PVQZ':     [{'name': 'cc-pVQZ'}],
              'CC-PV5Z':     [{'name': 'cc-pV5Z'}],
              'CC-PV6Z':     [{'name': 'cc-pV6Z'}],
              'SV':          [{'name': 'SV'}],
              'SVP':         [{'name': 'SVP'}],
              'TZV':         [{'name': 'TZV'}],
              'TZVP':        [{'name': 'TZVP'}],              
              'DEF2SV':      [{'name': 'Def2SV'}],
              'DEF2SVP':     [{'name': 'Def2SVP'}],
              'DEF2SVPP':    [{'name': 'Def2SVPP'}],
              'DEF2TZV':     [{'name': 'Def2TZV'}],
              'DEF2TZVP':    [{'name': 'Def2TZVP'}],
              'DEF2TZVPP':   [{'name': 'Def2TZVPP'}],
              'DEF2QZV':     [{'name': 'Def2QZV'}],
              'DEF2QZVP':    [{'name': 'Def2QZVP'}],
              'DEF2QZVPP':   [{'name': 'Def2QZVPP'}],
              'QZVP':        [{'name': 'QZVP'}],
              'MIDIX':       [{'name': 'MidiX'}],
              'EPR-II':      [{'name': 'EPR-II'}],
              'EPR-III':     [{'name': 'EPR-III'}],
              'UGBS':        [{'name': 'UGBS'}],     
              'MTSMALL':     [{'name': 'MTSmall'}],
              'DGDZVP':      [{'name': 'DGDZVP'}],
              'DGDZVP2':     [{'name': 'DGDZVP2'}],
              'DGTZVP':      [{'name': 'DGTZVP'}],
              'CBSB3':       [{'name': 'CBSB3'}],  
              'CBSB7':       [{'name': 'CBSB7'}],
              'SHC':         [{'name': 'SHC'}],
              'SEC':         [{'name': 'SHC'}],
              'CEP-4G':      [{'name': 'CEP-4G'}],
              'CEP-31G':     [{'name': 'CEP-31G'}],
              'CEP-121G':    [{'name': 'CEP-121G'}],
              'LANL1':       [{'name': 'LANL1'}],
              'LANL2':       [{'name': 'LANL2'}],
              'SDD':         [{'name': 'SDD'}],
              'OLDSDD':      [{'name': 'OldSDD'}], 
              'SDDALL':      [{'name': 'SDDAll'}],
              'GEN':         [{'name': 'General'}],
              'CHKBAS':      [{'name': 'CHKBAS'}],
              'EXTRABASIS':  [{'name': 'ExtraBasis'}],
              'DGA1':        [{'name': 'DGA1'}],
              'DGA2':        [{'name': 'DGA2'}],
              'SVPFIT':      [{'name': 'SVPFit'}],
              'TZVPFIT':     [{'name': 'TZVPFit'}],
              'W06':         [{'name': 'W06'}],
              'CHF':         [{'name': 'CHF'}],
1007
1008
              'FIT':         [{'name': 'FIT'}],
              'AUTO':        [{'name': 'AUTO'}],
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
             }

        global xc, method, basisset, xcWrite, methodWrite, basissetWrite, methodreal, basissetreal, exc, corr, exccorr, methodprefix
        xc = None
        method = None
        basisset = None
        xcWrite = False
        methodWrite = False
        basissetWrite = False
        methodreal = None
        basissetreal = None 
        methodprefix = None
        exc = None
        corr = None
        exccorr = None
1024

1025
1026
1027
1028
1029
        settings = section["x_gaussian_settings"]
        settings = map(str.strip, settings)  
        settings = [''.join(map(str,settings))]
        settings = str(settings)
        settings = re.sub('[-]{2,}', '', settings)
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1030
        backend.addValue("x_gaussian_settings_corrected", settings)
1031

Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1032
        method1 = settings.replace("['#p ","").replace("['#P ","").replace("['#","")
1033
1034
1035
1036
        method1 = method1.upper()

        if 'ONIOM' not in method1: 
          if settings.find("/") >= 0:
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1037
               method1 = settings.split('/')[0].replace("['#p ","").replace("['#P ","").replace("['#","")
1038
1039
1040
               method1 = method1.upper()
               for x in method1.split():
                  method2 = str(x)
1041
                  if method2 != 'RHF' and method2 != 'UHF' and method2 != 'ROHF' and method2 != 'UFF':
1042
1043
1044
1045
1046
1047
1048
                     if (method2[0] == 'R' and method2[0:2] != 'RO') or method2[0] == 'U':
                        methodprefix = method2[0] 
                        method2 = method2[1:]
                     elif method2[0:2] == 'RO':
                        methodprefix = method2[0:2]
                        method2 = method2[2:]
                  if method2[0] == 'S' or method2[0] == 'B' or method2[0] == 'O':
1049
1050
1051
1052
1053
                     if method2[1] != '2' and method2[1] != '3':
                        exc = method2[0]
                        corr = method2[1:]
                        if exc in xcDict.keys() and corr in xcDict.keys():
                           xc = xcDict.get([exc][-1]) + xcDict.get([corr][-1])
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
                  if method2[0:3] == 'BRX' or method2[0:3] == 'G96':
                     exc = method2[0:3]
                     corr = method2[3:]
                  if exc in xcDict.keys() and corr in xcDict.keys():
                      xc = xcDict.get([exc][-1]) + xcDict.get([corr][-1])
                  if method2[0:5] == 'WPBEH':
                     exc = method2[0:5]
                     corr = method2[6:]
                     if exc in xcDict.keys() and corr in xcDict.keys():
                        xc = xcDict.get([exc][-1]) + xcDict.get([corr][-1])
                  if method2[0:3] == 'LC-':
                     exccorr = method2[3:]
                     if exccorr in xcDict.keys():
                        xc = 'LC-' + xcDict.get([exccorr][-1])
                  if method2 in xcDict.keys():
                     xc = method2
                     xcWrite= True
1071
                     methodWrite = True
1072
1073
1074
1075
1076
1077
1078
1079
                     method = 'DFT'
                  if method2 in methodDict.keys():
                     method = method2
                     methodWrite = True
                     methodreal = method2
                  else:
                     for n in range(2,9):
                        if method2[0:n] in methodDict.keys():
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
                          if method2[0:n] in xcDict.keys():
                            method = 'DFT'
                            methodWrite = True
                          else:
                            method = method2[0:n]
                            methodWrite = True
                            methodreal = method2
                          if method2[0:9] == 'CBSEXTRAP':
                            method = method2[0:9]
                            methodWrite = True
                            methodreal = method2
               rest = settings.split('/')[1].replace("'","").replace("]","")
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
               rest = rest.upper() 
               for x in rest.split():
                  if x in basissetDict.keys():
                     basisset = x
                     basissetWrite = True
                     basissetreal = x
                  if 'D95' in x:
                     method2 = x
                     basisset = method2[0:3]
                     basissetWrite = True
                     basissetreal = method2
                  if 'AUG-' in x:
                     method2 = x
                     basisset = method2[4:]
                     basissetWrite = True
                     basissetreal = method2
                  if 'UGBS' in x:
                     method2 = x
                     basisset = method2[0:4]
                     basissetWrite = True
                     basissetreal = method2
                  if 'CBSB7' in x:
                     method2 = x
                     basisset = method2[0:5]
                     basissetWrite = True
                     basissetreal = method2
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
                  if 'LANL1' in x:
                     method2 = x
                     basisset = method2[0:5]
                     basissetWrite = True
                     basissetreal = method2
                  if 'LANL2' in x:
                     method2 = x
                     basisset = method2[0:5]
                     basissetWrite = True
                     basissetreal = method2
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
                  if '6-31' in x:
                     method2 = x
                     if '6-311' in x:
                        basisset = '6-311G'
                        basissetWrite = True
                        basissetreal = '6-311' + method2[5:]
                     else:
                        basisset = '6-31G'
                        basissetWrite = True
                        basissetreal = '6-31' + method2[4:]
1138
1139
1140
1141
1142
1143
1144
1145
1146
                  slashes = settings.count('/')
                  if slashes > 1:
                    rest2 = settings.split()[1]
                    rest2 = rest2.upper()
                    for z in rest2.split('/'):
                       if z in basissetDict.keys():
                         basisset = z
                    basissetWrite = True
                    basissetreal = rest2.split('/')[1] + '/' + basisset
1147
1148
1149
1150
1151
          else:
               method1 = settings.split()
               for x in method1: 
                  method2 = str(x)
                  method2 = method2.upper() 
1152
                  if method2 != 'RHF' and method2 != 'UHF' and method2 != 'ROHF' and method2 != 'UFF':
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
                    if (method2[0] == 'R' and method2[0:2] != 'RO') or method2[0] == 'U':
                      methodprefix = method2[0] 
                      method2 = method2[1:]
                    elif method2[0:2] == 'RO':
                      methodprefix = method2[0:2] 
                      method2 = method2[2:]
                  if method2[0] == 'S' or method2[0] == 'B' or method2[0] == 'O':
                   if method2[0] in xcDict.keys() and method2[1:] in xcDict.keys():
                      exc = method2[0]
                      corr = method2[1:]
                      xc = xcDict.get([exc][-1]) + xcDict.get([corr][-1])
                  if method2[0:3] == 'BRX' or method2[0:3] == 'G96':
                   exc = method2[0:3]
                   corr = method2[3:]
                   if exc in xcDict.keys() and corr in xcDict.keys():
                      xc = xcDict.get([exc][-1]) + xcDict.get([corr][-1])
                  if method2[0:5] == 'WPBEH':
                   exc = method2[0:5]
                   corr = method2[6:]
                   if exc in xcDict.keys() and corr in xcDict.keys():
                      xc = xcDict.get([exc][-1]) + xcDict.get([corr][-1])
                  if method2[0:3] == 'LC-':
                   exccorr = method2[3:]
                   if exccorr in xcDict.keys():
                      xc = 'LC-' + xcDict.get([exccorr][-1])
                  if method2 in xcDict.keys(): 
                   xc = method2
                   xcWrite= True
                   method = 'DFT'
                  if method2 in methodDict.keys():
                   method = method2 
                   methodWrite = True
                   methodreal = method2
                  else:
                   for n in range(2,9):
                      if method2[0:n] in methodDict.keys():
                         method = method2[0:n]
                         methodWrite = True
                         methodreal = method2
                      if method2[0:9] == 'CBSEXTRAP':
                         method = method2[0:9]
                         methodWrite = True
                         methodreal = method2
                  if method2 in basissetDict.keys():
                   basisset = method2
                   basissetWrite = True
                   basissetreal = method2
                  if 'D95' in method2:
                   basisset = method2[0:3]
                   basissetWrite = True
                   basissetreal = method2
                  if 'AUG-' in method2:
                   basisset = method2[4:]
                   basissetWrite = True
                   basissetreal = method2
                  if 'UGBS' in method2:
                   basisset = method2[0:4]
                   basissetWrite = True
                   basissetreal = method2
                  if 'CBSB7' in method2:
                   basisset = method2[0:5]
                   basissetWrite = True
                   basissetreal = method2
                  if '6-31' in method2:
                   if '6-311' in method2:
                      basisset = '6-311G'
                      basissetWrite = True
                      basissetreal = '6-311' + method2[5:]
                   else:
                      basisset = '6-31G'
                      basissetWrite = True
                      basissetreal = '6-31' + method2[4:]

# special options for ONIOM calculations
        else:
          method = 'ONIOM'       
          methodWrite = True
          method1 = settings.split()
          for x in method1:
             method2 = str(x)
             method2 = method2.upper()
             if 'ONIOM' in method2:
                methodreal = method2
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1236
        
1237
1238
# description for hybrid coefficient
        xcHybridCoeffDescr = 'hybrid coefficient $\\alpha$'
1239
        hseFunc = 'HSEH1PBE'
1240
1241
1242
1243
1244
1245
1246
# functionals where hybrid_xc_coeff is written
        writeHybridCoeff = ['B3LYP', 'OHSE2PBE', 'HSEh1PBE', 'PBE1PBE' ]
        if xc is not None:
          # check if only one xc keyword was found in output
          if len([xc]) > 1:
              logger.error("Found %d settings for the xc functional: %s. This leads to an undefined behavior of the calculation and no metadata can be written for xc." % (len(xc), xc))
          else:
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1247
              backend.superBackend.addValue('x_gaussian_xc', [xc][-1])
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
            # check for hybrid_xc_coeff
#                hybridCoeff = valuesDict.get('hybrid_xc_coeff')
            # write hybrid_xc_coeff for certain functionals
#                if hybridCoeff is not None and xc[-1] in writeHybridCoeff:
#                    backend.superBackend.addValue('hybrid_xc_coeff', hybridCoeff[-1])
            # convert xc functional for metadata
              if xcWrite:
              # get list of xc components according to parsed value
                  xcList = xcDict.get([xc][-1])
                  if xcList is not None:
                  # loop over the xc components
                      for xcItem in xcList:
                          xcName = xcItem.get('name')
                          if xcName is not None:
                          # write section and XC_functional_name
                              gIndexTmp = backend.openSection('section_XC_functionals')
                              backend.addValue('XC_functional_name', xcName)
                            # write hybrid_xc_coeff for B3LYP and HSE03 into XC_functional_parameters
#                                if hybridCoeff is not None and xc[-1] in ['B3LYP', 'OHSE2PBE']:
#                                    backend.addValue('XC_functional_parameters', {xcHybridCoeffDescr: hybridCoeff[-1]})
                            # write hybrid_xc_coeff for HSE06
#                                elif xc[-1] == hseFunc:
                                # add hybrid_xc_coeff
#                                    if hybridCoeff is not None:
#                                        hybrid = hybridCoeff[-1]
#                                    else:
#                                        hybrid = 0.25
#                                    parameters[xcHybridCoeffDescr] = hybrid
#                                    backend.addValue('XC_functional_parameters', parameters)
                            # adjust weight of functionals that are affected by hybrid_xc_coeff
#                                elif hybridCoeff is not None and 'convert' in xcItem:
#                                    backend.addValue('XC_functional_weight', xcItem['convert'](hybridCoeff[-1]))
                            # write weight if present for current xcItem
#                                else:
#                                    xcWeight = xcItem.get('weight')
#                                    if xcWeight is not None:
#                                        backend.addValue('XC_functional_weight', xcWeight)
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1285
                              backend.closeSection('section_XC_functionals', gIndexTmp)
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
                          else:
                              logger.error("The dictionary for xc functional '%s' does not have the key 'name'. Please correct the dictionary xcDict in %s." % (xc[-1], os.path.basename(__file__)))
                  else:
                      logger.error("The xc functional '%s' could not be converted for the metadata. Please add it to the dictionary xcDict in %s." % (xc[-1], os.path.basename(__file__)))

# Write electronic structure method to metadata

        if method is not None:
          # check if only one method keyword was found in output
          if len([method]) > 1:
              logger.error("Found %d settings for the method: %s. This leads to an undefined behavior of the calculation and no metadata can be written for the method." % (len(method), method))
          else:
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1298
              backend.superBackend.addValue('x_gaussian_method', [method][-1])
1299
1300
1301
1302
1303
1304
1305
1306
1307
          methodList = methodDict.get([method][-1])
          if methodWrite:
               if methodList is not None:
        # loop over the method components
                  for methodItem in methodList:
                        methodName = methodItem.get('name')
                        if methodName is not None:
                 # write section and method name
                           gIndexTmp = backend.openSection('x_gaussian_section_elstruc_method')
1308
                           if methodprefix != None and methodreal != None:
1309
                              backend.addValue('x_gaussian_elstruc_method_name', str(methodprefix) + methodreal)
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1310
                              backend.closeSection('x_gaussian_section_elstruc_method', gIndexTmp)
1311
                           elif methodreal != None:
1312
                              backend.addValue('x_gaussian_elstruc_method_name', methodreal)
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1313
                              backend.closeSection('x_gaussian_section_elstruc_method', gIndexTmp)
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
                        else:
                              logger.error("The dictionary for method '%s' does not have the key 'name'. Please correct the dictionary methodDict in %s." % (method[-1], os.path.basename(__file__)))
               else:
                      logger.error("The method '%s' could not be converted for the metadata. Please add it to the dictionary methodDict in %s." % (method[-1], os.path.basename(__file__)))

#Write basis sets to metadata

        if basisset is not None:
          # check if only one method keyword was found in output
          if len([basisset]) > 1:
              logger.error("Found %d settings for the basis set: %s. This leads to an undefined behavior of the calculation and no metadata can be written for the basis set." % (len(method), method))
          else:
1326
              backend.superBackend.addValue('basis_set', basisset)
1327
1328
1329
1330
1331
1332
1333
          basissetList = basissetDict.get([basisset][-1])
          if basissetWrite:
               if basissetList is not None:
        # loop over the basis set components
                  for basissetItem in basissetList:
                        basissetName = basissetItem.get('name')
                        if basissetName is not None:
1334
                 # write section and basis set name(s)
1335
1336
                           gIndexTmp = backend.openSection('section_basis_set_atom_centered')
                           backend.addValue('basis_set_atom_centered_short_name', basissetreal)
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1337
                           backend.closeSection('section_basis_set_atom_centered', gIndexTmp)
1338
1339
1340
1341
1342
                        else:
                              logger.error("The dictionary for basis set '%s' does not have the key 'name'. Please correct the dictionary basissetDict in %s." % (basisset[-1], os.path.basename(__file__)))
               else:
                      logger.error("The basis set '%s' could not be converted for the metadata. Please add it to the dictionary basissetDict in %s." % (basisset[-1], os.path.basename(__file__)))

1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
      def onOpen_section_system(self, backend, gIndex, section):
          # keep track of the latest system description section
          self.secSystemDescriptionIndex = gIndex

      def onClose_section_system(self, backend, gIndex, section):
            # write/store unit cell if present and set flag self.periodicCalc
            if(section['x_gaussian_geometry_lattice_vector_x']):
              unit_cell = []
              for i in ['x', 'y', 'z']:
                  uci = str(section['x_gaussian_geometry_lattice_vector_' + i])
                  uci = uci.split() 
                  for i in range(len(uci)):
                    uci[i] = str(uci[i]).replace("[","").replace("'","").replace("]","").replace("\"","").replace(",","")
                    uci[i] = float(uci[i])
                  if uci is not None:
                     uci = convert_unit(uci, "angstrom", "m")
                     unit_cell.append(uci)
              if unit_cell:
                  # from metadata: "The first index is x,y,z and the second index the lattice vector."
                  # => unit_cell has already the right format
                  backend.addArrayValues('simulation_cell', np.asarray(unit_cell))
                  if np.shape(unit_cell) == (3, 1):
                    backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, False, False]))
                  if np.shape(unit_cell) == (3, 2):
                    backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, False]))
                  if np.shape(unit_cell) == (3, 3):
                    backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
                  self.periodicCalc = True
            if(section["x_gaussian_atomic_masses"]):
               atomicmasses = str(section["x_gaussian_atomic_masses"])
               atmass = []
               mass = [float(f) for f in atomicmasses[1:].replace("'","").replace(",","").replace("]","").replace(" ."," 0.").replace(" -."," -0.").split()]
               atmass = np.append(atmass, mass)
               numberofatoms = len(atmass)
               backend.addArrayValues("x_gaussian_masses", atmass)
               backend.addValue("x_gaussian_number_of_atoms",numberofatoms)
1379

1380
# which values to cache or forward (mapping meta name -> CachingLevel)
1381

1382
cachingLevelForMetaName = {
1383
        "x_gaussian_atom_x_coord": CachingLevel.Cache,
1384
1385
1386
        "x_gaussian_atom_y_coord": CachingLevel.Cache,
        "x_gaussian_atom_z_coord": CachingLevel.Cache,
        "x_gaussian_atomic_number": CachingLevel.Cache,
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1387
        "x_gaussian_section_geometry": CachingLevel.Forward,
1388
1389
1390
        "x_gaussian_atom_x_force": CachingLevel.Cache,
        "x_gaussian_atom_y_force": CachingLevel.Cache,
        "x_gaussian_atom_z_force": CachingLevel.Cache,
1391
        "x_gaussian_section_frequencies": CachingLevel.Forward,
Rosendo Valero Montero's avatar
Rosendo Valero Montero committed
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
        "x_gaussian_frequency_values": CachingLevel.Cache,
        "x_gaussian_frequencies": CachingLevel.ForwardAndCache,
        "x_gaussian_reduced_masses": CachingLevel.Cache,
        "x_gaussian_red_masses": CachingLevel.ForwardAndCache,
        "x_gaussian_normal_modes": CachingLevel.Cache,
        "x_gaussian_normal_mode_values": CachingLevel.ForwardAndCache,
        "x_gaussian_atomic_masses": CachingLevel.ForwardAndCache, 
        "x_gaussian_section_force_constant_matrix": CachingLevel.Forward,
        "x_gaussian_force_constant_values": CachingLevel.ForwardAndCache,
        "x_gaussian_force_constants": CachingLevel.Cache,
        "x_gaussian_section_eigenvalues": CachingLevel.Forward,
        "x_gaussian_alpha_occ_eigenvalues_values":CachingLevel.Cache,
        "x_gaussian_alpha_vir_eigenvalues_values":CachingLevel.Cache,
        "x_gaussian_alpha_eigenvalues": CachingLevel.ForwardAndCache,
        "x_gaussian_alpha_occupations": CachingLevel.ForwardAndCache,
        "x_gaussian_beta_occ_eigenvalues_values":CachingLevel.Cache,
        "x_gaussian_beta_vir_eigenvalues_values":CachingLevel.Cache,
        "x_gaussian_beta_eigenvalues": CachingLevel.ForwardAndCache,
        "x_gaussian_beta_occupations": CachingLevel.ForwardAndCache,
        "x_gaussian_section_orbital_symmetries": CachingLevel.Forward,
        "x_gaussian_alpha_occ_symmetry_values":CachingLevel.Cache,
        "x_gaussian_alpha_vir_symmetry_values":CachingLevel.Cache,
        "x_gaussian_beta_occ_symmetry_values":CachingLevel.Cache,
        "x_gaussian_beta_vir_symmetry_values":CachingLevel.Cache,  
        "x_gaussian_alpha_symmetries": CachingLevel.ForwardAndCache,
        "x_gaussian_beta_symmetries": CachingLevel.ForwardAndCache,
        "x_gaussian_section_molecular_multipoles": CachingLevel.Forward,
        "dipole_moment_x": CachingLevel.Cache,
        "dipole_moment_y": CachingLevel.Cache,
        "dipole_moment_z": CachingLevel.Cache,
        "quadrupole_moment_xx": CachingLevel.Cache,  
        "quadrupole_moment_yy": CachingLevel.Cache,
        "quadrupole_moment_zz": CachingLevel.Cache,
        "quadrupole_moment_xy": CachingLevel.Cache,
        "quadrupole_moment_xz": CachingLevel.Cache,
        "quadrupole_moment_yz": CachingLevel.Cache,
        "octapole_moment_xxx": CachingLevel.Cache,
        "octapole_moment_yyy": CachingLevel.Cache,
        "octapole_moment_zzz": CachingLevel.Cache,
        "octapole_moment_xyy": CachingLevel.Cache,
        "octapole_moment_xxy": CachingLevel.Cache,
        "octapole_moment_xxz": CachingLevel.Cache,
        "octapole_moment_xzz": CachingLevel.Cache,
        "octapole_moment_yzz": CachingLevel.Cache,
        "octapole_moment_yyz": CachingLevel.Cache,
        "octapole_moment_xyz": CachingLevel.Cache,
        "hexadecapole_moment_xxxx": CachingLevel.Cache,
        "hexadecapole_moment_yyyy": CachingLevel.Cache,
        "hexadecapole_moment_zzzz": CachingLevel.Cache,
        "hexadecapole_moment_xxxy": CachingLevel.Cache,
        "hexadecapole_moment_xxxz": CachingLevel.Cache,
        "hexadecapole_moment_yyyx": CachingLevel.Cache,
        "hexadecapole_moment_yyyz": CachingLevel.Cache,
        "hexadecapole_moment_zzzx": CachingLevel.Cache,
        "hexadecapole_moment_zzzy": CachingLevel.Cache,
        "hexadecapole_moment_xxyy": CachingLevel.Cache,
        "hexadecapole_moment_xxzz": CachingLevel.Cache,
        "hexadecapole_moment_yyzz": CachingLevel.Cache,
        "hexadecapole_moment_xxyz": CachingLevel.Cache,
        "hexadecapole_moment_yyxz": CachingLevel.Cache,
        "hexadecapole_moment_zzxy": CachingLevel.Cache, 
        "x_gaussian_molecular_multipole_values": CachingLevel.ForwardAndCache,
        "x_gaussian_single_configuration_calculation_converged": CachingLevel.ForwardAndCache,
        "x_gaussian_geometry_optimization_converged": CachingLevel.ForwardAndCache,
        "section_method": CachingLevel.Forward,
        "x_gaussian_section_elstruc_method": CachingLevel.Cache,
        "x_gaussian_elstruc_method_name": CachingLevel.ForwardAndCache,
        "XC_functional_name": CachingLevel.ForwardAndCache, 
        "basis_set_atom_centered_short_name": CachingLevel.ForwardAndCache,
        "x_gaussian_settings": CachingLevel.Cache,
        "x_gaussian_settings_corrected": CachingLevel.ForwardAndCache,
        "section_system": CachingLevel.Forward,
        "x_gaussian_atomic_masses": CachingLevel.Cache,
        "x_gaussian_masses": CachingLevel.ForwardAndCache,
        "x_gaussian_number_of_atoms": CachingLevel.ForwardAndCache