Skip to content

Commit

Permalink
Merge branch 'rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Sep 23, 2021
2 parents 84eeea7 + a47b6c6 commit 32a8b95
Show file tree
Hide file tree
Showing 41 changed files with 3,104 additions and 3,776 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: publish PyPI and TestPyPI

on: push

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Make sdist and bdist_wheel
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish package to TestPyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/rc')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/master')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://pre-commit.com for more informatio
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
args:
- "--max-line-length=88"
- "--ignore=E203,W503"

- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
args:
- --line-length=88
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
graft example
include setup.json
include LICENSE
include pyproject.toml
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AiiDA Phonopy plugin
====================
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/aiida-phonopy/aiida-phonopy/develop.svg)](https://results.pre-commit.ci/latest/github/aiida-phonopy/aiida-phonopy/develop)

This a phonopy plugin for AiiDA. This plugin includes workflows to
calculate phonons with supercell and finite displacement approaches.
Currently it provides interfaces only to VASP.
# AiiDA Phonopy plugin

This a phonopy plugin for AiiDA. This plugin includes workflows to calculate
phonons with supercell and finite displacement approaches. Currently VASP and QE
are supported.
113 changes: 59 additions & 54 deletions aiida_phonopy/calcs/base.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
"""Base class of PhonopyCalculation and Phono3pyCalculation."""

from aiida.engine import CalcJob
from aiida.common import CalcInfo, CodeInfo
from aiida.plugins import DataFactory
from aiida.orm import Bool
from aiida_phonopy.common.file_generators import get_BORN_txt

Dict = DataFactory('dict')
StructureData = DataFactory('structure')
ArrayData = DataFactory('array')
Dict = DataFactory("dict")
StructureData = DataFactory("structure")
ArrayData = DataFactory("array")
Float = DataFactory("float")
Bool = DataFactory("bool")


class BasePhonopyCalculation(CalcJob):
"""
A basic plugin for calculating force constants using Phonopy.
"""A basic plugin for calculating force constants using Phonopy.
Requirement: the node should be able to import phonopy if NAC is used
"""

_INPUT_NAC = 'BORN'
_INPUT_NAC = "BORN"

@classmethod
def define(cls, spec):
"""
dataset : Dict, ArrayData, optional
In Dict, this is similar to phonopy.dataset. This can be either
type-I or type-II. In ArrayData, this can contain arrays of forces
and displacements like type-II phonopy dataset, for which the array
names are 'forces' and 'displacements'.
"""

"""Define inputs, outputs, and outline."""
super().define(spec)

spec.input('settings', valid_type=Dict,
help='Phonopy parameters')
spec.input('structure', valid_type=StructureData,
help='Unit cell structure')
spec.input('fc_only', valid_type=Bool,
help='Only force constants are calculated.',
default=lambda: Bool(False))
spec.input('force_sets', valid_type=ArrayData, required=False,
help='Sets of forces in supercells')
spec.input('dataset', valid_type=ArrayData, required=False,
help='Sets of displacements and forces in supercells')
spec.input('nac_params', valid_type=ArrayData, required=False,
help='NAC parameters')
spec.input('primitive', valid_type=StructureData, required=False,
help='Primitive cell structure')
spec.input('dataset', valid_type=(Dict, ArrayData), required=False,
help='Displacements and forces dataset')
spec.inputs['metadata']['options']['withmpi'].default = False
spec.input("settings", valid_type=Dict, help="Phonopy parameters.")
spec.input("structure", valid_type=StructureData, help="Unit cell structure.")
spec.input("symmetry_tolerance", valid_type=Float, default=lambda: Float(1e-5))
spec.input(
"fc_only",
valid_type=Bool,
help="Only force constants are calculated.",
default=lambda: Bool(False),
)
spec.input(
"force_sets",
valid_type=ArrayData,
required=False,
help="Sets of forces in supercells",
)
spec.input(
"nac_params", valid_type=ArrayData, required=False, help="NAC parameters."
)
spec.input(
"primitive",
valid_type=StructureData,
required=False,
help="Primitive cell structure only necessary NAC is applied.",
)
spec.input(
"dataset",
valid_type=(Dict, ArrayData),
required=False,
help="Displacements and forces dataset.",
)

def prepare_for_submission(self, folder):
"""Create the input files from the input nodes passed to this instance of the `CalcJob`.
:param folder: an `aiida.common.folders.Folder` to temporarily write files on disk
:return: `aiida.common.datastructures.CalcInfo` instance
"""

"""Prepare calcinfo."""
self.logger.info("prepare_for_submission")

# These three lists are updated in self._create_additional_files(folder)
Expand All @@ -68,18 +69,22 @@ def prepare_for_submission(self, folder):
# ================= prepare the python input files =================

# BORN
if (not self.inputs.fc_only and
'nac_params' in self.inputs and
'primitive' in self.inputs and
'symmetry_tolerance' in self.inputs.settings.attributes):
if (
not self.inputs.fc_only
and "nac_params" in self.inputs
and "primitive" in self.inputs
):
born_txt = get_BORN_txt(
self.inputs.nac_params,
self.inputs.primitive,
self.inputs.settings['symmetry_tolerance'])
with folder.open(self._INPUT_NAC, 'w', encoding='utf8') as handle:
self.inputs.symmetry_tolerance,
)
with folder.open(self._INPUT_NAC, "w", encoding="utf8") as handle:
handle.write(born_txt)
for params in self._additional_cmd_params:
params.append('--nac')
params.append("--nac")

self.inputs.metadata.options.withmpi = False

# ============================ calcinfo ===============================

Expand All @@ -93,13 +98,13 @@ def prepare_for_submission(self, folder):
calcinfo.retrieve_list = self._internal_retrieve_list

calcinfo.codes_info = []
for i, (default_params, additional_params) in enumerate(zip(
self._calculation_cmd, self._additional_cmd_params)):
for i, (default_params, additional_params) in enumerate(
zip(self._calculation_cmd, self._additional_cmd_params)
):
codeinfo = CodeInfo()
codeinfo.cmdline_params = default_params + additional_params
cmdline_params = default_params + additional_params
codeinfo.cmdline_params = cmdline_params
codeinfo.code_uuid = self.inputs.code.uuid
codeinfo.stdout_name = "%s%d" % (
self.options.output_filename, i + 1)
codeinfo.withmpi = False
calcinfo.codes_info.append(codeinfo)

Expand Down
140 changes: 0 additions & 140 deletions aiida_phonopy/calcs/phono3py.py

This file was deleted.

0 comments on commit 32a8b95

Please sign in to comment.