added CrystalFamily, CrystalLattice, CrystalKinematics typehints
This commit is contained in:
parent
0a52ae3b6f
commit
c6a188a1fe
|
@ -2,11 +2,11 @@ from typing import Union, Dict, List, Tuple
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from ._typehints import FloatSequence
|
from ._typehints import FloatSequence, CrystalFamily, CrystalLattice, CrystalKinematics
|
||||||
from . import util
|
from . import util
|
||||||
from . import Rotation
|
from . import Rotation
|
||||||
|
|
||||||
lattice_symmetries = {
|
lattice_symmetries: Dict[CrystalLattice, CrystalFamily] = {
|
||||||
'aP': 'triclinic',
|
'aP': 'triclinic',
|
||||||
|
|
||||||
'mP': 'monoclinic',
|
'mP': 'monoclinic',
|
||||||
|
@ -32,8 +32,8 @@ class Crystal():
|
||||||
"""Crystal lattice."""
|
"""Crystal lattice."""
|
||||||
|
|
||||||
def __init__(self,*,
|
def __init__(self,*,
|
||||||
family = None,
|
family: CrystalFamily = None,
|
||||||
lattice = None,
|
lattice: CrystalLattice = None,
|
||||||
a: float = None, b: float = None, c: float = None,
|
a: float = None, b: float = None, c: float = None,
|
||||||
alpha: float = None, beta: float = None, gamma: float = None,
|
alpha: float = None, beta: float = None, gamma: float = None,
|
||||||
degrees: bool = False):
|
degrees: bool = False):
|
||||||
|
@ -208,7 +208,7 @@ class Crystal():
|
||||||
... }
|
... }
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_basis = {
|
_basis: Dict[CrystalFamily, Dict[str, np.ndarray]] = {
|
||||||
'cubic': {'improper':np.array([ [-1. , 0. , 1. ],
|
'cubic': {'improper':np.array([ [-1. , 0. , 1. ],
|
||||||
[ np.sqrt(2.) , -np.sqrt(2.) , 0. ],
|
[ np.sqrt(2.) , -np.sqrt(2.) , 0. ],
|
||||||
[ 0. , np.sqrt(3.) , 0. ] ]),
|
[ 0. , np.sqrt(3.) , 0. ] ]),
|
||||||
|
@ -322,12 +322,12 @@ class Crystal():
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
direction|plane : numpy.ndarray of shape (...,3)
|
direction|plane : numpy.ndarray, shape (...,3)
|
||||||
Vector along direction or plane normal.
|
Vector along direction or plane normal.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
Miller : numpy.ndarray of shape (...,3)
|
Miller : numpy.ndarray, shape (...,3)
|
||||||
Lattice vector of direction or plane.
|
Lattice vector of direction or plane.
|
||||||
Use util.scale_to_coprime to convert to (integer) Miller indices.
|
Use util.scale_to_coprime to convert to (integer) Miller indices.
|
||||||
|
|
||||||
|
@ -348,12 +348,12 @@ class Crystal():
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
uvw|hkl : numpy.ndarray of shape (...,3)
|
uvw|hkl : numpy.ndarray, shape (...,3)
|
||||||
Miller indices of crystallographic direction or plane normal.
|
Miller indices of crystallographic direction or plane normal.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
vector : numpy.ndarray of shape (...,3)
|
vector : numpy.ndarray, shape (...,3)
|
||||||
Crystal frame vector along [uvw] direction or (hkl) plane normal.
|
Crystal frame vector along [uvw] direction or (hkl) plane normal.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -366,7 +366,7 @@ class Crystal():
|
||||||
|
|
||||||
|
|
||||||
def kinematics(self,
|
def kinematics(self,
|
||||||
mode: str) -> Dict[str, List[np.ndarray]]:
|
mode: CrystalKinematics) -> Dict[str, List[np.ndarray]]:
|
||||||
"""
|
"""
|
||||||
Return crystal kinematics systems.
|
Return crystal kinematics systems.
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ class Crystal():
|
||||||
Directions and planes of deformation mode families.
|
Directions and planes of deformation mode families.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_kinematics = {
|
_kinematics: Dict[CrystalLattice, Dict[CrystalKinematics, List[np.ndarray]]] = {
|
||||||
'cF': {
|
'cF': {
|
||||||
'slip': [np.array([
|
'slip': [np.array([
|
||||||
[+0,+1,-1, +1,+1,+1],
|
[+0,+1,-1, +1,+1,+1],
|
||||||
|
@ -626,7 +626,7 @@ class Crystal():
|
||||||
|
|
||||||
|
|
||||||
def relation_operations(self,
|
def relation_operations(self,
|
||||||
model: str) -> Tuple[str, Rotation]:
|
model: str) -> Tuple[CrystalLattice, Rotation]:
|
||||||
"""
|
"""
|
||||||
Crystallographic orientation relationships for phase transformations.
|
Crystallographic orientation relationships for phase transformations.
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ class Crystal():
|
||||||
https://doi.org/10.1016/j.actamat.2004.11.021
|
https://doi.org/10.1016/j.actamat.2004.11.021
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_orientation_relationships = {
|
_orientation_relationships: Dict[str, Dict[CrystalLattice,np.ndarray]] = {
|
||||||
'KS': {
|
'KS': {
|
||||||
'cF' : np.array([
|
'cF' : np.array([
|
||||||
[[-1, 0, 1],[ 1, 1, 1]],
|
[[-1, 0, 1],[ 1, 1, 1]],
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import inspect
|
import inspect
|
||||||
import copy
|
import copy
|
||||||
from typing import Union, Callable, Dict, Any, Tuple
|
from typing import Union, Callable, List, Dict, Any, Tuple
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from ._typehints import FloatSequence, IntSequence
|
from ._typehints import FloatSequence, IntSequence, CrystalFamily, CrystalLattice
|
||||||
from . import Rotation
|
from . import Rotation
|
||||||
from . import Crystal
|
from . import Crystal
|
||||||
from . import util
|
from . import util
|
||||||
|
@ -98,8 +98,8 @@ class Orientation(Rotation,Crystal):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
rotation: Union[FloatSequence, Rotation] = np.array([1.,0.,0.,0.]),
|
rotation: Union[FloatSequence, Rotation] = np.array([1.,0.,0.,0.]),
|
||||||
*,
|
*,
|
||||||
family: str = None,
|
family: CrystalFamily = None,
|
||||||
lattice: str = None,
|
lattice: CrystalLattice = None,
|
||||||
a: float = None, b: float = None, c: float = None,
|
a: float = None, b: float = None, c: float = None,
|
||||||
alpha: float = None, beta: float = None, gamma: float = None,
|
alpha: float = None, beta: float = None, gamma: float = None,
|
||||||
degrees: bool = False):
|
degrees: bool = False):
|
||||||
|
@ -787,7 +787,7 @@ class Orientation(Rotation,Crystal):
|
||||||
@property
|
@property
|
||||||
def symmetry_operations(self) -> Rotation:
|
def symmetry_operations(self) -> Rotation:
|
||||||
"""Symmetry operations as Rotations."""
|
"""Symmetry operations as Rotations."""
|
||||||
_symmetry_operations = {
|
_symmetry_operations: Dict[CrystalFamily, List] = {
|
||||||
'cubic': [
|
'cubic': [
|
||||||
[ 1.0, 0.0, 0.0, 0.0 ],
|
[ 1.0, 0.0, 0.0, 0.0 ],
|
||||||
[ 0.0, 1.0, 0.0, 0.0 ],
|
[ 0.0, 1.0, 0.0, 0.0 ],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Functionality for typehints."""
|
"""Functionality for typehints."""
|
||||||
|
|
||||||
from typing import Sequence, Union, TextIO
|
from typing import Sequence, Union, Literal, TextIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -10,5 +10,9 @@ FloatSequence = Union[np.ndarray,Sequence[float]]
|
||||||
IntSequence = Union[np.ndarray,Sequence[int]]
|
IntSequence = Union[np.ndarray,Sequence[int]]
|
||||||
FileHandle = Union[TextIO, str, Path]
|
FileHandle = Union[TextIO, str, Path]
|
||||||
NumpyRngSeed = Union[int, IntSequence, np.random.SeedSequence, np.random.Generator]
|
NumpyRngSeed = Union[int, IntSequence, np.random.SeedSequence, np.random.Generator]
|
||||||
|
CrystalFamily = Union[None,Literal['triclinic', 'monoclinic', 'orthorhombic', 'tetragonal', 'hexagonal', 'cubic']]
|
||||||
|
CrystalLattice = Union[None,Literal['aP', 'mP', 'mS', 'oP', 'oS', 'oI', 'oF', 'tP', 'tI', 'hP', 'cP', 'cI', 'cF']]
|
||||||
|
CrystalKinematics = Literal['slip', 'twin']
|
||||||
|
|
||||||
# BitGenerator does not exists in older numpy versions
|
# BitGenerator does not exists in older numpy versions
|
||||||
#NumpyRngSeed = Union[int, IntSequence, np.random.SeedSequence, np.random.BitGenerator, np.random.Generator]
|
#NumpyRngSeed = Union[int, IntSequence, np.random.SeedSequence, np.random.BitGenerator, np.random.Generator]
|
||||||
|
|
Loading…
Reference in New Issue