Skip to content

Commit

Permalink
SelfConsistentHubbard: new implementation
Browse files Browse the repository at this point in the history
The following changes are applied:
* Inputs adapted for handling both onsite and intersite
  cases (U and U+V)
* New inputs for skipping the first relaxation and for
   controlling the frequency of the call to the relax workflow
* Validation for magnetic inputs
* Outline change: always perform an scf with smearing,
   than recognize if it is a metal or insultaor; if insulator,
   than do scf with fixed occupation.
* The check on convergence over Hubbard parameters
   is performed separately on onsite (U) and intersite (V).
* Protocols through the `get_builder_from_protocol`
* `clean_workdir` input
  • Loading branch information
bastonero authored and sphuber committed May 4, 2023
1 parent 1e7ede1 commit 39682ba
Show file tree
Hide file tree
Showing 8 changed files with 1,002 additions and 312 deletions.
752 changes: 479 additions & 273 deletions src/aiida_quantumespresso_hp/workflows/hubbard.py

Large diffs are not rendered by default.

Empty file.
25 changes: 25 additions & 0 deletions src/aiida_quantumespresso_hp/workflows/protocols/hubbard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
default_inputs:
clean_workdir: True
meta_convergence: True
tolerance_onsite: 0.1
tolerance_intersite: 0.01
skip_first_relax: False
scf:
kpoints_distance: 0.4

default_protocol: moderate
protocols:
moderate:
description: 'Protocol to perform the computation at normal precision at moderate computational cost.'
precise:
description: 'Protocol to perform the computation at high precision at higher computational cost.'
tolerance_onsite: 0.01
tolerance_intersite: 0.005
scf:
kpoints_distance: 0.2
fast:
description: 'Protocol to perform the computation at low precision at minimal computational cost for testing purposes.'
tolerance_onsite: 0.2
tolerance_intersite: 0.1
scf:
kpoints_distance: 0.6
7 changes: 7 additions & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
testpaths = tests
filterwarnings =
ignore::DeprecationWarning:aio_pika:
ignore::DeprecationWarning:frozendict:
ignore::DeprecationWarning:sqlalchemy_utils:
ignore::DeprecationWarning:pkg_resources:
Empty file.
82 changes: 82 additions & 0 deletions tests/workflows/protocols/test_hubbard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
"""Tests for the ``SelfConsistentHubbardWorkChain.get_builder_from_protocol`` method."""
from aiida.engine import ProcessBuilder
import pytest

from aiida_quantumespresso_hp.workflows.hubbard import SelfConsistentHubbardWorkChain


def test_get_available_protocols():
"""Test ``SelfConsistentHubbardWorkChain.get_available_protocols``."""
protocols = SelfConsistentHubbardWorkChain.get_available_protocols()
assert sorted(protocols.keys()) == ['fast', 'moderate', 'precise']
assert all('description' in protocol for protocol in protocols.values())


def test_get_default_protocol():
"""Test ``SelfConsistentHubbardWorkChain.get_default_protocol``."""
assert SelfConsistentHubbardWorkChain.get_default_protocol() == 'moderate'


def test_default(fixture_code, data_regression, generate_hubbard_structure, serialize_builder):
"""Test ``SelfConsistentHubbardWorkChain.get_builder_from_protocol`` for the default protocol."""
pw_code = fixture_code('quantumespresso.pw')
hp_code = fixture_code('quantumespresso.hp')
hubbard_structure = generate_hubbard_structure()

builder = SelfConsistentHubbardWorkChain.get_builder_from_protocol(pw_code, hp_code, hubbard_structure)

assert isinstance(builder, ProcessBuilder)
data_regression.check(serialize_builder(builder))


@pytest.mark.parametrize(
'overrides', (
{
'relax_frequency': 3
},
{
'tolerance_onsite': 1
},
{
'tolerance_intersite': 1
},
{
'meta_convergence': False
},
{
'clean_workdir': False
},
)
)
def test_overrides(fixture_code, generate_hubbard_structure, overrides):
"""Test specifying different``overrides`` for the ``get_builder_from_protocol()`` method."""
pw_code = fixture_code('quantumespresso.pw')
hp_code = fixture_code('quantumespresso.hp')
hubbard_structure = generate_hubbard_structure()

builder = SelfConsistentHubbardWorkChain.get_builder_from_protocol(
pw_code, hp_code, hubbard_structure, overrides=overrides
)

for key, value in overrides.items():
assert builder[key].value == value


def test_options(fixture_code, generate_hubbard_structure):
"""Test specifying ``options`` for the ``get_builder_from_protocol()`` method."""
pw_code = fixture_code('quantumespresso.pw')
hp_code = fixture_code('quantumespresso.hp')
hubbard_structure = generate_hubbard_structure()

queue_name = 'super-fast'
withmpi = False # The protocol default is ``True``

options = {'queue_name': queue_name, 'withmpi': withmpi}
builder = SelfConsistentHubbardWorkChain.get_builder_from_protocol(
pw_code, hp_code, hubbard_structure, options_pw=options, options_hp=options
)

assert builder.hubbard.hp.metadata['options']['queue_name'] == queue_name
assert builder.scf.pw.metadata['options']['queue_name'] == queue_name
assert builder.relax.base.pw.metadata['options']['queue_name'] == queue_name
96 changes: 96 additions & 0 deletions tests/workflows/protocols/test_hubbard/test_default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
clean_workdir: true
hubbard:
hp:
code: test.quantumespresso.hp@localhost
metadata:
options:
max_wallclock_seconds: 43200
resources:
num_machines: 1
withmpi: true
parameters:
INPUTHP:
conv_thr_chi: 5.0e-06
settings:
parent_folder_symlink: true
parallelize_atoms: true
parallelize_qpoints: true
qpoints_distance: 0.8
hubbard_structure: CoLiO2
meta_convergence: true
relax:
base:
kpoints_distance: 0.15
kpoints_force_parity: false
pw:
code: test.quantumespresso.pw@localhost
metadata:
options:
max_wallclock_seconds: 43200
resources:
num_machines: 1
withmpi: true
parameters:
CELL:
cell_dofree: all
press_conv_thr: 0.5
CONTROL:
calculation: vc-relax
etot_conv_thr: 4.0e-05
forc_conv_thr: 0.0001
tprnfor: true
tstress: true
ELECTRONS:
conv_thr: 8.0e-10
electron_maxstep: 80
mixing_beta: 0.4
SYSTEM:
degauss: 0.01
ecutrho: 240.0
ecutwfc: 30.0
nosym: false
occupations: smearing
smearing: cold
pseudos:
Co: Co<md5=04edd96127402ab6ffc358660b52a2db>
Li: Li<md5=90ac4658c7606c7ad16e40ce66db5a86>
O: O<md5=721f9895631356f7d4610e60de16fd63>
max_meta_convergence_iterations: 5
meta_convergence: true
volume_convergence: 0.02
scf:
kpoints_distance: 0.4
kpoints_force_parity: false
pw:
code: test.quantumespresso.pw@localhost
metadata:
options:
max_wallclock_seconds: 43200
resources:
num_machines: 1
withmpi: true
parameters:
CONTROL:
calculation: scf
etot_conv_thr: 4.0e-05
forc_conv_thr: 0.0001
tprnfor: true
tstress: true
ELECTRONS:
conv_thr: 8.0e-10
electron_maxstep: 80
mixing_beta: 0.4
SYSTEM:
degauss: 0.01
ecutrho: 240.0
ecutwfc: 30.0
nosym: false
occupations: smearing
smearing: cold
pseudos:
Co: Co<md5=04edd96127402ab6ffc358660b52a2db>
Li: Li<md5=90ac4658c7606c7ad16e40ce66db5a86>
O: O<md5=721f9895631356f7d4610e60de16fd63>
skip_first_relax: false
tolerance_intersite: 0.01
tolerance_onsite: 0.1
Loading

0 comments on commit 39682ba

Please sign in to comment.