Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-dftb-plus
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-dftb-plus
Commits
a0ed1f98
Commit
a0ed1f98
authored
8 years ago
by
Adriel Domínguez
Browse files
Options
Downloads
Patches
Plain Diff
Added context for the parser
parent
f579847e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-dftb+/parser_dftb_plus.py
+28
-2
28 additions, 2 deletions
parser/parser-dftb+/parser_dftb_plus.py
with
28 additions
and
2 deletions
parser/parser-dftb+/parser_dftb_plus.py
+
28
−
2
View file @
a0ed1f98
import
setup_paths
from
builtins
import
object
from
nomadcore.simple_parser
import
SimpleMatcher
as
SM
,
mainFunction
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
import
os
,
sys
,
json
import
numpy
as
np
class
dftb_plusContext
(
object
):
"""
context for dftb_plus parser
"""
def
__init__
(
self
):
self
.
parser
=
None
def
initialize_values
(
self
):
"""
allows to reset values if the same superContext is used to parse different files
"""
pass
def
startedParsing
(
self
,
path
,
parser
):
"""
called when parsing starts
"""
self
.
parser
=
parser
# allows to reset values if the same superContext is used to parse different files
self
.
initialize_values
()
def
onClose_section_molecule_type
(
self
,
backend
,
gIndex
,
section
):
atom_charge
=
section
[
'
x_dftbp_charge
'
]
if
atom_charge
is
not
None
:
backend
.
addArrayValues
(
'
atom_in_molecule_charge
'
,
np
.
asarray
(
atom_charge
))
# description of the input
mainFileDescription
=
SM
(
...
...
@@ -38,7 +63,7 @@ mainFileDescription = SM(
sections
=
[
'
section_molecule_type
'
],
subMatchers
=
[
SM
(
r
"
\s*Atom\s*Net charge
"
),
SM
(
r
"
\s*(?P<atom>\d+)\s*(?P<
atom_in_molecule
_charge>[+-]?\d+\.\d+)\s*
"
,
repeats
=
True
),
SM
(
r
"
\s*(?P<atom>\d+)\s*(?P<
x_dftbp
_charge>[+-]?\d+\.\d+)\s*
"
,
repeats
=
True
),
#SM(r"\s*")
],
),
...
...
@@ -106,4 +131,5 @@ metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__f
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
if
__name__
==
"
__main__
"
:
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
)
superContext
=
dftb_plusContext
()
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
,
superContext
=
superContext
)
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