Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-octopus
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
nomad-lab
parser-octopus
Commits
e358af6a
Commit
e358af6a
authored
Aug 5, 2020
by
temok-mx
Browse files
Options
Downloads
Patches
Plain Diff
Fermi energy: added capability to parse from static/info
parent
6ce09bd7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
octopusparser/aseoct.py
+27
-41
27 additions, 41 deletions
octopusparser/aseoct.py
octopusparser/parser_octopus.py
+6
-3
6 additions, 3 deletions
octopusparser/parser_octopus.py
with
33 additions
and
44 deletions
octopusparser/aseoct.py
+
27
−
41
View file @
e358af6a
...
@@ -310,8 +310,14 @@ def read_static_info_kpoints(fd):
...
@@ -310,8 +310,14 @@ def read_static_info_kpoints(fd):
return
dict
(
ibz_k_points
=
ibz_k_points
,
k_point_weights
=
k_point_weights
)
return
dict
(
ibz_k_points
=
ibz_k_points
,
k_point_weights
=
k_point_weights
)
def
read_static_info_eigenvalues
(
fd
,
energy_unit
):
#def read_static_info_eigenvalues(fd, energy_unit):
#import os # tmk
def
read_static_info_eigenvalues_efermi
(
fd
,
energy_unit
):
'''
Parse eigenvalues and Fermi Energy from `static/info`
fd: file descriptor
energy_unit: string
Returns: dictionary
'''
values_sknx
=
{}
values_sknx
=
{}
nbands
=
0
nbands
=
0
...
@@ -321,14 +327,11 @@ def read_static_info_eigenvalues(fd, energy_unit):
...
@@ -321,14 +327,11 @@ def read_static_info_eigenvalues(fd, energy_unit):
if
line
.
startswith
(
'
#
'
):
if
line
.
startswith
(
'
#
'
):
continue
continue
if
line
.
startswith
(
'
Fermi
'
):
# tmk
if
line
.
startswith
(
'
Fermi
'
):
# tmk
pass
# print(line)
# print(line, '##') # OK!
tokens
=
line
.
split
()
unit
=
{
'
eV
'
:
eV
,
'
H
'
:
Hartree
}[
tokens
[
-
1
]]
eFermi
=
float
(
tokens
[
-
2
])
*
unit
if
not
line
[:
1
].
isdigit
():
if
not
line
[:
1
].
isdigit
():
# print('hithere', line)
# I SHOULD JUMP BACK ONE LINE RIGTH HERE
# fd.seek(-len(line))
# I TRIED THIS:
# fd.seek(fd.tell() - len(line))
# -> "OSError: telling position disabled by next() call"
break
break
tokens
=
line
.
split
()
tokens
=
line
.
split
()
...
@@ -351,11 +354,13 @@ def read_static_info_eigenvalues(fd, energy_unit):
...
@@ -351,11 +354,13 @@ def read_static_info_eigenvalues(fd, energy_unit):
eps_skn
=
eps_skn
.
transpose
(
1
,
0
,
2
).
copy
()
eps_skn
=
eps_skn
.
transpose
(
1
,
0
,
2
).
copy
()
occ_skn
=
occ_skn
.
transpose
(
1
,
0
,
2
).
copy
()
occ_skn
=
occ_skn
.
transpose
(
1
,
0
,
2
).
copy
()
assert
eps_skn
.
flags
.
contiguous
assert
eps_skn
.
flags
.
contiguous
#print('save to dictionary: ', nspins, nkpts, nbands, eps_skn, occ_skn, eFermi)
return
dict
(
nspins
=
nspins
,
return
dict
(
nspins
=
nspins
,
nkpts
=
nkpts
,
nkpts
=
nkpts
,
nbands
=
nbands
,
nbands
=
nbands
,
eigenvalues
=
eps_skn
,
eigenvalues
=
eps_skn
,
occupations
=
occ_skn
)
occupations
=
occ_skn
,
efermi
=
eFermi
)
def
read_static_info_energy
(
fd
,
energy_unit
):
def
read_static_info_energy
(
fd
,
energy_unit
):
...
@@ -367,34 +372,22 @@ def read_static_info_energy(fd, energy_unit):
...
@@ -367,34 +372,22 @@ def read_static_info_energy(fd, energy_unit):
def
read_static_info
(
fd
):
def
read_static_info
(
fd
):
# fd: file descriptor
results
=
{}
results
=
{}
# print('?????????????????????', type(fd)) # tmk
# print('read_static_info()@aseoct.py') # tmk
def
get_energy_unit
(
line
):
# Convert "title [unit]": ---> unit
def
get_energy_unit
(
line
):
# Convert "title [unit]": ---> unit
return
{
'
[eV]
'
:
eV
,
'
[H]
'
:
Hartree
}[
line
.
split
()[
1
].
rstrip
(
'
:
'
)]
return
{
'
[eV]
'
:
eV
,
'
[H]
'
:
Hartree
}[
line
.
split
()[
1
].
rstrip
(
'
:
'
)]
for
line
in
fd
:
for
line
in
fd
:
# print('line::', line.strip())
if
line
.
startswith
(
'
Fermi
'
):
#print('EUREKA:', line)
if
line
.
strip
(
'
*
'
).
strip
().
startswith
(
'
Brillouin zone
'
):
if
line
.
strip
(
'
*
'
).
strip
().
startswith
(
'
Brillouin zone
'
):
#print('X1', line)
results
.
update
(
read_static_info_kpoints
(
fd
))
results
.
update
(
read_static_info_kpoints
(
fd
))
elif
line
.
startswith
(
'
Eigenvalues [
'
):
elif
line
.
startswith
(
'
Eigenvalues [
'
):
#print('X2', line)
unit
=
get_energy_unit
(
line
)
unit
=
get_energy_unit
(
line
)
results
.
update
(
read_static_info_eigenvalues
(
fd
,
unit
))
results
.
update
(
read_static_info_eigenvalues_efermi
(
fd
,
unit
))
fd
.
seek
(
0
,
0
)
# TMK:
## print('I found:', results['efermi'])
elif
line
.
startswith
(
'
Fermi
'
):
#print('X2b1') # TMK:
fd
.
seek
(
-
1
,
1
)
# TMK:
#print('X2b2', line)
elif
line
.
startswith
(
'
Energy [
'
):
elif
line
.
startswith
(
'
Energy [
'
):
#print('\nX3', line)
unit
=
get_energy_unit
(
line
)
unit
=
get_energy_unit
(
line
)
results
.
update
(
read_static_info_energy
(
fd
,
unit
))
results
.
update
(
read_static_info_energy
(
fd
,
unit
))
elif
line
.
startswith
(
'
Total Magnetic Moment
'
):
elif
line
.
startswith
(
'
Total Magnetic Moment
'
):
#print('X4', line)
if
0
:
if
0
:
line
=
next
(
fd
)
line
=
next
(
fd
)
values
=
line
.
split
()
values
=
line
.
split
()
...
@@ -415,12 +408,10 @@ def read_static_info(fd):
...
@@ -415,12 +408,10 @@ def read_static_info(fd):
results
[
'
magmoms
'
]
=
np
.
array
(
mag_moment
)
results
[
'
magmoms
'
]
=
np
.
array
(
mag_moment
)
elif
line
.
startswith
(
'
Dipole
'
):
elif
line
.
startswith
(
'
Dipole
'
):
#print('X5', line)
assert
line
.
split
()[
-
1
]
==
'
[Debye]
'
assert
line
.
split
()[
-
1
]
==
'
[Debye]
'
dipole
=
[
float
(
next
(
fd
).
split
()[
-
1
])
for
i
in
range
(
3
)]
dipole
=
[
float
(
next
(
fd
).
split
()[
-
1
])
for
i
in
range
(
3
)]
results
[
'
dipole
'
]
=
np
.
array
(
dipole
)
*
Debye
results
[
'
dipole
'
]
=
np
.
array
(
dipole
)
*
Debye
elif
line
.
startswith
(
'
Forces
'
):
elif
line
.
startswith
(
'
Forces
'
):
#print('X6', line)
forceunitspec
=
line
.
split
()[
-
1
]
forceunitspec
=
line
.
split
()[
-
1
]
forceunit
=
{
'
[eV/A]
'
:
eV
/
Angstrom
,
forceunit
=
{
'
[eV/A]
'
:
eV
/
Angstrom
,
'
[H/b]
'
:
Hartree
/
Bohr
}[
forceunitspec
]
'
[H/b]
'
:
Hartree
/
Bohr
}[
forceunitspec
]
...
@@ -434,23 +425,17 @@ def read_static_info(fd):
...
@@ -434,23 +425,17 @@ def read_static_info(fd):
forces
.
append
([
float
(
f
)
for
f
in
tokens
])
forces
.
append
([
float
(
f
)
for
f
in
tokens
])
results
[
'
forces
'
]
=
np
.
array
(
forces
)
*
forceunit
results
[
'
forces
'
]
=
np
.
array
(
forces
)
*
forceunit
elif
line
.
startswith
(
'
Fermi
'
):
elif
line
.
startswith
(
'
Fermi
'
):
#print('X7', line)
# this check is 'one line too late'
# hence we capture Fermi energy from
# `read_static_info_eigenvalues()`
# print('Point 1', line)
tokens
=
line
.
split
()
tokens
=
line
.
split
()
unit
=
{
'
eV
'
:
eV
,
'
H
'
:
Hartree
}[
tokens
[
-
1
]]
unit
=
{
'
eV
'
:
eV
,
'
H
'
:
Hartree
}[
tokens
[
-
1
]]
eFermi
=
float
(
tokens
[
-
2
])
*
unit
eFermi
=
float
(
tokens
[
-
2
])
*
unit
results
[
'
efermi
'
]
=
eFermi
results
[
'
efermi
'
]
=
eFermi
# print("helloo, eFermi:", eFermi, unit)
# print('####1', line)
# print('####1', line)
# TMK: MARKUS:the last `elif` should be simply `if`
# otherwise when the head `if` is True
# then all other `elif`s wont be evaluated
if
line
.
startswith
(
'
Fermi
'
):
tokens
=
line
.
split
()
unit
=
{
'
eV
'
:
eV
,
'
H
'
:
Hartree
}[
tokens
[
-
1
]]
eFermi
=
float
(
tokens
[
-
2
])
*
unit
results
[
'
efermi
'
]
=
eFermi
print
(
'
####2
'
,
line
)
if
'
ibz_k_points
'
not
in
results
:
if
'
ibz_k_points
'
not
in
results
:
results
[
'
ibz_k_points
'
]
=
np
.
zeros
((
1
,
3
))
results
[
'
ibz_k_points
'
]
=
np
.
zeros
((
1
,
3
))
...
@@ -467,8 +452,9 @@ def read_static_info(fd):
...
@@ -467,8 +452,9 @@ def read_static_info(fd):
break
break
eFermi
=
all_energies
[
arg
]
eFermi
=
all_energies
[
arg
]
results
[
'
efermi
'
]
=
eFermi
results
[
'
efermi
'
]
=
eFermi
print
(
'
eFermi NOW
'
,
eFermi
)
# this produces bad estimate
# print('eFermi estimate', eFermi) # this produces bad estimate
# ----
#print('finish', results['efermi'])
return
results
return
results
...
...
...
...
This diff is collapsed.
Click to expand it.
octopusparser/parser_octopus.py
+
6
−
3
View file @
e358af6a
...
@@ -110,13 +110,13 @@ def parse_infofile(meta_info_env, pew, fname):
...
@@ -110,13 +110,13 @@ def parse_infofile(meta_info_env, pew, fname):
pew
.
addValue
(
names
[
tokens
[
0
]],
pew
.
addValue
(
names
[
tokens
[
0
]],
convert_unit
(
float
(
tokens
[
2
]),
nomadunit
))
convert_unit
(
float
(
tokens
[
2
]),
nomadunit
))
if
tokens
[
0
]
==
'
Fermi energy
'
:
if
tokens
[
0
]
==
'
Fermi energy
'
:
pass
# print(tokens)
# print(tokens)
# print('#', line)
# print('#', line)
def
parse_logfile
(
meta_info_env
,
pew
,
fname
):
def
parse_logfile
(
meta_info_env
,
pew
,
fname
):
'''
Parse the mainfile
'''
maxlines
=
100
maxlines
=
100
with
open
(
fname
)
as
fd
:
with
open
(
fname
)
as
fd
:
for
i
,
line
in
enumerate
(
fd
):
for
i
,
line
in
enumerate
(
fd
):
...
@@ -131,6 +131,9 @@ def parse_logfile(meta_info_env, pew, fname):
...
@@ -131,6 +131,9 @@ def parse_logfile(meta_info_env, pew, fname):
def
parse_gridinfo
(
metaInfoEnv
,
pew
,
fname
):
def
parse_gridinfo
(
metaInfoEnv
,
pew
,
fname
):
'''
fname: main filename
'''
results
=
{}
results
=
{}
with
open
(
fname
)
as
fd
:
with
open
(
fname
)
as
fd
:
...
@@ -541,7 +544,7 @@ def parse_without_class(fname, backend, parser_info):
...
@@ -541,7 +544,7 @@ def parse_without_class(fname, backend, parser_info):
pew
.
addValue
(
'
single_configuration_calculation_to_system_ref
'
,
pew
.
addValue
(
'
single_configuration_calculation_to_system_ref
'
,
system_gid
)
system_gid
)
# print('Parse info file %s' % fname) #, file=fd)
# print('Parse info file %s' % fname) #, file=fd)
logging
.
debug
(
'
Parse info file %s
'
%
fname
)
logging
.
debug
(
'
Parse info file %s
'
%
fname
)
# mainfile
parse_infofile
(
metaInfoEnv
,
pew
,
fname
)
parse_infofile
(
metaInfoEnv
,
pew
,
fname
)
with
open_section
(
'
section_method
'
)
as
method_gid
:
with
open_section
(
'
section_method
'
)
as
method_gid
:
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
sign in
to comment