Skip to content
Snippets Groups Projects
Commit 9106b56c authored by Luy, Jan-Niclas (jluy)'s avatar Luy, Jan-Niclas (jluy)
Browse files

first version

parents
No related branches found
No related tags found
No related merge requests found
# use glob syntax.
syntax: glob
*~
*.bak
*.off
*.old
*.pyc
*.bk
*.swp
.DS_Store
__pycache__/
# logging files
detailed.log
# eclipse conf file
.settings
.classpath
.project
.manager
.scala_dependencies
# idea
.idea
*.iml
# building
target
build
null
tmp*
temp*
dist
test-output
build.log
# other scm
.svn
.CVS
.hg*
# switch to regexp syntax.
# syntax: regexp
# ^\.pc/
#SHITTY output not in target directory
build.log
#emacs TAGS
TAGS
lib/
env/
# Setuptools install folder
vaspparser.egg-info/
.directory
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
This is the main repository of the [NOMAD](https://www.nomad-coe.eu/) parser for
[VASP](http://www.vasp.at/).
# Example
```python
from vaspparser import VASPRunParserInterface
import matplotlib.pyplot as mpl
# 1. Initialize a parser with a set of default units.
default_units = ["eV"]
parser = VASPRunParserInterface(default_units=default_units)
# 2. Parse a file
path = "path/to/main.file"
results = parser.parse(path)
# 3. Query the results with using the id's created specifically for NOMAD.
scf_energies = results["energy_total_scf_iteration"]
mpl.plot(scf_energies)
mpl.show()
```
# Installation
The code is python 3 compatible. First download and install
the nomadcore package:
```sh
git clone https://gitlab.mpcdf.mpg.de/nomad-lab/python-common.git
cd python-common
pip install -r requirements.txt
pip install -e .
```
Then download the metainfo definitions to the same folder where the
'python-common' repository was cloned:
```sh
git clone https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-info.git
```
Finally download and install the parser:
```sh
git clone https://gitlab.mpcdf.mpg.de/nomad-lab/parser-vasp.git
cd parser-vasp
pip install -e .
```
# Copyright 2019-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 numpy as np
from ase.io import read as ase_read
from scipy.constants import physical_constants as pc
from nomadcore.simple_parser import SimpleMatcher
from nomadcore.baseclasses import ParserInterface, MainHierarchicalParser
from nomad.parsing import LocalBackend
"""
A very basic BAND parser.
"""
class BANDParser(ParserInterface):
def get_metainfo_filename(self):
return 'band.nomadmetainfo.json'
def get_parser_info(self):
return {
'name': 'band_parser',
'version': '1.0.0'
}
def setup_version(self):
self.setup_main_parser(None)
def setup_main_parser(self, _):
self.main_parser = MainParser(self.parser_context)
class MainParser(MainHierarchicalParser):
def __init__(self, parser_context, *args, **kwargs):
super().__init__(parser_context, *args, **kwargs)
self.lattice_vectors = []
self.atom_labels = []
self.atom_positions = []
self.configuration_periodic_dimensions = []
self.XC_functional_name = []
self.GGA_functional_name = []
self.root_matcher = SimpleMatcher(
name='root',
#adHoc=self.hallo,
startReStr=r'B A N D',
weak=True,
sections=['section_run'],
subMatchers=[
SimpleMatcher(
startReStr=r'\s\*\s*Amsterdam\sDensity\sFunctional\s*\(ADF\)\s*2018\s*\*.*',
subMatchers=[
SimpleMatcher(startReStr=r'\s\*\s{47}r(?P<program_version>\d+).*')
],
endReStr=r'\s\*{2}.*'),
SimpleMatcher(
startReStr=r'Geometry.*',
sections=['section_system'],
subMatchers=[
SimpleMatcher(
startReStr=r' Index Symbol x \(bohr\) y \(bohr\) z \(bohr\).*',
subMatchers=[
SimpleMatcher(
startReStr=r'\s*\d+\s+([A-Z][a-z]?)\s+(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*', repeats=True, startReAction=self.save_atoms)
],
endReStr=r'\s*'
),
SimpleMatcher(
startReStr=r'Lattice vectors \(bohr\).*',
subMatchers=[
SimpleMatcher(
startReStr=r'\s*\d+\s+(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*', repeats=True, startReAction=self.save_lattice)
],
endReStr=r'\s*'
)
]
),
SimpleMatcher(
startReStr=r' DENSITY FUNCTIONAL POTENTIAL \(scf\)',
sections=['section_method'],
subMatchers=[
#SimpleMatcher(
# sections=['section_XC_functionals'],
# startReStr=r' LDA: (?P<XC_functional_name>[a-z,A-Z]*).*'
#),
SimpleMatcher(
startReStr=r' Gradient Corrections: ([a-z,A-Z]*)c\s*([a-z,A-Z]*)x.*', startReAction=self.save_functional
),
SimpleMatcher(
sections=['section_XC_functionals'],
startReStr=r' Meta-GGA: (?P<XC_functional_name>[a-z,A-Z]*).*',
)
],
endReStr=r' DENSITY FUNCTIONAL ENERGY \(post-scf\)'
),
SimpleMatcher(
sections=['section_single_configuration_calculation'],
startReStr=r'Energy \(hartree\) (?P<energy_total>-\d+\.\d+).*'
)
]
)
def hallo(*args):
print("hallo")
def save_atoms(self, _, groups):
self.atom_positions.append([float(groups[1]), float(groups[2]), float(groups[3])])
self.atom_labels.append(groups[0])
def save_lattice(self, _, groups):
self.lattice_vectors.append([float(groups[0]), float(groups[1]), float(groups[2])])
def save_functional(self, _, groups):
if groups != None:
#print('hallo')
self.GGA_functional_name.append([groups[0], groups[1]])
def onClose_section_system(self, backend, *args, **kwargs):
backend.addArrayValues('atom_labels', np.array(self.atom_labels))
backend.addArrayValues('atom_positions', np.array(self.atom_positions)*pc['Bohr radius'][0])
#print(self.lattice_vectors)
for _ in range(0, len(self.lattice_vectors)):
self.configuration_periodic_dimensions.append(True)
for _ in range(len(self.lattice_vectors),3):
self.configuration_periodic_dimensions.append(False)
#print(self.configuration_periodic_dimensions)
for _ in range(len(self.lattice_vectors),3):
self.lattice_vectors.append([0,0,0])
backend.addArrayValues('lattice_vectors', np.array(self.lattice_vectors)*pc['Bohr radius'][0])
backend.addArrayValues('configuration_periodic_dimensions', np.array(self.configuration_periodic_dimensions))
def onClose_section_method(self, backend, *args, **kwargs):
backend.addValue('electronic_structure_method', 'DFT')
if self.GGA_functional_name != []:
print(self.GGA_functional_name)
backend.openNonOverlappingSection('section_XC_functionals')
backend.addValue('XC_functional_name', 'GGA_X_' + self.GGA_functional_name[0][1])
backend.closeNonOverlappingSection('section_XC_functionals')
backend.openNonOverlappingSection('section_XC_functionals')
backend.addValue('XC_functional_name', 'GGA_C_' + self.GGA_functional_name[0][0])
backend.closeNonOverlappingSection('section_XC_functionals')
def onClose_section_run(self, backend, *args, **kwargs):
backend.addValue('program_name', 'band')
backend.addValue('program_basis_set_type', 'slater')
if __name__ == "__main__":
parser = BANDParser(backend=LocalBackend)
parser.parse(sys.argv[1])
#parser.parser_context.super_backend.write_json(sys.stdout)
print(parser.parser_context.super_backend)
#TODO
#total energy Energy (hartree)
#band gap
#dipole moment Final bond energy (PBE)
#DOS
#charge
#k-points
#basis set with core treatment
#ADF: Not yet in AMS
setup.py 0 → 100644
# Copyright 2016-2018 Fawzi Mohamed, Lauri Himanen, Danio Brambila, Ankit Kariryaa, Henning Glawe
#
# 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.
from setuptools import setup, find_packages
def main():
setup(
name='bandparserparser',
version='0.1',
description='NOMAD parser implementation for BAND.',
author='Jan-Niclas Luy',
license='APACHE 2.0',
packages=find_packages(),
install_requires=[
'nomadcore'
],
)
if __name__ == '__main__':
main()
Task SinglePoint
System
Atoms
C 4.20841220373118 3.45611719839938 9.07148656008858
C 4.60942765685646 4.70840106966320 8.60114630078779
C 4.84052914205430 2.31103866702846 8.58529767791637
C 5.81243041053302 2.41257376680009 7.57900262727124
C 6.18209336585513 3.66212080216538 6.99698199435122
C 5.58302954760823 4.81014785839936 7.59876715501555
H 6.34251001247308 1.49745749378760 7.28900982940025
H 4.58500846524342 1.32723688534692 8.98373329025968
H 3.43339066763259 3.37560734899743 9.83493384082070
H 4.16620188680006 5.61845192816735 9.01086711930024
H 5.92574418075738 5.81362159314164 7.31746951599620
End
Lattice
8.7211398618 0.0000000000000000 0.0000000000000000
0.0000000000000000 7.5603201617 0.0000000000000000
End
End
UseSymmetry False
Engine Band
Basis
Type DZP
Core large
End
XC
MetaGGA TPSS
dispersion Grimme3 BJdamp
END
KSpace
Regular
NumberOfPoints 1 1
end
! Quality GammaOnly
End
NumericalQuality Good
Unrestricted True
Occupations
1 15 // 14
end
Relativity
Level Scalar
End
SCF
Mixing 0.2
Iterations 300
End
Convergence
criterion 1E-6
End
UseSymmetry False
Dependency basis=1e-8
EndEngine
This diff is collapsed.
Task SinglePoint
System
Atoms
C 4.20841220373118 3.45611719839938 9.07148656008858
C 4.60942765685646 4.70840106966320 8.60114630078779
C 4.84052914205430 2.31103866702846 8.58529767791637
C 5.81243041053302 2.41257376680009 7.57900262727124
C 6.18209336585513 3.66212080216538 6.99698199435122
C 5.58302954760823 4.81014785839936 7.59876715501555
H 6.34251001247308 1.49745749378760 7.28900982940025
H 4.58500846524342 1.32723688534692 8.98373329025968
H 3.43339066763259 3.37560734899743 9.83493384082070
H 4.16620188680006 5.61845192816735 9.01086711930024
H 5.92574418075738 5.81362159314164 7.31746951599620
End
Lattice
8.7211398618 0.0000000000000000 0.0000000000000000
0.0000000000000000 7.5603201617 0.0000000000000000
End
End
UseSymmetry False
Engine Band
Basis
Type DZP
Core large
End
XC
LDA LDA
GGA PBE
dispersion Grimme3 BJdamp
END
KSpace
Regular
NumberOfPoints 1 1
end
! Quality GammaOnly
End
NumericalQuality Good
Unrestricted True
Occupations
1 15 // 14
end
Relativity
Level Scalar
End
SCF
Mixing 0.2
Iterations 300
End
Convergence
criterion 1E-6
End
UseSymmetry False
Dependency basis=1e-8
EndEngine
This diff is collapsed.
Task SinglePoint
System
Lattice
8.7211398618 0.0000000000000000 0.0000000000000000
0.0000000000000000 7.5603201617 0.0000000000000000
End
Atoms
Cu 3.63381118279662 2.51757905352594 1.02778935999078
Cu 3.63381118279662 5.03515810705188 1.02778935999078
Cu 3.63381118279662 7.55273716057781 1.02778935999078
Cu 7.99438111369662 2.51757905352594 1.02778935999078
Cu 7.99438111369662 5.03515810705188 1.02778935999078
Cu 7.99438111369662 7.55273716057781 1.02778935999078
Cu 1.45351749620676 6.29395141397493 1.02778935999078
Cu 1.45351749620676 8.81155314846135 1.02778935999078
Cu 1.45351749620676 3.77634967948850 1.02778935999078
Cu 5.81408742710676 1.25879330692305 1.02778935999078
Cu 5.81408742710676 3.77637236044899 1.02778935999078
Cu 5.81408742710676 6.29395141397493 1.02778935999078
Cu 2.18325887414287 0.00095668291326 3.09649406977073
Cu 2.17881109281336 2.51494806210967 3.09649406977073
Cu 2.17918610182741 5.03636019795759 3.09581572404471
Cu 6.54041883935691 2.52861712096202 3.12550876650614
Cu 6.54093338660876 5.02232824373747 3.12748213589091
Cu 6.53907578381819 7.55143678551000 3.08835392105856
Cu 4.36891606174774 1.27401223140855 3.12082201421732
Cu 4.36371826239011 3.77293241477541 3.11730695000070
Cu 4.36647414258644 6.28041088056532 3.11369938409417
Cu 8.69188043756366 3.77621359372559 3.14514995866391
Cu 8.72628533431846 6.28834165641495 3.09239316151800
Cu 8.72113986180000 8.80913384600960 3.09874494422523
Cu 0.71935013979078 2.51314870591118 5.17352701503232
Cu 0.71851291036405 5.03791762391090 5.17217032358029
Cu 0.72664973385511 7.55464236125856 5.16905610001995
Cu 5.07209284766481 2.50645782256808 5.21663280253085
Cu 5.05772913031243 5.04221944608290 5.19094816663222
Cu 5.08745949610131 7.56349549616791 5.15077159931421
Cu 2.89896793804135 1.25501314684220 5.17084446602490
Cu 2.87026666675617 3.77489809801746 5.15644503629542
Cu 2.89497365598465 6.29828347742758 5.16791524584438
Cu 7.29941092038950 1.21728714923532 5.10855999481816
Cu 7.29266075813647 3.77632699852802 5.34036922973513
Cu 7.29114327980052 6.32423805654270 5.12690616331717
end
End
UseSymmetry False
Engine Band
Basis
Type DZP
Core large
End
XC
LDA LDA
GGA PBE
dispersion Grimme3 BJdamp
END
KSpace
Regular
NumberOfPoints 1 1
end
! Quality GammaOnly
End
Unrestricted True
Occupations
1 198 // 198
End
NumericalQuality Good
!Unrestricted True
Relativity
Level Scalar
End
UseSymmetry False
SCF
Mixing 0.2
Iterations 300
End
Convergence
criterion 1E-6
NoDegenerate True
End
Dependency basis=1e-8
EndEngine
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment