keep data close to where it is used

This commit is contained in:
Martin Diehl 2021-07-18 16:02:05 +02:00
parent 212a4ed63c
commit 86a60283c3
1 changed files with 455 additions and 463 deletions

View File

@ -172,6 +172,8 @@ class Crystal():
""" """
Corners of the standard triangle. Corners of the standard triangle.
Notes
-----
Not yet defined for monoclinic. Not yet defined for monoclinic.
@ -322,70 +324,6 @@ class Crystal():
def kinematics(self,mode): def kinematics(self,mode):
master = self._kinematics[self.lattice][mode]
if self.lattice == 'hP':
return {'direction':util.Bravais_to_Miller(uvtw=master[:,0:4]),
'plane': util.Bravais_to_Miller(hkil=master[:,4:8])}
else:
return {'direction':master[:,0:3],
'plane': master[:,3:6]}
def relation_operations(self,model):
"""
Crystallographic orientation relationships for phase transformations.
Parameters
----------
model : str
Name of orientation relationship.
Returns
-------
operations : (string, damask.Rotation)
Rotations characterizing the orientation relationship.
References
----------
S. Morito et al., Journal of Alloys and Compounds 577:s587-s592, 2013
https://doi.org/10.1016/j.jallcom.2012.02.004
K. Kitahara et al., Acta Materialia 54(5):1279-1288, 2006
https://doi.org/10.1016/j.actamat.2005.11.001
Y. He et al., Journal of Applied Crystallography 39:72-81, 2006
https://doi.org/10.1107/S0021889805038276
H. Kitahara et al., Materials Characterization 54(4-5):378-386, 2005
https://doi.org/10.1016/j.matchar.2004.12.015
Y. He et al., Acta Materialia 53(4):1179-1190, 2005
https://doi.org/10.1016/j.actamat.2004.11.021
"""
if model not in self.orientation_relationships:
raise KeyError(f'unknown orientation relationship "{model}"')
r = self.orientation_relationships[model]
sl = self.lattice
ol = (set(r)-{sl}).pop()
m = r[sl]
o = r[ol]
p_,_p = np.zeros(m.shape[:-1]+(3,)),np.zeros(o.shape[:-1]+(3,))
p_[...,0,:] = m[...,0,:] if m.shape[-1] == 3 else util.Bravais_to_Miller(uvtw=m[...,0,0:4])
p_[...,1,:] = m[...,1,:] if m.shape[-1] == 3 else util.Bravais_to_Miller(hkil=m[...,1,0:4])
_p[...,0,:] = o[...,0,:] if o.shape[-1] == 3 else util.Bravais_to_Miller(uvtw=o[...,0,0:4])
_p[...,1,:] = o[...,1,:] if o.shape[-1] == 3 else util.Bravais_to_Miller(hkil=o[...,1,0:4])
return (ol,Rotation.from_parallel(p_,_p))
@property
def orientation_relationships(self):
return {k:v for k,v in self._orientation_relationships.items() if self.lattice in v}
_kinematics = { _kinematics = {
'cF': { 'cF': {
'slip' : np.array([ 'slip' : np.array([
@ -407,7 +345,7 @@ class Crystal():
[+1,+0,-1, +1,+0,+1], [+1,+0,-1, +1,+0,+1],
[+0,+1,+1, +0,+1,-1], [+0,+1,+1, +0,+1,-1],
[+0,+1,-1, +0,+1,+1], [+0,+1,-1, +0,+1,+1],
],'d'), ],dtype=float),
'twin' : np.array([ 'twin' : np.array([
[-2, 1, 1, 1, 1, 1], [-2, 1, 1, 1, 1, 1],
[ 1,-2, 1, 1, 1, 1], [ 1,-2, 1, 1, 1, 1],
@ -473,7 +411,7 @@ class Crystal():
[+1,+1,+1, -3,+2,+1], [+1,+1,+1, -3,+2,+1],
[+1,+1,-1, +3,-2,+1], [+1,+1,-1, +3,-2,+1],
[+1,-1,+1, +3,+2,-1], [+1,-1,+1, +3,+2,-1],
],'d'), ],dtype=float),
'twin' : np.array([ 'twin' : np.array([
[-1, 1, 1, 2, 1, 1], [-1, 1, 1, 2, 1, 1],
[ 1, 1, 1, -2, 1, 1], [ 1, 1, 1, -2, 1, 1],
@ -524,7 +462,7 @@ class Crystal():
[+1,+1,-2,+3, -1,-1,+2,+2], [+1,+1,-2,+3, -1,-1,+2,+2],
[-1,+2,-1,+3, +1,-2,+1,+2], [-1,+2,-1,+3, +1,-2,+1,+2],
[-2,+1,+1,+3, +2,-1,-1,+2], [-2,+1,+1,+3, +2,-1,-1,+2],
],'d'), ],dtype=float),
'twin' : np.array([ 'twin' : np.array([
[-1, 0, 1, 1, 1, 0,-1, 2], # shear = (3-(c/a)^2)/(sqrt(3) c/a) <-10.1>{10.2} [-1, 0, 1, 1, 1, 0,-1, 2], # shear = (3-(c/a)^2)/(sqrt(3) c/a) <-10.1>{10.2}
[ 0,-1, 1, 1, 0, 1,-1, 2], [ 0,-1, 1, 1, 0, 1,-1, 2],
@ -553,8 +491,47 @@ class Crystal():
],dtype=float), ],dtype=float),
}, },
} }
master = _kinematics[self.lattice][mode]
if self.lattice == 'hP':
return {'direction':util.Bravais_to_Miller(uvtw=master[:,0:4]),
'plane': util.Bravais_to_Miller(hkil=master[:,4:8])}
else:
return {'direction':master[:,0:3],
'plane': master[:,3:6]}
def relation_operations(self,model):
"""
Crystallographic orientation relationships for phase transformations.
Parameters
----------
model : str
Name of orientation relationship.
Returns
-------
operations : (string, damask.Rotation)
Rotations characterizing the orientation relationship.
References
----------
S. Morito et al., Journal of Alloys and Compounds 577:s587-s592, 2013
https://doi.org/10.1016/j.jallcom.2012.02.004
K. Kitahara et al., Acta Materialia 54(5):1279-1288, 2006
https://doi.org/10.1016/j.actamat.2005.11.001
Y. He et al., Journal of Applied Crystallography 39:72-81, 2006
https://doi.org/10.1107/S0021889805038276
H. Kitahara et al., Materials Characterization 54(4-5):378-386, 2005
https://doi.org/10.1016/j.matchar.2004.12.015
Y. He et al., Acta Materialia 53(4):1179-1190, 2005
https://doi.org/10.1016/j.actamat.2004.11.021
"""
_orientation_relationships = { _orientation_relationships = {
'KS': { 'KS': {
'cF' : np.array([ 'cF' : np.array([
@ -825,5 +802,20 @@ class Crystal():
],dtype=float), ],dtype=float),
}, },
} }
orientation_relationships = {k:v for k,v in _orientation_relationships.items() if self.lattice in v}
if model not in orientation_relationships:
raise KeyError(f'unknown orientation relationship "{model}"')
r = orientation_relationships[model]
sl = self.lattice
ol = (set(r)-{sl}).pop()
m = r[sl]
o = r[ol]
p_,_p = np.zeros(m.shape[:-1]+(3,)),np.zeros(o.shape[:-1]+(3,))
p_[...,0,:] = m[...,0,:] if m.shape[-1] == 3 else util.Bravais_to_Miller(uvtw=m[...,0,0:4])
p_[...,1,:] = m[...,1,:] if m.shape[-1] == 3 else util.Bravais_to_Miller(hkil=m[...,1,0:4])
_p[...,0,:] = o[...,0,:] if o.shape[-1] == 3 else util.Bravais_to_Miller(uvtw=o[...,0,0:4])
_p[...,1,:] = o[...,1,:] if o.shape[-1] == 3 else util.Bravais_to_Miller(hkil=o[...,1,0:4])
return (ol,Rotation.from_parallel(p_,_p))