Commit 4bd88851 authored by Pardini, Lorenzo (lopa)'s avatar Pardini, Lorenzo (lopa)
Browse files

parse total and scf energy and add test files

parent 4b602f56
import setup_paths
from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM
import numpy as np
from nomadcore.simple_parser import SimpleMatcher as SM, mainFunction
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.caching_backend import CachingLevel
import os, sys, json
class ExcitingParserContext(object):
def startedParsing(self, path, parser):
self.parser=parser
def onClose_exciting_section_lattice_vectors(self, backend, gIndex, section):
latticeX = section["exciting_geometry_lattice_vector_x"]
latticeY = section["exciting_geometry_lattice_vector_y"]
latticeZ = section["exciting_geometry_lattice_vector_z"]
# print "section", section.simpleValues
# print "latticeX",latticeX
# print "latticeY",latticeY
# print "latticeZ",latticeZ
cell = [[latticeX[0],latticeY[0],latticeZ[0]],
[latticeX[1],latticeY[1],latticeZ[1]],
[latticeX[2],latticeY[2],latticeZ[2]]]
backend.addValue("simulation_cell", cell)
# description of the input
mainFileDescription = SM(
name = 'root',
weak = True,
startReStr = "",
subMatchers = [
SM(name = 'newRun',
startReStr = r"\s*# SampleParser #\s*",
repeats = True,
required = True,
forwardMatch = True,
sections = ['section_run'],
subMatchers = [
SM(name = 'header',
startReStr = r"\s*# SampleParser #\s*")
])
])
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/exciting.nomadmetainfo.json
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)
parserInfo = {
"name": "parser_exciting",
"version": "1.0"
}
class ExcitingParserContext(object):
"""main place to keep the parser status, open ancillary files,..."""
def __init__(self):
self.scfIterNr = 0
# just examples, you probably want to remove the following two triggers
def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
"""trigger called when section_single_configuration_calculation is closed"""
#backend.addValue("", self.scfIterNr)
logging.getLogger("nomadcore.parsing").info("closing section_single_configuration_calculation gIndex %d %s", gIndex, section.simpleValues)
self.scfIterNr = 0
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*=",
sections = ["section_run"],
subMatchers = [
SM(name = 'input',
startReStr = r"\|\sStarting initialization",
endReStr = r"\|\sEnding initialization",
sections = ['section_system_description'],
subMatchers = [
SM(startReStr = r"\sLattice vectors \(cartesian\) :",
sections = ["exciting_section_lattice_vectors"],
subMatchers = [
def onClose_section_scf_iteration(self, backend, gIndex, section):
"""trigger called when section_scf_iteration is closed"""
logging.getLogger("nomadcore.parsing").info("closing section_scf_iteration bla gIndex %d %s", gIndex, section.simpleValues)
self.scfIterNr += 1
SM(startReStr = r"\s*(?P<exciting_geometry_lattice_vector_x__bohr>[-+0-9.]+)\s+(?P<exciting_geometry_lattice_vector_y__bohr>[-+0-9.]+)\s+(?P<exciting_geometry_lattice_vector_z__bohr>[-+0-9.]+)", repeats = True)
])
]),
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 = [
SM(r"\s*Total energy\s*:\s*(?P<energy_total_scf_iteration__hartree>[-0-9.]+)")
]),
SM(name="final_energy",
startReStr = r"\| Convergence targets achieved. Performing final SCF iteration\s*\+",
endReStr = r"\| Self-consistent loop stopped\s*\+",
subMatchers = [
SM(r"\s*Total energy\s*:\s*(?P<energy_total__hartree>[-0-9.]+)")
])
]
)
])
])
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)
# which values to cache or forward (mapping meta name -> CachingLevel)
cachingLevelForMetaName = {}
cachingLevelForMetaName = {
"exciting_geometry_lattice_vector_x":CachingLevel.Cache,
"exciting_geometry_lattice_vector_y":CachingLevel.Cache,
"exciting_geometry_lattice_vector_z":CachingLevel.Cache,
"exciting_section_lattice_vectors": CachingLevel.Ignore
}
if __name__ == "__main__":
mainFunction(mainFileDescription, metaInfoEnv, parserInfo,
cachingLevelForMetaName = cachingLevelForMetaName,
superContext = ExcitingParserContext())
# for name in metaInfoEnv.infoKinds:
# print 'nameo', name
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, cachingLevelForMetaName = cachingLevelForMetaName, superContext=ExcitingParserContext())
<?xml version="1.0" encoding="UTF-8"?>
<spdb xsi:noNamespaceSchemaLocation="../../xml/species.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sp chemicalSymbol="Ag" name="silver" z="-47.0000" mass="196631.6997">
<muffinTin rmin="0.100000E-04" radius="2.0000" rinf="23.9999" radialmeshPoints="400"/>
<atomicState n="1" l="0" kappa="1" occ="2.00000" core="true"/>
<atomicState n="2" l="0" kappa="1" occ="2.00000" core="true"/>
<atomicState n="2" l="1" kappa="1" occ="2.00000" core="true"/>
<atomicState n="2" l="1" kappa="2" occ="4.00000" core="true"/>
<atomicState n="3" l="0" kappa="1" occ="2.00000" core="true"/>
<atomicState n="3" l="1" kappa="1" occ="2.00000" core="true"/>
<atomicState n="3" l="1" kappa="2" occ="4.00000" core="true"/>
<atomicState n="3" l="2" kappa="2" occ="4.00000" core="true"/>
<atomicState n="3" l="2" kappa="3" occ="6.00000" core="true"/>
<atomicState n="4" l="0" kappa="1" occ="2.00000" core="false"/>
<atomicState n="4" l="1" kappa="1" occ="2.00000" core="false"/>
<atomicState n="4" l="1" kappa="2" occ="4.00000" core="false"/>
<atomicState n="4" l="2" kappa="2" occ="4.00000" core="false"/>
<atomicState n="4" l="2" kappa="3" occ="6.00000" core="false"/>
<atomicState n="5" l="0" kappa="1" occ="1.00000" core="false"/>
<basis>
<default type="lapw" trialEnergy="0.1500" searchE="false"/>
<custom l="0" type="apw+lo" trialEnergy="0.1500" searchE="true"/>
<custom l="1" type="apw+lo" trialEnergy="0.1500" searchE="true"/>
<custom l="2" type="apw+lo" trialEnergy="0.1500" searchE="true"/>
<lo l="0">
<wf matchingOrder="0" trialEnergy="0.1500" searchE="true"/>
<wf matchingOrder="1" trialEnergy="0.1500" searchE="true"/>
<wf matchingOrder="0" trialEnergy="-3.4920" searchE="true"/>
</lo>
<lo l="1">
<wf matchingOrder="0" trialEnergy="0.1500" searchE="true"/>
<wf matchingOrder="1" trialEnergy="0.1500" searchE="true"/>
<wf matchingOrder="0" trialEnergy="-2.2857" searchE="true"/>
</lo>
</basis>
<!-- Exciting code version: Lithium -->
<!-- Generation Scheme: simple -->
</sp>
</spdb>
<?xml version="1.0" encoding="UTF-8"?>
<spdb xsi:noNamespaceSchemaLocation="../../xml/species.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sp chemicalSymbol="Ag" name="silver" z="-47.0000" mass="196631.6997">
<muffinTin rmin="0.100000E-04" radius="2.0000" rinf="23.9999" radialmeshPoints="400"/>
<atomicState n="1" l="0" kappa="1" occ="2.00000" core="true"/>
<atomicState n="2" l="0" kappa="1" occ="2.00000" core="true"/>
<atomicState n="2" l="1" kappa="1" occ="2.00000" core="true"/>
<atomicState n="2" l="1" kappa="2" occ="4.00000" core="true"/>
<atomicState n="3" l="0" kappa="1" occ="2.00000" core="true"/>
<atomicState n="3" l="1" kappa="1" occ="2.00000" core="true"/>
<atomicState n="3" l="1" kappa="2" occ="4.00000" core="true"/>
<atomicState n="3" l="2" kappa="2" occ="4.00000" core="true"/>
<atomicState n="3" l="2" kappa="3" occ="6.00000" core="true"/>
<atomicState n="4" l="0" kappa="1" occ="2.00000" core="false"/>
<atomicState n="4" l="1" kappa="1" occ="2.00000" core="false"/>
<atomicState n="4" l="1" kappa="2" occ="4.00000" core="false"/>
<atomicState n="4" l="2" kappa="2" occ="4.00000" core="false"/>
<atomicState n="4" l="2" kappa="3" occ="6.00000" core="false"/>
<atomicState n="5" l="0" kappa="1" occ="1.00000" core="false"/>
<basis>
<default>
<wf matchingOrder="0" trialEnergy="0.1500" searchE="false"/>
</default>
<custom l="0">
<wf matchingOrder="0" trialEnergy="0.7050" searchE="true"/>
</custom>
<custom l="1">
<wf matchingOrder="0" trialEnergy="1.4125" searchE="true"/>
</custom>
<custom l="2">
<wf matchingOrder="0" trialEnergy="0.1500" searchE="true"/>
</custom>
<lo l="0">
<wf matchingOrder="0" trialEnergy="0.7050" searchE="true"/>
<wf matchingOrder="1" trialEnergy="0.7050" searchE="true"/>
</lo>
<lo l="1">
<wf matchingOrder="0" trialEnergy="1.4125" searchE="true"/>
<wf matchingOrder="1" trialEnergy="1.4125" searchE="true"/>
</lo>
<lo l="2">
<wf matchingOrder="0" trialEnergy="0.1500" searchE="true"/>
<wf matchingOrder="1" trialEnergy="0.1500" searchE="true"/>
</lo>
<lo l="0">
<wf matchingOrder="0" trialEnergy="0.7050" searchE="true"/>
<wf matchingOrder="1" trialEnergy="0.7050" searchE="true"/>
<wf matchingOrder="0" trialEnergy="-3.0320" searchE="true"/>
</lo>
<lo l="1">
<wf matchingOrder="0" trialEnergy="1.4125" searchE="true"/>
<wf matchingOrder="1" trialEnergy="1.4125" searchE="true"/>
<wf matchingOrder="0" trialEnergy="-1.6845" searchE="true"/>
</lo>
</basis>
<!-- This file was automatically generated-->
<!-- Default linearization energies have been replaced by that -->
<!-- found using findlinentype='Wigner_Seitz' method -->
</sp>
</spdb>
Distance between is = 1 (Ag), ia = 1 and
is = 1 (Ag), ia = 1 : 0.000000000
3 : nkpt
15 : nstsv
1 0.000000000 0.000000000 0.000000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -3.033910903 2.000000000
2 -1.688676855 2.000000000
3 -1.688676672 2.000000000
4 -1.688676672 2.000000000
5 0.4133732778E-01 2.000000000
6 0.1668181756 2.000000000
7 0.1668181756 2.000000000
8 0.1668182657 2.000000000
9 0.2068098488 2.000000000
10 0.2068098488 2.000000000
11 0.9141656727 0.000000000
12 1.046125283 0.000000000
13 1.046125283 0.000000000
14 1.046125617 0.000000000
15 1.228680960 0.000000000
2 0.5000000000 0.000000000 0.000000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -3.033263682 2.000000000
2 -1.695002073 2.000000000
3 -1.689665902 2.000000000
4 -1.689665726 2.000000000
5 0.1025259294 2.000000000
6 0.1658609869 2.000000000
7 0.1658615656 2.000000000
8 0.2350947630 2.000000000
9 0.2350952844 2.000000000
10 0.3133632645 1.500000001
11 0.4677188960 0.000000000
12 0.8873202647 0.000000000
13 0.9817097536 0.000000000
14 0.9817102968 0.000000000
15 1.181311263 0.000000000
3 0.5000000000 0.5000000000 0.000000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -3.033103597 2.000000000
2 -1.695165353 2.000000000
3 -1.691453525 2.000000000
4 -1.691453322 2.000000000
5 0.1004292777 2.000000000
6 0.1071938228 2.000000000
7 0.2339712825 2.000000000
8 0.2415072217 2.000000000
9 0.2415072680 2.000000000
10 0.3862971434 0.000000000
11 0.5806413181 0.000000000
12 0.7187834289 0.000000000
13 0.7187836505 0.000000000
14 0.9670877386 0.000000000
15 0.9714104883 0.000000000
Species : 1 (Ag)
atom 1 is equivalent to atom(s)
1
Species : 1 (Ag), atom : 1
n = 1, l = 0, k = 1 : -929.3758515
n = 2, l = 0, k = 1 : -136.4290240
n = 2, l = 1, k = 1 : -126.7708318
n = 2, l = 1, k = 2 : -120.3328300
n = 3, l = 0, k = 1 : -24.63292269
n = 3, l = 1, k = 1 : -20.79093404
n = 3, l = 1, k = 2 : -19.65461152
n = 3, l = 2, k = 2 : -12.84731149
n = 3, l = 2, k = 3 : -12.61836258
This diff is collapsed.
3 : nkpt; k-point, vkl, wkpt, nmat below
1 0.000000000 0.000000000 0.000000000 0.1250000000 78
2 0.5000000000 0.000000000 0.000000000 0.5000000000 89
3 0.5000000000 0.5000000000 0.000000000 0.3750000000 105
+----------------------------+
| Real-space lattice vectors |
+----------------------------+
vector a1 : 3.860050000 3.860050000 0.000000000
vector a2 : 3.860050000 0.000000000 3.860050000
vector a3 : 0.000000000 3.860050000 3.860050000
Stored column-wise as a matrix :
3.860050000 3.860050000 0.000000000
3.860050000 0.000000000 3.860050000
0.000000000 3.860050000 3.860050000
Inverse of matrix :
0.1295320009 0.1295320009 -0.1295320009
0.1295320009 -0.1295320009 0.1295320009
-0.1295320009 0.1295320009 0.1295320009
Unit cell volume : 115.0293819
+----------------------------------+
| Reciprocal-space lattice vectors |
+----------------------------------+
vector b1 : 0.8138735647 0.8138735647 -0.8138735647
vector b2 : 0.8138735647 -0.8138735647 0.8138735647
vector b3 : -0.8138735647 0.8138735647 0.8138735647
Stored column-wise as a matrix :
0.8138735647 0.8138735647 -0.8138735647
0.8138735647 -0.8138735647 0.8138735647
-0.8138735647 0.8138735647 0.8138735647
Inverse of matrix :
0.6143460381 0.6143460381 -0.000000000
0.6143460381 -0.000000000 0.6143460381
-0.000000000 0.6143460381 0.6143460381
Brillouin zone volume : 2.156407426
Species : 1 (Ag), atom : 1
APW functions :
l = 0, order = 1 : 0.7050000000
l = 1, order = 1 : 1.412500000
l = 2, order = 1 : 0.1500000000
l = 3, order = 1 : 0.1500000000
l = 3, order = 2 : 0.1500000000
l = 4, order = 1 : 0.1500000000
l = 4, order = 2 : 0.1500000000
l = 5, order = 1 : 0.1500000000
l = 5, order = 2 : 0.1500000000
l = 6, order = 1 : 0.1500000000
l = 6, order = 2 : 0.1500000000
l = 7, order = 1 : 0.1500000000
l = 7, order = 2 : 0.1500000000
l = 8, order = 1 : 0.1500000000
l = 8, order = 2 : 0.1500000000
local-orbital functions :
l.o. = 1, l = 0, order = 1 : 0.7050000000
l.o. = 1, l = 0, order = 2 : 0.7050000000
l.o. = 2, l = 1, order = 1 : 1.412500000
l.o. = 2, l = 1, order = 2 : 1.412500000
l.o. = 3, l = 2, order = 1 : 0.1500000000
l.o. = 3, l = 2, order = 2 : 0.1500000000
l.o. = 4, l = 0, order = 1 : 0.7050000000
l.o. = 4, l = 0, order = 2 : 0.7050000000
l.o. = 4, l = 0, order = 3 : -3.032000000
l.o. = 5, l = 1, order = 1 : 1.412500000
l.o. = 5, l = 1, order = 2 : 1.412500000
l.o. = 5, l = 1, order = 3 : -1.684450000
0.9257914574E-01
0.6966438463E-01
0.5480255867E-02
0.2401027659E-02
0.3846448053E-04
0.1484553775E-04
0.9011989557E-06
0.2951798968E-06
0.6527934099E-08
0.3702401446E-09
(translation vectors and rotation matrices are in lattice coordinates)
48 : nsymcrys
Crystal symmetry : 1
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
1 0 0
0 1 0
0 0 1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 2
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 -1 -1
0 0 1
1 0 0
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 3
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 -1 -1
0 1 0
0 0 1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 4
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 -1 -1
0 1 0
1 0 0
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 5
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 -1 -1
1 0 0
0 0 1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 6
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 -1 -1
1 0 0
0 1 0
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 7
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 0 0
0 -1 0
0 0 -1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 8
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 0 0
0 -1 0
1 1 1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 9
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 0 0
0 0 -1
0 -1 0
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 10
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 0 0
0 0 -1
1 1 1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 11
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 0 0
1 1 1
0 -1 0
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 12
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
-1 0 0
1 1 1
0 0 -1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 13
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
0 -1 0
-1 0 0
0 0 -1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 14
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
0 -1 0
-1 0 0
1 1 1
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 15
spatial translation :
0.000000000 0.000000000 0.000000000
spatial rotation :
0 -1 0
0 0 -1
-1 0 0
global spin rotation :
1 0 0
0 1 0
0 0 1
Crystal symmetry : 16
spatial translation :
0.000000000 0.000000000 0.000000000