Phonopy and ASE Tutorial#

In this tutorial you will learn how to run an automated calculation of phonons by calculating the forces using ASE.

We will use the aiida_phonopy.workflows.ase.PhonopyAseWorkChain, which is based on aiida_pythonjob. This workflow takes care of:

  • Pre-processing: generating the (supercell) structures with displacements on top of which computing forces (for frozen phonons)

  • Gather all information in PhonopyData, ready to be post-processed

  • (optional) Post-process: calculate phonon-related properties, such as phonon band structure and (P)DOS, thermal properties, and so on by using PhonopyCalculation.

In this tutorial we will make use of the silicon structure to give you an overall understanding of the usage.

Let’s get started!

from local_module import load_temp_profile
from aiida.plugins import DataFactory, WorkflowFactory

# If you download this file, you can run it with your own profile.
# Put these lines instead:
# from aiida import load_profile
# load_profile()
load_temp_profile(
    name="ase-tutorial",
    add_computer=True,
    add_phonopy_code=True,
)

StructureData = DataFactory("core.structure")
PhonopyAseWorkChain = WorkflowFactory("phonopy.ase")
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:64: AiidaDeprecationWarning: The `Code` class is deprecated. To create an instance, use the `aiida.orm.nodes.data.code.installed.InstalledCode` or `aiida.orm.nodes.data.code.portable.PortableCode` for a "remote" or "local" code, respectively. If you are using this class to compare type, e.g. in `isinstance`, use `aiida.orm.nodes.data.code.abstract.AbstractCode`. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:77: AiidaDeprecationWarning: The `Code` plugin is deprecated, use the `InstalledCode` (`core.code.remote`) instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:487: AiidaDeprecationWarning: `Code.set_remote_computer_exec` method is deprecated, use `InstalledCode`. (this will be removed in v3)
  warn_deprecation('`Code.set_remote_computer_exec` method is deprecated, use `InstalledCode`.', version=3)
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:556: AiidaDeprecationWarning: `Code.is_local` method is deprecated, use a `PortableCode` instance and check the type. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:517: AiidaDeprecationWarning: `Code.get_remote_computer` method is deprecated, use the `computer` attribute instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:507: AiidaDeprecationWarning: `Code.get_remote_exec_path` method is deprecated, use `InstalledCode.filepath_executable` instead. (this will be removed in v3)
  warn_deprecation(

Let’s define the alumin structure using the ASE module

from ase.build import bulk

atoms = bulk("Al", a=1.5456658) # Note: this is NOT the experimental lattice constant, but the good value for the force field used in the tutorial
structure = StructureData(ase=atoms)
If you have your own structure, e.g., in .cif or .xyz format, you can simply use the followig snippet#
from ase.io import read

atoms = read("/path/to/file.cif") # here, any format supported by ASE
structure = StructureData(ase=atoms)

Automated calculation via PhonopyAseWorkChain#

We now want to choose an ASE calculator that we want to give to the workchain, so that it will compute with it all the forces on all the displaced structures. The calculation will be performed automatically by the PhonopyAseWorkChain, which will give us a PhonopyData as output that stores all the displacements and forces needed to compute phonons-related properties.

The calculator can be:

  • a simple empirical forces field, like a Lenard-Jones potential (presented in this example)

  • a DFT calculator (e.g., Quantum ESPRESSO, VASP, Abinit, and so on, interfaced by ASE)

  • a pre-trained machine-learning potential (e.g., NequIP, Allegro, MACE, MatterSim, GAP, FLARE, and so on, interfaced with ASE)

These should be installed and able to run on your machine or on a remote cluster.

from ase.calculators.lj import LennardJones
from aiida.orm import Dict, load_code
from aiida.engine import run_get_node

inputs = PhonopyAseWorkChain.get_populated_builder(
    structure=structure,
    calculator=LennardJones(),
    max_number_of_atoms=200,
    pythonjob_inputs={"computer": "local_direct"},
    phonopy_inputs={
        "code": load_code("phonopy@local_direct"),
        "parameters": Dict({"band":"auto"})
    },
)

results, node = run_get_node(PhonopyAseWorkChain, **inputs)
05/04/2026 04:39:29 PM <906> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [10|PhonopyAseWorkChain|run_forces]: submitting `PythonJob` <PK=16> with supercell n.o 1
05/04/2026 04:39:34 PM <906> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [10|PhonopyAseWorkChain|run_phonopy]: submitting `PhonopyCalculation` <PK=25>
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:556: AiidaDeprecationWarning: `Code.is_local` method is deprecated, use a `PortableCode` instance and check the type. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:517: AiidaDeprecationWarning: `Code.get_remote_computer` method is deprecated, use the `computer` attribute instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:556: AiidaDeprecationWarning: `Code.is_local` method is deprecated, use a `PortableCode` instance and check the type. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/aiida/orm/nodes/data/code/legacy.py:507: AiidaDeprecationWarning: `Code.get_remote_exec_path` method is deprecated, use `InstalledCode.filepath_executable` instead. (this will be removed in v3)
  warn_deprecation(
05/04/2026 04:39:39 PM <906> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [10|PhonopyAseWorkChain|inspect_phonopy]: WARNING: no force constants in output
05/04/2026 04:39:39 PM <906> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [10|PhonopyAseWorkChain|on_terminated]: remote folders will not be cleaned
results['output_phonopy']['phonon_bands'].show_mpl()
_images/7294877e30a47c63fb1feb833841fa410a74924f7836367f038e63fbe1ae79e7.png

Manual post-processing#

You can still of course use the output PhonopyData to get a Phonopy instance, allowing you to directly post-process the data locally.

ph = node.outputs.phonopy_data.get_phonopy_instance()
ph.produce_force_constants()
ph.auto_band_structure(plot=True)
<module 'matplotlib.pyplot' from '/home/docs/checkouts/readthedocs.org/user_builds/aiida-phonopy/envs/latest/lib/python3.10/site-packages/matplotlib/pyplot.py'>
_images/2e21f689f1c42ed84d0db25fa6c7fd7bc2da458c5c3d855a1b16c241cc09120b.png