Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gpaw #1

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
474b1a8
Adding pypi deployment
maxhutch Dec 8, 2020
e20632f
Bump version to test pypi
maxhutch Dec 8, 2020
388f709
Working, so switching to a normal version bump.
maxhutch Dec 8, 2020
87ec542
read release version from package version
hegdevinayi Dec 8, 2020
7174eea
fix missing refactor to dftinputgen in MANIFEST
hegdevinayi Dec 8, 2020
ea1c7de
Merge pull request #5 from CitrineInformatics/admin/deploy-pypi
hegdevinayi Dec 8, 2020
d825a27
ask setuptools to include data files
hegdevinayi Dec 8, 2020
7ac84da
version bump
hegdevinayi Dec 8, 2020
14bee32
Merge pull request #6 from CitrineInformatics/hotfix/add-datafiles
hegdevinayi Dec 8, 2020
2a12777
adds gpaw
lancekavalsky Dec 8, 2020
e62b7a0
Fix typos base_recipe -> calculation_presets and dftinpgen -> dftinpu…
lancekavalsky Dec 15, 2020
ca21406
fix import typo
lancekavalsky Dec 15, 2020
03d7759
Start updating gpaw syntax to match qe
lancekavalsky Dec 15, 2020
60ed5df
Reformat with black
lancekavalsky Dec 15, 2020
41a9864
Adds allowing gpaw input file name to write to
lancekavalsky Dec 17, 2020
957b4e6
fixes merge conflicts
lancekavalsky Dec 17, 2020
c679973
Start adding gpaw tests
lancekavalsky Dec 17, 2020
ea301a9
Updates MANIFEST.in to include gpaw
lancekavalsky Dec 17, 2020
d25d7a6
reformatting
lancekavalsky Dec 17, 2020
503eed8
Adds bulk_opt_hcp settings test
lancekavalsky Dec 18, 2020
8eb89d6
fixes indentation of bulk_opt function definition in script
lancekavalsky Dec 22, 2020
51f348a
Adds line to exclude from black formatting
lancekavalsky Dec 22, 2020
f71ee59
rename test bulk_opt script
lancekavalsky Dec 22, 2020
8adf43d
adds tests for more calculation presets and scripts as strings
lancekavalsky Dec 22, 2020
3810d76
if no settings found will return empty calc object that will use gpaw…
lancekavalsky Dec 22, 2020
dc1ee55
Fixes typo that prevented updating settings. Adds additional tests
lancekavalsky Dec 22, 2020
02dcc2d
rename preset relax -> surface_relax
lancekavalsky Dec 22, 2020
ad9314b
structure filename for the written gpaw script can now be specified
lancekavalsky Dec 23, 2020
c9cf8b7
Adds docstring for gpaw class
lancekavalsky Jan 2, 2021
c090043
Updates function for optimizing bulk hcp structures
lancekavalsky Jan 4, 2021
f867854
calc_obj_as_str -> calculator_object_as_str
lancekavalsky Jan 4, 2021
e46e788
Adds ability to write gpaw restart files
lancekavalsky Jan 4, 2021
24a0ae4
Removes Fraction dependence in written bulk_opt function
lancekavalsky Jan 4, 2021
e3ad07e
Removes unused imports
lancekavalsky Jan 4, 2021
e3af7c3
Fixes docstring for gpaw class
lancekavalsky Jan 6, 2021
b3e52dd
Adds gpaw documentation
lancekavalsky Jan 6, 2021
e070478
Reformats according to PEP8
lancekavalsky Jan 8, 2021
3f112f5
new script fmt to read restart files automatically
lancekavalsky Aug 30, 2021
a0b5d5a
various fixes
lancekavalsky Oct 18, 2021
735d0eb
add gpaw cli
lancekavalsky Oct 20, 2021
89cd147
add surface adsorbate vibrations calcs
lancekavalsky Oct 21, 2021
b3f0eae
tests for gpaw cli, add from_scratch to gpaw cli
lancekavalsky Oct 21, 2021
95ab3aa
specify txt output
lancekavalsky Oct 26, 2021
4d89b93
fix txt output in cli test
lancekavalsky Oct 26, 2021
b43e184
fix restart logic in case of empty output traj
lancekavalsky Oct 26, 2021
31c4d9b
update readme to include gpaw
lancekavalsky Oct 29, 2021
0bf5a81
line break before operator allowed per pep-8
hegdevinayi Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
language: python

python:
- '2.7'
- '3.8'

install:
- pip install -r requirements.txt
- pip install -r test_requirements.txt
- pip install -e .

