Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-gpaw
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-gpaw
Commits
78cebe38
Commit
78cebe38
authored
9 years ago
by
Mikkel Strange
Browse files
Options
Downloads
Patches
Plain Diff
updated parser to handle different basis sets
parent
de4fced5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
parser/parser-gpaw/parser.py
+37
-13
37 additions, 13 deletions
parser/parser-gpaw/parser.py
parser/parser-gpaw/tar.py
+3
-3
3 additions, 3 deletions
parser/parser-gpaw/tar.py
with
40 additions
and
16 deletions
parser/parser-gpaw/parser.py
+
37
−
13
View file @
78cebe38
import
os
from
contextlib
import
contextmanager
import
numpy
as
np
#from nomadcore.unit_conversion.unit_conversion import convert_unit as cu
from
ase.data
import
chemical_symbols
from
nomadcore.unit_conversion.unit_conversion
import
convert_unit
as
cu
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
tar
import
Reader
...
...
@@ -14,13 +15,16 @@ def open_section(p, name):
p
.
closeSection
(
name
,
gid
)
def
c
u
(
value
,
unit
=
None
):
def
c
(
value
,
unit
=
None
):
"""
Dummy function for unit conversion
"""
return
value
return
cu
(
value
,
unit
)
parser_info
=
{
"
name
"
:
"
parser_gpaw
"
,
"
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/gpaw.nomadmetainfo.json
"
))
path
=
'
../../../../nomad-meta-info/meta_info/nomad_meta_info/
'
+
\
'
gpaw.nomadmetainfo.json
'
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
path
))
metaInfoEnv
,
warns
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
...
...
@@ -28,33 +32,53 @@ metaInfoEnv, warns = loadJsonFile(filePath=metaInfoPath,
uri
=
None
)
# TODO: convert to SI units
def
parse
(
filename
):
p
=
JsonParseEventsWriterBackend
(
metaInfoEnv
)
o
=
open_section
r
=
Reader
(
filename
)
p
.
startedParsingSession
(
filename
,
parser_info
)
with
o
(
p
,
'
section_run
'
):
p
.
addValue
(
'
program_name
'
,
'
GPAW
'
)
if
r
.
Mode
==
'
pw
'
:
with
o
(
p
,
'
section_basis_set_cell_associated
'
):
p
.
addValue
(
'
basis_set_cell_associated_name
'
,
'
PW_%.1f_Ry
'
%
(
r
.
PlaneWaveCutoff
*
2.0
))
# in Ry
p
.
addRealValue
(
'
basis_set_plane_wave_cutoff
'
,
c
(
r
.
PlaneWaveCutoff
,
'
hartree
'
))
elif
r
.
Mode
==
'
fd
'
:
with
o
(
p
,
'
section_basis_set_cell_associated
'
):
h1
=
np
.
linalg
.
norm
(
r
.
UnitCell
[
0
])
/
r
.
dims
[
'
ngptsx
'
]
h2
=
np
.
linalg
.
norm
(
r
.
UnitCell
[
1
])
/
r
.
dims
[
'
ngptsy
'
]
h3
=
np
.
linalg
.
norm
(
r
.
UnitCell
[
2
])
/
r
.
dims
[
'
ngptsz
'
]
h
=
(
h1
+
h2
+
h3
)
/
3.0
p
.
addValue
(
'
basis_set_cell_associated_name
'
,
'
GR_%.1f
'
%
(
c
(
h
,
'
bohr
'
)
*
1.0E15
))
# in fm
elif
r
.
Mode
==
'
lcao
'
:
pass
with
o
(
p
,
'
section_system_describtion
'
):
p
.
addArrayValues
(
'
simulation_cell
'
,
r
.
UnitCell
)
p
.
addArrayValues
(
'
atom_label
'
,
r
.
CartesianPositions
)
p
.
addArrayValues
(
'
simulation_cell
'
,
c
(
r
.
UnitCell
,
'
bohr
'
))
symbols
=
np
.
array
([
chemical_symbols
[
z
]
for
z
in
r
.
AtomicNumbers
])
p
.
addArrayValues
(
'
atom_label
'
,
symbols
)
p
.
addArrayValues
(
'
atom_position
'
,
c
(
r
.
CartesianPositions
,
'
bohr
'
))
p
.
addArrayValues
(
'
configuration_periodic_dimensions
'
,
np
.
array
(
r
.
BoundaryConditions
,
bool
))
with
o
(
p
,
'
section_single_configuration_calculation
'
):
p
.
addRealValue
(
'
energy_total
'
,
r
.
Epot
)
p
.
addRealValue
(
'
energy_XC
'
,
r
.
Exc
)
p
.
addRealValue
(
'
electronic_kinetic_energy
'
,
r
.
Ekin
)
p
.
addRealValue
(
'
energy_total
'
,
c
(
r
.
Epot
,
'
hartree
'
)
)
p
.
addRealValue
(
'
energy_XC
'
,
c
(
r
.
Exc
,
'
hartree
'
)
)
p
.
addRealValue
(
'
electronic_kinetic_energy
'
,
c
(
r
.
Ekin
,
'
hartree
'
)
)
if
'
CartesianForces
'
in
r
:
p
.
addArrayValues
(
'
atom_forces_free
'
,
r
.
CartesianForces
)
p
.
addArrayValues
(
'
atom_forces_free
'
,
c
(
r
.
CartesianForces
,
'
bohr/hartree
'
))
with
o
(
p
,
'
section_method
'
):
p
.
addValue
(
'
XC_functional
'
,
r
.
XCFunctional
)
with
o
(
p
,
'
section_eigenvalues_group
'
):
for
eps_kn
,
occ_kn
in
zip
(
r
.
Eigenvalues
,
r
.
OccupationNumbers
):
with
o
(
p
,
'
section_eigenvalues
'
):
p
.
addArrayValues
(
'
eigenvalues_eigenvalues
'
,
eps_kn
)
p
.
addArrayValues
(
'
eigenvalues_eigenvalues
'
,
c
(
eps_kn
,
'
hartree
'
))
p
.
addArrayValues
(
'
eigenvalues_occupation
'
,
occ_kn
)
p
.
addArrayValues
(
'
eigenvalues_kpoints
'
,
r
.
IBZKPoints
)
p
.
finishedParsingSession
(
"
ParseSuccess
"
,
None
)
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
parser/parser-gpaw/tar.py
+
3
−
3
View file @
78cebe38
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
register
or
sign in
to comment