Get started#

Requirements#

To work with aiida-phonopy, you should have:

  • installed aiida-core.

  • configured an AiiDA profile.

Please refer to the documentation of aiida-core for detailed instructions.

Installation#

The Python package can be installed from the Python Package Index (PyPI) or directly from the source:

The recommended method of installation is to use the Python package manager pip:

$ pip install aiida-phonopy

This will install the latest stable version that was released to the PyPI.

To install the package from source, first clone the repository and then install using pip:

$ git clone https://github.com/aiida-phonopy/aiida-phonopy
$ pip install -e aiida-phonopy

The -e flag will install the package in editable mode, meaning that changes to the source code will be automatically picked up.

Setup#

Computer#

To run Phonopy calculations on a compute resource, the computer should first be set up in AiiDA. This can be done from the command line interface (CLI) or the Python application programming interface (API). In this example, we will set up the localhost, the computer where AiiDA itself is running:

To set up a computer, use the verdi CLI of aiida-core.

$ verdi computer setup -n -L localhost -H localhost -T core.local -S core.direct -w $AIIDA_PATH/workdir

After creating the localhost computer, configure the core.local transport using:

$ verdi computer configure core.local localhost -n --safe-interval 0

Verify that the computer was properly setup by running:

$ verdi computer test localhost

To setup a computer using the Python API, run the following code in a Python script with verdi run or in the verdi shell:

from aiida.orm import Computer
from pathlib import Path

computer = Computer(
    label='localhost',
    hostname='localhost',
    transport_type='core.local',
    scheduler_type='core.direct',
    workdir=Path('$AIIDA_PATH/workdir').absolute().as_posix()
).store()
computer.configure()

For more detailed information, please refer to the documentation on setting up compute resources.

Note

The computer workdir is where AiiDA will run the calculations for codes set up for this computer. The commands above will set the workdir of the localhost computer in $AIIDA_PATH/workdir.

Code#

To run a Phonopy code, it should first be setup in AiiDA. This can be done from the command line interface (CLI) or the Python application programming interface (API). In this example, we will setup the phonopy code that is installed on the computer where AiiDA is running:

To setup a particular Phonopy code, use the verdi CLI of aiida-core.

$ verdi code create core.code.installed -n --computer localhost --label phonopy --default-calc-job-plugin phonopy.phonopy --filepath-executable $(which phonopy)

To set up the Phonopy code using the Python API, run the following code in a Python script with verdi run or in the verdi shell:

from aiida.orm import InstalledCode
import shutil

computer = load_computer('localhost')
code = InstalledCode(
    label='phonopy',
    computer=computer,
    filepath_executable=shutil.which('phonopy'),
    default_calc_job_plugin='phonopy.phonopy',
).store()

Important

The CLI command and Python script above will automatically find the first phonopy binary in your PATH directories using the which command:

which phonopy

If you have installed phonopy in a different python environment, make sure to pass the correct filepath to the executable and activate the environment correctly. The latter can be done by adding the required commands to the preprend_text of the code.

For more detailed information, please refer to the documentation on setting up codes.