Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-atk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
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 is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-atk
Commits
ce58ded8
Commit
ce58ded8
authored
8 years ago
by
Mikkel Strange
Browse files
Options
Downloads
Patches
Plain Diff
more polishing
parent
19ca5f00
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
parser/parser-atk/atkio.py
+5
-0
5 additions, 0 deletions
parser/parser-atk/atkio.py
parser/parser-atk/parser_calculator.py
+26
-12
26 additions, 12 deletions
parser/parser-atk/parser_calculator.py
parser/parser-atk/parser_configurations.py
+1
-2
1 addition, 2 deletions
parser/parser-atk/parser_configurations.py
with
32 additions
and
14 deletions
parser/parser-atk/atkio.py
+
5
−
0
View file @
ce58ded8
...
@@ -19,6 +19,11 @@ class Reader:
...
@@ -19,6 +19,11 @@ class Reader:
self
.
calculator_x
[
gid
]
=
parse_calculator
(
self
.
f
,
calc_name
)
self
.
calculator_x
[
gid
]
=
parse_calculator
(
self
.
f
,
calc_name
)
def
initialize
(
self
):
def
initialize
(
self
):
"""
Read the names of the variables in the netcdf file for
configurations and calculators and setup
the finger print table which maps between calculated
quantities and configurations.
"""
self
.
conf_names
=
self
.
_read_configuration_names
()
self
.
conf_names
=
self
.
_read_configuration_names
()
self
.
calc_names
=
self
.
_read_calculator_names
()
self
.
calc_names
=
self
.
_read_calculator_names
()
self
.
finger_print_table
=
self
.
_read_finger_print_table
()
self
.
finger_print_table
=
self
.
_read_finger_print_table
()
...
...
This diff is collapsed.
Click to expand it.
parser/parser-atk/parser_calculator.py
+
26
−
12
View file @
ce58ded8
...
@@ -9,15 +9,18 @@ SphericalSymmetric = 'SphericalSymmetric'
...
@@ -9,15 +9,18 @@ SphericalSymmetric = 'SphericalSymmetric'
LDA
=
type
(
'
LDA
'
,
(
object
,),
{
'
PZ
'
:
'
LDA.PZ
'
,
LDA
=
type
(
'
LDA
'
,
(
object
,),
{
'
PZ
'
:
'
LDA.PZ
'
,
'
PW
'
:
'
LDA.PW
'
})()
'
PW
'
:
'
LDA.PW
'
,
'
RPA
'
:
'
LDA.RPA
'
})()
GGA
=
type
(
'
GGA
'
,
(
object
,),
{
'
PBE
'
:
'
GGA.PBE
'
,
GGA
=
type
(
'
GGA
'
,
(
object
,),
{
'
PBE
'
:
'
GGA.PBE
'
,
'
RPBE
'
:
'
GGA.RPBE
'
,
'
RPBE
'
:
'
GGA.RPBE
'
,
'
PW91
'
:
'
GGA.PW91
'
})()
'
PW91
'
:
'
GGA.PW91
'
,
'
PBES
'
:
'
GGA.PBES
'
})()
ptable
=
{
name
:
symbol
for
symbol
,
name
in
zip
(
data
.
chemical_symbols
,
ptable
=
{
name
:
symbol
for
symbol
,
name
in
zip
(
data
.
chemical_symbols
,
data
.
atomic_names
)}
data
.
atomic_names
)}
PeriodicTable
=
type
(
'
PeriodicTable
'
,
(
object
,),
ptable
)()
PeriodicTable
=
type
(
'
PeriodicTable
'
,
(
object
,),
ptable
)()
Preconditioner
=
type
(
'
Preconditioner
'
,
(
object
,),
{
'
Off
'
:
'
Off
'
,
Preconditioner
=
type
(
'
Preconditioner
'
,
(
object
,),
{
'
Off
'
:
'
Off
'
,
'
On
'
:
'
On
'
})
'
On
'
:
'
On
'
})
...
@@ -28,11 +31,14 @@ Preconditioner = type('Preconditioner', (object,), {'Off': 'Off',
...
@@ -28,11 +31,14 @@ Preconditioner = type('Preconditioner', (object,), {'Off': 'Off',
# class LCAOCalculator(object):
# class LCAOCalculator(object):
# def __init__(self, basis_set=None, ...)
# def __init__(self, basis_set=None, ...)
#
#
# is easily done, but a bit more work at the moment
# is easily done, but a bit more work at the moment
...
#
#
def
init
(
self
,
*
args
,
**
kwargs
):
def
init
(
self
,
*
args
,
**
kwargs
):
#if len(args)>0:
# print(*args)
#assert len(args) == 0
self
.
args
=
args
self
.
args
=
args
for
key
,
value
in
kwargs
.
iter
items
():
for
key
,
value
in
kwargs
.
items
():
setattr
(
self
,
key
,
value
)
setattr
(
self
,
key
,
value
)
...
@@ -42,23 +48,31 @@ clss = ['LCAOCalculator', 'BasisSet', 'ConfinedOrbital', 'CheckpointHandler',
...
@@ -42,23 +48,31 @@ clss = ['LCAOCalculator', 'BasisSet', 'ConfinedOrbital', 'CheckpointHandler',
'
NumericalAccuracyParameters
'
,
'
MonkhorstPackGrid
'
,
'
NumericalAccuracyParameters
'
,
'
MonkhorstPackGrid
'
,
'
NormConservingPseudoPotential
'
,
'
AnalyticalSplit
'
,
'
ConfinedOrbital
'
,
'
NormConservingPseudoPotential
'
,
'
AnalyticalSplit
'
,
'
ConfinedOrbital
'
,
'
PolarizationOrbital
'
,
'
PulayMixer
'
]
'
PolarizationOrbital
'
,
'
PulayMixer
'
]
for
cls
in
clss
:
for
cls
in
clss
:
code
=
cls
+
'
= type(
"'
+
cls
+
'"
, (object,)
'
+
'
, {
"
__init__
"
: init})
'
code
=
cls
+
'
= type(
"'
+
cls
+
'"
, (object,)
'
+
'
, {
"
__init__
"
: init})
'
exec
(
code
)
exec
(
code
)
def
parse_calculator
(
fd
,
conf
=
'
BulkConfiguration_gID000
'
,
verbose
=
False
):
def
parse_calculator
(
fd
,
calcname
):
"""
conf: the configuratio the calcualtor refers to
"""
calc: the configuratio the calcualtor refers to
The name of the calculator in the nc-file is
conf_calculator, fx BulkConfiguration_gID000_calculator
"""
"""
code
=
fd
.
variables
[
c
onf
+
'
_calculator
'
].
data
[:].
copy
()
code
=
fd
.
variables
[
c
alcname
].
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*LCAOCalculator\(
'
,
code
)
if
1
:
name
=
s
.
group
(
'
name
'
)
print
(
code
)
#s = re.search('\s*(?P<name>[0-9a-zA-Z_]+)\s*=\s*LCAOCalculator\(', code)
#name = s.group('name')
exec
(
code
)
exec
(
code
)
calc
=
(
locals
()[
name
])
for
obj
in
locals
().
values
():
return
calc
if
isinstance
(
obj
,
LCAOCalculator
):
return
obj
assert
0
,
'
No calculator found
'
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
from
scipy.io.netcdf
import
netcdf_file
from
scipy.io.netcdf
import
netcdf_file
fd
=
netcdf_file
(
'
Water.nc
'
,
'
r
'
)
fd
=
netcdf_file
(
'
Water.nc
'
,
'
r
'
)
calc
=
parse_calculator
(
fd
)
calc
=
parse_calculator
(
fd
,
'
BulkConfiguration_gID000_calculator
'
)
print
(
dir
(
calc
))
This diff is collapsed.
Click to expand it.
parser/parser-atk/parser_configurations.py
+
1
−
2
View file @
ce58ded8
...
@@ -15,7 +15,6 @@ Silicon = type('Silicon', (object,), {})
...
@@ -15,7 +15,6 @@ Silicon = type('Silicon', (object,), {})
Silicon
.
symbol
=
'
Si
'
Silicon
.
symbol
=
'
Si
'
class
UnitCell
:
class
UnitCell
:
def
__init__
(
self
,
a
,
b
,
c
,
origin
=
None
):
def
__init__
(
self
,
a
,
b
,
c
,
origin
=
None
):
self
.
cell
=
[
a
,
b
,
c
]
self
.
cell
=
[
a
,
b
,
c
]
...
@@ -64,5 +63,5 @@ if __name__ == '__main__':
...
@@ -64,5 +63,5 @@ if __name__ == '__main__':
import
re
import
re
from
scipy.io.netcdf
import
netcdf_file
from
scipy.io.netcdf
import
netcdf_file
fd
=
netcdf_file
(
'
Water.nc
'
,
'
r
'
)
fd
=
netcdf_file
(
'
Water.nc
'
,
'
r
'
)
atoms
=
parse_configuration
(
fd
,
verbose
=
True
)
atoms
=
parse_configuration
(
fd
,
'
BulkConfiguration_gID000
'
,
verbose
=
True
)
print
(
atoms
)
print
(
atoms
)
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