Skip to content

Commit

Permalink
Rename tau to kinetic energy (#173)
Browse files Browse the repository at this point in the history
* rename tau to kinetic_energy
* fix tests after renaming
  • Loading branch information
sudarshanv01 authored Nov 14, 2024
1 parent 36448f5 commit 3596b6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
15 changes: 7 additions & 8 deletions src/py4vasp/calculation/_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __str__(self):
_raise_error_if_no_data(self._raw_data.charge)
grid = self._raw_data.charge.shape[1:]
topology = calculation.topology.from_data(self._raw_data.structure.topology)
if self._selection == "tau":
if self._selection == "kinetic_energy":
name = "Kinetic energy"
elif self.is_nonpolarized():
name = "Nonpolarized"
Expand Down Expand Up @@ -114,15 +114,15 @@ def selections(self):
the 0-th component.
To nest density and component, please use parentheses, e.g. ``charge(1, 2)`` or
``3(tau)``.
``3(kinetic_energy)``.
For convenience, py4vasp accepts the following aliases
electronic charge density
*charge*, *n*, *charge_density*, and *electronic_charge_density*
kinetic energy density
*tau*, *kinetic_energy*, and *kinetic_energy_density*
*kinetic_energy*, *kinetic_energy*, and *kinetic_energy_density*
0th component
{component0}
Expand Down Expand Up @@ -367,7 +367,7 @@ def to_contour(
Take a slice of the kinetic energy density along the first lattice vector and
rotate it such that the normal of the plane aligns with the x axis.
>>> calc.density.to_contour("tau", a=0.3, normal="x")
>>> calc.density.to_contour("kinetic_energy", a=0.3, normal="x")
"""
cut, fraction = self._get_cut(a, b, c)
plane = slicing.plane(self._structure.lattice_vectors(), cut, normal)
Expand Down Expand Up @@ -427,7 +427,7 @@ def to_quiver(self, *, a=None, b=None, c=None, supercell=None, normal=None):
first lattice vector and rotate it such that the normal of the plane aligns with
the x axis.
>>> calc.density.to_quiver("tau", a=0.3, normal="x")
>>> calc.density.to_quiver("kinetic_energy", a=0.3, normal="x")
"""
cut, fraction = self._get_cut(a, b, c)
plane = slicing.plane(self._structure.lattice_vectors(), cut, normal)
Expand Down Expand Up @@ -468,9 +468,8 @@ def is_noncollinear(self):
@property
def _selection(self):
selection_map = {
"tau": "tau",
"kinetic_energy": "tau",
"kinetic_energy_density": "tau",
"kinetic_energy": "kinetic_energy",
"kinetic_energy_density": "kinetic_energy",
}
return selection_map.get(super()._selection)

Expand Down
12 changes: 6 additions & 6 deletions tests/calculation/test_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from py4vasp._third_party.view import Isosurface


@pytest.fixture(params=[None, "tau"])
@pytest.fixture(params=[None, "kinetic_energy"])
def density_source(request):
return request.param

Expand Down Expand Up @@ -76,7 +76,7 @@ def get_expected_dict(charge, source):

def get_expected_string(selection, source):
structure, *density = selection.split()
if source == "tau":
if source == "kinetic_energy":
density = "Kinetic energy"
elif not density:
density = "Nonpolarized"
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_collinear_plot(selection, collinear_density, Assert):
isosurfaces=isosurfaces,
)
if selection in ("magnetization", "mag", "m"):
# magnetization not allowed for tau
# magnetization not allowed for kinetic_energy
return
check_view(collinear_density, expected, Assert, selection=selection, isolevel=0.1)

Expand Down Expand Up @@ -208,7 +208,7 @@ def test_plotting_noncollinear_density(selections, noncollinear_density, Assert)
else:
expected_labels = (f"{source}({selection})" for selection in selections)
expected_density = noncollinear_density.ref.output[source][1:]
if "(" in selections[0]: # magnetization not allowed for tau
if "(" in selections[0]: # magnetization not allowed for kinetic_energy
return
isosurfaces = [
Isosurface(isolevel=0.2, color=_config.VASP_BLUE, opacity=0.3),
Expand Down Expand Up @@ -296,7 +296,7 @@ def test_collinear_to_contour(selection, collinear_density, Assert):
expected_label = f"{source}({selection})"
expected_data = collinear_density.ref.output[source][1, :, :, 7]
if selection in ("magnetization", "mag", "m"):
# magnetization not allowed for tau
# magnetization not allowed for kinetic_energy
return
expected_lattice = collinear_density.ref.structure.lattice_vectors()[:2, :2]
graph = collinear_density.to_contour(selection, c=-0.5)
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_noncollinear_to_contour(noncollinear_density, selections, Assert):
else:
expected_labels = (f"{source}({selection})" for selection in selections)
expected_data = noncollinear_density.ref.output[source][1:, :, 5, :]
if "(" in selections[0]: # magnetization not allowed for tau
if "(" in selections[0]: # magnetization not allowed for kinetic_energy
return
graph = noncollinear_density.to_contour(" ".join(selections), b=0.4)
expected_lattice = noncollinear_density.ref.structure.lattice_vectors()[::2, ::2]
Expand Down

0 comments on commit 3596b6a

Please sign in to comment.