Skip to content

Commit

Permalink
Merge pull request #5 from addman2/aiida2
Browse files Browse the repository at this point in the history
Add support for AiiDA 2
  • Loading branch information
scemama authored May 29, 2024
2 parents 0308e30 + d2921d0 commit d0bb59e
Show file tree
Hide file tree
Showing 30 changed files with 5,054 additions and 89 deletions.
49 changes: 23 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jobs:
# run: |
# pip install --upgrade pip
# pip install -e .[testing]
# reentry scan -r aiida
#
# - name: Run test suite
# env:
Expand All @@ -54,30 +53,29 @@ jobs:
#
# run: py.test --cov qp2 --cov-append .

docs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install --force-reinstall MarkupSafe==2.0.1
pip install -e .[docs]
reentry scan -r aiida
- name: Build docs
run: cd docs && make
- name: Add nojekyll file
run: touch docs/build/html/.nojekyll
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build/html
# docs:
# runs-on: ubuntu-latest
# timeout-minutes: 15
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python 3.8
# uses: actions/setup-python@v2
# with:
# python-version: 3.8
# - name: Install python dependencies
# run: |
# pip install --upgrade pip
# pip install --force-reinstall MarkupSafe==2.0.1
# pip install -e .[docs]
# - name: Build docs
# run: cd docs && make
# - name: Add nojekyll file
# run: touch docs/build/html/.nojekyll
# - name: Deploy
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./docs/build/html

