documenting
This commit is contained in:
parent
de428efca5
commit
d1c3d767cc
|
@ -324,6 +324,20 @@ class Crystal():
|
||||||
|
|
||||||
|
|
||||||
def kinematics(self,mode):
|
def kinematics(self,mode):
|
||||||
|
"""
|
||||||
|
Return kinematic sytems.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
mode : {'slip','twin'}
|
||||||
|
Deformation mode.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
direction_plane : dictionary
|
||||||
|
Direction and plane of deformation mode.
|
||||||
|
|
||||||
|
"""
|
||||||
_kinematics = {
|
_kinematics = {
|
||||||
'cF': {
|
'cF': {
|
||||||
'slip' : np.array([
|
'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:
|
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:
|
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 = damask.Orientation(lattice='cubic')
|
||||||
>>> o.IPF_color([0,0,1])
|
>>> o.IPF_color([0,0,1])
|
||||||
array([1., 0., 0.])
|
array([1., 0., 0.])
|
||||||
|
@ -859,7 +861,7 @@ class Orientation(Rotation,Crystal):
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
mode : {'slip', 'twin'}
|
mode : {'slip', 'twin'}
|
||||||
Type of kinematics.
|
Deformation mode.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
@ -868,7 +870,7 @@ class Orientation(Rotation,Crystal):
|
||||||
|
|
||||||
Examples
|
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.
|
cubic crystal in "Goss" orientation.
|
||||||
|
|
||||||
>>> import damask
|
>>> import damask
|
||||||
|
@ -880,13 +882,10 @@ class Orientation(Rotation,Crystal):
|
||||||
[ 0.000, 0.000, 0.000]])
|
[ 0.000, 0.000, 0.000]])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
d = self.to_frame(uvw=self.kinematics(mode)['direction'])
|
||||||
d = self.to_frame(uvw=self.kinematics(mode)['direction'])
|
p = self.to_frame(hkl=self.kinematics(mode)['plane'])
|
||||||
p = self.to_frame(hkl=self.kinematics(mode)['plane'])
|
P = np.einsum('...i,...j',d/np.linalg.norm(d,axis=1,keepdims=True),
|
||||||
except KeyError:
|
p/np.linalg.norm(p,axis=1,keepdims=True))
|
||||||
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))
|
|
||||||
|
|
||||||
return ~self.broadcast_to( self.shape+P.shape[:-2],mode='right') \
|
return ~self.broadcast_to( self.shape+P.shape[:-2],mode='right') \
|
||||||
@ np.broadcast_to(P,self.shape+P.shape)
|
@ np.broadcast_to(P,self.shape+P.shape)
|
||||||
|
|
|
@ -287,6 +287,8 @@ def project_stereographic(vector,direction='z',normalize=True,keepdims=False):
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
>>> import damask
|
||||||
|
>>> import numpy as np
|
||||||
>>> project_stereographic(np.ones(3))
|
>>> project_stereographic(np.ones(3))
|
||||||
[0.3660254, 0.3660254]
|
[0.3660254, 0.3660254]
|
||||||
>>> project_stereographic(np.ones(3),direction='x',normalize=False,keepdims=True)
|
>>> 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):
|
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
|
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.
|
Treat '1' in fro as literal value instead of dimensional placeholder.
|
||||||
Defaults to False.
|
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)',
|
beg = dict(left ='(^.*\\b)',
|
||||||
right='(^.*?\\b)')
|
right='(^.*?\\b)')
|
||||||
|
|
Loading…
Reference in New Issue