Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
parser-atk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nomad-lab
parser-atk
Commits
dc09cfb3
Commit
dc09cfb3
authored
Sep 18, 2016
by
Mikkel Strange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small changes
parent
ce3be585
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
35 deletions
+40
-35
parser/parser-atk/atkio2.py
parser/parser-atk/atkio2.py
+38
-33
parser/parser-atk/parser_configurations.py
parser/parser-atk/parser_configurations.py
+2
-2
No files found.
parser/parser-atk/atkio2.py
View file @
dc09cfb3
...
@@ -2,7 +2,7 @@ from copy import copy
...
@@ -2,7 +2,7 @@ from copy import copy
from
scipy.io.netcdf
import
netcdf_file
from
scipy.io.netcdf
import
netcdf_file
from
parser_configurations
import
parse_configuration
as
p_conf
from
parser_configurations
import
parse_configuration
as
p_conf
from
parser_calculator
import
parse_calculator
as
p_calc
from
parser_calculator
import
parse_calculator
as
p_calc
import
re
class
X
:
class
X
:
def
__init__
(
self
,
name
=
None
):
def
__init__
(
self
,
name
=
None
):
...
@@ -20,19 +20,28 @@ class Reader:
...
@@ -20,19 +20,28 @@ class Reader:
self
.
CommonConcepts
=
X
(
'CommonConcepts'
)
self
.
CommonConcepts
=
X
(
'CommonConcepts'
)
self
.
CommonConcepts
.
Configurations
=
X
(
'Configurations'
)
self
.
CommonConcepts
.
Configurations
=
X
(
'Configurations'
)
if
1
:
gIDs
=
[]
gIDs
=
[]
for
k
in
self
.
f
.
dimensions
.
keys
():
for
k
in
self
.
f
.
dimensions
.
keys
():
if
'_gID'
not
in
k
:
if
'_gID'
not
in
k
:
continue
continue
i
=
k
.
index
(
'_gID'
)
i
=
k
.
index
(
'_gID'
)
gID
=
int
(
k
[
i
+
4
:
i
+
7
])
gID
=
int
(
k
[
i
+
4
:
i
+
7
])
if
gID
not
in
gIDs
:
if
gID
not
in
gIDs
:
gIDs
.
append
(
gID
)
gIDs
.
append
(
gID
)
self
.
gIDs
=
gIDs
self
.
gIDs
=
gIDs
pm
=
re
.
compile
(
'MoleculeConfiguration(?P<gid>_gID[0-9][0-9][0-9])$'
)
pb
=
re
.
compile
(
'BulkConfiguration(?P<gid>_gID[0-9][0-9][0-9])$'
)
for
key
in
self
.
f
.
variables
.
keys
():
s
=
re
.
search
(
pm
,
key
)
if
s
is
not
None
:
self
.
conf_gID
=
s
.
group
(
'gid'
)
break
s
=
re
.
search
(
pb
,
key
)
if
s
is
not
None
:
self
.
conf_gID
=
s
.
group
(
'gid'
)
break
self
.
conf_gID
=
'_gID000'
self
.
atk_version
=
self
.
f
.
version
[
4
:].
decode
(
'utf-8'
)
self
.
atk_version
=
self
.
f
.
version
[
4
:].
decode
(
'utf-8'
)
self
.
finger_prints
=
[
x
.
split
(
':'
)
for
x
in
self
.
finger_prints
=
[
x
.
split
(
':'
)
for
x
in
self
.
f
.
fingerprint_table
.
\
self
.
f
.
fingerprint_table
.
\
...
@@ -58,17 +67,7 @@ class Reader:
...
@@ -58,17 +67,7 @@ class Reader:
self
.
wave_functions
=
X
(
'wave_functions'
)
self
.
wave_functions
=
X
(
'wave_functions'
)
def
extract_calculator
(
self
):
def
extract_calculator
(
self
):
#p_calc(self)
self
.
calculator
=
p_calc
(
self
.
f
,
self
.
conf_name
)
# dummy until p_calc stops crashing!
name
=
self
.
CommonConcepts
.
Configurations
.
name
+
self
.
conf_gID
self
.
calculator
=
p_calc
(
self
.
f
,
name
)
# self.calculator = X('calculator')
# self.calculator.basis = 'dzp'
# self.calculator.method = 'DFT'
# self.calculator.xc = 'LDA'
# self.calculator.charge = 0
# self.calculator.temp = 300.0 # icp
# self.calculator.dens_tolerance = 0.0001 # icp
def
extract_bandstructure
(
self
):
def
extract_bandstructure
(
self
):
self
.
wave_functions
=
X
(
'wave_functions'
)
self
.
wave_functions
=
X
(
'wave_functions'
)
...
@@ -115,15 +114,21 @@ class Reader:
...
@@ -115,15 +114,21 @@ class Reader:
ham
.
e_tot
=
ham
.
e_kin
+
ham
.
e_xc
+
ham
.
e_hartree
+
ham
.
e_S
ham
.
e_tot
=
ham
.
e_kin
+
ham
.
e_xc
+
ham
.
e_hartree
+
ham
.
e_S
def
extract_common_concepts
(
self
):
def
extract_common_concepts
(
self
):
if
'BulkConfiguration_gID000_dimension'
in
self
.
f
.
dimensions
.
keys
():
pm
=
re
.
compile
(
'MoleculeConfiguration(?P<gid>_gID[0-9][0-9][0-9])$'
)
self
.
CommonConcepts
.
Configurations
=
X
(
'BulkConfiguration'
)
pb
=
re
.
compile
(
'BulkConfiguration(?P<gid>_gID[0-9][0-9][0-9])$'
)
elif
'MoleculeConfiguration_gID000_dimension'
in
\
for
key
in
self
.
f
.
variables
.
keys
():
self
.
f
.
dimensions
.
keys
():
s
=
re
.
search
(
pm
,
key
)
self
.
CommonConcepts
.
Configurations
=
X
(
'MoleculeConfiguration'
)
if
s
is
not
None
:
else
:
self
.
conf_gID
=
s
.
group
(
'gid'
)
assert
0
,
'Not a Bulk or Molecule configurations found!'
self
.
conf_name
=
s
.
group
()
break
self
.
atoms
=
p_conf
(
self
.
f
,
self
.
CommonConcepts
.
Configurations
.
name
)
s
=
re
.
search
(
pb
,
key
)
if
s
is
not
None
:
self
.
conf_gID
=
s
.
group
(
'gid'
)
self
.
conf_name
=
s
.
group
()
break
print
(
self
.
conf_name
)
self
.
atoms
=
p_conf
(
self
.
f
,
self
.
conf_name
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
sys
import
sys
...
...
parser/parser-atk/parser_configurations.py
View file @
dc09cfb3
...
@@ -47,8 +47,8 @@ class BulkConfiguration:
...
@@ -47,8 +47,8 @@ class BulkConfiguration:
self
.
atoms
=
atoms
self
.
atoms
=
atoms
def
parse_configuration
(
fd
,
conf
type
=
'BulkConfiguration'
,
verbose
=
False
):
def
parse_configuration
(
fd
,
conf
name
,
verbose
=
False
):
code
=
fd
.
variables
[
conf
type
+
'_gID000'
].
data
[:].
copy
()
code
=
fd
.
variables
[
conf
name
].
data
[:].
copy
()
code
=
code
.
tostring
().
decode
(
"utf-8"
)
code
=
code
.
tostring
().
decode
(
"utf-8"
)
s
=
re
.
search
(
'\s*(?P<name>[0-9a-zA-Z_]+)\s*=\s*BulkConfiguration\('
,
code
)
s
=
re
.
search
(
'\s*(?P<name>[0-9a-zA-Z_]+)\s*=\s*BulkConfiguration\('
,
code
)
name
=
s
.
group
(
'name'
)
name
=
s
.
group
(
'name'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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