Metadata-Version: 2.4
Name: aiida-cif2j
Version: 0.1.1
Summary: AiiDA workflow plugin for calculating magnetic exchange interactions.
Author-email: "Dr. Benjamin T. Speake" <benjamin.speake@stfc.ac.uk>
License: BSD 3-Clause License
        
        Copyright (c) 2026, UKRI Science and Technology Facilities Council
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Source, https://github.com/stfc/aiida-cif2j
Project-URL: Documentation, https://stfc.github.io/aiida-cif2j/
Project-URL: Issue Tracker, https://github.com/stfc/aiida-cif2j/issues
Keywords: aiida,magnetic exchange
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Framework :: AiiDA
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiida-core<3,>=2.7
Requires-Dist: pymatgen
Requires-Dist: click
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=6.0; extra == "dev"
Requires-Dist: pytest-xdist>=3.0; extra == "dev"
Requires-Dist: ruff>=0.11.0; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Provides-Extra: tb2j
Requires-Dist: TB2J~=0.9; extra == "tb2j"
Provides-Extra: docs
Requires-Dist: sphinx>=8.0.2; extra == "docs"
Requires-Dist: piccolo-theme>=0.14.0; extra == "docs"
Requires-Dist: sphinx-toolbox; extra == "docs"
Requires-Dist: numpydoc; extra == "docs"
Dynamic: license-file

# AiiDA CIF2J

[![Release](https://img.shields.io/github/v/release/stfc/aiida-cif2j)](https://github.com/stfc/aiida-cif2j/releases)
[![PyPI](https://img.shields.io/pypi/v/aiida-cif2j)](https://pypi.org/project/aiida-cif2j/)

[![Docs status](https://github.com/stfc/aiida-cif2j/actions/workflows/ci-docs.yml/badge.svg?branch=main)](https://stfc.github.io/aiida-cif2j/)
[![Pipeline Status](https://github.com/stfc/aiida-cif2j/actions/workflows/ci-testing.yml/badge.svg?branch=main)](https://github.com/stfc/aiida-cif2j/actions)
[![Coverage Status](https://coveralls.io/repos/github/stfc/aiida-cif2j/badge.svg?branch=main)](https://coveralls.io/github/stfc/aiida-cif2j?branch=main)

<!-- [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.18392782-blue.svg)](https://doi.org/10.5281/zenodo.18392782) -->

An [AiiDA](https://www.aiida.net) plugin for calculating magnetic exchange interactions.

## Installation

This plugin is available through PyPI and should be installed using [`pip`](https://pip.pypa.io/en/stable/) python package manager.

``` bash
pip install aiida-cif2j
```

### Optional: Wannier90 Workflows

This project exposes a WorkChain which will carry out the full process of calculating
Wannier functions for a structure which are then directly fed into TB2J. This requires
two third party packages, `aiida-wannier90` and `aiida-wannier90-workflows`. Neither is
currently released on PyPI, so they must be installed from their git repositories. This
plugin ships a CLI command to do this for you:

``` bash
cif2j wannier90 install
```

## Requirements

To use this plugin a configured AiiDA profile and computer are required, as well as a compiled
[`wann2J.py`](https://github.com/mailhexu/TB2J) executable (from TB2J). For more information on how to set
up AiiDA refer to the
[AiiDA documentation](https://aiida.readthedocs.io/projects/aiida-core/en/latest/intro/get_started.html).

### Setup

To configure the TB2J plugin you will need to create a new AiiDA code object. The following is an example
of a basic YAML configuration file for a TB2J code:

``` yaml
label: tb2j
description: Wannier90 -> TB2J
computer: localhost
filepath_executable: wann2J.py
default_calc_job_plugin: cif2j.wannier_tb2j
use_double_quotes: false
with_mpi: false
prepend_text: ""
append_text: ""
```

Write this to a file named `tb2j.yml` ensuring the value for `computer` matches the label of your computer
configured in the previous step. The code can then be configured by running:

``` bash
verdi code create core.code.installed --config tb2j.yml -n
```

If successful, this will create a new AiiDA code with the label `tb2j` which can then be used to run TB2J
calculations within the AiiDA framework.

> **NOTE**:
> The full Wannier90 -> TB2J workflow requires a `pw2wannier90.x` code and a `wannier90.x` code to be
> configured on the *same* AiiDA computer. AiiDA cannot copy the intermediate files that `wannier90.x` reads
> directly between two different remote machines, so running these two codes on different computers will
> cause the workflow to fail.

See the [documentation](https://stfc.github.io/aiida-cif2j/) for the full list of calculation inputs,
parameters and outputs, the higher level WorkChains, and complete runnable examples.

## Examples

The following submits the full Wannier90 -> TB2J workflow starting from an MCIF structure file: Quantum
ESPRESSO SCF and Wannierisation (via `aiida-wannier90-workflows`), followed directly by TB2J. This can be
run either from the command line:

``` bash
cif2j wannier90 submit structure.mcif \
    --pw-code qe-pw@localhost \
    --pw2wannier90-code qe-pw2wannier90@localhost \
    --wannier90-code wannier90@localhost \
    --tb2j-code tb2j@localhost \
    --pseudo-family SSSP/1.3/PBE/efficiency
```

or from a Python script / `verdi shell`:

``` python
from aiida.engine import run
from aiida.orm import SinglefileData
from aiida.plugins import WorkflowFactory

WannierTB2J = WorkflowFactory("cif2j.wannier_tb2j")

builder = WannierTB2J.get_builder_from_protocol(
    codes={
        "pw": "qe-pw@localhost",
        "pw2wannier90": "qe-pw2wannier90@localhost",
        "wannier90": "wannier90@localhost",
        "tb2j": "tb2j@localhost",
    },
    structure=SinglefileData(file="/absolute/path/to/structure.mcif"),
    pseudo_family="SSSP/1.3/PBE/efficiency",
)

results, node = run.get_node(builder)
```

Magnetic elements and the Fermi energy are auto-detected in both cases, so neither needs to be supplied
explicitly. See the [examples documentation](https://stfc.github.io/aiida-cif2j/examples.html) for more,
including running TB2J directly from existing Wannier90 outputs and fixing magnetic elements/TB2J
parameters explicitly.


## License

[BSD 3-Clause License](LICENSE)

## Funding

Contributors to this project were funded by;

<div align="center">
    <a href="https://adalovelacecentre.ac.uk/">
        <img src="images/alc.svg" alt="ALC Logo" style="width: 30%">
    </a>
</div>
