parser_exciting.py 25.4 KB
Newer Older
1
from builtins import object
2
import setup_paths
3
4
import numpy as np
from nomadcore.simple_parser import SimpleMatcher as SM, mainFunction
5
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
6
from nomadcore.caching_backend import CachingLevel
7
from nomadcore.unit_conversion import unit_conversion
8
import os, sys, json, exciting_parser_dos,exciting_parser_bandstructure, exciting_parser_input
9

10
11
12
13
class ExcitingParserContext(object):

  def startedParsing(self, path, parser):
    self.parser=parser
14
15
    self.atom_pos = []
    self.atom_labels = []
16
17
18
19
20
21
22
23
    self.secMethodIndex = None     #LOLLO
    self.secSystemIndex = None     #LOLLO

  def onOpen_section_system(self, backend, gIndex, section):
    self.secSystemIndex = gIndex

  def onOpen_section_method(self, backend, gIndex, section):
    self.secMethodIndex = gIndex
24

25
26
27
28
  def onClose_x_exciting_section_lattice_vectors(self, backend, gIndex, section):
    latticeX = section["x_exciting_geometry_lattice_vector_x"]
    latticeY = section["x_exciting_geometry_lattice_vector_y"]
    latticeZ = section["x_exciting_geometry_lattice_vector_z"]
29
    cell = [[latticeX[0],latticeY[0],latticeZ[0]],
30
            [latticeX[1],latticeY[1],latticeZ[1]],
31
32
            [latticeX[2],latticeY[2],latticeZ[2]]]
    backend.addValue("simulation_cell", cell)
33

Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
34
35
36
37
  def onClose_x_exciting_section_reciprocal_lattice_vectors(self, backend, gIndex, section):
    recLatticeX = section["x_exciting_geometry_reciprocal_lattice_vector_x"]
    recLatticeY = section["x_exciting_geometry_reciprocal_lattice_vector_y"]
    recLatticeZ = section["x_exciting_geometry_reciprocal_lattice_vector_z"]
38
    recCell = [[recLatticeX[0],recLatticeY[0],recLatticeZ[0]],
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
39
            [recLatticeX[1],recLatticeY[1],recLatticeZ[1]],
40
41
            [recLatticeX[2],recLatticeY[2],recLatticeZ[2]]]
    backend.addValue("x_exciting_simulation_reciprocal_cell", recCell)
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
42

43
44
  def onClose_x_exciting_section_xc(self, backend, gIndex, section):
    xcNr = section["x_exciting_xc_functional"][0]
45
46
    xc_internal_map = {
        2: ['LDA_C_PZ', 'LDA_X_PZ'],
47
        3: ['LDA_C_PW', 'LDA_X_PZ'],
48
49
        4: ['LDA_C_XALPHA'],
        5: ['LDA_C_VBH'],
50
51
52
53
54
55
56
        20: ['GGA_C_PBE', 'GGA_X_PBE'],
        21: ['GGA_C_PBE', 'GGA_X_PBE_R'],
        22: ['GGA_C_PBE_SOL', 'GGA_X_PBE_SOL'],
        26: ['GGA_C_PBE', 'GGA_X_WC'],
        30: ['GGA_C_AM05', 'GGA_C_AM05'],
        300: ['GGA_C_BGCP', 'GGA_X_PBE'],
        406: ['HYB_GGA_XC_PBEH']
57
58
59
60
61
62
        }
    for xcName in xc_internal_map[xcNr]:
      gi = backend.openSection("section_XC_functionals")
      backend.addValue("XC_functional_name", xcName)
      backend.closeSection("section_XC_functionals", gi)

63
  def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
64
65
    backend.addValue('single_configuration_to_calculation_method_ref', self.secMethodIndex)
    backend.addValue('single_configuration_calculation_to_system_ref', self.secSystemIndex)
