diff --git a/python/damask/_crystal.py b/python/damask/_crystal.py index 7fc2e39b6..73d9f031c 100644 --- a/python/damask/_crystal.py +++ b/python/damask/_crystal.py @@ -26,7 +26,7 @@ lattice_symmetries = { class Crystal(): - """Lattice.""" + """Crystal lattice.""" def __init__(self,*, family = None, @@ -41,7 +41,7 @@ class Crystal(): ---------- family : {'triclinic', 'monoclinic', 'orthorhombic', 'tetragonal', 'hexagonal', 'cubic'}, optional. Name of the crystal family. - Will be infered if 'lattice' is given. + Will be inferred if 'lattice' is given. lattice : {'aP', 'mP', 'mS', 'oP', 'oS', 'oI', 'oF', 'tP', 'tI', 'hP', 'cP', 'cI', 'cF'}, optional. Name of the Bravais lattice in Pearson notation. a : float, optional @@ -110,14 +110,23 @@ class Crystal(): self.alpha = self.beta = self.gamma = None + def __repr__(self): + """Represent.""" + return '\n'.join([f'Crystal family {self.family}'] + + ([] if self.lattice is None else [f'Bravais lattice {self.lattice}']+ + list(map(lambda x:f'{x[0]}:{x[1]:.5g}', + zip(['a','b','c','alpha','beta','gamma',], + self.parameters)))) + ) + def __eq__(self,other): """ Equal to other. Parameters ---------- - other : Lattice - Lattice to check for equality. + other : Crystal + Crystal to check for equality. """ return self.lattice == other.lattice and \ @@ -325,7 +334,7 @@ class Crystal(): def kinematics(self,mode): """ - Return kinematic sytems. + Return crystal kinematics systems. Parameters ---------- @@ -335,7 +344,7 @@ class Crystal(): Returns ------- direction_plane : dictionary - Direction and plane of deformation mode. + Directions and planes of deformation mode families. """ _kinematics = { @@ -531,7 +540,7 @@ class Crystal(): Returns ------- operations : (string, damask.Rotation) - Rotations characterizing the orientation relationship. + Resulting lattice and rotations characterizing the orientation relationship. References ---------- diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 1bc28bc13..7007951da 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -108,7 +108,7 @@ class Orientation(Rotation,Crystal): An array of 3 x 5 random orientations reduced to the fundamental zone of tetragonal symmetry: >>> import damask - >>> o=damask.Orientation.from_random(shape=(3,5),lattice='tetragonal').reduced + >>> o=damask.Orientation.from_random(shape=(3,5),family='tetragonal').reduced """ @@ -138,9 +138,8 @@ class Orientation(Rotation,Crystal): def __repr__(self): """Represent.""" - return '\n'.join(([] if self.lattice is None else [f'Bravais lattice {self.lattice}']) - + ([f'Crystal family {self.family}']) - + [super().__repr__()]) + return '\n'.join([Crystal.__repr__(self), + Rotation.__repr__(self)]) def __copy__(self,rotation=None): @@ -862,7 +861,7 @@ class Orientation(Rotation,Crystal): ---------- N_slip|N_twin : iterable of int Number of deformation systems per family of the deformation system. - Use '*'. to select all. + Use '*' to select all. Returns ------- @@ -887,8 +886,8 @@ class Orientation(Rotation,Crystal): if (N_slip is not None) ^ (N_twin is None): raise KeyError('Specify either "N_slip" or "N_twin"') - kinematics = self.kinematics('slip' if N_twin is None else 'twin') - active = N_slip if N_twin is None else N_twin + kinematics,active = (self.kinematics('slip'),N_slip) if N_twin is None else \ + (self.kinematics('twin'),N_twin) if active == '*': active = [len(a) for a in kinematics['direction']] d = self.to_frame(uvw=np.vstack([kinematics['direction'][i][:n] for i,n in enumerate(active)]))