WIP: cleaning namespace
This commit is contained in:
parent
9d94b521ad
commit
c86e3e292c
|
@ -479,11 +479,11 @@ class Lattice: # ToDo: Make a subclass of Symmetry!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
lattices = {
|
lattices = {
|
||||||
'triclinic':{'symmetry':None},
|
'triclinic':{'system':None},
|
||||||
'bct':{'symmetry':'tetragonal'},
|
'bct': {'system':'tetragonal'},
|
||||||
'hex':{'symmetry':'hexagonal'},
|
'hex': {'system':'hexagonal'},
|
||||||
'fcc':{'symmetry':'cubic','c/a':1.0},
|
'fcc': {'system':'cubic','c/a':1.0},
|
||||||
'bcc':{'symmetry':'cubic','c/a':1.0},
|
'bcc': {'system':'cubic','c/a':1.0},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -498,7 +498,12 @@ class Lattice: # ToDo: Make a subclass of Symmetry!
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.lattice = lattice
|
self.lattice = lattice
|
||||||
self.symmetry = Symmetry(self.lattices[lattice]['symmetry'])
|
self.symmetry = Symmetry(self.lattices[lattice]['system'])
|
||||||
|
|
||||||
|
# transition to subclass
|
||||||
|
self.system = self.symmetry.system
|
||||||
|
self.in_SST = self.symmetry.in_SST
|
||||||
|
self.inFZ = self.symmetry.inFZ
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
|
@ -39,6 +39,11 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
else:
|
else:
|
||||||
self.rotation = Rotation.from_quaternion(rotation) # assume quaternion
|
self.rotation = Rotation.from_quaternion(rotation) # assume quaternion
|
||||||
|
|
||||||
|
def __getitem__(self,item):
|
||||||
|
if isinstance(item,tuple) and len(item) >= len(self):
|
||||||
|
raise IndexError('Too many indices')
|
||||||
|
return self.__class__(self.rotation[item],self.lattice)
|
||||||
|
|
||||||
|
|
||||||
def disorientation(self,
|
def disorientation(self,
|
||||||
other,
|
other,
|
||||||
|
@ -66,7 +71,7 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
r = b*aInv
|
r = b*aInv
|
||||||
for k in range(2):
|
for k in range(2):
|
||||||
r.inverse()
|
r.inverse()
|
||||||
breaker = self.lattice.symmetry.inFZ(r.as_Rodrigues(vector=True)) \
|
breaker = self.lattice.inFZ(r.as_Rodrigues(vector=True)) \
|
||||||
and (not SST or other.lattice.symmetry.inDisorientationSST(r.as_Rodrigues(vector=True)))
|
and (not SST or other.lattice.symmetry.inDisorientationSST(r.as_Rodrigues(vector=True)))
|
||||||
if breaker: break
|
if breaker: break
|
||||||
if breaker: break
|
if breaker: break
|
||||||
|
@ -79,17 +84,17 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
def inFZ_vec(self):
|
def inFZ_vec(self):
|
||||||
"""Check if orientations fall into Fundamental Zone."""
|
"""Check if orientations fall into Fundamental Zone."""
|
||||||
if not self.rotation.shape:
|
if not self.rotation.shape:
|
||||||
return self.lattice.symmetry.inFZ(self.rotation.as_Rodrigues(vector=True))
|
return self.lattice.inFZ(self.rotation.as_Rodrigues(vector=True))
|
||||||
else:
|
else:
|
||||||
return [self.lattice.symmetry.inFZ(\
|
return [self.lattice.inFZ(\
|
||||||
self.rotation.as_Rodrigues(vector=True)[l]) for l in range(self.rotation.shape[0])]
|
self.rotation.as_Rodrigues(vector=True)[l]) for l in range(self.rotation.shape[0])]
|
||||||
|
|
||||||
|
|
||||||
def inFZ(self):
|
def inFZ(self):
|
||||||
return self.lattice.symmetry.inFZ(self.rotation.as_Rodrigues(vector=True))
|
return self.lattice.inFZ(self.rotation.as_Rodrigues(vector=True))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def equivalent_vec(self):
|
def equivalent(self):
|
||||||
"""
|
"""
|
||||||
Return orientations which are symmetrically equivalent.
|
Return orientations which are symmetrically equivalent.
|
||||||
|
|
||||||
|
@ -97,12 +102,12 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
is added to the left of the rotation array.
|
is added to the left of the rotation array.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
s = self.lattice.symmetry.symmetry_operations #24 lines (sym) x 4 columns (quat)
|
s = self.lattice.symmetry.symmetry_operations
|
||||||
s = s.reshape(s.shape[:1]+(1,)*len(self.rotation.shape)+(4,)) #reshape zo (24,1,4)
|
s = s.reshape(s.shape[:1]+(1,)*len(self.rotation.shape)+(4,))
|
||||||
s = Rotation(np.broadcast_to(s,s.shape[:1]+self.rotation.quaternion.shape))
|
s = Rotation(np.broadcast_to(s,s.shape[:1]+self.rotation.quaternion.shape))
|
||||||
|
|
||||||
r = np.broadcast_to(self.rotation.quaternion,s.shape[:1]+self.rotation.quaternion.shape) #(24,NumRots,4)
|
r = np.broadcast_to(self.rotation.quaternion,s.shape[:1]+self.rotation.quaternion.shape)
|
||||||
r = Rotation(r) #(24, NumRot)
|
r = Rotation(r)
|
||||||
|
|
||||||
return self.__class__(s@r,self.lattice)
|
return self.__class__(s@r,self.lattice)
|
||||||
|
|
||||||
|
@ -140,7 +145,7 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
@property
|
@property
|
||||||
def reduced_vec(self):
|
def reduced_vec(self):
|
||||||
"""Transform orientation to fall into fundamental zone according to symmetry."""
|
"""Transform orientation to fall into fundamental zone according to symmetry."""
|
||||||
equi= self.equivalent_vec.rotation #equivalent orientations
|
equi= self.equivalent.rotation #equivalent orientations
|
||||||
r= 1 if not self.rotation.shape else equi.shape[1] #number of rotations
|
r= 1 if not self.rotation.shape else equi.shape[1] #number of rotations
|
||||||
num_equi=equi.shape[0] #number of equivalente orientations
|
num_equi=equi.shape[0] #number of equivalente orientations
|
||||||
quat= np.reshape( equi.as_quaternion(), (r*num_equi,4) ,order='F') #equivalents are listed in intiuitive order
|
quat= np.reshape( equi.as_quaternion(), (r*num_equi,4) ,order='F') #equivalents are listed in intiuitive order
|
||||||
|
@ -163,7 +168,7 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
def reduced(self):
|
def reduced(self):
|
||||||
"""Transform orientation to fall into fundamental zone according to symmetry."""
|
"""Transform orientation to fall into fundamental zone according to symmetry."""
|
||||||
for me in self.equivalentOrientations():
|
for me in self.equivalentOrientations():
|
||||||
if self.lattice.symmetry.inFZ(me.rotation.as_Rodrigues(vector=True)): break
|
if self.lattice.inFZ(me.rotation.as_Rodrigues(vector=True)): break
|
||||||
|
|
||||||
return self.__class__(me.rotation,self.lattice)
|
return self.__class__(me.rotation,self.lattice)
|
||||||
|
|
||||||
|
@ -197,9 +202,9 @@ class Orientation: # ToDo: make subclass of lattice and Rotation
|
||||||
|
|
||||||
def IPF_color(self,axis):
|
def IPF_color(self,axis):
|
||||||
"""TSL color of inverse pole figure for given axis. Not for hex or triclinic lattices."""
|
"""TSL color of inverse pole figure for given axis. Not for hex or triclinic lattices."""
|
||||||
eq = self.equivalent_vec
|
eq = self.equivalent
|
||||||
pole = eq.rotation @ np.broadcast_to(axis/np.linalg.norm(axis),eq.rotation.shape+(3,))
|
pole = eq.rotation @ np.broadcast_to(axis/np.linalg.norm(axis),eq.rotation.shape+(3,))
|
||||||
in_SST, color = self.lattice.symmetry.in_SST(pole,color=True)
|
in_SST, color = self.lattice.in_SST(pole,color=True)
|
||||||
|
|
||||||
# ignore duplicates (occur for highly symmetric orientations)
|
# ignore duplicates (occur for highly symmetric orientations)
|
||||||
found = np.zeros_like(in_SST[1],dtype=bool)
|
found = np.zeros_like(in_SST[1],dtype=bool)
|
||||||
|
|
|
@ -28,13 +28,13 @@ class TestOrientation_vec:
|
||||||
ori_vec=Orientation(quat,lattice)
|
ori_vec=Orientation(quat,lattice)
|
||||||
|
|
||||||
for s in range(len(ori_vec.lattice.symmetry.symmetryOperations())):
|
for s in range(len(ori_vec.lattice.symmetry.symmetryOperations())):
|
||||||
assert all(ori_vec.equivalent_vec.rotation.as_Eulers()[s,0] == \
|
assert all(ori_vec.equivalent.rotation.as_Eulers()[s,0] == \
|
||||||
ori0.equivalentOrientations()[s].rotation.as_Eulers())
|
ori0.equivalentOrientations()[s].rotation.as_Eulers())
|
||||||
assert all(ori_vec.equivalent_vec.rotation.as_quaternion()[s,1] == \
|
assert all(ori_vec.equivalent.rotation.as_quaternion()[s,1] == \
|
||||||
ori1.equivalentOrientations()[s].rotation.as_quaternion())
|
ori1.equivalentOrientations()[s].rotation.as_quaternion())
|
||||||
assert all(ori_vec.equivalent_vec.rotation.as_Rodrigues()[s,2] == \
|
assert all(ori_vec.equivalent.rotation.as_Rodrigues()[s,2] == \
|
||||||
ori2.equivalentOrientations()[s].rotation.as_Rodrigues())
|
ori2.equivalentOrientations()[s].rotation.as_Rodrigues())
|
||||||
assert all(ori_vec.equivalent_vec.rotation.as_cubochoric()[s,3] == \
|
assert all(ori_vec.equivalent.rotation.as_cubochoric()[s,3] == \
|
||||||
ori3.equivalentOrientations()[s].rotation.as_cubochoric())
|
ori3.equivalentOrientations()[s].rotation.as_cubochoric())
|
||||||
|
|
||||||
@pytest.mark.parametrize('lattice',Lattice.lattices)
|
@pytest.mark.parametrize('lattice',Lattice.lattices)
|
||||||
|
|
Loading…
Reference in New Issue