66
67
    dirPath = os.path.dirname(self.parser.fIn.name)
    dosFile = os.path.join(dirPath, "dos.xml")
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
68
    bandFile = os.path.join(dirPath, "bandstructure.xml")
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
69
    fermiSurfFile = os.path.join(dirPath, "FERMISURF.bxsf")
70
    inputFile = os.path.join(dirPath, "input.xml")
71
    gwFile = os.path.join(dirPath, "GW_INFO.OUT")
72
############# reading input file for atom positions##############
73
74
75
    if os.path.exists(inputFile):
      with open(inputFile) as f:
        exciting_parser_input.parseInput(f, backend)
76
77
78
    if os.path.exists(dosFile):
      with open(dosFile) as f:
        exciting_parser_dos.parseDos(f, backend)
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
79
80
81
    if os.path.exists(bandFile):
      with open(bandFile) as g:
        exciting_parser_bandstructure.parseBand(g, backend)
82
83
84
85
    if os.path.exists(gwFile):
        backend.addValue('electronic_structure_method', "G0W0")
    else:
        backend.addValue('electronic_structure_method', "DFT")
Pardini, Lorenzo (lopa)'s avatar
test    
Pardini, Lorenzo (lopa) committed
86
87
88

##########################Parsing Fermi surface##################

89
90
91
92
93
    if os.path.exists(fermiSurfFile):
      fermiGIndex = backend.openSection("x_exciting_section_fermi_surface")
      with open(fermiSurfFile) as g:
        grid = []
        all_vectors = []
94
        values = []
95
96
97
98
99
100
101
102
103
104
105
106
107
        origin = []
        vectors = []
        fermi = 0
        number_of_bands = 0
        mesh_size = 0
        fromH = unit_conversion.convert_unit_function("hartree", "J")
        while 1:
          s = g.readline()
          if not s: break
          s = s.strip()
          st = s.split()
          if len(st) == 3:
            if len(s) >= 40:
108
#              print("all_vectors=",all_vectors)
109
              all_vectors.append([])
110
#              print("all_vectors_dopo=",all_vectors)
111
112
113
114
              i = 0
              while i < 3:
                all_vectors[-1].append(float(st[i]))
                i += 1
115
#                print("all_vectors_fine=",all_vectors)
116
117
118
119
120
121
122
123
            elif st[0] == "Fermi":
              fermi = fromH(float(st[2]))
            else:
              j = 0
              while j < 3:
                grid.append(int(st[j]))
                j += 1
          elif len(st) == 2:
124
125
#            print("len(st)=",len(st))
#            print("st=",st)
126
127
#            values[0].append(int(st[1]))
            values.append([])
128
          elif len(s) >= 12 and len(st) == 1:
129
130
131
132
            try: float(st[0])
            except ValueError:
              continue
            else:
133
              values[-1].append(float(st[0]))
134
#              print("aaaaa=",values)
135
          elif len(s) < 5 and len(st) == 1:
136
137
            number_of_bands = st[0] 
#        print("rigriglia=", grid) 
138
        mesh_size = grid[0]*grid[1]*grid[2]
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#        print("mesh_size=",mesh_size)
        origin = all_vectors[0]
        vectors = all_vectors[1:]
#        origin.append(all_vectors[0])
#        vectors.append(all_vectors[1:])
#        backend.addArrayValues("x_exciting_number_of_bands_fermi_surface", np.asarray(number_of_bands))
        backend.addValue("x_exciting_number_of_bands_fermi_surface", int(number_of_bands))
#        print("ebbene=",number_of_bands)
#        print("ebbene2=",int(number_of_bands))
#        backend.addArrayValues("x_exciting_number_of_mesh_points_fermi_surface", np.asarray(mesh_size))
        backend.addValue("x_exciting_number_of_mesh_points_fermi_surface", int(mesh_size))
#        print("meshe=", mesh_size)
#        backend.addArrayValues("x_exciting_fermi_energy_fermi_surface", np.asarray(fermi))
        backend.addValue("x_exciting_fermi_energy_fermi_surface", float(fermi))
