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
ce58ded8
Commit
ce58ded8
authored
Sep 28, 2016
by
Mikkel Strange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more polishing
parent
19ca5f00
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
14 deletions
+32
-14
parser/parser-atk/atkio.py
parser/parser-atk/atkio.py
+5
-0
parser/parser-atk/parser_calculator.py
parser/parser-atk/parser_calculator.py
+26
-12
parser/parser-atk/parser_configurations.py
parser/parser-atk/parser_configurations.py
+1
-2
No files found.
parser/parser-atk/atkio.py
View file @
ce58ded8
...
...
@@ -19,6 +19,11 @@ class Reader:
self
.
calculator_x
[
gid
]
=
parse_calculator
(
self
.
f
,
calc_name
)
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
.
calc_names
=
self
.
_read_calculator_names
()
self
.
finger_print_table
=
self
.
_read_finger_print_table
()
...
...
parser/parser-atk/parser_calculator.py
View file @
ce58ded8
...
...
@@ -9,15 +9,18 @@ SphericalSymmetric = 'SphericalSymmetric'
LDA
=
type
(
'LDA'
,
(
object
,),
{
'PZ'
:
'LDA.PZ'
,
'PW'
:
'LDA.PW'
})()
'PW'
:
'LDA.PW'
,
'RPA'
:
'LDA.RPA'
})()
GGA
=
type
(
'GGA'
,
(
object
,),
{
'PBE'
:
'GGA.PBE'
,
'RPBE'
:
'GGA.RPBE'
,
'PW91'
:
'GGA.PW91'
})()
'PW91'
:
'GGA.PW91'
,
'PBES'
:
'GGA.PBES'
})()
ptable
=
{
name
:
symbol
for
symbol
,
name
in
zip
(
data
.
chemical_symbols
,
data
.
atomic_names
)}
PeriodicTable
=
type
(
'PeriodicTable'
,
(
object
,),
ptable
)()
Preconditioner
=
type
(
'Preconditioner'
,
(
object
,),
{
'Off'
:
'Off'
,
'On'
:
'On'
})
...
...
@@ -28,11 +31,14 @@ Preconditioner = type('Preconditioner', (object,), {'Off': 'Off',
# class LCAOCalculator(object):
# 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
):
#if len(args)>0:
# print(*args)
#assert len(args) == 0
self
.
args
=
args
for
key
,
value
in
kwargs
.
ite
rite
ms
():
for
key
,
value
in
kwargs
.
items
():
setattr
(
self
,
key
,
value
)
...
...
@@ -42,23 +48,31 @@ clss = ['LCAOCalculator', 'BasisSet', 'ConfinedOrbital', 'CheckpointHandler',
'NumericalAccuracyParameters'
,
'MonkhorstPackGrid'
,
'NormConservingPseudoPotential'
,
'AnalyticalSplit'
,
'ConfinedOrbital'
,
'PolarizationOrbital'
,
'PulayMixer'
]
for
cls
in
clss
:
code
=
cls
+
' = type("'
+
cls
+
'", (object,)'
+
', {"__init__": init})'
exec
(
code
)
def
parse_calculator
(
fd
,
conf
=
'BulkConfiguration_gID000'
,
verbose
=
False
):
"""conf: the configuratio the calcualtor refers to
def
parse_calculator
(
fd
,
calcname
):
"""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"
)
s
=
re
.
search
(
'\s*(?P<name>[0-9a-zA-Z_]+)\s*=\s*LCAOCalculator\('
,
code
)
name
=
s
.
group
(
'name'
)
if
1
:
print
(
code
)
#s = re.search('\s*(?P<name>[0-9a-zA-Z_]+)\s*=\s*LCAOCalculator\(', code)
#name = s.group('name')
exec
(
code
)
calc
=
(
locals
()[
name
])
return
calc
for
obj
in
locals
().
values
():
if
isinstance
(
obj
,
LCAOCalculator
):
return
obj
assert
0
,
'No calculator found'
if
__name__
==
'__main__'
:
from
scipy.io.netcdf
import
netcdf_file
fd
=
netcdf_file
(
'Water.nc'
,
'r'
)
calc
=
parse_calculator
(
fd
)
calc
=
parse_calculator
(
fd
,
'BulkConfiguration_gID000_calculator'
)
print
(
dir
(
calc
))
parser/parser-atk/parser_configurations.py
View file @
ce58ded8
...
...
@@ -15,7 +15,6 @@ Silicon = type('Silicon', (object,), {})
Silicon
.
symbol
=
'Si'
class
UnitCell
:
def
__init__
(
self
,
a
,
b
,
c
,
origin
=
None
):
self
.
cell
=
[
a
,
b
,
c
]
...
...
@@ -64,5 +63,5 @@ if __name__ == '__main__':
import
re
from
scipy.io.netcdf
import
netcdf_file
fd
=
netcdf_file
(
'Water.nc'
,
'r'
)
atoms
=
parse_configuration
(
fd
,
verbose
=
True
)
atoms
=
parse_configuration
(
fd
,
'BulkConfiguration_gID000'
,
verbose
=
True
)
print
(
atoms
)
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