Computing Hubbard parameters self-consistently

Computing Hubbard parameters self-consistently#

In this tutorial you will learn how to compute iteratively the Hubbard parameters through the SelfConsistentHubbardWorkChain.

Hide code cell content

from local_module import load_temp_profile
from aiida_quantumespresso.data.hubbard_structure import HubbardStructureData

# 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-selfconsistent-tutorial",
    add_computer=True,
    add_pw_code=True,
    add_hp_code=True,
    add_sssp=True,
)

# We initialize only the U, so that `hp.x` will understand it
# needs to compute only the onsite parameters.
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.store()
<HubbardStructureData: uuid: fe746b58-11be-4f89-8f6a-cad9ea32e2c7 (pk: 106)>

The cycle#

To have a full ab-initio calculation of Hubbard parameters, an iterative procedure should be employed. This forsees the following steps, to do in a cyclic way till the parameters don’t differ from the previous ones by a certain threshold, i.e. self-consistently.

The steps to do in order are:

  1. Perform a volume relaxation of the structure, starting from a zero value of Hubbard parameters (i.e. if it was a ‘non-Hubbard’ calculation).

  2. Perform the ground-state calculation (SCF) of the relaxed structure.

  3. Perform the linear response calculation to predict the new Hubbard values.

  4. If all U (and V) are within the desired threshold, stop, otherwise restart with the new values from (1).

Note for SCF (step 2)

Tipically, as these are electronic responses, the gound-state SCF can be performed with looser energy cutoffs and k poit density, and still retain the same accuracy on the prediction of Hubbard parameters.

Important

Before any production run, you should make sure to have converged such parameters.

Note for thresholds

Threshold for U and V may depend on the final goal, or property, of your research. From our experience, good values are of the order of 0.1 eV for the onsite parameters (U) and 0.01 eV for the intersites (V).

Automating the cycle#

As we already learnt from the previous tutorials (1,2), we can simply fill the builder of the work chain using the get_builder_from_protocol to get to know what the workflow is doing, and how this can help and speed up our research.

Warning

In this tutorial we will compute only the U on Co, and not the V for Co-O. This is to speed up the simulation, which on only a handful of cores would take tens of minutes, if not more.

This workflow may take 5 minutes (or more) to complete depending on your local resources.

from aiida.engine import run_get_node
from aiida_hubbard.workflows.hubbard import SelfConsistentHubbardWorkChain

builder = SelfConsistentHubbardWorkChain.get_builder_from_protocol(
    pw_code=data.pw_code, 
    hp_code=data.hp_code, 
    hubbard_structure=hubbard_structure,
    protocol="fast",
    overrides={
        "clean_workdir": False,
        "tolerance_onsite": 0.5,
        "tolerance_intersite": 0.1,
        "relax":{
            "base_init_relax":{
                "kpoints_distance":100.0,
                "pw":{
                    "parameters":{
                        "SYSTEM":{
                            "ecutwfc": 60.0, # to speed up the tutorial
                            "ecutrho": 60.0 * 8,
                        },
                    },
                },
            },
            "base_relax":{
                "kpoints_distance":100.0,
                "pw":{
                    "parameters":{
                        "SYSTEM":{
                            "ecutwfc": 60.0, # to speed up the tutorial
                            "ecutrho": 60.0 * 8,
                        },
                    },
                },
            }
        }, # to speed up the tutorial
        "scf":{
            "kpoints_distance":100.0, 
            "pw":{
                "parameters":{
                    "SYSTEM":{
                        "ecutwfc": 30.0, # to speed up the tutorial
                        "ecutrho": 30.0 * 8,
                    },
                },
            },
        }, 
        "hubbard":{"qpoints_distance":100.0, "parallelize_atoms":False, "parallelize_qpoints":False}}, # to speed up the tutorial
)

results, node = run_get_node(builder)

Hide code cell output