153
        backend.addArrayValues("x_exciting_grid_fermi_surface", np.asarray(grid))
154
155
#        print("griglia=", grid)
#        backend.addArrayValues("x_exciting_origin_fermi_surface", origin)
156
        backend.addArrayValues("x_exciting_origin_fermi_surface", np.asarray(origin))
157
#        print("origine=", origin)
158
        backend.addArrayValues("x_exciting_vectors_fermi_surface", np.asarray(vectors))
159
160
#        backend.addArrayValues("x_exciting_vectors_fermi_surface", vectors)
#        print("vettori=", vectors)
161
        backend.addArrayValues("x_exciting_values_fermi_surface", np.asarray(values))
162
#        print("valori=", values)
163
        backend.closeSection("x_exciting_section_fermi_surface",fermiGIndex)
164
165
        backend.addValue('single_configuration_to_calculation_method_ref', self.secMethodIndex)
        backend.addValue('single_configuration_calculation_to_system_ref', self.secSystemIndex)
166
167
#######################TOTAL FORCES####################

168
169
170
171
172
173
174
175
176
177
178
179
#####    f_st = []
#####    if f_st:
#####      f_st = section['x_exciting_store_total_forces']
#####      atom_forces = [[],[]]
#####      coord = []
#####      for i in range (0, len(f_st)):
#####        f_st[i] = f_st[i].split()
#####        atom_forces[0].append(int(f_st[i][0]))
#####        atom_forces[1].append([])
#####        for j in range (3,6):
#####          atom_forces[1][-1].append(float(f_st[i][j]))
#      backend.addArrayValues("x_exciting_atom_forces",np.asarray(f_st))      
180

181
  def onClose_section_system(self, backend, gIndex, section):
182
    dirPath = os.path.dirname(self.parser.fIn.name)
183
    backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#    spin = section["x_exciting_spin_treatment"][0]
#    print("spin=",spin, type(spin))
#    print ("aqui?",spin[0])
#    spinTreat = spin
#    print("spinTreat=",spinTreat)
#    spinTreat=spin[0].strip()
#    print("rispin=",spin)
#    if "unpolarised" in spin:
#      number_of_spin_channels = 1
#    else:
#      number_of_spin_channels = 2
#    print("number_of_spin_channels=",number_of_spin_channels)
#    print("x_exciting_spin_treatment=",section["x_exciting_spin_treatment"])
    eigvalFile = os.path.join(dirPath, "EIGVAL.OUT")
    if os.path.exists(eigvalFile):
      eigvalGIndex = backend.openSection("section_eigenvalues")
      with open(eigvalFile) as g:
          eigvalKpoint=[]
#          eigvalVal=[[],[],[]]
#          eigvalOcc=[[],[]]
          eigvalVal=[]
          eigvalOcc=[]
#          print("x_exciting_spin_treatment=",section["x_exciting_spin_treatment"])
          fromH = unit_conversion.convert_unit_function("hartree", "J")
          while 1:
            s = g.readline()
            if not s: break
            s = s.strip()
            if len(s) < 20:
              continue
            elif len(s) > 50:
              eigvalVal.append([])
              eigvalOcc.append([])
#              eigvalVal[1].append([])
#              eigvalVal[2].append([])
#              eigvalOcc[0].append([])
#              eigvalOcc[1].append([])
              eigvalKpoint.append([float(x) for x in s.split()[1:4]])
            else:
              try: int(s[0])
              except ValueError:
                continue
              else:
                n, e, occ = s.split()
                eigvalVal[-1].append(fromH(float(e)))
                eigvalOcc[-1].append(float(occ))
#                eigvalVal[1][-1].append(int(n))
#                eigvalVal[2][-1].append(fromH(float(e)))
#                eigvalOcc[0][-1].append(int(n))
#                eigvalOcc[1][-1].append(float(occ))
          backend.addArrayValues("eigenvalues_kpoints", np.asarray(eigvalKpoint))
          backend.addArrayValues("eigenvalues_values", np.asarray([eigvalVal]))
          backend.addArrayValues("eigenvalues_occupation", np.asarray([eigvalOcc]))
          backend.closeSection("section_eigenvalues",eigvalGIndex)
