Skip to content

Commit

Permalink
PwBaseWorkChain: make magnetism from overrides absolute
Browse files Browse the repository at this point in the history
When using the `get_builder_from_protocol()` method from the
`PwBaseWorkChain`, setting `spin_type` to `COLLINEAR` while not
specifying the `initial_magnetic_moments` will result in a set of
default magnetic moments being used, based on the `magnetization.yaml`
file. This means that even when `SYSTEM.starting_magnetization` is
specified in the `overrides`, these are simply ignored in favor of the
defaults.

Here we make the `overrides` _absolute_, i.e. the
`starting_magnetization` is only set to the default in case it is not
specified in the `overrides`. This is once again based on the principle
that we should avoid quietly overriding inputs that the user explicitly
specified.
  • Loading branch information
mbercx committed Sep 16, 2021
1 parent 206124a commit 3ba4f39
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aiida_quantumespresso/workflows/pw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ def get_builder_from_protocol(
parameters['SYSTEM'].pop('smearing')

if spin_type is SpinType.COLLINEAR:
starting_magnetization = get_starting_magnetization(structure, pseudo_family, initial_magnetic_moments)

parameters['SYSTEM']['nspin'] = 2
parameters['SYSTEM']['starting_magnetization'] = starting_magnetization
if 'starting_magnetization' not in parameters['SYSTEM']:
starting_magnetization = get_starting_magnetization(structure, pseudo_family, initial_magnetic_moments)

parameters['SYSTEM']['starting_magnetization'] = starting_magnetization

# pylint: disable=no-member
builder = cls.get_builder()
Expand Down

0 comments on commit 3ba4f39

Please sign in to comment.