script:
- pytest --cov=src/ --cov-report term-missing --cov-report term:skip-covered --cov-config=tox.ini --cov-fail-under=100 -svv .
- flake8 src
- pytest --cov=src/ --cov-report term-missing --cov-report term:skip-covered --cov-config=tox.ini
--cov-fail-under=100 -svv .
- flake8 src
deploy:
- provider: pypi
user: CitrineInformatics
password: "$PYPI_PASSWORD"
distributions: sdist bdist_wheel
skip_existing: true
on:
tags: true
env:
global:
secure: M9HI5bpY5t4Rd17rjdrSo6QF4jV2JMi3hOgMzMGgly4jP1NoafOBSpJHy4TisBeE8eyrkJPJurMnF0Fw7kACtpCMT6h8tLE4r6Ss97542MJnFLV33hILdcwJZjAYfaQ0q5lrWmtNr420y5kvD1EjL3jQnYYVJC2wjAb4b5C8Ji5i/43n5Vuk3aO2BG8IzNXF0buqtAWIwyclOpr/QjkSWxf+ptj4Fv64Cy84aVTFMOGL523DRVkZgCl5vdq6gSpFTk9S/a2G16LM6GPU3ohKRzIGRzRv8HsGL4oyi2c+NjzysIdOq7yx/8crM4fADAl+xG3bh8biYJY6PVfxrR4ttNdL6UFxg0xUwPVpmngL+YjUS6DOi7cVs9VoaqsPq5mrrcZ5HvL+RaJt43o0okxBqvmZW/SRJs0fAdDLu1UKIxzH9MTpdQmuUhCyyh6muePnnzvNkSzXnZRSO2z/DUmLsRiA3qMJkY/CSIWvxqj9+tVvAT9jRjb+loWBrra3FR5+sMikmoT/Qd27xCYSrwTMBy7jgw4mOh6xNK6FmT1nS/JDpH0KrZDXwjsB2uHSw9G1EnrBF7fhXCTx7SodD9ypwKrB0aIUrRj2iUcsAKGN4mVz92KvF/OhhuLmH2+hiivSM98k2R36bZfhEuAqFTSN5DM/UoqLXckdr63vahxHlEA=
10 changes: 6 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include src/dftinpgen/*.txt
include src/dftinpgen/data/*.json
include src/dftinpgen/qe/settings/*.json
include src/dftinpgen/qe/settings/calculation_presets/*.json
include src/dftinputgen/*.txt
include src/dftinputgen/data/*.json
include src/dftinputgen/qe/settings/*.json
include src/dftinputgen/qe/settings/calculation_presets/*.json
include src/dftinputgen/gpaw/settings/*.json
include src/dftinputgen/gpaw/settings/calculation_presets/*.json
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ documentation.

1. [pw.x](https://www.quantum-espresso.org/Doc/INPUT_PW.html) from the
[Quantum Espresso package](https://www.quantum-espresso.org/)
2. (under development) Post-processing utilities for pw.x:
2. [GPAW](https://wiki.fysik.dtu.dk/gpaw/index.html) including functions for
`surface relaxation`, `adsorbate vibration calculations`, and `lattice
parameter optimization` (fcc, bcc, and hcp)
3. (under development) Post-processing utilities for pw.x:
[dos.x](https://www.quantum-espresso.org/Doc/INPUT_DOS.html),
[bands.x](https://www.quantum-espresso.org/Doc/INPUT_BANDS.html),
[projwfc.x](https://www.quantum-espresso.org/Doc/INPUT_PROJWFC.html)
Expand Down
4 changes: 3 additions & 1 deletion docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
author = "Vinay Hegde <[email protected]>"

# The full version, including alpha/beta/rc tags
release = "0.1.0"
version_file = os.path.join("..", "..", "src", "dftinputgen", "VERSION.txt")
with open(version_file, "r") as fr:
release = fr.read().strip()


# -- General configuration ---------------------------------------------------
Expand Down
14 changes: 13 additions & 1 deletion docs/src/developer_notes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ Code Organization
settings/
tags_and_groups.json
...
base_recipes/
calculation_presets/
scf.json
vc-relax.json
...
gpaw/
gpaw.py
...
settings/
tags_and_groups.json
...
calculation_presets/
bulk_opt.json
bulk_opt_hcp.json
...
vasp/
...

Expand All @@ -33,6 +43,8 @@ Code Organization
- ``dftinputgen.qe``: derived classes that can generate input files for various
DFT-based and postprocessing codes in the Quantum Espresso suite (more
:ref:`here <ssec-qe>`)
- ``dftinputgen.gpaw``: derived classes that can generate input python scripts
for the GPAW package (more :ref:`here <ssec-gpaw>`).
- ``dftinputgen.vasp``: [under development] derived classes that can generate
input files for the VASP package.
- ``dftinputgen.utils``: general-purpose helper functions, e.g. chemical formula
Expand Down
49 changes: 49 additions & 0 deletions docs/src/module_reference/gpaw/gpaw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.. _sssec-gpaw:

Input GPAW
++++++++++

The :class:`GPAWInputGenerator <dftinputgen.gpaw.GPAWInputGenerator>` class
(derived from :class:`DftInputGenerator <dftinputgen.base.DftInputGenerator>`)
implements functionality to generate python scripts for the `GPAW`_
package.

Python scripts are written that use `ASE`_ with GPAW specified via a
calculator object. This calculator object is where all settings for
the DFT calculation is given. An example of the calculator object
that is automatically written is given below.

.. code-block:: python

slab.calc = GPAW(
h=0.16,
kpts={'size': [4, 4, 1]},
occupations={'name': 'fermi-dirac', 'width': 0.05},
poissonsolver={'dipolelayer': 'xy'},
xc='BEEF-vdW'
)

For each calculator setting, a list of valid parameters is looked up from
a ``GPAW_TAGS`` dictionary which is then defined within the written
calculator object (more information about the valid calculator parameters
and defaults provided as ``calculation_presets`` is :ref:`here
<sssec-gpaw-input-settings>`).

Currently supported calculations include relaxations, bulk optimizations,
and total energy.

**Note:** The scripts are written assuming that the crystal structure
is stored in an `ASE readable format`_ (e.g. traj, cif, etc..) with
the desired initial magnetic moments defined.

.. _`GPAW`: https://wiki.fysik.dtu.dk/gpaw/index.html
.. _`ASE`: https://wiki.fysik.dtu.dk/ase/
.. _`ASE readable format`: https://wiki.fysik.dtu.dk/ase/ase/io/io.html

Interfaces
==========

.. automodule:: dftinputgen.gpaw.gpaw
:members:
:inherited-members:
:undoc-members:
21 changes: 21 additions & 0 deletions docs/src/module_reference/gpaw/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _ssec-gpaw:

Input generators for GPAW
+++++++++++++++++++++++++

``dftinputgen`` provides an input generator class for the `GPAW`_ package.
More information :ref:`here <sssec-gpaw>`

.. _`GPAW`: https://wiki.fysik.dtu.dk/gpaw/index.html


.. automodule:: dftinputgen.gpaw
:members:
:undoc-members:

.. toctree::
:maxdepth: 2
:hidden:

gpaw
settings
33 changes: 33 additions & 0 deletions docs/src/module_reference/gpaw/settings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. _sssec-gpaw-input-settings:

Input settings
++++++++++++++

All input settings have been parsed from the `GPAW manual`_
(last updated January 2021).
The calculator parameter names are stored in `tags_and_groups.json`_.
These parameter names are then made available to the user via
a module level variable ``GPAW_TAGS``.

The settings module also makes available a few sets of default settings
to be used for common DFT calculations such as ``surface_relax``,
and ``bulk_opt``.
The defaults are stored in JSON files in the `calculation_presets`_ module.
These can be accessed by the user via a module level variable ``GPAW_PRESETS``.
Note that these presets are only reasonable defaults and are not meant to be
prescriptive.

.. _`GPAW manual`: https://wiki.fysik.dtu.dk/gpaw/documentation/manual.html#parameters
.. _`tags_and_groups.json`: https://github.com/CitrineInformatics/dft-input-gen/blob/master/src/dftinputgen/qe/settings/tags_and_groups.json
.. _`calculation_presets`: https://github.com/CitrineInformatics/dft-input-gen/tree/master/src/dftinputgen/qe/settings/calculation_presets

.. automodule:: dftinputgen.gpaw.settings
:members:
:undoc-members:
:special-members:

.. automodule:: dftinputgen.gpaw.settings.calculation_presets
:members:
:undoc-members:
:special-members:

1 change: 1 addition & 0 deletions docs/src/module_reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Module reference

base
qe/index
gpaw/index
utils
data
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
author_email="[email protected]",
packages=find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
install_requires=["six", "numpy", "ase <= 3.17"],
entry_points={"console_scripts": ["dftinputgen = dftinputgen.cli:driver"]},
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion src/dftinputgen/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.2
8 changes: 8 additions & 0 deletions src/dftinputgen/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from dftinputgen.demo.pwx import build_pwx_parser
from dftinputgen.demo.pwx import generate_pwx_input_files
from dftinputgen.demo.gpaw import build_gpaw_parser
from dftinputgen.demo.gpaw import generate_gpaw_input_files


def get_parser():
Expand All @@ -28,6 +30,12 @@ def get_parser():
# other subparsers, to be added similarly, go here
# e.g. ones for gpaw/vasp

# gpaw subparser
gpaw_help = "Generate a python input file for GPAW"
gpaw_parser = subparsers.add_parser("gpaw", help=gpaw_help)
build_gpaw_parser(gpaw_parser)
gpaw_parser.set_defaults(func=generate_gpaw_input_files)

return parser


Expand Down
117 changes: 117 additions & 0 deletions src/dftinputgen/demo/gpaw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
"""Demo generating input files for doing a calculation with pw.x."""

import json
import argparse

from dftinputgen.utils import read_crystal_structure
from dftinputgen.gpaw import GPAWInputGenerator


def _get_default_parser():
description = "Input file generation for gpaw."
return argparse.ArgumentParser(description=description)


def build_gpaw_parser(parser):
"""Adds GPAW arguments to the input `argparse.ArgumentParser` object."""
# Required:
crystal_structure = "(REQUIRED) File with the input crystal structure"
parser.add_argument(
"-i",
"--crystal-structure",
type=read_crystal_structure,
help=crystal_structure,
required=True,
)

# Optional:
calculation_presets = "Preset group of tags and default values to use"
parser.add_argument(
"-pre",
"--calculation-presets",
choices=[
"surface_relax",
"bulk_opt",
"bulk_opt_hcp",
"molecule",
"surface_adsorbate_vibrations",
],
default=None,
help=calculation_presets,
)

custom_settings_file = "JSON file with custom DFT settings to use"
parser.add_argument(
"-file",
"--custom-settings-file",
default=None,
help=custom_settings_file,
)

custom_settings_dict = """JSON string with a dictionary of custom DFT
settings to use. Example: '{"pseudo_dir": "/path/to/pseudo_dir/"}'"""
parser.add_argument(
"-dict",
"--custom-settings-dict",
default="{}",
type=json.loads,
help=custom_settings_dict,
)

write_location = "Directory to write the input file(s) in"
parser.add_argument("-loc", "--write-location", help=write_location)

gpaw_input_file = "Name of the GPAW input file to be written"
parser.add_argument("-o", "--gpaw-input-file", help=gpaw_input_file)

gpaw_restart_file = "Name of the GPAW restart file that the written script\
will read from"
parser.add_argument("-r", "--gpaw-restart-file", help=gpaw_restart_file)

input_struct_filename = "Name of the input structure that the written\
script will read from"
parser.add_argument(
"-is", "--input_struct_filename", help=input_struct_filename
)

overwrite_files = "To overwrite files or not, that is the question"
parser.add_argument("-ov", "--overwrite_files", help=overwrite_files)

from_scratch = "Whether the calculation should be run from scratch"
parser.add_argument("-fs", "--from-scratch", help=from_scratch)


def generate_gpaw_input_files(args):
"""Write input files for the input crystal structure."""
gig = GPAWInputGenerator(
crystal_structure=args.crystal_structure,
calculation_presets=args.calculation_presets,
custom_sett_file=args.custom_settings_file,
custom_sett_dict=args.custom_settings_dict,
write_location=args.write_location,
gpaw_input_file=args.gpaw_input_file,
gpaw_restart_file=args.gpaw_restart_file,
input_struct_filename=args.input_struct_filename,
overwrite_files=args.overwrite_files,
from_scratch=args.from_scratch,
)
gig.write_input_files()


def run_demo(*sys_args):
"""End-to-end run of pw.x input file generation."""
parser = _get_default_parser()
build_gpaw_parser(parser)
args = parser.parse_args(*sys_args)
generate_gpaw_input_files(args)


if __name__ == "__main__":
"""
When run as a script, this module will generate input files to use with
GPAW, for a specified crystal structure, calculation presets, and any
custom DFT settings on top of preset defaults.

For a list of optional arguments, run this script with "-h" argument.
"""
run_demo() # pragma: no cover
1 change: 1 addition & 0 deletions src/dftinputgen/gpaw/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from dftinputgen.gpaw.gpaw import GPAWInputGenerator # noqa: F401
Loading