documenting
This commit is contained in:
parent
de428efca5
commit
d1c3d767cc
|
@ -324,6 +324,20 @@ class Crystal():
|
|||
|
||||
|
||||
def kinematics(self,mode):
|
||||
"""
|
||||
Return kinematic sytems.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mode : {'slip','twin'}
|
||||
Deformation mode.
|
||||
|
||||
Returns
|
||||
-------
|
||||
direction_plane : dictionary
|
||||
Direction and plane of deformation mode.
|
||||
|
||||
"""
|
||||
_kinematics = {
|
||||
'cF': {
|
||||
'slip' : np.array([
|
||||
|
|
|
@ -107,7 +107,8 @@ class Orientation(Rotation,Crystal):
|
|||
--------
|
||||
An array of 3 x 5 random orientations reduced to the fundamental zone of tetragonal symmetry:
|
||||
|
||||
>>> damask.Orientation.from_random(shape=(3,5),lattice='tetragonal').reduced
|
||||
>>> import damask
|
||||
>>> o=damask.Orientation.from_random(shape=(3,5),lattice='tetragonal').reduced
|
||||
|
||||
"""
|
||||
|
||||
|
@ -712,6 +713,7 @@ class Orientation(Rotation,Crystal):
|
|||
--------
|
||||
Inverse pole figure color of the e_3 direction for a crystal in "Cube" orientation with cubic symmetry:
|
||||
|
||||
>>> import damask
|
||||
>>> o = damask.Orientation(lattice='cubic')
|
||||
>>> o.IPF_color([0,0,1])
|
||||
array([1., 0., 0.])
|
||||
|
@ -859,7 +861,7 @@ class Orientation(Rotation,Crystal):
|
|||
Parameters
|
||||
----------
|
||||
mode : {'slip', 'twin'}
|
||||
Type of kinematics.
|
||||
Deformation mode.
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
@ -868,7 +870,7 @@ class Orientation(Rotation,Crystal):
|
|||
|
||||
Examples
|
||||
--------
|
||||
Schmid matrix (in lab frame) of slip systems of a face-centered
|
||||
Schmid matrix (in lab frame) of first slip system of a face-centered
|
||||
cubic crystal in "Goss" orientation.
|
||||
|
||||
>>> import damask
|
||||
|
@ -880,13 +882,10 @@ class Orientation(Rotation,Crystal):
|
|||
[ 0.000, 0.000, 0.000]])
|
||||
|
||||
"""
|
||||
try:
|
||||
d = self.to_frame(uvw=self.kinematics(mode)['direction'])
|
||||
p = self.to_frame(hkl=self.kinematics(mode)['plane'])
|
||||
except KeyError:
|
||||
raise (f'"{mode}" not defined for lattice "{self.lattice}"')
|
||||
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.einsum('...i,...j',d/np.linalg.norm(d,axis=1,keepdims=True),
|
||||
p/np.linalg.norm(p,axis=1,keepdims=True))
|
||||
|
||||
return ~self.broadcast_to( self.shape+P.shape[:-2],mode='right') \
|
||||
@ np.broadcast_to(P,self.shape+P.shape)
|
||||
|
|
|
@ -287,6 +287,8 @@ def project_stereographic(vector,direction='z',normalize=True,keepdims=False):
|
|||
|
||||
Examples
|
||||
--------
|
||||
>>> import damask
|
||||
>>> import numpy as np
|
||||
>>> project_stereographic(np.ones(3))
|
||||
[0.3660254, 0.3660254]
|
||||
>>> project_stereographic(np.ones(3),direction='x',normalize=False,keepdims=True)
|
||||
|
@ -339,7 +341,7 @@ def hybrid_IA(dist,N,rng_seed=None):
|
|||
|
||||
def shapeshifter(fro,to,mode='left',keep_ones=False):
|
||||
"""
|
||||
Return a tuple that reshapes 'fro' to become broadcastable to 'to'.
|
||||
Return dimensions that reshape 'fro' to become broadcastable to 'to'.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -356,6 +358,22 @@ def shapeshifter(fro,to,mode='left',keep_ones=False):
|
|||
Treat '1' in fro as literal value instead of dimensional placeholder.
|
||||
Defaults to False.
|
||||
|
||||
Returns
|
||||
-------
|
||||
new_dims : tuple
|
||||
Dimensions for reshape.
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> import numpy as np
|
||||
>>> from damask import util
|
||||
>>> a = np.ones((3,4,2))
|
||||
>>> b = np.ones(4)
|
||||
>>> b_extended = b.reshape(util.shapeshifter(b.shape,a.shape))
|
||||
>>> (a * np.broadcast_to(b_extended,a.shape)).shape
|
||||
(3,4,2)
|
||||
|
||||
|
||||
"""
|
||||
beg = dict(left ='(^.*\\b)',
|
||||
right='(^.*?\\b)')
|
||||
|
|
Loading…
Reference in New Issue