Merge branch 'orientation-polish' into restructure-Orientation-2
This commit is contained in:
commit
4e0b3abeec
|
@ -340,7 +340,7 @@ class Crystal():
|
||||||
"""
|
"""
|
||||||
_kinematics = {
|
_kinematics = {
|
||||||
'cF': {
|
'cF': {
|
||||||
'slip' : np.array([
|
'slip' :[np.array([
|
||||||
[+0,+1,-1, +1,+1,+1],
|
[+0,+1,-1, +1,+1,+1],
|
||||||
[-1,+0,+1, +1,+1,+1],
|
[-1,+0,+1, +1,+1,+1],
|
||||||
[+1,-1,+0, +1,+1,+1],
|
[+1,-1,+0, +1,+1,+1],
|
||||||
|
@ -352,15 +352,15 @@ class Crystal():
|
||||||
[+1,+1,+0, +1,-1,-1],
|
[+1,+1,+0, +1,-1,-1],
|
||||||
[+0,+1,+1, -1,+1,-1],
|
[+0,+1,+1, -1,+1,-1],
|
||||||
[+1,+0,-1, -1,+1,-1],
|
[+1,+0,-1, -1,+1,-1],
|
||||||
[-1,-1,+0, -1,+1,-1],
|
[-1,-1,+0, -1,+1,-1]]),
|
||||||
|
np.array([
|
||||||
[+1,+1,+0, +1,-1,+0],
|
[+1,+1,+0, +1,-1,+0],
|
||||||
[+1,-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],
|
||||||
[+0,+1,+1, +0,+1,-1],
|
[+0,+1,+1, +0,+1,-1],
|
||||||
[+0,+1,-1, +0,+1,+1],
|
[+0,+1,-1, +0,+1,+1]])],
|
||||||
],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],
|
||||||
[ 1, 1,-2, 1, 1, 1],
|
[ 1, 1,-2, 1, 1, 1],
|
||||||
|
@ -372,11 +372,10 @@ class Crystal():
|
||||||
[ 1,-1, 2, 1,-1,-1],
|
[ 1,-1, 2, 1,-1,-1],
|
||||||
[ 2, 1,-1, -1, 1,-1],
|
[ 2, 1,-1, -1, 1,-1],
|
||||||
[-1,-2,-1, -1, 1,-1],
|
[-1,-2,-1, -1, 1,-1],
|
||||||
[-1, 1, 2, -1, 1,-1],
|
[-1, 1, 2, -1, 1,-1]])]
|
||||||
],dtype=float),
|
|
||||||
},
|
},
|
||||||
'cI': {
|
'cI': {
|
||||||
'slip' : np.array([
|
'slip' :[np.array([
|
||||||
[+1,-1,+1, +0,+1,+1],
|
[+1,-1,+1, +0,+1,+1],
|
||||||
[-1,-1,+1, +0,+1,+1],
|
[-1,-1,+1, +0,+1,+1],
|
||||||
[+1,+1,+1, +0,-1,+1],
|
[+1,+1,+1, +0,-1,+1],
|
||||||
|
@ -388,7 +387,8 @@ class Crystal():
|
||||||
[-1,+1,+1, +1,+1,+0],
|
[-1,+1,+1, +1,+1,+0],
|
||||||
[-1,+1,-1, +1,+1,+0],
|
[-1,+1,-1, +1,+1,+0],
|
||||||
[+1,+1,+1, -1,+1,+0],
|
[+1,+1,+1, -1,+1,+0],
|
||||||
[+1,+1,-1, -1,+1,+0],
|
[+1,+1,-1, -1,+1,+0]]),
|
||||||
|
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],
|
||||||
[+1,+1,-1, +2,-1,+1],
|
[+1,+1,-1, +2,-1,+1],
|
||||||
|
@ -400,7 +400,8 @@ class Crystal():
|
||||||
[+1,+1,-1, +1,+1,+2],
|
[+1,+1,-1, +1,+1,+2],
|
||||||
[+1,-1,+1, -1,+1,+2],
|
[+1,-1,+1, -1,+1,+2],
|
||||||
[-1,+1,+1, +1,-1,+2],
|
[-1,+1,+1, +1,-1,+2],
|
||||||
[+1,+1,+1, +1,+1,-2],
|
[+1,+1,+1, +1,+1,-2]]),
|
||||||
|
np.array([
|
||||||
[+1,+1,-1, +1,+2,+3],
|
[+1,+1,-1, +1,+2,+3],
|
||||||
[+1,-1,+1, -1,+2,+3],
|
[+1,-1,+1, -1,+2,+3],
|
||||||
[-1,+1,+1, +1,-2,+3],
|
[-1,+1,+1, +1,-2,+3],
|
||||||
|
@ -424,9 +425,8 @@ 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],
|
||||||
[+1,-1,+1, +3,+2,-1],
|
[+1,-1,+1, +3,+2,-1]])],
|
||||||
],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],
|
||||||
[ 1, 1,-1, 2,-1, 1],
|
[ 1, 1,-1, 2,-1, 1],
|
||||||
|
@ -438,26 +438,29 @@ class Crystal():
|
||||||
[ 1, 1,-1, 1, 1, 2],
|
[ 1, 1,-1, 1, 1, 2],
|
||||||
[ 1,-1, 1, -1, 1, 2],
|
[ 1,-1, 1, -1, 1, 2],
|
||||||
[-1, 1, 1, 1,-1, 2],
|
[-1, 1, 1, 1,-1, 2],
|
||||||
[ 1, 1, 1, 1, 1,-2],
|
[ 1, 1, 1, 1, 1,-2]])]
|
||||||
],dtype=float),
|
|
||||||
},
|
},
|
||||||
'hP': {
|
'hP': {
|
||||||
'slip' : np.array([
|
'slip' :[np.array([
|
||||||
[+2,-1,-1,+0, +0,+0,+0,+1],
|
[+2,-1,-1,+0, +0,+0,+0,+1],
|
||||||
[-1,+2,-1,+0, +0,+0,+0,+1],
|
[-1,+2,-1,+0, +0,+0,+0,+1],
|
||||||
[-1,-1,+2,+0, +0,+0,+0,+1],
|
[-1,-1,+2,+0, +0,+0,+0,+1]]),
|
||||||
|
np.array([
|
||||||
[+2,-1,-1,+0, +0,+1,-1,+0],
|
[+2,-1,-1,+0, +0,+1,-1,+0],
|
||||||
[-1,+2,-1,+0, -1,+0,+1,+0],
|
[-1,+2,-1,+0, -1,+0,+1,+0],
|
||||||
[-1,-1,+2,+0, +1,-1,+0,+0],
|
[-1,-1,+2,+0, +1,-1,+0,+0]]),
|
||||||
|
np.array([
|
||||||
[-1,+1,+0,+0, +1,+1,-2,+0],
|
[-1,+1,+0,+0, +1,+1,-2,+0],
|
||||||
[+0,-1,+1,+0, -2,+1,+1,+0],
|
[+0,-1,+1,+0, -2,+1,+1,+0],
|
||||||
[+1,+0,-1,+0, +1,-2,+1,+0],
|
[+1,+0,-1,+0, +1,-2,+1,+0]]),
|
||||||
|
np.array([
|
||||||
[-1,+2,-1,+0, +1,+0,-1,+1],
|
[-1,+2,-1,+0, +1,+0,-1,+1],
|
||||||
[-2,+1,+1,+0, +0,+1,-1,+1],
|
[-2,+1,+1,+0, +0,+1,-1,+1],
|
||||||
[-1,-1,+2,+0, -1,+1,+0,+1],
|
[-1,-1,+2,+0, -1,+1,+0,+1],
|
||||||
[+1,-2,+1,+0, -1,+0,+1,+1],
|
[+1,-2,+1,+0, -1,+0,+1,+1],
|
||||||
[+2,-1,-1,+0, +0,-1,+1,+1],
|
[+2,-1,-1,+0, +0,-1,+1,+1],
|
||||||
[+1,+1,-2,+0, +1,-1,+0,+1],
|
[+1,+1,-2,+0, +1,-1,+0,+1]]),
|
||||||
|
np.array([
|
||||||
[-2,+1,+1,+3, +1,+0,-1,+1],
|
[-2,+1,+1,+3, +1,+0,-1,+1],
|
||||||
[-1,-1,+2,+3, +1,+0,-1,+1],
|
[-1,-1,+2,+3, +1,+0,-1,+1],
|
||||||
[-1,-1,+2,+3, +0,+1,-1,+1],
|
[-1,-1,+2,+3, +0,+1,-1,+1],
|
||||||
|
@ -469,49 +472,51 @@ class Crystal():
|
||||||
[+1,+1,-2,+3, +0,-1,+1,+1],
|
[+1,+1,-2,+3, +0,-1,+1,+1],
|
||||||
[-1,+2,-1,+3, +0,-1,+1,+1],
|
[-1,+2,-1,+3, +0,-1,+1,+1],
|
||||||
[-1,+2,-1,+3, +1,-1,+0,+1],
|
[-1,+2,-1,+3, +1,-1,+0,+1],
|
||||||
[-2,+1,+1,+3, +1,-1,+0,+1],
|
[-2,+1,+1,+3, +1,-1,+0,+1]]),
|
||||||
|
np.array([
|
||||||
[-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],
|
||||||
[+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]])],
|
||||||
],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],
|
||||||
[ 1,-1, 0, 1, -1, 1, 0, 2],
|
[ 1,-1, 0, 1, -1, 1, 0, 2],
|
||||||
[ 1, 0,-1, 1, -1, 0, 1, 2],
|
[ 1, 0,-1, 1, -1, 0, 1, 2],
|
||||||
[ 0, 1,-1, 1, 0,-1, 1, 2],
|
[ 0, 1,-1, 1, 0,-1, 1, 2],
|
||||||
[-1, 1, 0, 1, 1,-1, 0, 2],
|
[-1, 1, 0, 1, 1,-1, 0, 2]]),
|
||||||
|
np.array([
|
||||||
[-1,-1, 2, 6, 1, 1,-2, 1], # shear = 1/(c/a) <11.6>{-1-1.1}
|
[-1,-1, 2, 6, 1, 1,-2, 1], # shear = 1/(c/a) <11.6>{-1-1.1}
|
||||||
[ 1,-2, 1, 6, -1, 2,-1, 1],
|
[ 1,-2, 1, 6, -1, 2,-1, 1],
|
||||||
[ 2,-1,-1, 6, -2, 1, 1, 1],
|
[ 2,-1,-1, 6, -2, 1, 1, 1],
|
||||||
[ 1, 1,-2, 6, -1,-1, 2, 1],
|
[ 1, 1,-2, 6, -1,-1, 2, 1],
|
||||||
[-1, 2,-1, 6, 1,-2, 1, 1],
|
[-1, 2,-1, 6, 1,-2, 1, 1],
|
||||||
[-2, 1, 1, 6, 2,-1,-1, 1],
|
[-2, 1, 1, 6, 2,-1,-1, 1]]),
|
||||||
|
np.array([
|
||||||
[ 1, 0,-1,-2, 1, 0,-1, 1], # shear = (4(c/a)^2-9)/(4 sqrt(3) c/a) <10.-2>{10.1}
|
[ 1, 0,-1,-2, 1, 0,-1, 1], # shear = (4(c/a)^2-9)/(4 sqrt(3) c/a) <10.-2>{10.1}
|
||||||
[ 0, 1,-1,-2, 0, 1,-1, 1],
|
[ 0, 1,-1,-2, 0, 1,-1, 1],
|
||||||
[-1, 1, 0,-2, -1, 1, 0, 1],
|
[-1, 1, 0,-2, -1, 1, 0, 1],
|
||||||
[-1, 0, 1,-2, -1, 0, 1, 1],
|
[-1, 0, 1,-2, -1, 0, 1, 1],
|
||||||
[ 0,-1, 1,-2, 0,-1, 1, 1],
|
[ 0,-1, 1,-2, 0,-1, 1, 1],
|
||||||
[ 1,-1, 0,-2, 1,-1, 0, 1],
|
[ 1,-1, 0,-2, 1,-1, 0, 1]]),
|
||||||
|
np.array([
|
||||||
[ 1, 1,-2,-3, 1, 1,-2, 2], # shear = 2((c/a)^2-2)/(3 c/a) <11.-3>{11.2}
|
[ 1, 1,-2,-3, 1, 1,-2, 2], # shear = 2((c/a)^2-2)/(3 c/a) <11.-3>{11.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],
|
||||||
[-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]])]
|
||||||
],dtype=float),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
master = _kinematics[self.lattice][mode]
|
master = _kinematics[self.lattice][mode]
|
||||||
if self.lattice == 'hP':
|
if self.lattice == 'hP':
|
||||||
return {'direction':util.Bravais_to_Miller(uvtw=master[:,0:4]),
|
return {'direction':[util.Bravais_to_Miller(uvtw=m[:,0:4]) for m in master],
|
||||||
'plane': util.Bravais_to_Miller(hkil=master[:,4:8])}
|
'plane': [util.Bravais_to_Miller(hkil=m[:,4:8]) for m in master]}
|
||||||
else:
|
else:
|
||||||
return {'direction':master[:,0:3],
|
return {'direction':[m[:,0:3] for m in master],
|
||||||
'plane': master[:,3:6]}
|
'plane': [m[:,3:6] for m in master]}
|
||||||
|
|
||||||
|
|
||||||
def relation_operations(self,model):
|
def relation_operations(self,model):
|
||||||
|
|
|
@ -854,14 +854,15 @@ class Orientation(Rotation,Crystal):
|
||||||
@ np.broadcast_to(v,self.shape+v.shape)
|
@ np.broadcast_to(v,self.shape+v.shape)
|
||||||
|
|
||||||
|
|
||||||
def Schmid(self,mode):
|
def Schmid(self,*,N_slip=None,N_twin=None):
|
||||||
u"""
|
u"""
|
||||||
Calculate Schmid matrix P = d ⨂ n in the lab frame for given lattice shear kinematics.
|
Calculate Schmid matrix P = d ⨂ n in the lab frame for selected deformation systems.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
mode : {'slip', 'twin'}
|
N_slip|N_twin : iterable of int
|
||||||
Deformation mode.
|
Number of deformation systems per deformation system.
|
||||||
|
Use '*'. to select all.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
@ -876,14 +877,22 @@ class Orientation(Rotation,Crystal):
|
||||||
>>> import damask
|
>>> import damask
|
||||||
>>> import numpy as np
|
>>> import numpy as np
|
||||||
>>> np.set_printoptions(3,suppress=True,floatmode='fixed')
|
>>> np.set_printoptions(3,suppress=True,floatmode='fixed')
|
||||||
>>> damask.Orientation.from_Eulers(phi=[0,45,0],degrees=True,lattice='cF').Schmid('slip')[0]
|
>>> O = damask.Orientation.from_Euler_angles(phi=[0,45,0],degrees=True,lattice='cF')
|
||||||
|
>>> O.Schmid(N_slip=[1])
|
||||||
array([[ 0.000, 0.000, 0.000],
|
array([[ 0.000, 0.000, 0.000],
|
||||||
[ 0.577, -0.000, 0.816],
|
[ 0.577, -0.000, 0.816],
|
||||||
[ 0.000, 0.000, 0.000]])
|
[ 0.000, 0.000, 0.000]])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
d = self.to_frame(uvw=self.kinematics(mode)['direction'])
|
if (N_slip is not None) ^ (N_twin is None):
|
||||||
p = self.to_frame(hkl=self.kinematics(mode)['plane'])
|
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
|
||||||
|
if active == '*': active = [len(a) for a in kinematics]
|
||||||
|
|
||||||
|
d = self.to_frame(uvw=np.vstack([kinematics['direction'][i][:n] for i,n in enumerate(active)]))
|
||||||
|
p = self.to_frame(hkl=np.vstack([kinematics['plane'][i][:n] for i,n in enumerate(active)]))
|
||||||
P = np.einsum('...i,...j',d/np.linalg.norm(d,axis=1,keepdims=True),
|
P = np.einsum('...i,...j',d/np.linalg.norm(d,axis=1,keepdims=True),
|
||||||
p/np.linalg.norm(p,axis=1,keepdims=True))
|
p/np.linalg.norm(p,axis=1,keepdims=True))
|
||||||
|
|
||||||
|
|
|
@ -440,10 +440,10 @@ class TestOrientation:
|
||||||
|
|
||||||
@pytest.mark.parametrize('lattice',['hP','cI','cF']) #tI not included yet
|
@pytest.mark.parametrize('lattice',['hP','cI','cF']) #tI not included yet
|
||||||
def test_Schmid(self,update,ref_path,lattice):
|
def test_Schmid(self,update,ref_path,lattice):
|
||||||
L = Orientation(lattice=lattice)
|
O = Orientation(lattice=lattice) # noqa
|
||||||
for mode in ['slip','twin']:
|
for mode in ['slip','twin']:
|
||||||
reference = ref_path/f'{lattice}_{mode}.txt'
|
reference = ref_path/f'{lattice}_{mode}.txt'
|
||||||
P = L.Schmid(mode)
|
P = O.Schmid(N_slip='*') if mode == 'slip' else O.Schmid(N_twin='*')
|
||||||
if update:
|
if update:
|
||||||
table = Table(P.reshape(-1,9),{'Schmid':(3,3,)})
|
table = Table(P.reshape(-1,9),{'Schmid':(3,3,)})
|
||||||
table.save(reference)
|
table.save(reference)
|
||||||
|
@ -453,7 +453,6 @@ class TestOrientation:
|
||||||
def test_Schmid_vectorize(self,lattice):
|
def test_Schmid_vectorize(self,lattice):
|
||||||
O = Orientation.from_random(shape=4,lattice=lattice) # noqa
|
O = Orientation.from_random(shape=4,lattice=lattice) # noqa
|
||||||
for mode in ['slip','twin']:
|
for mode in ['slip','twin']:
|
||||||
P = O.Schmid(mode)
|
P = O.Schmid(N_slip='*') if mode == 'slip' else O.Schmid(N_twin='*')
|
||||||
print(P.shape)
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
assert np.allclose(Orientation(rotation=O[i],lattice=lattice).Schmid(mode),P[:,i])
|
assert np.allclose(Orientation(rotation=O[i],lattice=lattice).Schmid(mode),P[:,i])
|
||||||
|
|
Loading…
Reference in New Issue