Skip to content

Commit

Permalink
fix polar mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamd committed Oct 19, 2020
1 parent 2645959 commit 70c9348
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions emmet-core/emmet/core/polar.py
Expand Up @@ -10,6 +10,8 @@
from emmet.core.structure import StructureMetadata
from emmet.stubs import Matrix3D, Vector3D

from pymatgen.analysis.piezo import PiezoTensor as BasePiezoTensor

VoigtVector = Tuple[float, float, float, float, float, float]
PiezoTensor = Tuple[VoigtVector, VoigtVector, VoigtVector]
PiezoTensor.__doc__ = "Rank 3 real space tensor in Voigt notation" # type: ignore
Expand Down Expand Up @@ -80,7 +82,7 @@ class Piezoelectric(PropertyDoc):
@classmethod
def from_ionic_and_electronic(cls, ionic: Matrix3D, electronic: Matrix3D):

total = np.sum(ionic, electronic).tolist() # type: np.array
total = BasePiezoTensor.from_voigt(np.sum(ionic, electronic))

directions, charges, strains = np.linalg.svd(total, full_matrices=False)
max_index = np.argmax(np.abs(charges))
Expand All @@ -95,8 +97,8 @@ def from_ionic_and_electronic(cls, ionic: Matrix3D, electronic: Matrix3D):
return cls(
**{
"total": total.zeroed().voigt,
"ionic": ionic.zeroed().voigt,
"static": static.zeroed().voigt,
"ionic": ionic,
"static": electronic,
"e_ij_max": charges[max_index],
"max_direction": np.round(max_direction / min_val),
"strain_for_max": strains[max_index],
Expand Down

0 comments on commit 70c9348

Please sign in to comment.