Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the convergence check in self-consistent workflow #68

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/aiida_quantumespresso_hp/workflows/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def check_convergence(self):
new = np.array(new_onsites, dtype='object')
diff = np.abs(old[:, 4] - new[:, 4])

if (diff > self.inputs.tolerance_onsite).all():
if (diff > self.inputs.tolerance_onsite).any():
check_onsites = False
self.report(f'Hubbard onsites parameters are not converged. Max difference is {diff.max()}.')

Expand All @@ -644,7 +644,7 @@ def check_convergence(self):
new = np.array(new_intersites, dtype='object')
diff = np.abs(old[:, 4] - new[:, 4])

if (diff > self.inputs.tolerance_intersite).all():
if (diff > self.inputs.tolerance_intersite).any():
check_onsites = False
self.report(f'Hubbard intersites parameters are not converged. Max difference is {diff.max()}.')

Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def _generate_structure(structure_id=None):
def generate_hubbard_structure(generate_structure):
"""Return a `HubbardStructureData` representing bulk silicon."""

def _generate_hubbard_structure(only_u=False, u_value=1e-5, v_value=1e-5):
def _generate_hubbard_structure(only_u=False, u_value=1e-5, v_value=1e-5, u_o_value=1e-5):
"""Return a `StructureData` representing bulk silicon."""
from aiida_quantumespresso.data.hubbard_structure import HubbardStructureData

Expand All @@ -386,9 +386,12 @@ def _generate_hubbard_structure(only_u=False, u_value=1e-5, v_value=1e-5):

if only_u:
hubbard_structure.initialize_onsites_hubbard('Co', '3d', u_value)
hubbard_structure.initialize_onsites_hubbard('O', '2p', u_o_value)
else:
hubbard_structure.initialize_onsites_hubbard('Co', '3d', u_value)
hubbard_structure.initialize_onsites_hubbard('O', '2p', u_o_value)
hubbard_structure.initialize_intersites_hubbard('Co', '3d', 'O', '2p', v_value)
hubbard_structure.initialize_intersites_hubbard('O', '2p', 'Co', '3d', u_o_value)

return hubbard_structure

Expand Down
Loading