Computing Hubbard parameters#

In this tutorial you will learn how to calculate the Hubbard parameters step by step using aiida-hubbard.

We can divide this goal in three phases:

  • Define the manifolds: define the target Hubbard manifolds via the HubbardStructureData

  • SCF ground-state: calculate the ground-state using the PwBaseWorkChain

  • DFPT calculation: use the HpBaseWorkChain to do a self-consistent perturbation calculation to predict the Hubbard parameters.

In this tutorial we will make use of the silicon structure to give you an overall understanding of the usage of the package. If you are interested in more advanced features, please have a look at the next tutorial or to the how tos.

Let’s get started!

Defining the target manifold through the HubbardStructureData#

The Hubbard correction is a corrective term that is added to the Hamiltonian of a system which suffers from great self-interaction errors. This is usually the case for transition metals on their d manifolds. An extra correction to account for the hybridization can be accounted for with the ligands, typically belonging to the p element group. Such interaction needs to be localized in space. This is the reason why we need to define the projectors. Quantum ESPRESSO allows you to define different type of projections \(| \phi^I_m \rangle\) (\(m\) orbital quantum number, \(I\) atom in cell). Currently, the ortho-atomic projectors are the most accurate ones implemented.

Still, we need to ask the program on which atoms \(I\) and which manifolds \(m\) to project and correct for this self-interaction.

Since manifolds and atoms belong to the structure, then you need to definet them together as an HubbardStructureData.

In the following, we take LiCoO2 as example, and we suppose we want to target the 3d orbitals of cobalt and the intersite interaction between 2p of oxygen and 3d of cobalt.

Note

By default we set ortho-atomic projectors and we use the Dudarev formulation.

Hide code cell content

from local_module import load_temp_profile

