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

PhononWorkChain: smearing for magnetic metals #22

Merged
merged 1 commit into from
Jul 5, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,4 @@ _aiida_*
# Autogenerated API docs
docs/source/reference/api/aiida_vibroscopy
docs/source/reference/cli
tox.ini
9 changes: 8 additions & 1 deletion src/aiida_vibroscopy/workflows/phonons/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def set_ctx_variables(self):
parameters = self.inputs.scf.pw.parameters.get_dict()
nspin = parameters.get('SYSTEM', {}).get('nspin', 1)
self.ctx.is_magnetic = (nspin != 1)
self.ctx.is_insulator = True
self.ctx.plus_hubbard = False
self.ctx.old_plus_hubbard = False

Expand Down Expand Up @@ -365,6 +366,12 @@ def inspect_base_supercell(self):
self.report(f'base supercell scf failed with exit status {workchain.exit_status}')
return self.exit_codes.ERROR_FAILED_BASE_SCF

parameters = workchain.outputs.output_parameters.dict
if parameters.occupations == 'smearing':
bands = workchain.outputs.output_band
fermi_energy = parameters.fermi_energy
self.ctx.is_insulator, _ = orm.find_bandgap(bands, fermi_energy=fermi_energy)

def run_forces(self):
"""Run an scf for each supercell with displacements."""
if self.ctx.plus_hubbard or self.ctx.old_plus_hubbard:
Expand Down Expand Up @@ -398,7 +405,7 @@ def run_forces(self):
parameters.setdefault('SYSTEM', {})
parameters.setdefault('ELECTRONS', {})

if self.ctx.is_magnetic:
if self.ctx.is_magnetic and self.ctx.is_insulator:
parameters['SYSTEM']['occupations'] = 'fixed'

for name in ('smearing', 'degauss', 'starting_magnetization'):
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ def _generate_base_scf_workchain_node(exit_status=0, with_trajectory=False):

# Add output Dict
parameters = orm.Dict({
'occupations': 'fixed',
'number_of_bands': 5,
'total_magnetization': 1,
'volume': 10,
Expand Down
2 changes: 2 additions & 0 deletions tests/workflows/phonons/test_phonon.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_setup(generate_workchain_phonon):
process.setup()

assert process.ctx.is_magnetic == False
assert process.ctx.is_insulator == True
assert process.ctx.plus_hubbard == False
assert process.ctx.old_plus_hubbard == False
assert 'preprocess_data' in process.ctx
Expand Down Expand Up @@ -212,6 +213,7 @@ def test_inspect_base_supercell(
process.ctx.scf_supercell_0 = generate_base_scf_workchain_node(exit_status=exit_status)
result = process.inspect_base_supercell()
assert result == expected_result
assert process.ctx.is_insulator


@pytest.mark.usefixtures('aiida_profile')
Expand Down