ph.x#

The ph.x code of Quantum ESPRESSO is used to compute phonons using density-functional perturbation theory.

Plugin class

aiida_quantumespresso.calculations.ph.PhCalculation

Plugin entry point

quantumespresso.ph

How to launch a ph.x calculation#

Note

In order to run a ph.x calculation, you first need to have completed a pw.x calculation. See the tutorial or how-to guide for more information.

Once you have successfully run a PwCalculation you can run a ph.x calculation through the PhCalculation plugin as follows:

#!/usr/bin/env runaiida
# -*- coding: utf-8 -*-
from aiida.engine import run
from aiida.orm import Dict, KpointsData, StructureData, load_code, load_group

# Load the code configured for ``ph.x``. Make sure to replace this string
# with the label of a ``Code`` that you configured in your profile.
code = load_code('ph@localhost')
builder = code.get_builder()

# Replace ``IDENTIFIER_PW_CALCULATION`` with the pk of the completed ``PwCalculation``
builder.parent_folder = load_code(IDENTIFIER_PW_CALCULATION).outputs.remote_folder
builder.parameters = Dict({'INPUTPH': {}})

# Generate a 1x1x1 q-point mesh
qpoints = KpointsData()
qpoints.set_kpoints_mesh([1, 1, 1])
builder.qpoints = qpoints

# Run the calculation on 1 CPU and kill it if it runs longer than 1800 seconds.
# Set ``withmpi`` to ``False`` if ``ph.x`` was compiled without MPI support.
builder.metadata.options = {
    'resources': {
        'num_machines': 1,
    },
    'max_wallclock_seconds': 1800,
    'withmpi': False,
}

results, node = run.get_node(builder)
print(f'Calculation: {node.process_class}<{node.pk}> {node.process_state.value} [{node.exit_status}]')
print(f'Results: {results}')
assert node.is_finished_ok, f'{node} failed: [{node.exit_status}] {node.exit_message}'

Note that you will have to replace IDENTIFIER_PW_CALCULATION with the identifier (pk or UUID) of the completed PwCalculation.

How to define input file parameters#

The ph.x code supports many parameters that can be defined through the input file, as shown on the official documentation. Parameters that are part of the INPUTPH card should be specified through the parameters input of the PwCalculation plugin. The parameters are specified using a Python dictionary, for example:

parameters = {
    'INPUTPH': {
        'tr2_ph' : 1.0e-8,
        'epsil' : True,
        'ldisp' : True,
    }
}

The parameters dictionary should be wrapped in a Dict node and assigned to the parameters input of the process builder:

from aiida.orm import Dict, load_code
builder = load_code('ph').get_builder()
parameters = {
    ...
}
builder.parameters = Dict(parameters)

The q-points of the input file are specified with a KpointsData node through the qpoints input of the PhCalculation plugin.

Warning

There are a number of input parameters that cannot be set, as they will be automatically set by the plugin based on other inputs, such as the structure. These include:

  • INPUTPH.outdir

  • INPUTPH.verbosity

  • INPUTPH.prefix

  • INPUTPH.fildyn

  • INPUTPH.ldisp

  • INPUTPH.nq1

  • INPUTPH.nq2

  • INPUTPH.nq3

  • INPUTPH.qplot