From f27969caf9ab3013705921c8c89b6963f8f2ecaf Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 8 May 2022 23:22:03 +0200 Subject: [PATCH] documenting and testing --- python/damask/_rotation.py | 17 ++++++++++++++--- python/tests/test_Orientation.py | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index a0baf1a0b..b24c864b3 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -1126,8 +1126,8 @@ class Rotation: Notes ----- - The default crystal direction (θ=0,φ=0) direction is [0 0 1], - the default sample direction (θ=0,φ=0) is z. + The crystal direction for (θ=0,φ=0) is [0 0 1], + the sample direction for (θ=0,φ=0) is z. Polar coordinates follow the ISO 80000-2:2019 convention typically used in physics. @@ -1137,7 +1137,18 @@ class Rotation: Examples -------- - tbd + Create an ideal α-fiber texture (<1 1 0> ǀǀ RD=x) consisting of + 200 orientations: + + >>> import damask + >>> import numpy as np + >>> alpha = damask.Rotation.from_fiber_component([np.pi/4.,0.],[np.pi/2.,0.],shape=200) + + Create an ideal γ-fiber texture (<1 1 1> ǀǀ ND=z) consisting of + 100 orientations: + + >>> import damask + >>> gamma = damask.Rotation.from_fiber_component([54.7,45.0],[0.,0.],shape=100,degrees=True) """ rng = np.random.default_rng(rng_seed) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 729967539..17da524d8 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -158,6 +158,13 @@ class TestOrientation: sigma=0.0,shape=None,rng_seed=0,lattice='cI').quaternion == r.quaternion) + @pytest.mark.parametrize('crystal,sample,direction,color',[([np.pi/4,0],[np.pi/2,0],[1,0,0],[0,1,0]), + ([np.arccos(3**(-.5)),np.pi/4,0],[0,0],[0,0,1],[0,0,1])]) + def test_fiber_IPF(self,crystal,sample,direction,color): + fiber = Orientation.from_fiber_component(crystal=crystal,sample=sample,family='cubic',shape=200) + print(np.allclose(fiber.IPF_color(direction),color)) + + @pytest.mark.parametrize('kwargs',[ dict(lattice='aP',a=1.0,b=1.1,c=1.2,alpha=np.pi/4.5,beta=np.pi/3.5,gamma=np.pi/2.5), dict(lattice='mP',a=1.0,b=1.1,c=1.2, beta=np.pi/3.5),