Skip to content

Commit

Permalink
VASP does not write charge component for orbital moments
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-schlipf committed Jun 17, 2024
1 parent ac9f063 commit f0c8a10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/py4vasp/_calculation/magnetism.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def _collinear_moments(self):
def _noncollinear_moments(self, selection):
spin_moments = self._raw_data.spin_moments[self._steps, 1:]
if self._has_orbital_moments:
orbital_moments = self._raw_data.orbital_moments[self._steps, 1:]
orbital_moments = self._raw_data.orbital_moments[self._steps]
else:
orbital_moments = np.zeros_like(spin_moments)
if selection == "orbital":
Expand All @@ -246,7 +246,7 @@ def _add_spin_and_orbital_moments(self):
if not self._has_orbital_moments:
return {}
spin_moments = self._raw_data.spin_moments[self._steps, 1:]
orbital_moments = self._raw_data.orbital_moments[self._steps, 1:]
orbital_moments = self._raw_data.orbital_moments[self._steps]
direction_axis = 1 if spin_moments.ndim == 4 else 0
return {
"spin_moments": np.moveaxis(spin_moments, direction_axis, -1),
Expand Down
2 changes: 1 addition & 1 deletion tests/calculation/test_magnetism.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __getitem__(self, step):
reference.moments = np.moveaxis(raw_magnetism.spin_moments[:, 1:4], 1, 3)
else:
spin_moments = np.moveaxis(raw_magnetism.spin_moments[:, 1:4], 1, 3)
orbital_moments = np.moveaxis(raw_magnetism.orbital_moments[:, 1:4], 1, 3)
orbital_moments = np.moveaxis(raw_magnetism.orbital_moments, 1, 3)
reference.moments = spin_moments + orbital_moments
reference.spin_moments = spin_moments
reference.orbital_moments = orbital_moments
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,10 @@ def _magnetism(selection):
spin_moments=_make_data(np.arange(np.prod(shape)).reshape(shape)),
)
if selection == "orbital_moments":
magnetism.orbital_moments = _make_data(np.sqrt(magnetism.spin_moments))
remove_charge_component = magnetism.spin_moments[:, 1:]
magnetism.orbital_moments = _make_data(np.sqrt(remove_charge_component))
print("spin_moments", magnetism.spin_moments.shape)
print("orb_moments", magnetism.orbital_moments.shape)
return magnetism


Expand Down

0 comments on commit f0c8a10

Please sign in to comment.