compatible with material.yaml
This commit is contained in:
parent
bb5db3e79c
commit
b5be4c3fa5
|
@ -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=np.vstack(self.kinematics(mode)['direction']))
|
if (N_slip is not None) ^ (N_twin is None):
|
||||||
p = self.to_frame(hkl=np.vstack(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