Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-exciting
Commits
a65c9a08
Commit
a65c9a08
authored
Sep 21, 2017
by
Pardini, Lorenzo (lopa)
Browse files
fixed GW parser
parent
1c4afcf4
Changes
3
Hide whitespace changes
Inline
Side-by-side
parser/parser-exciting/exciting_parser_bandstructure.py
View file @
a65c9a08
...
...
@@ -41,7 +41,7 @@ class BandHandler(xml.sax.handler.ContentHandler):
elif
name
==
"vertex"
and
self
.
inBand
:
self
.
vertexCoord
.
append
(
attrs
.
getValue
(
"coord"
))
label
=
attrs
.
getValue
(
"label"
)
if
label
==
"Gamma"
:
if
(
label
==
"Gamma"
)
or
(
label
==
"Gamma"
)
:
self
.
vertexLabels
.
append
(
'
\u0393
'
)
else
:
self
.
vertexLabels
.
append
(
label
)
...
...
parser/parser-exciting/exciting_parser_gw.py
View file @
a65c9a08
...
...
@@ -32,7 +32,7 @@ class GWContext(object):
self
.
parser
=
parser
self
.
initialize_values
()
def
onClose_x_exciting_section_GW
_method
(
self
,
backend
,
gIndex
,
section
):
def
onClose_x_exciting_section_GW
(
self
,
backend
,
gIndex
,
section
):
dirPath
=
os
.
path
.
dirname
(
self
.
parser
.
fIn
.
name
)
if
os
.
access
(
os
.
path
.
join
(
dirPath
,
"EVALQP.DAT"
),
os
.
F_OK
):
...
...
@@ -41,14 +41,39 @@ class GWContext(object):
eigvalGWFile
=
os
.
path
.
join
(
dirPath
,
"EVALQP.TXT"
)
else
:
pass
# eigvalGWFile = os.path.join(dirPath, "EVALQP.DAT")
dosGWFile
=
os
.
path
.
join
(
dirPath
,
"TDOS-QP.OUT"
)
bandCarbGWFile
=
os
.
path
.
join
(
dirPath
,
"bandstructure-qp.dat"
)
bandBorGWFile
=
os
.
path
.
join
(
dirPath
,
"BAND-QP.OUT"
)
# bandGWFile = os.path.join(dirPath, "bandstructure-qp.dat")
vertexGWFile
=
os
.
path
.
join
(
dirPath
,
"BANDLINES.OUT"
)
vertexLabGWFile
=
os
.
path
.
join
(
dirPath
,
"bandstructure.xml"
)
selfCorGWFile
=
os
.
path
.
join
(
dirPath
,
"SELFC.DAT"
)
inputFile
=
os
.
path
.
join
(
dirPath
,
"input.xml"
)
if
os
.
path
.
exists
(
inputFile
):
selfGWSetGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_settings"
)
singularity
=
'mpd'
actype
=
'pade'
npol
=
0
scrtype
=
"rpa"
with
open
(
inputFile
)
as
g
:
while
1
:
s
=
g
.
readline
()
if
not
s
:
break
s
=
s
.
strip
()
s
=
s
.
split
(
'='
)
if
s
[
0
]
==
"singularity"
:
freq_conv
=
s
[
1
][
1
:
-
1
]
if
s
[
0
]
==
"actype"
:
actype
=
s
[
1
][
1
:
-
1
]
if
s
[
0
]
==
"npol"
:
npol
=
s
[
1
][
1
:
-
1
]
if
s
[
0
]
==
"scrtype"
:
scrtype
=
s
[
1
][
1
:
-
1
]
backend
.
addValue
(
"x_exciting_GW_self_energy_singularity_treatment"
,
singularity
)
backend
.
addValue
(
"x_exciting_GW_self_energy_c_analytical_continuation"
,
actype
)
backend
.
addValue
(
"x_exciting_GW_self_energy_c_number_of_poles"
,
npol
)
backend
.
addValue
(
"x_exciting_GW_screened_Coulomb"
,
scrtype
)
backend
.
closeSection
(
"x_exciting_section_GW_settings"
,
selfGWSetGIndex
)
if
os
.
path
.
exists
(
vertexGWFile
):
with
open
(
vertexGWFile
)
as
g
:
...
...
@@ -62,9 +87,7 @@ class GWContext(object):
self
.
vertexDist
.
append
(
float
(
s
[
0
]))
elif
float
(
s
[
0
])
!=
self
.
vertexDist
[
-
1
]:
self
.
vertexDist
.
append
(
float
(
s
[
0
]))
# print("vertexDist",self.vertexDist)
self
.
vertexNum
=
len
(
self
.
vertexDist
)
-
1
# print("vertexNum",self.vertexNum)
if
os
.
path
.
exists
(
vertexLabGWFile
):
with
open
(
vertexLabGWFile
)
as
g
:
...
...
@@ -77,22 +100,10 @@ class GWContext(object):
f
=
s
[
4
].
split
(
"
\"
"
)
self
.
vertexLabels
.
append
(
f
[
1
])
if
os
.
path
.
exists
(
selfCorGWFile
):
selfGWGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_self_energy"
)
with
open
(
selfCorGWFile
)
as
g
:
while
1
:
s
=
g
.
readline
()
if
not
s
:
break
s
=
s
.
strip
()
backend
.
closeSection
(
"x_exciting_section_GW_self_energy"
,
selfGWGIndex
)
if
os
.
path
.
exists
(
eigvalGWFile
):
eigvalGWOutGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_output"
)
eigvalGWGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_qp_eigenvalues"
)
with
open
(
eigvalGWFile
)
as
g
:
# print("ggggggggggg=",g)
qpGWKpoint
=
[]
Sx
=
[[],[]]
Sc
=
[[],[]]
...
...
@@ -110,7 +121,6 @@ class GWContext(object):
Sc
[
i
].
append
([])
qpE
[
i
].
append
([])
Znk
[
i
].
append
([])
# x,y,z,weight = float(s.split()[3]),float(s.split()[4]),float(s.split()[5]),float(s.split()[6])
x
,
y
,
z
=
float
(
s
.
split
()[
3
]),
float
(
s
.
split
()[
4
]),
float
(
s
.
split
()[
5
])
qpGWKpoint
[
-
1
].
append
(
x
)
qpGWKpoint
[
-
1
].
append
(
y
)
...
...
@@ -142,10 +152,11 @@ class GWContext(object):
backend
.
addValue
(
"x_exciting_GW_self_energy_x"
,
Sx
)
backend
.
addValue
(
"x_exciting_GW_self_energy_c"
,
Sc
)
backend
.
closeSection
(
"x_exciting_section_GW_self_energy"
,
selfGWGIndex
)
backend
.
closeSection
(
"x_exciting_section_GW_output"
,
eigvalGWOutGIndex
)
####################DOS######################
if
os
.
path
.
exists
(
dosGWFile
):
dosGWOutGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_output"
)
dosGWGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_dos"
)
fromH
=
unit_conversion
.
convert_unit_function
(
"hartree"
,
"J"
)
with
open
(
dosGWFile
)
as
g
:
...
...
@@ -157,7 +168,6 @@ class GWContext(object):
s
=
s
.
strip
()
s
=
s
.
split
()
ene
,
value
=
fromH
(
float
(
s
[
0
])),
float
(
s
[
1
])
# ene, value = float(s[0]), float(s[1])
dosEnergies
.
append
(
ene
)
if
not
self
.
spinTreat
:
for
i
in
range
(
0
,
2
):
...
...
@@ -168,12 +178,12 @@ class GWContext(object):
backend
.
addValue
(
"x_exciting_GW_dos_values"
,
dosValues
)
backend
.
addValue
(
"x_exciting_GW_number_of_dos_values"
,
len
(
dosEnergies
))
backend
.
closeSection
(
"x_exciting_section_GW_dos"
,
dosGWGIndex
)
backend
.
closeSection
(
"x_exciting_section_GW_output"
,
dosGWOutGIndex
)
##################BANDSTRUCTURE#####################
if
os
.
path
.
exists
(
bandCarbGWFile
):
bandGWOutGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_output"
)
bandGWGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_k_band"
)
# bandGWSegmGIndex = backend.openSection("x_exciting_section_GW_k_band_segment")
fromH
=
unit_conversion
.
convert_unit_function
(
"hartree"
,
"J"
)
with
open
(
bandCarbGWFile
)
as
g
:
...
...
@@ -201,7 +211,6 @@ class GWContext(object):
numK
=
int
(
s
[
3
])
elif
len
(
s
)
>
0
:
for
i
in
range
(
0
,
2
):
# ene = fromH(float(s[6]))
bandEnergies
[
i
][
-
1
].
append
(
fromH
(
float
(
s
[
6
])))
if
int
(
s
[
0
])
==
1
:
kpoint
.
append
([])
...
...
@@ -213,48 +222,21 @@ class GWContext(object):
for
i
in
range
(
0
,
2
):
bandEnergies
[
i
].
pop
()
# print("numBand=",numBand)
# print("numK=",numK)
for
i
in
range
(
1
,
numK
):
# print("i=",i)
# print("dist[i-1]=",dist[i-1])
# print("dist[i]=",dist[i])
if
dist
[
i
]
==
dist
[
i
-
1
]:
# pass
Kindex
.
append
(
i
)
Kindex
.
append
(
numK
)
# del dist[i]
for
i
in
range
(
0
,
len
(
Kindex
)
-
1
):
segmK
.
append
(
dist
[
Kindex
[
i
]:
Kindex
[
i
+
1
]])
for
i
in
range
(
0
,
len
(
segmK
)):
# print("i=",i)
# print("segmK[i]=",segmK[i])
segmLength
.
append
(
len
(
segmK
[
i
]))
# bandEnergiesSegm.append([])
for
i
in
range
(
0
,
2
):
bandEnergiesSegm
.
append
([])
for
j
in
range
(
0
,
numBand
):
bandEnergiesSegm
[
i
].
append
([])
for
k
in
range
(
0
,
len
(
Kindex
)
-
1
):
# print("l=",k)
# print("len(Kindex)=",len(Kindex))
# print("Kindex[l]=",Kindex[k])
# print("bandEnergies[Kindex[k]:Kindex[k+1]]=",bandEnergies[Kindex[k]:Kindex[k+1]])
bandEnergiesSegm
[
i
][
j
].
append
(
bandEnergies
[
i
][
j
][
Kindex
[
k
]:
Kindex
[
k
+
1
]])
# print("i=",i)
# print("Kindex[i]=",Kindex[i])
# del dist[Kindex[i]]
# print("bandEnergies=",bandEnergies)
# print("self.vertexDist=",self.vertexDist)
# print("dist=",dist)
# print("len(dist)=",len(dist))
# print("segmK=",segmK)
# print("segmLength=",segmLength)
# print("bandEnergiesSegm=",bandEnergiesSegm)
# print("Kindex=",Kindex)
for
i
in
range
(
0
,
len
(
Kindex
)
-
1
):
bandGWBE
.
append
([])
for
j
in
range
(
0
,
2
):
...
...
@@ -264,28 +246,21 @@ class GWContext(object):
for
l
in
range
(
0
,
numBand
):
bandGWBE
[
i
][
j
][
-
1
].
append
(
bandEnergiesSegm
[
j
][
l
][
i
][
k
])
# print("bandGWBE=",bandGWBE)
for
i
in
range
(
0
,
len
(
Kindex
)
-
1
):
# print("i=",i)
# print("len(bandGWBE[i])=",len(bandGWBE[i][0]))
bandGWSegmGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_k_band_segment"
)
# print("bandGWBE[i]=",len(bandGWBE[i][0]))
backend
.
addValue
(
"x_exciting_GW_band_energies"
,
bandGWBE
[
i
])
backend
.
closeSection
(
"x_exciting_section_GW_k_band_segment"
,
bandGWSegmGIndex
)
backend
.
closeSection
(
"x_exciting_section_GW_k_band"
,
bandGWGIndex
)
#
backend.closeSection("x_exciting_section_GW_
k_band_segmen
t",bandGW
Segm
GIndex)
backend
.
closeSection
(
"x_exciting_section_GW_
outpu
t"
,
bandGW
Out
GIndex
)
if
os
.
path
.
exists
(
bandBorGWFile
)
and
not
os
.
path
.
exists
(
bandCarbGWFile
):
#
print("QUI???
")
bandGWOutGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_output
"
)
bandGWGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_k_band"
)
# bandGWSegmGIndex = backend.openSection("x_exciting_section_GW_k_band_segment")
fromH
=
unit_conversion
.
convert_unit_function
(
"hartree"
,
"J"
)
# fromH = 1.0
with
open
(
bandBorGWFile
)
as
g
:
bandEnergies
=
[[[]],[[]]]
kappa
=
[[[]],[[]]]
# kpoint = []
dist1
=
[[]]
Kindex
=
[
0
]
segmK
=
[]
...
...
@@ -303,28 +278,12 @@ class GWContext(object):
bandEnergies
[
i
].
append
([])
kappa
[
i
].
append
([])
dist1
.
append
([])
# print("bandEnergies[0]=",bandEnergies[0])
# if not dist1:
# elif s[0] == "#":
# for i in range(0,2):
# bandEnergies[i].append([])
# numBand = int(s[2])
# numK = int(s[3])
elif
len
(
s
)
>
0
:
for
i
in
range
(
0
,
2
):
# ene = fromH(float(s[6]))
bandEnergies
[
i
][
-
1
].
append
(
fromH
(
float
(
s
[
1
])))
kappa
[
i
][
-
1
].
append
(
float
(
s
[
0
]))
# bandEnergies[i][-1].append(fromH(float(s[1])))
# if int(s[0]) == 1:
# if not dist1:
# print("s[0]=",s[0])
# print("dist1=",dist1)
# kpoint.append([])
dist1
[
-
1
].
append
(
float
(
s
[
0
]))
# kpoint[-1].append([float(s[2]),float(s[3]),float(s[4])])
numK
=
len
(
kappa
[
0
][
0
])
# print("numK=",numK)
for
i
in
kappa
[
0
][
0
]:
if
kappa
[
0
][
0
].
count
(
i
)
>
1
:
kappa
[
0
][
0
].
remove
(
i
)
...
...
@@ -333,54 +292,21 @@ class GWContext(object):
for
i
in
range
(
0
,
2
):
bandEnergies
[
i
].
pop
()
numBand
=
len
(
bandEnergies
[
0
])
# numK = len(kappa[0][0])
# print("kappa=",numK)
# print("bandnergies=",numBand)
# vertex = 0
for
i
in
range
(
1
,
numK
+
self
.
vertexNum
-
1
):
# print("i=",i)
# print("dist1[i-1]=",dist1[0][i-1])
# print("dist1[i]=",dist1[0][i])
if
dist1
[
0
][
i
]
==
dist1
[
0
][
i
-
1
]:
# vertex +=1
# print("vertex=",vertex)
# pass
Kindex
.
append
(
i
)
# print("vertex=",vertex)
Kindex
.
append
(
numK
+
self
.
vertexNum
-
1
)
# del dist1[i]
for
i
in
range
(
0
,
len
(
Kindex
)
-
1
):
segmK
.
append
(
dist1
[
0
][
Kindex
[
i
]:
Kindex
[
i
+
1
]])
for
i
in
range
(
0
,
len
(
segmK
)):
# print("i=",i)
# print("segmK[i]=",segmK[i])
# print("len(segmK)=",len(segmK))
segmLength
.
append
(
len
(
segmK
[
i
]))
# bandEnergiesSegm.append([])
for
i
in
range
(
0
,
2
):
bandEnergiesSegm
.
append
([])
for
j
in
range
(
0
,
numBand
):
bandEnergiesSegm
[
i
].
append
([])
for
k
in
range
(
0
,
len
(
Kindex
)
-
1
):
# for k in range (0,len(Kindex)):
# print("l=",k)
# print("len(Kindex)=",len(Kindex))
# print("Kindex[l]=",Kindex[k])
# print("bandEnergies[Kindex[k]:Kindex[k+1]]=",bandEnergies[Kindex[k]:Kindex[k+1]])
bandEnergiesSegm
[
i
][
j
].
append
(
bandEnergies
[
i
][
j
][
Kindex
[
k
]:
Kindex
[
k
+
1
]])
# print("i=",i)
# print("Kindex[i]=",Kindex[i])
# del dist1[Kindex[i]]
# print("bandEnergies=",bandEnergies)
# print("self.vertexDist=",self.vertexDist)
# print("dist1=",dist1)
# print("len(dist1)=",len(dist1))
# print("segmK=",segmK)
# print("segmLength=",segmLength)
# print("bandEnergiesSegm=",bandEnergiesSegm)
# print("Kindex=",Kindex)
for
i
in
range
(
0
,
len
(
Kindex
)
-
1
):
bandGWBE
.
append
([])
for
j
in
range
(
0
,
2
):
...
...
@@ -390,38 +316,24 @@ class GWContext(object):
for
l
in
range
(
0
,
numBand
):
bandGWBE
[
i
][
j
][
-
1
].
append
(
bandEnergiesSegm
[
j
][
l
][
i
][
k
])
# print("bandGWBE=",bandGWBE)
for
i
in
range
(
0
,
len
(
Kindex
)
-
1
):
bandGWSegmGIndex
=
backend
.
openSection
(
"x_exciting_section_GW_k_band_segment"
)
# print("diomerda")
# print("bandGWBE[i]=",len(bandGWBE[i][0]))
backend
.
addValue
(
"x_exciting_GW_band_energies"
,
bandGWBE
[
i
])
backend
.
closeSection
(
"x_exciting_section_GW_k_band_segment"
,
bandGWSegmGIndex
)
backend
.
closeSection
(
"x_exciting_section_GW_k_band"
,
bandGWGIndex
)
#
backend.closeSection("x_exciting_section_GW_
k_band_segmen
t",bandGW
Segm
GIndex)
backend
.
closeSection
(
"x_exciting_section_GW_
outpu
t"
,
bandGW
Out
GIndex
)
def
buildGWMatchers
():
return
SM
(
name
=
'root'
,
weak
=
True
,
startReStr
=
"\*\s*GW input parameters\s*\*"
,
sections
=
[
"x_exciting_section_GW"
,
"x_exciting_section_GW_
m
et
hod
"
],
sections
=
[
"x_exciting_section_GW"
,
"x_exciting_section_GW_
s
et
tings
"
],
subMatchers
=
[
# SM(name = 'GWinput',
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
# startReStr = "\s*GW taskname:\s*"
SM
(
r
"\s*(?P<x_exciting_GW_type>[-a-zA-Z0-9]+)\s*-\s*[-a-zA-Z0-9]+\s*run"
)
#,
# SM(r"\s*(?P<x_exciting_GW_type>[-a-zA-Z0-9]+)\s*-\s*[-a-zA-Z0-9]+\s*run"),
# SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"),
# SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"),
# SM(r"\s*(?P<x_wien2k_smearing_kind>[A-Z]+)\s*\s*(?P<x_wien2k_smearing_width__rydberg>[-+0-9.]+)\s*.*"),
# SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX")
# SM(r"\s*GW taskname\:\s*")
SM
(
r
"\s*Number of empty states \(GW\):\s*(?P<x_exciting_GW_polarizability_empty_states>[0-9]+)\s*"
)
])
def
get_cachingLevelForMetaName
(
metaInfoEnv
,
CachingLvl
):
"""Sets the caching level for the metadata.
...
...
parser/parser-exciting/parser_exciting.py
View file @
a65c9a08
...
...
@@ -6,20 +6,9 @@ from nomadcore.simple_parser import SimpleMatcher as SM, mainFunction
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.caching_backend
import
CachingLevel
from
nomadcore.unit_conversion
import
unit_conversion
import
os
,
sys
,
json
,
exciting_parser_dos
,
exciting_parser_bandstructure
,
exciting_parser_gw
import
os
,
sys
,
json
,
exciting_parser_dos
,
exciting_parser_bandstructure
,
exciting_parser_gw
#, exciting_parser_gw_bor
from
ase
import
Atoms
#def elasticCheck(path):
# print("path=", path)
# pat = path.split("/")
# if pat[-1] == "INFO.OUT":
# print("NO", pat)
# else:
# print("YES", pat)
#
#elasticCheck(self.path)
# continue
class
ExcitingParserContext
(
object
):
def
__init__
(
self
):
...
...
@@ -29,16 +18,6 @@ class ExcitingParserContext(object):
self
.
metaInfoEnv
=
self
.
parser
.
parserBuilder
.
metaInfoEnv
def
startedParsing
(
self
,
path
,
parser
):
# print("path=", path)
# pat = path.split("/")
# print("pat=", pat)
# if pat[-1] == "INFO.OUT":
# pass
# else:
# pass
# self.initialize_values()
# self.metaInfoEnv = self.parser.parserBuilder.metaInfoEnv
# self.initialize_values()
self
.
parser
=
parser
self
.
initialize_values
()
self
.
atom_pos
=
[]
...
...
@@ -56,20 +35,21 @@ class ExcitingParserContext(object):
def
onOpen_section_method
(
self
,
backend
,
gIndex
,
section
):
self
.
secMethodIndex
=
gIndex
# gwFile = os.path.join(dirPath,None)
mainFile
=
self
.
parser
.
fIn
.
fIn
.
name
dirPath
=
os
.
path
.
dirname
(
self
.
parser
.
fIn
.
name
)
# gwFile = os.path.join(dirPath,"GW_INFO.OUT")
# gwFile = os.path.join(dirPath, "GW_INFO.OUT")
###
if
os
.
access
(
os
.
path
.
join
(
dirPath
,
"GW_INFO.OUT"
),
os
.
F_OK
):
gwFile
=
os
.
path
.
join
(
dirPath
,
"GW_INFO.OUT"
)
elif
os
.
access
(
os
.
path
.
join
(
dirPath
,
"GWINFO.OUT"
),
os
.
F_OK
):
gwFile
=
os
.
path
.
join
(
dirPath
,
"GWINFO.OUT"
)
else
:
gwFile
=
os
.
path
.
join
(
dirPath
,
"GW_INFO.OUT"
)
###
if
os
.
path
.
exists
(
gwFile
):
gw_File
=
os
.
path
.
join
(
dirPath
,
"GW_INFO.OUT"
)
gwFile
=
os
.
path
.
join
(
dirPath
,
"GWINFO.OUT"
)
if
os
.
path
.
exists
(
gw_File
):
subSuperContext
=
exciting_parser_gw
.
GWContext
()
subParser
=
AncillaryParser
(
fileDescription
=
exciting_parser_gw
.
buildGWMatchers
(),
parser
=
self
.
parser
,
cachingLevelForMetaName
=
exciting_parser_gw
.
get_cachingLevelForMetaName
(
self
.
metaInfoEnv
,
CachingLevel
.
PreOpenedIgnore
),
superContext
=
subSuperContext
)
with
open
(
gw_File
)
as
fIn
:
subParser
.
parseFile
(
fIn
)
elif
os
.
path
.
exists
(
gwFile
):
subSuperContext
=
exciting_parser_gw
.
GWContext
()
subParser
=
AncillaryParser
(
fileDescription
=
exciting_parser_gw
.
buildGWMatchers
(),
...
...
@@ -87,7 +67,6 @@ class ExcitingParserContext(object):
[
latticeX
[
1
],
latticeY
[
1
],
latticeZ
[
1
]],
[
latticeX
[
2
],
latticeY
[
2
],
latticeZ
[
2
]]]
self
.
sim_cell
=
cell
# print("self.sim_cell=",self.sim_cell)
backend
.
addValue
(
"simulation_cell"
,
cell
)
def
onClose_x_exciting_section_reciprocal_lattice_vectors
(
self
,
backend
,
gIndex
,
section
):
...
...
@@ -126,14 +105,10 @@ class ExcitingParserContext(object):
dosFile
=
os
.
path
.
join
(
dirPath
,
"dos.xml"
)
bandFile
=
os
.
path
.
join
(
dirPath
,
"bandstructure.xml"
)
fermiSurfFile
=
os
.
path
.
join
(
dirPath
,
"FERMISURF.bxsf"
)
# inputFile = os.path.join(dirPath, "input.xml")
gw_File
=
os
.
path
.
join
(
dirPath
,
"GW_INFO.OUT"
)
gwFile
=
os
.
path
.
join
(
dirPath
,
"GWINFO.OUT"
)
eigvalFile
=
os
.
path
.
join
(
dirPath
,
"EIGVAL.OUT"
)
# if os.path.exists(inputFile):
# with open(inputFile) as f:
# exciting_parser_input.parseInput(f, backend)
if
os
.
path
.
exists
(
dosFile
):
with
open
(
dosFile
)
as
f
:
exciting_parser_dos
.
parseDos
(
f
,
backend
,
self
.
spinTreat
)
...
...
@@ -141,9 +116,7 @@ class ExcitingParserContext(object):
with
open
(
bandFile
)
as
g
:
exciting_parser_bandstructure
.
parseBand
(
g
,
backend
,
self
.
spinTreat
)
if
os
.
path
.
exists
(
gwFile
)
or
os
.
path
.
exists
(
gw_File
):
# with open(gwFile) as f:
backend
.
addValue
(
'electronic_structure_method'
,
"G0W0"
)
# exciting_parser_gw.parseGW(f, backend, self.spinTreat)
else
:
backend
.
addValue
(
'electronic_structure_method'
,
"DFT"
)
if
os
.
path
.
exists
(
eigvalFile
):
...
...
@@ -184,8 +157,6 @@ class ExcitingParserContext(object):
eigvalOccSpin
[
0
].
append
(
eigvalOcc
[
i
][
0
:
nstsv
])
eigvalValSpin
[
1
].
append
(
eigvalVal
[
i
][
0
:
nstsv
])
eigvalOccSpin
[
1
].
append
(
eigvalOcc
[
i
][
0
:
nstsv
])
# backend.addArrayValues("eigenvalues_values", np.asarray(eigvalValSpin))
# backend.addArrayValues("eigenvalues_occupation", np.asarray(eigvalOccSpin))
backend
.
addValue
(
"eigenvalues_values"
,
eigvalValSpin
)
backend
.
addValue
(
"eigenvalues_occupation"
,
eigvalOccSpin
)
else
:
...
...
@@ -197,9 +168,6 @@ class ExcitingParserContext(object):
backend
.
addValue
(
"eigenvalues_values"
,
eigvalValSpin
)
backend
.
addValue
(
"eigenvalues_occupation"
,
eigvalOccSpin
)
backend
.
addValue
(
"eigenvalues_kpoints"
,
eigvalKpoint
)
# backend.addArrayValues("eigenvalues_values", np.asarray(eigvalValSpin))
# backend.addArrayValues("eigenvalues_occupation", np.asarray(eigvalOccSpin))
# backend.addArrayValues("eigenvalues_kpoints", np.asarray(eigvalKpoint))
backend
.
closeSection
(
"section_eigenvalues"
,
eigvalGIndex
)
##########################Parsing Fermi surface##################
...
...
@@ -272,28 +240,13 @@ class ExcitingParserContext(object):
self
.
secSystemDescriptionIndex
=
gIndex
# atoms = Atoms()
if
self
.
atom_pos
and
self
.
cell_format
[
0
]
==
'cartesian'
:
backend
.
addArrayValues
(
'atom_positions'
,
np
.
asarray
(
self
.
atom_pos
))
# print("self.atom_pos=",np.asarray(self.atom_pos))
elif
self
.
atom_pos
and
self
.
cell_format
[
0
]
==
'lattice'
:
# i = 1
atoms
=
Atoms
(
self
.
atom_labels
,
self
.
atom_pos
,
cell
=
[(
1
,
0
,
0
),(
0
,
1
,
0
),(
0
,
0
,
1
)])
atoms
.
set_cell
(
self
.
sim_cell
,
scale_atoms
=
True
)
# print("position_lattice",atoms.get_positions()[1])
# while i < len(self.atom_labels):
#
# atoms = Atoms(self.atom_labels, self.atom_pos,self.sim_cell)
# print("attomi=",atoms)
self
.
atom_pos
=
atoms
.
get_positions
()
backend
.
addArrayValues
(
'atom_positions'
,
np
.
asarray
(
self
.
atom_pos
))
# print("self.atom_pos_lattice=",np.asarray(self.atom_pos))
# i = 0
# while i < len(self.atom_labels):
# print("self.atom_pos=",np.asarray(self.atom_pos))
# pass
# s##sarrayelf.atom_pos = []
if
self
.
atom_labels
is
not
None
:
backend
.
addArrayValues
(
'atom_labels'
,
np
.
asarray
(
self
.
atom_labels
))
self
.
atom_labels
=
[]
...
...
@@ -303,7 +256,6 @@ class ExcitingParserContext(object):
smearing_internal_map
=
{
"Gaussian"
:
[
'gaussian'
],
"Methfessel-Paxton"
:
[
'methfessel-paxton'
],
# "Methfessel-Paxton 2": ['methfessel-paxton'],
"Fermi-Dirac"
:
[
'fermi'
],
"Extended"
:
[
'tetrahedra'
]
}
...
...
@@ -315,49 +267,17 @@ class ExcitingParserContext(object):
fromB
=
unit_conversion
.
convert_unit_function
(
"bohr"
,
"m"
)
formt
=
section
[
'x_exciting_atom_position_format'
]
self
.
cell_format
=
formt
# print("formt=",formt)
pos
=
[
section
[
'x_exciting_geometry_atom_positions_'
+
i
]
for
i
in
[
'x'
,
'y'
,
'z'
]]
# print("ddd",pos)
pl
=
[
len
(
comp
)
for
comp
in
pos
]
# print("pelle=",pl)
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
):
if
formt
[
0
]
==
'cartesian'
:
# print("cartesian?")
self
.
atom_pos
.
append
([
fromB
(
pos
[
0
][
i
]),
fromB
(
pos
[
1
][
i
]),
fromB
(
pos
[
2
][
i
])])
# print("self.atom_pos=",self.atom_pos)
else
:
# atoms = ase.Atoms(self.atom_labels, self.atom_pos,self.sim_cell)
# print("atoms.get_positions()=",atoms.get_positions())
# print("self.sim_cell=",self.sim_cell)
# print("lattice")
self
.
atom_pos
.
append
([
pos
[
0
][
i
],
pos
[
1
][
i
],
pos
[
2
][
i
]])
# if formt[0] == 'lattice':
#
self
.
atom_labels
=
self
.
atom_labels
+
(
section
[
'x_exciting_geometry_atom_labels'
]
*
natom
)
# if formt[0] == 'lattice':
# atoms = ase.Atoms(self.atom_labels, self.atom_pos,self.sim_cell)
# print("atoms.get_positions()=",atoms.get_positions())
# print("self.atom_labels=", self.atom_labels)
# def onClose_section_run(self, backend, gIndex, section):
# self.secGWIndex = gIndex
#
# mainFile = self.parser.fIn.fIn.name
# dirPath = os.path.dirname(self.parser.fIn.name)
# gwFile = os.path.join(dirPath, "GW_INFO.OUT")
# if os.path.exists(gwFile):
# subSuperContext = exciting_parser_gw.GWContext()
# subParser = AncillaryParser(
# fileDescription = exciting_parser_gw.buildGWMatchers(),
# parser = self.parser,
# cachingLevelForMetaName = exciting_parser_gw.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
# superContext = subSuperContext)
# with open(gwFile) as fIn:
# subParser.parseFile(fIn)
def
onClose_section_method
(
self
,
backend
,
gIndex
,
value
):
if
value
[
"electronic_structure_method"
][
-
1
]
==
"G0W0"
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment