Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-vasp
Compare Revisions
1a0c8cb0801375a78134c67f7a6d31319a338503...8c2e56b0d9d17b777b5fa6a61c8e2877444ab603
Commits (3)
Removed unnecessary fermi level for DOS.
· 8776a0bc
Lauri Himanen
authored
Jul 14, 2020
8776a0bc
Converted to use metainfo
· 2c8b7763
Alvin Noe Ladines
authored
Jul 28, 2020
2c8b7763
Switched to FairdiParser with archive not backend.
· 8c2e56b0
Markus Scheidgen
authored
Jul 30, 2020
8c2e56b0
Expand all
Hide whitespace changes
Inline
Side-by-side
vaspparser/__init__.py
View file @
8c2e56b0
...
...
@@ -18,28 +18,34 @@ import gzip
import
bz2
import
lzma
from
nomadcore.baseclasses
import
ParserInterface
import
nomadcore.baseclasses
from
nomad.datamodel
import
EntryArchive
from
vaspparser.parser_vasprun
import
parserInfo
from
vaspparser.parser_vasprun
import
VasprunContext
,
XmlParser
,
parserInfo
from
.metainfo
import
m_env
from
vaspparser.parser_vasprun
import
VasprunContext
,
XmlParser
,
parser_info
from
nomad.parsing.parser
import
FairdiParser
from
vaspparser.parser_outcar
import
VaspOutcarParser
from
nomad.parsing.legacy
import
CoEInterfaceParser
class
VASPRunMainParser
:
"""
The main parser class that is called for all run types. Parses the VASP
.xml output files.
"""
def
__init__
(
self
,
parser_context
):
self
.
parser_context
=
parser_context
class
VASPParser
(
FairdiParser
):
def
__init__
(
self
):
super
().
__init__
(
name
=
'parsers/vasp'
,
code_name
=
'VASP'
,
code_homepage
=
'https://www.vasp.at/'
,
mainfile_mime_re
=
r
'(application/.*)|(text/.*)'
,
mainfile_contents_re
=
(
r
'^\s*<\?xml version="1\.0" encoding="ISO-8859-1"\?>\s*'
r
'?\s*<modeling>'
r
'?\s*<generator>'
r
'?\s*<i name="program" type="string">\s*vasp\s*</i>'
r
'?'
),
supported_compressions
=
[
'gz'
,
'bz2'
,
'xz'
]
)
def
parse
(
self
,
filepath
,
archive
,
logger
=
None
):
self
.
_metainfo_env
=
m_env
def
parse
(
self
,
filepath
):
# the nomadcore.baseclasses.logger is set for each parsing run
superContext
=
VasprunContext
(
logger
=
nomadcore
.
baseclasses
.
logger
)
parser
=
XmlParser
(
parserInfo
,
superContext
)
backend
=
self
.
parser_context
.
super_backend
super_context
=
VasprunContext
(
logger
=
logger
)
parser
=
XmlParser
(
parser_info
,
super_context
,
metainfo_env
=
m_env
)
open_file
=
open
if
filepath
.
endswith
(
'.gz'
):
...
...
@@ -49,46 +55,4 @@ class VASPRunMainParser:
elif
filepath
.
endswith
(
'.xz'
):
open_file
=
lzma
.
open
parser
.
parse
(
os
.
path
.
abspath
(
filepath
),
open_file
(
filepath
,
'rt'
),
backend
)
class
VASPRunParserInterface
(
ParserInterface
):
"""
This class handles the initial setup before any parsing can happen. It
determines which version of BigDFT was used to generate the output and then
sets up a correct main parser.
After the implementation has been setup, you can parse the files with
parse().
"""
def
__init__
(
self
,
metainfo_to_keep
=
None
,
backend
=
None
,
default_units
=
None
,
metainfo_units
=
None
,
debug
=
True
,
log_level
=
logging
.
ERROR
,
store
=
True
):
super
(
VASPRunParserInterface
,
self
).
__init__
(
metainfo_to_keep
,
backend
,
default_units
,
metainfo_units
,
debug
,
log_level
,
store
)
def
setup_version
(
self
):
"""
Setups the version by looking at the output file and the version
specified in it.
"""
# Setup the root folder to the fileservice that is used to access files
dirpath
,
filename
=
os
.
path
.
split
(
self
.
parser_context
.
main_file
)
dirpath
=
os
.
path
.
abspath
(
dirpath
)
self
.
parser_context
.
file_service
.
setup_root_folder
(
dirpath
)
self
.
parser_context
.
file_service
.
set_file_id
(
filename
,
"output"
)
self
.
main_parser
=
VASPRunMainParser
(
self
.
parser_context
)
def
get_metainfo_filename
(
self
):
return
"vasp.nomadmetainfo.json"
def
get_parser_info
(
self
):
return
parserInfo
class
VASPRunParser
(
CoEInterfaceParser
):
def
__init__
(
self
):
super
().
__init__
(
VASPRunParserInterface
)
parser
.
parse
(
os
.
path
.
abspath
(
filepath
),
open_file
(
filepath
,
'rt'
),
archive
)
vaspparser/__main__.py
0 → 100644
View file @
8c2e56b0
# Copyright 2016-2018 Markus Scheidgen
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
sys
import
json
from
vaspparser
import
VASPParser
if
__name__
==
"__main__"
:
archive
=
VASPParser
.
main
(
sys
.
argv
[
1
])
json
.
dump
(
archive
.
m_to_dict
(),
sys
.
stdout
,
indent
=
2
)
\ No newline at end of file
vaspparser/parser_vasprun.py
View file @
8c2e56b0
This diff is collapsed.
Click to expand it.