pre-commit:
runs-on: ubuntu-latest
Expand All @@ -92,7 +90,6 @@ jobs:
run: |
pip install --upgrade pip
pip install -e .[pre-commit,docs,testing]
reentry scan -r aiida
- name: Run pre-commit
run: |
pre-commit install
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
*.swp
~*
*~
.project
*.egg*
.DS_Store
.coverage
.DS_Store
.project
.pytest_cache
.vscode
build/
configs/
dist/
pip-wheel-metadata/
examples/*.pdf
pip-wheel-metadata/
170 changes: 115 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,142 @@
[![Build Status](https://github.com/TREX-CoE/aiida-qp2/workflows/ci/badge.svg?branch=master)](https://github.com/TREX-CoE/aiida-qp2/actions)
[![PyPI version](https://badge.fury.io/py/aiida-qp2.svg)](https://badge.fury.io/py/aiida-qp2)

# aiida-qp2
# AiiDA-qp2

AiiDA plugin for [Quantum Package 2.0](https://github.com/QuantumPackage/qp2) (QP2).
## Installation

This is a brief installation guide fo aiida-qp2. First one needs to setup properly `aiida` it should be installed when package is installed. Also RabbitMQ is importat to run `aiida`.

This plugin is the modified output of the
[AiiDA plugin cutter](https://github.com/aiidateam/aiida-plugin-cutter),
intended to help developers get started with their AiiDA plugins.
```
# It is better to run it in some kind of virtual environment.
$ pip install aiida-qp2
```

## Repository contents
Command line code completion with `TAB` is very usefull, dont hesitate to activate it and use it:

* [`aiida_qp2/`](aiida_qp2/): The main source code of the plugin package
* [`calculations.py`](aiida_qp2/calculations.py): A new `QP2Calculation` `CalcJob` class
* [`parsers.py`](aiida_qp2/parsers.py): A new `Parser` for the `QP2Calculation`
* [`docs/`](docs/): A documentation template. The [ReadTheDocs documentation](https://trex-coe.github.io/aiida-qp2/) is built and deployed on the `gh-pages` branch.
* [`examples/`](examples/): Examples of how to submit a calculation using this plugin
* [`LICENSE`](LICENSE): License for your plugin
* [`MANIFEST.in`](MANIFEST.in): Configure non-Python files to be included for publication on [PyPI](https://pypi.org/)
* [`README.md`](README.md): This file
* [`setup.json`](setup.json): Plugin metadata for registration on [PyPI](https://pypi.org/) and the [AiiDA plugin registry](https://aiidateam.github.io/aiida-registry/) (including entry points)
* [`setup.py`](setup.py): Installation script for pip / [PyPI](https://pypi.org/)
* [`.pre-commit-config.yaml`](.pre-commit-config.yaml): Configuration of [pre-commit hooks](https://pre-commit.com/) that sanitize coding style and check for syntax errors. Enable via `pip install -e .[pre-commit] && pre-commit install`
* [`.github/`](.github/): [Github Actions](https://github.com/features/actions) configuration
* [`ci.yml`](.github/workflows/ci.yml): runs tests and builds documentation at every new commit
* [`publish-on-pypi.yml`](.github/workflows/publish-on-pypi.yml): automatically deploy git tags to PyPI
```
eval "$(_VERDI_COMPLETE=bash_source verdi)"
```

### AiiDA profile

## Features
First we need to setup profile. One can use `postgreSQL` as a db backend but for simplicity we will show you SQLite setup:

* Initialize a wave function file (EZFIO) based on `StructureData` instance and `qp_create_ezfio` dictionary.
This step can optionally use `BasisSet` and/or `Pseudopotential` nodes produced by the
[`aiida-gaussian-datatypes`](https://github.com/addman2/aiida-gaussian-datatypes/tree/development_trvb) plugin.
* Run calculations (e.g. HF, CIPSI) in a given order according to the `qp_commands` list. Some pre- or post-processing (e.g. `shell` scripting) is also possible by providing a list of commands in `qp_prepend` or `qp_append` keys of the `parameters` Dict, respectively.
* Export TREXIO file from the QP-native EZFIO format.
```
$ verdi profile setup core.sqlite_dos
```

You will be promted some questions but answering them is very easy. Setting up PostgreSQL more challenging, however, it is recomended for larger projects.

## Installation
### AiiDA computer

```shell
pip install aiida-qp2
verdi quicksetup # better to set up a new profile
verdi plugin list aiida.calculations # should now show your calclulation plugins
Now you need to specify computer where you want to run your calculations. Here is the setup for your local computer. First setup a `yaml` file with setting called `localhost.yaml` and then setup the code.

```
$ cat > localhost.yaml
---
label: "localhost"
hostname: "localhost"
transport: "core.local"
scheduler: "core.direct"
work_dir: "/var/tmp/aiida"
use_double_quotes: true
mpirun_command: "mpirun -np {tot_num_mpiprocs}"
mpiprocs_per_machine: "8"
prepend_text: " "
append_text: " "
$ verdi computer setup --config localhost.yaml
```

## Usage
One can test the computer via `verdi computer test <label>`.

### AiiDA code

Lastly we need to setup the code. Again to do the most simple setup one can pull docker image from docker hub.

```
$ docker pull docker://addman151/qp2-aiida:tagname
See [`Demo-aiida-qp.md`](examples/Demo-aiida-qp.md) and `.py` files in the [`examples/`](examples/) directory.
# you can use tagname:latest - for serial qmcchem
# or you can use tagname:intel - for parallel
```

For instance, the `example_trexio_from_xyz.py` is the 3-step workflow using the plugin.
Unfortunatelly, the image is litle bit large, something what has to be fix in the future. When the image is downloaded we can continue by creating new code node inside AiiDA. Again we will use an yaml file.

```shell
verdi daemon start # make sure the daemon is running
cd examples
python example_trexio_from_xyz.py # prepare and submit the calculation
verdi process list -a # check record of calculation
```
$ cat > qp.yaml
engine_command: "docker run -v $(pwd):/data {image_name}"
wrap_cmdline_params: false
use_double_quotes: false
image_name: 'qp2-aiida'
label: 'qp2-docker'
description: 'quantum package 2'
default_calc_job_plugin:
- 'qp2.create'
- 'qp2.run'
filepath_executable: '/bin/entrypoint.sh'
computer: 'localhost'
prepend_text: ' '
append_text: ' '
$ verdi code create core.code.containerized --config qp.yaml
```

1. Create the EZFIO wave function file from the `hcn.xyz` file using a given basis set.
2. Run SCF calculation using the previously created wave function and parse the output file looking for the Hartree-Fock energy.
3. Export TREXIO wave function file by converting EZFIO format using `TREXIO_TEXT` back end.
Now run `verdi status` and you should not see any error messages:
```
✔ version: AiiDA v2.5.1
✔ config: /home/.../.aiida
✔ profile: profile
✔ storage: SqliteDosStorage[...]: open,
✔ rabbitmq: Connected to RabbitMQ v3.8.9 as amqp://guest:guest@...
```

## Running AiiDA qp2

## Development
N.B.: One can execute console script either through `verdi data qp2.cli` command or with a shortcut `aqp`

```shell
git clone https://github.com/TREX-CoE/aiida-qp2 .
cd aiida-qp2
pip install -e .[pre-commit] # install extra dependencies
pre-commit install # install pre-commit hooks
```
echo "2
## License
H 0.0 0.0 0.0
H 0.7 0.0 0.0" > H2.xyz
MIT
verdi data qp2.cli create Hydrogen2 --code qp2-docker@localhost --structure H2.xyz
# Or equivalent with:
# aqp create --code qp2-docker@localhost --structure H2.xyz
## Contact
verdi data qp2.cli list # Find pk of your project
[email protected]
verdi data qp2.cli activate <pk> # preplace by pk
[email protected]
verdi data qp2.cli run scf # Finally running HF calculation
verdi data qp2.cli show # Look at the results
```

I wrote these command from head hopefully there are no mistakes.

## Running QMC=Chem

Pull `QMC=Chem` docker image

```
docker pull docker://addman151/qmcchem-aiida
```

You can install this code in the same way how the qp code was installed. In fact this image contain also `qp` so you can you this image also for previous calculations.

Recomended workflow follows:

```
aqp run save_for_qmcchem --trexio-bug-fix
```

The option `--trexio-bug-fix` is there because there is a bug where one has to manually put absolute path to the trexio file. This flag will fix it.

Now run `QMC=Chem`:

```
aqp run qmcchem -p "-t 1800" -p "-l 20"
```
82 changes: 82 additions & 0 deletions README.md.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[![Build Status](https://github.com/TREX-CoE/aiida-qp2/workflows/ci/badge.svg?branch=master)](https://github.com/TREX-CoE/aiida-qp2/actions)
[![PyPI version](https://badge.fury.io/py/aiida-qp2.svg)](https://badge.fury.io/py/aiida-qp2)

# aiida-qp2

AiiDA plugin for [Quantum Package 2.0](https://github.com/QuantumPackage/qp2) (QP2).

This plugin is the modified output of the
[AiiDA plugin cutter](https://github.com/aiidateam/aiida-plugin-cutter),
intended to help developers get started with their AiiDA plugins.

## Repository contents

* [`aiida_qp2/`](aiida_qp2/): The main source code of the plugin package
* [`calculations.py`](aiida_qp2/calculations.py): A new `QP2Calculation` `CalcJob` class
* [`parsers.py`](aiida_qp2/parsers.py): A new `Parser` for the `QP2Calculation`
* [`docs/`](docs/): A documentation template. The [ReadTheDocs documentation](https://trex-coe.github.io/aiida-qp2/) is built and deployed on the `gh-pages` branch.
* [`examples/`](examples/): Examples of how to submit a calculation using this plugin
* [`LICENSE`](LICENSE): License for your plugin
* [`MANIFEST.in`](MANIFEST.in): Configure non-Python files to be included for publication on [PyPI](https://pypi.org/)
* [`README.md`](README.md): This file
* [`setup.json`](setup.json): Plugin metadata for registration on [PyPI](https://pypi.org/) and the [AiiDA plugin registry](https://aiidateam.github.io/aiida-registry/) (including entry points)
* [`setup.py`](setup.py): Installation script for pip / [PyPI](https://pypi.org/)
* [`.pre-commit-config.yaml`](.pre-commit-config.yaml): Configuration of [pre-commit hooks](https://pre-commit.com/) that sanitize coding style and check for syntax errors. Enable via `pip install -e .[pre-commit] && pre-commit install`
* [`.github/`](.github/): [Github Actions](https://github.com/features/actions) configuration
* [`ci.yml`](.github/workflows/ci.yml): runs tests and builds documentation at every new commit
* [`publish-on-pypi.yml`](.github/workflows/publish-on-pypi.yml): automatically deploy git tags to PyPI


## Features

* Initialize a wave function file (EZFIO) based on `StructureData` instance and `qp_create_ezfio` dictionary.
This step can optionally use `BasisSet` and/or `Pseudopotential` nodes produced by the
[`aiida-gaussian-datatypes`](https://github.com/addman2/aiida-gaussian-datatypes/tree/development_trvb) plugin.
* Run calculations (e.g. HF, CIPSI) in a given order according to the `qp_commands` list. Some pre- or post-processing (e.g. `shell` scripting) is also possible by providing a list of commands in `qp_prepend` or `qp_append` keys of the `parameters` Dict, respectively.
* Export TREXIO file from the QP-native EZFIO format.


## Installation

```shell
pip install aiida-qp2
verdi quicksetup # better to set up a new profile
verdi plugin list aiida.calculations # should now show your calclulation plugins
```

## Usage

See [`Demo-aiida-qp.md`](examples/Demo-aiida-qp.md) and `.py` files in the [`examples/`](examples/) directory.

For instance, the `example_trexio_from_xyz.py` is the 3-step workflow using the plugin.

```shell
verdi daemon start # make sure the daemon is running
cd examples
python example_trexio_from_xyz.py # prepare and submit the calculation
verdi process list -a # check record of calculation
```

1. Create the EZFIO wave function file from the `hcn.xyz` file using a given basis set.
2. Run SCF calculation using the previously created wave function and parse the output file looking for the Hartree-Fock energy.
3. Export TREXIO wave function file by converting EZFIO format using `TREXIO_TEXT` back end.


## Development

```shell
git clone https://github.com/TREX-CoE/aiida-qp2 .
cd aiida-qp2
pip install -e .[pre-commit] # install extra dependencies
pre-commit install # install pre-commit hooks
```

## License

MIT

## Contact

[email protected]

[email protected]
Loading

0 comments on commit d0bb59e

Please sign in to comment.