Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
- add calcfunctions birch_murnaghan_fit and calculate_delta.
- add a eos workchain which has the similar framework as eos workchain in common
workflow package.
  • Loading branch information
unkcpz committed Oct 29, 2020
1 parent 1921868 commit f3ba1d9
Show file tree
Hide file tree
Showing 49 changed files with 2,137 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source=aiida_sssp_workflow
36 changes: 36 additions & 0 deletions .github/check_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Check that version numbers match.
Check version number in setup.json and aiida_sssp_workflow/__init__.py and make sure
they match.
"""
from __future__ import absolute_import
from __future__ import print_function
import os
import json
import sys

this_path = os.path.split(os.path.realpath(__file__))[0]

# Get content of setup.json
setup_fname = 'setup.json'
setup_path = os.path.join(this_path, os.pardir, setup_fname)
with open(setup_path) as f:
setup_content = json.load(f)

# Get version from python package
sys.path.insert(0, os.path.join(this_path, os.pardir))
import aiida_sssp_workflow # pylint: disable=wrong-import-position
version = aiida_sssp_workflow.__version__

if version != setup_content['version']:
print("Version number mismatch detected:")
print("Version number in '{}': {}".format(setup_fname,
setup_content['version']))
print("Version number in '{}/__init__.py': {}".format(
'aiida_sssp_workflow', version))
sys.exit(1)

# Overwrite version in setup.json
#setup_content['version'] = version
#with open(setup_path, 'w') as f:
# json.dump(setup_content, f, indent=4, sort_keys=True)
6 changes: 6 additions & 0 deletions .github/install_aiida_github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
git clone https://github.com/aiidateam/aiida_core ../aiida_core
cd ../aiida_core
git checkout $AIIDA_DEVELOP_GIT_HASH
pip install -e .[docs,pre-commit,testing]
cd ${TRAVIS_BUILD_DIR}
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: ci

on: [push, pull_request]

jobs:

tests:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [3.7]
backend: ['django']
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -
echo 'deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
echo 'deb https://dl.bintray.com/rabbitmq/debian bionic main' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install postgresql-10 rabbitmq-server graphviz
sudo systemctl status rabbitmq-server.service
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing]
reentry scan -r aiida
- name: Run test suite
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
run: py.test --cov aiida_sssp_workflow --cov-append .

docs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[docs]
reentry scan -r aiida
- name: Build docs
run: cd docs && make

pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
reentry scan -r aiida
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
40 changes: 40 additions & 0 deletions .github/workflows/publish-on-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish on PyPI

on:
push:
tags:
# After vMajor.Minor.Patch _anything_ is allowed (without "/") !
- v[0-9]+.[0-9]+.[0-9]+*

jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'aiidateam/aiida-sssp-workflow' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Upgrade setuptools and install package
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -e .
- name: Assert package version
env:
TAG_VERSION: ${{ github.ref }}
run: python ./.github/check_version.py

- name: Build source distribution
run: python ./setup.py sdist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.pyc
*.swo
*.swp
~*
*~
.project
*.egg*
.DS_Store
.coverage
.pytest_cache
.vscode
.idea/
build/
dist/
pip-wheel-metadata/
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Install pre-commit hooks via:
# pre-commit install

# yapf = yet another python formatter
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.28.0
hooks:
- id: yapf
name: yapf
args: ["-i"]

- repo: local
hooks:
# prospector: collection of linters
- id: prospector
language: system
types: [file, python]
name: prospector
description: "This hook runs Prospector: https://github.com/landscapeio/prospector"
entry: prospector

- id: version-number
name: Check version numbers
entry: python ./.github/check_version.py
language: system
files: '^(setup.json)|(aiida_sssp_workflow/__init__.py)'
9 changes: 9 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 The AiiDA Team.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include setup.json
include LICENSE
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ MIT
[email protected]

# aiida-sssp-workflow
# aiida-sssp-workflow
7 changes: 7 additions & 0 deletions aiida_sssp_workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
aiida_sssp_workflow
SSSP verification workflows
"""

__version__ = "0.1.0a0"
Empty file.
52 changes: 52 additions & 0 deletions aiida_sssp_workflow/calculations/birch_murnaghan_fit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
"""
Birch-Murnaghan fit as calcfunction refactor from eosfit.py v3.1 write by Kurt Lejaeghere
Copyright (C) 2012 Kurt Lejaeghere <[email protected]>, Center for
Molecular Modeling (CMM), Ghent University, Ghent, Belgium
"""
from aiida.engine import calcfunction
from aiida import orm

@calcfunction
def birch_murnaghan_fit(volume_energy: orm.Dict) -> orm.Dict:
import numpy as np

volumes = np.array(list(volume_energy['volumes'].values()))
energies = np.array(list(volume_energy['energies'].values()))
fitdata = np.polyfit(volumes ** (-2. / 3.), energies, 3, full=True)
ssr = fitdata[1]
sst = np.sum((energies - np.average(energies)) ** 2.)
residuals0 = ssr / sst
deriv0 = np.poly1d(fitdata[0])
deriv1 = np.polyder(deriv0, 1)
deriv2 = np.polyder(deriv1, 1)
deriv3 = np.polyder(deriv2, 1)

volume0 = 0
x = 0
for x in np.roots(deriv1):
if x > 0 and deriv2(x) > 0:
volume0 = x ** (-3. / 2.)
break

if volume0 == 0:
print('Error: No minimum could be found')
exit()

derivV2 = 4. / 9. * x ** 5. * deriv2(x)
derivV3 = (-20. / 9. * x ** (13. / 2.) * deriv2(x) -
8. / 27. * x ** (15. / 2.) * deriv3(x))
bulk_modulus0 = derivV2 / x ** (3. / 2.)
bulk_deriv0 = -1 - x ** (-3. / 2.) * derivV3 / derivV2

echarge = 1.60217733e-19
# TODO 'E0': minimum energy, per atom,
res = orm.Dict(dict={
'volume0': volume0,
'bulk_modulus0': bulk_modulus0 * echarge * 1.0e21,
'bulk_deriv0': bulk_deriv0,
'residuals0': residuals0[0],
'volume0_unit': 'A^3/atom',
'bulk_modulus0_unit': 'GPa',
})
return res
Loading

0 comments on commit f3ba1d9

Please sign in to comment.