Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Sep 8, 2020
2 parents a31e580 + 727a1dd commit d4ee83c
Show file tree
Hide file tree
Showing 7 changed files with 6,167 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.3.1] - 2020-09-09

* cp2k_pdos: add support for list-of-atoms output

## [0.3.0] - 2020-09-09

* add cp2k_pdos tool
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Modular CP2K output file parsers, mostly in the form of regular expressions plus
* `cp2kparse` ... parse CP2K output files (for restart & input files look at the [cp2k-input-tools](https://github.com/cp2k/cp2k-input-tools) project)
* `xyz_restart_parser` ... when restarts occur during an MD you may end up with duplicated frames in the trajectory, this tool filters them
* `cp2k_bs2csv` ... convert a CP2K band structure file to multiple (one-per-set) CSV files for easier plotting. There is also an API available if you need to import bandstructure data into your application.
* `cp2k_pdos` ... bring CP2Ks PDOS dump into a more CSV-like form for easier plotting/parsing

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion cp2k_output_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.3.0"
__version__ = "0.3.1"

__all__ = ["builtin_matchers", "parse_iter"]

Expand Down
10 changes: 7 additions & 3 deletions cp2k_output_tools/scripts/pdos.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
Convert the discrete CP2K PDOS points to a smoothed curve using convoluted gaussians.
If you have separate alpha/beta-spin pdos files (spin-unrestricted calculation),
pass both files as arguments to get one common grid for both of them.
"""

# Copyright (c) 2020 Tiziano Müller <[email protected]>,
Expand All @@ -15,7 +18,8 @@


HEADER_MATCH = re.compile(
r"\# Projected DOS for atomic kind (?P<element>\w+) at iteration step i = \d+, E\(Fermi\) = [ \t]* (?P<Efermi>[^\t ]+) a\.u\."
r"\# Projected DOS for (?:atomic kind \w+|list \d+ of \d+ atoms,)"
r" at iteration step i = \d+, E\(Fermi\) = [ \t]* (?P<Efermi>[^\t ]+) a\.u\."
)

# Column indexes, starting from 0
Expand Down Expand Up @@ -45,7 +49,7 @@ def cp2k_pdos():
metavar="<PDOS-file>",
type=str,
nargs="+",
help="the PDOS file generated by CP2K, specify two (alpha/beta) files for a common grid",
help="the PDOS file generated by CP2K, specify two files (alpha/beta) in a spin-unrestricted case",
)
parser.add_argument("--sigma", "-s", type=float, default=0.02, help="sigma for the gaussian distribution (default: 0.02)")
parser.add_argument("--de", "-d", type=float, default=0.001, help="integration step size (default: 0.001)")
Expand All @@ -67,7 +71,7 @@ def cp2k_pdos():
print(
f"The file '{pdosfilename}' does not look like a CP2K PDOS output.\n"
"If it is indeed a correct output file, please report an issue at\n"
" https://github.com/dev-zero/cp2k-tools/issues"
" https://github.com/cp2k/cp2k-output-tools/issues"
)
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cp2k-output-tools"
version = "0.3.0"
version = "0.3.1"
description = "Python tools to handle CP2K output files"
authors = ["Tiziano Müller <[email protected]>"]
repository = "https://github.com/cp2k/cp2k-output-tools"
Expand Down
6,144 changes: 6,144 additions & 0 deletions tests/inputs/list-of-atoms.pdos

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/test_pdos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ def test_pdos(script_runner):
assert ret.success
assert "Nr of lines: 936" in ret.stderr
assert "Energy_[eV]" in ret.stdout


@pytest.mark.script_launch_mode("subprocess")
def test_pdos_list_of_atoms(script_runner):
ret = script_runner.run("cp2k_pdos", str(TEST_DIR / "inputs" / "list-of-atoms.pdos"))

assert ret.success
assert "Nr of lines: 6142" in ret.stderr
assert "Energy_[eV]" in ret.stdout

0 comments on commit d4ee83c

Please sign in to comment.