#          print ("values= ", eigvalVal)


241
242
243
244
245
#    inputFile = os.path.join(dirPath, "input.xml")
############# reading input file ##############
#    if os.path.exists(inputFile):
#      with open(inputFile) as f:
#        exciting_parser_input.parseInput(f, backend)
246
    self.secSystemDescriptionIndex = gIndex
247

248
249
250
251
    if self.atom_pos:
       backend.addArrayValues('atom_positions', np.asarray(self.atom_pos))
    self.atom_pos = []
    if self.atom_labels is not None:
252
       backend.addArrayValues('atom_labels', np.asarray(self.atom_labels))
253
    self.atom_labels = []
254
    
255
256

  def onClose_x_exciting_section_atoms_group(self, backend, gIndex, section):
Mohamed, Fawzi Roberto (fawzi)'s avatar
Mohamed, Fawzi Roberto (fawzi) committed
257
258
    pos = [section['x_exciting_geometry_atom_positions_' + i] for i in ['x', 'y', 'z']]
    pl = [len(comp) for comp in pos]
259
260
261
262
263
264
    natom = pl[0]
    if pl[1] != natom or pl[2] != natom:
      raise Exception("invalid number of atoms in various components %s" % pl)
    for i in range(natom):
      self.atom_pos.append([pos[0][i], pos[1][i], pos[2][i]])
    self.atom_labels = self.atom_labels + (section['x_exciting_geometry_atom_labels'] * natom)
265

266
267
268
#  def onClose_section_run(self, backend, gIndex, section):
#    print("x_exciting_spin_treatment_run=",section["x_exciting_spin_treatment"])

269
270
271
272
273
274
275
mainFileDescription = \
    SM(name = "root matcher",
       startReStr = "",
       weak = True,
       subMatchers = [
         SM(name = "header",
         startReStr = r"\s*\|\s*EXCITING\s*(?P<program_version>[-a-zA-Z0-9]+)\s*started\s*=",
276
         fixedStartValues={'program_name': 'exciting', 'program_basis_set_type': '(L)APW+lo' },
277
            sections = ["section_run", "section_method"],
278
279
280
281
         subMatchers = [
	   SM(name = 'input',
              startReStr = r"\|\sStarting initialization",
              endReStr = r"\|\sEnding initialization",
282
              sections = ['section_system'],
283
284
              subMatchers = [
                SM(startReStr = r"\sLattice vectors \(cartesian\) :",
285
                sections = ["x_exciting_section_lattice_vectors"],
286
                subMatchers = [
287

288
    SM(startReStr = r"\s*(?P<x_exciting_geometry_lattice_vector_x__bohr>[-+0-9.]+)\s+(?P<x_exciting_geometry_lattice_vector_y__bohr>[-+0-9.]+)\s+(?P<x_exciting_geometry_lattice_vector_z__bohr>[-+0-9.]+)", repeats = True)
289
                ]),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
290
                SM(startReStr = r"\sReciprocal lattice vectors \(cartesian\) :",
291
                sections = ["x_exciting_section_reciprocal_lattice_vectors"],
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
292
293
                subMatchers = [

294
    SM(startReStr = r"\s*(?P<x_exciting_geometry_reciprocal_lattice_vector_x__bohr_1>[-+0-9.]+)\s+(?P<x_exciting_geometry_reciprocal_lattice_vector_y__bohr_1>[-+0-9.]+)\s+(?P<x_exciting_geometry_reciprocal_lattice_vector_z__bohr_1>[-+0-9.]+)", repeats = True)
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
295
                ]),
296
297
298
    SM(r"\s*Unit cell volume\s*:\s*(?P<x_exciting_unit_cell_volume__bohr3>[-0-9.]+)"),
    SM(r"\s*Brillouin zone volume\s*:\s*(?P<x_exciting_brillouin_zone_volume__bohr_3>[-0-9.]+)"),
    SM(r"\s*Species\s*:\s*[0-9]\s*\((?P<x_exciting_geometry_atom_labels>[-a-zA-Z0-9]+)\)", repeats = True,
299
      sections = ["x_exciting_section_atoms_group"],
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
300
       subMatchers = [
301
302
#        SM(r"\s*muffin-tin radius\s*:\s*(?P<x_exciting_muffin_tin_radius__bohr>[-0-9.]+)", repeats = True),
#        SM(r"\s*# of radial points in muffin-tin\s*:\s*(?P<x_exciting_muffin_tin_points>[-0-9.]+)", repeats = True),
303
304
305
306
        SM(startReStr = r"\s*atomic positions\s*\(lattice\)\s*:\s*",
           subMatchers = [
                    SM(r"\s*(?P<x_exciting_geometry_atom_number>[+0-9]+)\s*:\s*(?P<x_exciting_geometry_atom_positions_x__bohr>[-+0-9.]+)\s*(?P<x_exciting_geometry_atom_positions_y__bohr>[-+0-9.]+)\s*(?P<x_exciting_geometry_atom_positions_z__bohr>[-+0-9.]+)", repeats = True)
         ])
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
307
    ]),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
308
309
    SM(r"\s*Total number of atoms per unit cell\s*:\s*(?P<x_exciting_number_of_atoms>[-0-9.]+)"),
    SM(r"\s*Spin treatment\s*:\s*(?P<x_exciting_spin_treatment>[-a-zA-Z\s*]+)"),
310
#    SM(r"\s*Spin treatment\s*:\s*(?P<x_exciting_spin_treatment>[-a-zA-Z+]\s*)"),
311
312
313
314
    SM(r"\s*k-point grid\s*:\s*(?P<x_exciting_number_kpoint_x>[-0-9.]+)\s+(?P<x_exciting_number_kpoint_y>[-0-9.]+)\s+(?P<x_exciting_number_kpoint_z>[-0-9.]+)"),
    SM(r"\s*k-point offset\s*:\s*(?P<x_exciting_kpoint_offset_x>[-0-9.]+)\s+(?P<x_exciting_kpoint_offset_y>[-0-9.]+)\s+(?P<x_exciting_kpoint_offset_z>[-0-9.]+)"),
    SM(r"\s*Total number of k-points\s*:\s*(?P<x_exciting_number_kpoints>[-0-9.]+)"),
    SM(r"\s*R\^MT_min \* \|G\+k\|_max \(rgkmax\)\s*:\s*(?P<x_exciting_rgkmax__bohr>[-0-9.]+)"),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
315
    SM(r"\s*Maximum \|G\+k\| for APW functions\s*:\s*(?P<x_exciting_gkmax__bohr_1>[-0-9.]+)"),
316
317
318
    SM(r"\s*Maximum \|G\| for potential and density\s*:\s*(?P<x_exciting_gmaxvr__bohr_1>[-0-9.]+)"),
    SM(r"\s*G-vector grid sizes\s*:\s*(?P<x_exciting_gvector_size_x>[-0-9.]+)\s+(?P<x_exciting_gvector_size_y>[-0-9.]+)\s+(?P<x_exciting_gvector_size_z>[-0-9.]+)"),
    SM(r"\s*Total number of G-vectors\s*:\s*(?P<x_exciting_gvector_total>[-0-9.]+)"),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
319
320
    SM(startReStr = r"\s*Maximum angular momentum used for\s*",
        subMatchers = [
321
          SM(r"\s*APW functions\s*:\s*(?P<x_exciting_lmaxapw>[-0-9.]+)")
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
322
        ]),
323
324
325
326
327
328
329
330
331
332
    SM(r"\s*Total nuclear charge\s*:\s*(?P<x_exciting_nuclear_charge>[-0-9.]+)"),
    SM(r"\s*Total electronic charge\s*:\s*(?P<x_exciting_electronic_charge>[-0-9.]+)"),
    SM(r"\s*Total core charge\s*:\s*(?P<x_exciting_core_charge>[-0-9.]+)"),
    SM(r"\s*Total valence charge\s*:\s*(?P<x_exciting_valence_charge>[-0-9.]+)"),
    SM(r"\s*Effective Wigner radius, r_s\s*:\s*(?P<x_exciting_wigner_radius>[-0-9.]+)"),
    SM(r"\s*Number of empty states\s*:\s*(?P<x_exciting_empty_states>[-0-9.]+)"),
    SM(r"\s*Total number of valence states\s*:\s*(?P<x_exciting_valence_states>[-0-9.]+)"),
    SM(r"\s*Maximum Hamiltonian size\s*:\s*(?P<x_exciting_hamiltonian_size>[-0-9.]+)"),
    SM(r"\s*Maximum number of plane-waves\s*:\s*(?P<x_exciting_pw>[-0-9.]+)"),
    SM(r"\s*Total number of local-orbitals\s*:\s*(?P<x_exciting_lo>[-0-9.]+)"),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
333
334
    SM(startReStr = r"\s*Exchange-correlation type\s*:\s*(?P<x_exciting_xc_functional>[-0-9.]+)",
       sections = ['x_exciting_section_xc']),
335
336
    SM(r"\s*Smearing scheme\s*:\s*(?P<x_exciting_smearing_type>[-a-zA-Z0-9]+)"),
    SM(r"\s*Smearing width\s*:\s*(?P<x_exciting_smearing_width__hartree>[-0-9.]+)"),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
337
    SM(r"\s*Using\s*(?P<x_exciting_potential_mixing>[-a-zA-Z\s*]+)\s*potential mixing")
338
    ]),
339
340
341
342
343
344
345
346
347
348
            SM(name = "single configuration iteration",
              startReStr = r"\|\s*Self-consistent loop started\s*\+",
              sections = ["section_single_configuration_calculation"],
              repeats = True,
              subMatchers = [
                SM(name = "scfi totE",
                 startReStr =r"\|\s*SCF iteration number\s*:",
                  sections = ["section_scf_iteration"],
                  repeats = True,
                  subMatchers = [
349
                   SM(r"\s*Total energy\s*:\s*(?P<energy_total_scf_iteration__hartree>[-0-9.]+)"),
350
                   SM(r"\s*Fermi energy\s*:\s*(?P<x_exciting_fermi_energy_scf_iteration__hartree>[-0-9.]+)"),
351
                   SM(r"\s*Kinetic energy\s*:\s*(?P<electronic_kinetic_energy_scf_iteration__hartree>[-0-9.]+)"),
352
353
354
                   SM(r"\s*Coulomb energy\s*:\s*(?P<x_exciting_coulomb_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Exchange energy\s*:\s*(?P<x_exciting_exchange_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Correlation energy\s*:\s*(?P<x_exciting_correlation_energy_scf_iteration__hartree>[-0-9.]+)"),
355
                   SM(r"\s*Sum of eigenvalues\s*:\s*(?P<energy_sum_eigenvalues_scf_iteration__hartree>[-0-9.]+)"),
356
357
                   SM(r"\s*Effective potential energy\s*:\s*(?P<x_exciting_effective_potential_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Coulomb potential energy\s*:\s*(?P<x_exciting_coulomb_potential_energy_scf_iteration__hartree>[-0-9.]+)"),
358
                   SM(r"\s*xc potential energy\s*:\s*(?P<energy_XC_potential_scf_iteration__hartree>[-0-9.]+)"),
359
360
361
362
363
                   SM(r"\s*Hartree energy\s*:\s*(?P<x_exciting_hartree_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Electron-nuclear energy\s*:\s*(?P<x_exciting_electron_nuclear_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Nuclear-nuclear energy\s*:\s*(?P<x_exciting_nuclear_nuclear_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Madelung energy\s*:\s*(?P<x_exciting_madelung_energy_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Core-electron kinetic energy\s*:\s*(?P<x_exciting_core_electron_kinetic_energy_scf_iteration__hartree>[-0-9.]+)"),
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
364
                   SM(r"\s*Absolute change in total energy   (target)\s*:\s*(?P<energy_change_scf_iteration__hartree>[-0-9.]+)"),
365
366
367
368
369
370
371
372
373
                   SM(r"\s*DOS at Fermi energy \(states\/Ha\/cell\)\s*:\s*(?P<x_exciting_dos_fermi_scf_iteration__hartree_1>[-0-9.]+)"),
                   SM(r"\s*core leakage\s*:\s*(?P<x_exciting_core_leakage_scf_iteration>[-0-9.]+)"),
                   SM(r"\s*interstitial\s*:\s*(?P<x_exciting_interstitial_charge_scf_iteration>[-0-9.]+)"),
                   SM(r"\s*total charge in muffin-tins\s*:\s*(?P<x_exciting_total_MT_charge_scf_iteration>[-0-9.]+)"),
                   SM(r"\s*Estimated fundamental gap\s*:\s*(?P<x_exciting_gap_scf_iteration__hartree>[-0-9.]+)"),
                   SM(r"\s*Wall time \(seconds\)\s*:\s*(?P<x_exciting_time_scf_iteration>[-0-9.]+)"),
                   SM(r"\s*RMS change in effective potential \(target\)\s*:\s*(?P<x_exciting_effective_potential_convergence_scf_iteration>[0-9]\.[0-9]*([E]?[-]?[0-9]+))"),
                   SM(r"\s*Absolute change in total energy\s*\(target\)\s*:\s*(?P<x_exciting_energy_convergence_scf_iteration>[0-9]\.[0-9]*([E]?[-]?[0-9]+))"),
                   SM(r"\s*Charge distance\s*\(target\)\s*:\s*(?P<x_exciting_charge_convergence_scf_iteration>[0-9]\.[0-9]*([E]?[-]?[0-9]+))")
374
                  ]),
375
                SM(name="final_quantities",
376
377
378
                  startReStr = r"\| Convergence targets achieved. Performing final SCF iteration\s*\+",
                  endReStr = r"\| Self-consistent loop stopped\s*\+",
                   subMatchers = [
379
                     SM(r"\s*Total energy\s*:\s*(?P<energy_total__hartree>[-0-9.]+)"),
380
                     SM(r"\s*Fermi energy\s*:\s*(?P<x_exciting_fermi_energy__hartree>[-0-9.]+)"),
381
                     SM(r"\s*Kinetic energy\s*:\s*(?P<electronic_kinetic_energy__hartree>[-0-9.]+)"),
382
383
384
                     SM(r"\s*Coulomb energy\s*:\s*(?P<x_exciting_coulomb_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Exchange energy\s*:\s*(?P<x_exciting_exchange_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Correlation energy\s*:\s*(?P<x_exciting_correlation_energy__hartree>[-0-9.]+)"),
385
                     SM(r"\s*Sum of eigenvalues\s*:\s*(?P<energy_sum_eigenvalues__hartree>[-0-9.]+)"),
386
387
                     SM(r"\s*Effective potential energy\s*:\s*(?P<x_exciting_effective_potential_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Coulomb potential energy\s*:\s*(?P<x_exciting_coulomb_potential_energy__hartree>[-0-9.]+)"),
388
                     SM(r"\s*xc potential energy\s*:\s*(?P<energy_XC_potential__hartree>[-0-9.]+)"),
389
390
391
392
393
394
395
396
397
398
                     SM(r"\s*Hartree energy\s*:\s*(?P<x_exciting_hartree_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Electron-nuclear energy\s*:\s*(?P<x_exciting_electron_nuclear_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Nuclear-nuclear energy\s*:\s*(?P<x_exciting_nuclear_nuclear_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Madelung energy\s*:\s*(?P<x_exciting_madelung_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*Core-electron kinetic energy\s*:\s*(?P<x_exciting_core_electron_kinetic_energy__hartree>[-0-9.]+)"),
                     SM(r"\s*DOS at Fermi energy \(states\/Ha\/cell\)\s*:\s*(?P<x_exciting_dos_fermi__hartree_1>[-0-9.]+)"),
                     SM(r"\s*core leakage\s*:\s*(?P<x_exciting_core_leakage>[-0-9.]+)"),
                     SM(r"\s*interstitial\s*:\s*(?P<x_exciting_interstitial_charge>[-0-9.]+)"),
                     SM(r"\s*total charge in muffin-tins\s*:\s*(?P<x_exciting_total_MT_charge>[-0-9.]+)"),
                     SM(r"\s*Estimated fundamental gap\s*:\s*(?P<x_exciting_gap__hartree>[-0-9.]+)")
399
400
401
402
403
404
405
406
407
                   ]),
                SM(name="final_forces",
                  startReStr = r"\| Writing atomic positions and forces\s*\-",
#                  endReStr = r"\| Groundstate module stopped\s*\*",
                  endReStr = r"\s* Atomic force components including IBS \(cartesian\)\s*:",
                   subMatchers = [
                     SM(name="total_forces",
                     startReStr = r"\s*Total atomic forces including IBS \(cartesian\)\s*:",
##                       SM(r"\s*atom\s*(?P<x_exciting_store_total_forces>[0-9]+\s*[A-Za-z]+\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)",
408
409
410
411
412
#####                     subMatchers = [
#####                     SM(r"\s*atom\s*(?P<x_exciting_store_total_forces>[0-9]+\s*[A-Za-z]+\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+)",
#####                          repeats = True)
#####                   ] )
)
413
414
415
416
417
418
419
420
421
#                     print ("number atoms=", x_exciting_number_of_atoms)
#                     SM(name="force_components",
#                     startReStr = r"\s*Atomic force components including IBS \(cartesian\)\s*:",
#                     forwardMatch = True,
#                     subMatchers = [
#                     SM(r"\s*atom\s*(?P<x_exciting_store_total_forces>[0-9]+\s*[A-Za-z]+\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)", weak = True),
#                     SM(r"\s*(?P<x_exciting_store_total_forces>\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)"),
#                     SM(r"\s*(?P<x_exciting_store_total_forces>\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)")
#                     SM(r"\s*(?P<x_exciting_store_total_forces>\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)"),
422
#                   ] 
423
#                    )
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
                   ])
               ]
            )
          ])
    ])




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

metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/exciting.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
440

441
cachingLevelForMetaName = {
442
443
444
                            "x_exciting_geometry_lattice_vector_x":CachingLevel.Cache,
                            "x_exciting_geometry_lattice_vector_y":CachingLevel.Cache,
                            "x_exciting_geometry_lattice_vector_z":CachingLevel.Cache,
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
445
446
447
448
449
                            "x_exciting_section_lattice_vectors": CachingLevel.Ignore,
                            "x_exciting_geometry_reciprocal_lattice_vector_x":CachingLevel.Cache,
                            "x_exciting_geometry_reciprocal_lattice_vector_y":CachingLevel.Cache,
                            "x_exciting_geometry_reciprocal_lattice_vector_z":CachingLevel.Cache,
                            "x_exciting_section_reciprocal_lattice_vectors": CachingLevel.Ignore
450
                          }
451
452

if __name__ == "__main__":
453
454
#    for name in metaInfoEnv.infoKinds:
#        print 'nameo', name
Pardini, Lorenzo (lopa)'s avatar
Pardini, Lorenzo (lopa) committed
455
    mainFunction(mainFileDescription, metaInfoEnv, parserInfo, cachingLevelForMetaName = cachingLevelForMetaName, superContext=ExcitingParserContext())