From 4701eea10f450ea61627eb5b4118a5f1060b75ea Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 3 Jun 2021 10:02:49 +0200 Subject: [PATCH] decoupling Orientation and Lattice/LatticeFamily --- python/damask/_orientation.py | 19 +++++++------------ python/tests/test_Orientation.py | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index a3aa44564..d661dd475 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -32,9 +32,9 @@ lattice_symmetries = { _parameter_doc = \ """ - family : {'triclinic', 'monoclinic', 'orthorhombic', 'tetragonal', 'hexagonal', 'cubic'} + family : {'triclinic', 'monoclinic', 'orthorhombic', 'tetragonal', 'hexagonal', 'cubic'} Crystal family. Mutual exclusive with 'lattice' parameter. - lattice : {'aP', 'mP', 'mS', 'oP', 'oS', 'oI', 'oF', 'tP', 'tI', 'hP', 'cP', 'cI', 'cF'}. + lattice : {'aP', 'mP', 'mS', 'oP', 'oS', 'oI', 'oF', 'tP', 'tI', 'hP', 'cP', 'cI', 'cF'}. Bravais lattice in Pearson notation. Mutual exclusive with 'family' parameter. a : float, optional @@ -139,7 +139,6 @@ class Orientation(Rotation): self.structure = l = LatticeFamily(self.family) # noqa self.immutable = l.immutable self.basis = l.basis - self.symmetry_operations = l.symmetry_operations self.a = self.b = self.c = None self.alpha = self.beta = self.gamma = None @@ -152,7 +151,6 @@ class Orientation(Rotation): self.structure = l = Lattice(self.lattice, a,b,c, alpha,beta,gamma, degrees) # noqa self.immutable = l.immutable self.basis = l.basis - self.symmetry_operations = l.symmetry_operations self.a = l.a self.b = l.b @@ -178,11 +176,6 @@ class Orientation(Rotation): + ([f'Crystal family {self.family}']) + [super().__repr__()]) - @property - def parameters(self): - """Return lattice parameters a, b, c, alpha, beta, gamma.""" - return (self.a,self.b,self.c,self.alpha,self.beta,self.gamma) - def __copy__(self,**kwargs): """Create deep copy.""" @@ -437,7 +430,8 @@ class Orientation(Rotation): is added to the left of the Rotation array. """ - o = self.symmetry_operations.broadcast_to(self.symmetry_operations.shape+self.shape,mode='right') + sym_ops = self.structure.symmetry_operations + o = sym_ops.broadcast_to(sym_ops.shape+self.shape,mode='right') return self.copy(rotation=o*Rotation(self.quaternion).broadcast_to(o.shape,mode='left')) @@ -817,11 +811,12 @@ class Orientation(Rotation): Lab frame vector (or vectors if with_symmetry) along [uvw] direction or (hkl) plane normal. """ + sym_ops = self.structure.symmetry_operations # ToDo: simplify 'with_symmetry' v = self.to_frame(uvw=uvw,hkl=hkl) if with_symmetry: - v = self.symmetry_operations.broadcast_to(self.symmetry_operations.shape+v.shape[:-1],mode='right') \ - @ np.broadcast_to(v,self.symmetry_operations.shape+v.shape) + v = sym_ops.broadcast_to(sym_ops.shape+v.shape[:-1],mode='right') \ + @ np.broadcast_to(v,sym_ops.shape+v.shape) return ~(self if self.shape+v.shape[:-1] == () else self.broadcast_to(self.shape+v.shape[:-1],mode='right')) \ @ np.broadcast_to(v,self.shape+v.shape) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index a1302bcb7..ced7022f1 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -75,7 +75,7 @@ class TestOrientation: ]) def test_invalid_init(self,kwargs): with pytest.raises(ValueError): - Orientation(**kwargs).parameters # noqa + Orientation(**kwargs) @pytest.mark.parametrize('kwargs',[ dict(lattice='aP',a=1.0,b=1.1,c=1.2,alpha=np.pi/4,beta=np.pi/3,gamma=np.pi/2), @@ -436,7 +436,7 @@ class TestOrientation: a=a,b=b,c=c, alpha=alpha,beta=beta,gamma=gamma) assert o.to_pole(**{kw:vector,'with_symmetry':with_symmetry}).shape \ - == o.shape + (o.symmetry_operations.shape if with_symmetry else ()) + vector.shape + == o.shape + (o.structure.symmetry_operations.shape if with_symmetry else ()) + vector.shape @pytest.mark.parametrize('lattice',['hP','cI','cF']) def test_Schmid(self,update,ref_path,lattice):