# If you download this file, you can run it with your own profile.
# Put these lines instead:
# from aiida import load_profile
# load_profile()
data = load_temp_profile(
    name="hubbard-base-tutorial",
    add_computer=True,
    add_pw_code=True,
    add_hp_code=True,
    add_sssp=True,
)
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:406: AiidaDeprecationWarning: `Code.set_input_plugin_name` method is deprecated, use the `default_calc_job_plugin` property instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:388: AiidaDeprecationWarning: `Code.set_prepend_text` method is deprecated, use the `prepend_text` property instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:406: AiidaDeprecationWarning: `Code.set_input_plugin_name` method is deprecated, use the `default_calc_job_plugin` property instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/site-packages/aiida/orm/nodes/data/code/legacy.py:388: AiidaDeprecationWarning: `Code.set_prepend_text` method is deprecated, use the `prepend_text` property instead. (this will be removed in v3)
  warn_deprecation(
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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(
Report: downloading patch versions information... 
 [OK]
Report: downloading selected pseudopotentials archive... 
 [OK]
Report: downloading selected pseudopotentials metadata... 
 [OK]

Let’s define the HubbardStructureData:

from aiida_quantumespresso.data.hubbard_structure import HubbardStructureData

a, b, c, d = 1.40803, 0.81293, 4.68453, 1.62585
cell = [[a, -b, c], [0.0, d, c], [-a, -b, c]]
sites = [
    ['Co', 'Co', (0, 0, 0)],
    ['O',   'O', (0, 0, 3.6608)], 
    ['O',   'O', (0, 0, 10.392)], 
    ['Li', 'Li', (0, 0, 7.0268)],
]
hubbard_structure = HubbardStructureData(cell=cell, sites=sites)
hubbard_structure.initialize_onsites_hubbard("Co", "3d")
hubbard_structure.initialize_intersites_hubbard("Co", "3d", "O", "2p")
hubbard_structure.store()
<HubbardStructureData: uuid: e7f67116-a0d2-476c-a35b-265691ed6b3c (pk: 106)>

Let’s visualize what will be print in the Hubbard card of Quantum ESPRESSO.

from aiida_quantumespresso.utils.hubbard import HubbardUtils
print(HubbardUtils(hubbard_structure).get_hubbard_card())
HUBBARD	ortho-atomic
 V	Co-3d	Co-3d	1	1	1e-08
 V	Co-3d	O-2p	1	46	1e-08

As you can see, the desired interactions have been initialized correctly. This is important because hp.x needs to know which atoms need to be perturbed. As you will see later, hp.x will take care of adding the remaining interactions with neighbouring atoms.

Important

When you use your own structures, make sure to have your ‘Hubbard atoms’ first in the list of atoms. This is due to the way the hp.x routine works internally, requiring those to be first. You can simply do this with the following snippet (IF THE NODE IS YET NOT STORED!):

from aiida_quantumespresso.utils.hubbard import HubbardUtils
HubbardUtils(hubbard_structure).reorder_atoms

Calculating the SCF ground-state#

Now that we have defined the structure, we can calculate its ground-state via an SCF using the PwBaseWorkChain. We can fill the inputs of the builder of the PwBaseWorkChain through the get_builder_from_protocol() method.

from aiida.engine import run_get_node
from aiida.orm import KpointsData
from aiida_quantumespresso.workflows.pw.base import PwBaseWorkChain
from aiida_quantumespresso.common.types import ElectronicType
kpoints = KpointsData()
kpoints.set_kpoints_mesh([1,1,1])

builder = PwBaseWorkChain.get_builder_from_protocol(
    code=data.pw_code, # modify here if you downloaded the notebook
    structure=hubbard_structure,
    protocol="fast",
    electronic_type=ElectronicType.INSULATOR,
    overrides={"kpoints":kpoints, "clean_workdir":False}
)
results, pw_node = run_get_node(builder)
results

Hide code cell output

12/19/2025 04:19:54 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [112|PwBaseWorkChain|run_process]: launching PwCalculation<115> iteration #1
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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(
12/19/2025 04:20:16 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [112|PwBaseWorkChain|results]: work chain completed after 1 iterations
12/19/2025 04:20:16 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [112|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
{'remote_folder': <RemoteData: uuid: f6b33ab7-f38c-4ee2-b0a8-d7ee3323e618 (pk: 116)>,
 'retrieved': <FolderData: uuid: b219cb34-a500-490a-9c88-e3fca6d5d5d7 (pk: 117)>,
 'output_parameters': <Dict: uuid: d5806ec4-155d-4dfc-b964-98fd553724e9 (pk: 120)>,
 'output_trajectory': <TrajectoryData: uuid: f63d0ba7-f458-4894-bc1f-78fdb1ceafe2 (pk: 119)>,
 'output_band': <BandsData: uuid: 82b308a6-e8aa-4694-8d72-521041e32e03 (pk: 118)>}

As you can notice from the results, the workchain (actually, the PwCalculation!) has a remote_folder output. This is what we need in order to run the HpBaseWorkChain.

DFPT calculation of Hubbard parameters#

We can perturb the ground-state previously found to compute the Hubbard parameters. Here we will need to use the HpBaseWorkChain, and link the remote_folder previously produced via the parent_scf input.

from aiida.orm import Dict
from aiida_hubbard.workflows.hp.base import HpBaseWorkChain

qpoints = KpointsData()
qpoints.set_kpoints_mesh([1,1,1])

builder = HpBaseWorkChain.get_builder()
builder.hp.code = data.hp_code
builder.hp.hubbard_structure = data.structure
builder.hp.parameters = Dict({"INPUTHP":{"conv_thr_chi": 1e-4}})
builder.hp.qpoints = qpoints
builder.hp.parent_scf = pw_node.outputs.remote_folder

Or via the get_builder_from_protocol:

from aiida_hubbard.workflows.hp.base import HpBaseWorkChain

builder = HpBaseWorkChain.get_builder_from_protocol(
    code=data.hp_code, # modify here if you downloaded the notebook
    protocol="fast",
    parent_scf_folder=pw_node.outputs.remote_folder,
    overrides={'hp':{'hubbard_structure':hubbard_structure}},
)

results, hp_node = run_get_node(builder)
results

Hide code cell output

12/19/2025 04:20:16 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [127|HpBaseWorkChain|run_process]: launching HpCalculation<130> iteration #1
/home/docs/checkouts/readthedocs.org/user_builds/aiida-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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-hubbard/conda/stable/lib/python3.9/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(
12/19/2025 04:20:44 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [127|HpBaseWorkChain|results]: work chain completed after 1 iterations
12/19/2025 04:20:45 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [127|HpBaseWorkChain|on_terminated]: cleaned remote folders of calculations: 130
12/19/2025 04:20:45 PM <3122> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [127|HpBaseWorkChain|on_terminated]: cleaned remote folders of calculations: 130
{'remote_folder': <RemoteData: uuid: 02fb0823-06f5-434b-8d9c-a4c98e7d997f (pk: 131)>,
 'retrieved': <FolderData: uuid: 284476b5-a9d7-409b-a063-cee13c2fbe7e (pk: 132)>,
 'parameters': <Dict: uuid: 2b19772e-d8e2-4b89-9ba3-a08c57250450 (pk: 133)>,
 'hubbard_structure': <HubbardStructureData: uuid: a184f223-bbe1-439d-8a52-7061ba64e8ad (pk: 137)>,
 'hubbard': <Dict: uuid: 62c17d22-da25-48e6-9689-4f8a7e665d02 (pk: 134)>,
 'hubbard_chi': <ArrayData: uuid: bbe58e6d-1c1c-433e-982c-587c0fe086b0 (pk: 136)>,
 'hubbard_matrices': <ArrayData: uuid: 0c7af547-d6f6-4bce-9c3d-78a822857567 (pk: 135)>}

🚀 Let’s inspect the results!

print(HubbardUtils(results['hubbard_structure']).get_hubbard_card())
HUBBARD	ortho-atomic
 V	Co-3d	Co-3d	1	1	9.8969
 V	Co-3d	O-2p	1	11	3.3429
 V	Co-3d	O-2p	1	22	3.3407

Final considerations#

We managed to compute the Hubbard parameters of LiCoO2 fully ab initio! 🎉 However, we had to execute quite a few steps manually, which can be tedious and error prone. Moreover, there are the following considerations:

  1. For larger and more complex structures you will need to perturb many more atoms. Moreover, to get converged results you will need more than one q point. Click here to learn how to parallelize over atoms and q points.

  2. To do a full self-consistent calculation of these parameters, you should relax your structure with the Hubbard parameters from the hp.x run, repeat the steps of this tutorial, relax again, and do this procedure over and over till convergence. Learn the automated way here!

Learn more and in details

To learn the full sets of inputs, to use proficiently the get_builder_from_protocol and more, have a look at the following sections:

Note

We suggest to proceed first with the tutorial for point (1) and then the one for point (2). Nevertheless, tutorial (1) is not strictly necessary for (2).