08/19/2026 11:00:16 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|setup]: system is treated to be non-magnetic because `nspin == 1` in `scf.pw.parameters` input.
08/19/2026 11:00:16 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_relax]: launching PwRelaxWorkChain<136> iteration #1
08/19/2026 11:00:16 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [136|PwRelaxWorkChain|run_init_relax]: launching PwBaseWorkChain<138> for initial relaxation.
08/19/2026 11:00:17 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [138|PwBaseWorkChain|run_process]: launching PwCalculation<143> iteration #1
08/19/2026 11:01:04 AM <52115> aiida.parser.PwParser: [ERROR] The ionic minimization cycle converged but the thresholds are exceeded in the final SCF.
08/19/2026 11:01:04 AM <52115> aiida.orm.nodes.process.calculation.calcjob.CalcJobNode: [WARNING] output parser returned exit code<501>: The ionic minimization cycle converged but the thresholds are exceeded in the final SCF.
08/19/2026 11:01:04 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [138|PwBaseWorkChain|report_error_handled]: PwCalculation<143> failed with exit status 501: The ionic minimization cycle converged but the thresholds are exceeded in the final SCF.
08/19/2026 11:01:04 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [138|PwBaseWorkChain|report_error_handled]: Action taken: consider structure final, but report exit code.
08/19/2026 11:01:04 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [138|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:01:05 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [138|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:01:06 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [136|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<152>
08/19/2026 11:01:06 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [152|PwBaseWorkChain|run_process]: launching PwCalculation<157> iteration #1
08/19/2026 11:02:02 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [152|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:02:02 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [152|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:03 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [136|PwRelaxWorkChain|should_run_relax]: Work chain completed after 1 iterations.
08/19/2026 11:02:03 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [136|PwRelaxWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:03 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_scf_smearing]: launching PwBaseWorkChain<166> with smeared occupations
08/19/2026 11:02:03 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [166|PwBaseWorkChain|run_process]: launching PwCalculation<171> iteration #1
08/19/2026 11:02:10 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [166|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:02:10 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [166|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:11 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|recon_scf]: after relaxation, system is determined to be an insulator
08/19/2026 11:02:11 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_scf_fixed]: launching PwBaseWorkChain<179> with fixed occupations
08/19/2026 11:02:11 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179|PwBaseWorkChain|run_process]: launching PwCalculation<184> iteration #1
08/19/2026 11:02:17 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:02:17 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [179|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:18 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_hp]: launching HpWorkChain<192> iteration #1
08/19/2026 11:02:18 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [192|HpWorkChain|run_base_workchain]: running in serial, launching HpBaseWorkChain<198>
08/19/2026 11:02:19 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [198|HpBaseWorkChain|run_process]: launching HpCalculation<201> iteration #1
08/19/2026 11:02:25 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [198|HpBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:02:25 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [198|HpBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:25 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [198|HpBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:26 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [192|HpWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:02:27 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|check_convergence]: Hubbard onsites parameters are not converged. Max difference is 8.05399999.
08/19/2026 11:02:27 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_relax]: launching PwRelaxWorkChain<211> iteration #2
08/19/2026 11:02:27 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [211|PwRelaxWorkChain|run_init_relax]: launching PwBaseWorkChain<213> for initial relaxation.
08/19/2026 11:02:27 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [213|PwBaseWorkChain|run_process]: launching PwCalculation<218> iteration #1
08/19/2026 11:03:22 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [213|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:03:23 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [213|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:03:23 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [211|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<227>
08/19/2026 11:03:23 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [227|PwBaseWorkChain|run_process]: launching PwCalculation<232> iteration #1
08/19/2026 11:04:10 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [227|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:04:10 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [227|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:11 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [211|PwRelaxWorkChain|should_run_relax]: Work chain completed after 1 iterations.
08/19/2026 11:04:11 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [211|PwRelaxWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:12 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_scf_smearing]: launching PwBaseWorkChain<241> with smeared occupations
08/19/2026 11:04:12 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [241|PwBaseWorkChain|run_process]: launching PwCalculation<246> iteration #1
08/19/2026 11:04:19 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [241|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:04:19 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [241|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:19 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|recon_scf]: after relaxation, system is determined to be an insulator
08/19/2026 11:04:20 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_scf_fixed]: launching PwBaseWorkChain<254> with fixed occupations
08/19/2026 11:04:20 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [254|PwBaseWorkChain|run_process]: launching PwCalculation<259> iteration #1
08/19/2026 11:04:24 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [254|PwBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:04:24 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [254|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:25 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_hp]: launching HpWorkChain<267> iteration #2
08/19/2026 11:04:25 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [267|HpWorkChain|run_base_workchain]: running in serial, launching HpBaseWorkChain<273>
08/19/2026 11:04:25 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [273|HpBaseWorkChain|run_process]: launching HpCalculation<276> iteration #1
08/19/2026 11:04:32 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [273|HpBaseWorkChain|results]: work chain completed after 1 iterations
08/19/2026 11:04:32 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [273|HpBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:32 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [273|HpBaseWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:33 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [267|HpWorkChain|on_terminated]: remote folders will not be cleaned
08/19/2026 11:04:34 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|check_convergence]: Hubbard parameters are converged. Stopping the cycle.
08/19/2026 11:04:34 AM <52115> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [133|SelfConsistentHubbardWorkChain|run_results]: Hubbard parameters self-consistently converged in 2 iterations

Let’s inspect the status of the work chain to see the full self-consistency on screen!

%verdi process status {node.pk}
SelfConsistentHubbardWorkChain<133> Finished [0] [2:run_results]
    ├── PwRelaxWorkChain<136> Finished [0] [3:results]
    │   ├── PwBaseWorkChain<138> Finished [501] [2:while_(should_run_process)(2:inspect_process)]
    │   │   ├── create_kpoints_from_distance<139> Finished [0]
    │   │   └── PwCalculation<143> Finished [501]
    │   └── PwBaseWorkChain<152> Finished [0] [3:results]
    │       ├── create_kpoints_from_distance<153> Finished [0]
    │       └── PwCalculation<157> Finished [0]
    ├── PwBaseWorkChain<166> Finished [0] [3:results]
    │   ├── create_kpoints_from_distance<167> Finished [0]
    │   └── PwCalculation<171> Finished [0]
    ├── PwBaseWorkChain<179> Finished [0] [3:results]
    │   ├── create_kpoints_from_distance<180> Finished [0]
    │   └── PwCalculation<184> Finished [0]
    ├── HpWorkChain<192> Finished [0] [3:results]
    │   ├── create_kpoints_from_distance<194> Finished [0]
    │   └── HpBaseWorkChain<198> Finished [0] [3:results]
    │       └── HpCalculation<201> Finished [0]
    ├── PwRelaxWorkChain<211> Finished [0] [3:results]
    │   ├── PwBaseWorkChain<213> Finished [0] [3:results]
    │   │   ├── create_kpoints_from_distance<214> Finished [0]
    │   │   └── PwCalculation<218> Finished [0]
    │   └── PwBaseWorkChain<227> Finished [0] [3:results]
    │       ├── create_kpoints_from_distance<228> Finished [0]
    │       └── PwCalculation<232> Finished [0]
    ├── PwBaseWorkChain<241> Finished [0] [3:results]
    │   ├── create_kpoints_from_distance<242> Finished [0]
    │   └── PwCalculation<246> Finished [0]
    ├── PwBaseWorkChain<254> Finished [0] [3:results]
    │   ├── create_kpoints_from_distance<255> Finished [0]
    │   └── PwCalculation<259> Finished [0]
    └── HpWorkChain<267> Finished [0] [3:results]
        ├── create_kpoints_from_distance<269> Finished [0]
        └── HpBaseWorkChain<273> Finished [0] [3:results]
            └── HpCalculation<276> Finished [0]

And of course, here you have the final relaxed structure with fully self-consistent ab-initio Hubbard parameters! 🎉

from aiida_quantumespresso.utils.hubbard import HubbardUtils
print(HubbardUtils(results['hubbard_structure']).get_hubbard_card())
HUBBARD	ortho-atomic
 U	Co-3d	7.861

Final considerations#

We managed to compute the Hubbard parameters self-consistently with a series of relaxations, scfs, and hp calculations, all fully automated! 🎉

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: