Skip to content

Commit

Permalink
Hubbard: fix not overridden max_iterations (#37)
Browse files Browse the repository at this point in the history
The `max_iterations` input was not overridden.
We also change the `skip_first_relax` from `non_db` True to False,
and make it storable.
  • Loading branch information
bastonero authored May 22, 2023
1 parent 39682ba commit 0d82c1e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/aiida_quantumespresso_hp/workflows/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ def define(cls, spec):
)
spec.input(
'skip_first_relax',
valid_type=bool,
default=lambda: False,
non_db=True,
valid_type=orm.Bool,
default=lambda: orm.Bool(False),
help='If True, skip the first relaxation'
)
spec.input(
Expand Down Expand Up @@ -288,9 +287,10 @@ def get_builder_from_protocol(
builder.relax = relax
builder.scf = scf
builder.hubbard = hubbard
builder.skip_first_relax = inputs['skip_first_relax']
builder.skip_first_relax = orm.Bool(inputs['skip_first_relax'])
builder.tolerance_onsite = orm.Float(inputs['tolerance_onsite'])
builder.tolerance_intersite = orm.Float(inputs['tolerance_intersite'])
builder.max_iterations = orm.Int(inputs['max_iterations'])
builder.meta_convergence = orm.Bool(inputs['meta_convergence'])
builder.clean_workdir = orm.Bool(inputs['clean_workdir'])

Expand All @@ -305,7 +305,7 @@ def setup(self):
self.ctx.is_insulator = None
self.ctx.is_magnetic = False
self.ctx.iteration = 0
self.ctx.skip_first_relax = self.inputs.skip_first_relax
self.ctx.skip_first_relax = self.inputs.skip_first_relax.value
self.ctx.relax_frequency = 1
if 'relax_frequency' in self.inputs:
self.ctx.relax_frequency = self.inputs.relax_frequency.value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
default_inputs:
clean_workdir: True
max_iterations: 10
meta_convergence: True
tolerance_onsite: 0.1
tolerance_intersite: 0.01
Expand Down
12 changes: 9 additions & 3 deletions tests/workflows/protocols/test_hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ def test_default(fixture_code, data_regression, generate_hubbard_structure, seri

@pytest.mark.parametrize(
'overrides', (
{
'relax_frequency': 3
},
{
'tolerance_onsite': 1
},
{
'tolerance_intersite': 1
},
{
'skip_first_relax': True
},
{
'relax_frequency': 3
},
{
'max_iterations': 1
},
{
'meta_convergence': False
},
Expand Down
1 change: 1 addition & 0 deletions tests/workflows/protocols/test_hubbard/test_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ hubbard:
parallelize_qpoints: true
qpoints_distance: 0.8
hubbard_structure: CoLiO2
max_iterations: 10
meta_convergence: true
relax:
base:
Expand Down
4 changes: 3 additions & 1 deletion tests/workflows/test_hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def test_magnetic_setup(generate_workchain_hubbard, generate_inputs_hubbard):
@pytest.mark.usefixtures('aiida_profile')
def test_skip_first_relax(generate_workchain_hubbard, generate_inputs_hubbard):
"""Test `SelfConsistentHubbardWorkChain` when skipping only the first relax."""
from aiida.orm import Bool

inputs = generate_inputs_hubbard()
inputs['skip_first_relax'] = True
inputs['skip_first_relax'] = Bool(True)
process = generate_workchain_hubbard(inputs=inputs)

process.setup()
Expand Down

0 comments on commit 0d82c1e

Please sign in to comment.