From 077da6ca2a5422042320a44c3268a1778b075f4c Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 16 Aug 2021 13:19:10 -0400 Subject: [PATCH 01/12] removed incorrect parts of help --- python/damask/_crystal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_crystal.py b/python/damask/_crystal.py index 73d9f031c..2c2c4eba8 100644 --- a/python/damask/_crystal.py +++ b/python/damask/_crystal.py @@ -320,8 +320,8 @@ class Crystal(): Returns ------- - vector : numpy.ndarray of shape (...,3) or (N,...,3) - Crystal frame vector (or vectors if with_symmetry) along [uvw] direction or (hkl) plane normal. + vector : numpy.ndarray of shape (...,3) + Crystal frame vector along [uvw] direction or (hkl) plane normal. """ if (uvw is not None) ^ (hkl is None): From 8759d82e87f2ef200f24ce51bd8339fec68fc2fb Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 16 Aug 2021 13:23:31 -0400 Subject: [PATCH 02/12] to_pole now blends; corrected help texts --- python/damask/_orientation.py | 27 ++-- python/tests/test_Orientation.py | 262 ++++++++++++++++++------------- 2 files changed, 172 insertions(+), 117 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 7007951da..a568eb0f1 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -517,15 +517,15 @@ class Orientation(Rotation,Crystal): Notes ----- Currently requires same crystal family for both orientations. - For extension to cases with differing symmetry see A. Heinz and P. Neumann 1991 and 10.1107/S0021889808016373. + For extension to cases with differing symmetry see A. Heinz and P. Neumann 1991 and 10.1107/S0021889808016373. Examples -------- Disorientation between two specific orientations of hexagonal symmetry: >>> import damask - >>> a = damask.Orientation.from_Eulers(phi=[123,32,21],degrees=True,lattice='hexagonal') - >>> b = damask.Orientation.from_Eulers(phi=[104,11,87],degrees=True,lattice='hexagonal') + >>> a = damask.Orientation.from_Euler_angles(phi=[123,32,21],degrees=True,family='hexagonal') + >>> b = damask.Orientation.from_Euler_angles(phi=[104,11,87],degrees=True,family='hexagonal') >>> a.disorientation(b) Crystal family hexagonal Quaternion: (real=0.976, imag=<+0.189, +0.018, +0.103>) @@ -616,7 +616,7 @@ class Orientation(Rotation,Crystal): ---------- vector : numpy.ndarray of shape (...,3) Lab frame vector to align with crystal frame direction. - Shape of other blends with shape of own rotation array. + Shape of vector blends with shape of own rotation array. For example, a rotation array of shape (3,2) and a (2,4) vector array result in (3,2,4) outputs. proper : bool, optional Consider only vectors with z >= 0, hence combine two neighboring SSTs. @@ -696,6 +696,8 @@ class Orientation(Rotation,Crystal): ---------- vector : numpy.ndarray of shape (...,3) Vector to colorize. + Shape of vector blends with shape of own rotation array. + For example, a rotation array of shape (3,2) and a (2,4) vector array result in (3,2,4) outputs. in_SST : bool, optional Consider symmetrically equivalent orientations such that poles are located in SST. Defaults to True. @@ -713,7 +715,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 = damask.Orientation(family='cubic') >>> o.IPF_color([0,0,1]) array([1., 0., 0.]) @@ -835,22 +837,27 @@ class Orientation(Rotation,Crystal): ---------- uvw|hkl : numpy.ndarray of shape (...,3) Miller indices of crystallographic direction or plane normal. + Shape of vector blends with shape of own rotation array. + For example, a rotation array of shape (3,2) and a (2,4) vector array result in (3,2,4) outputs. with_symmetry : bool, optional Calculate all N symmetrically equivalent vectors. Returns ------- - vector : numpy.ndarray of shape (...,3) or (N,...,3) + vector : numpy.ndarray of shape (...,3) or (...,N,3) Lab frame vector (or vectors if with_symmetry) along [uvw] direction or (hkl) plane normal. """ v = self.to_frame(uvw=uvw,hkl=hkl) + blend = util.shapeblender(self.shape,v.shape[:-1]) if with_symmetry: sym_ops = self.symmetry_operations - v = sym_ops.broadcast_to(sym_ops.shape+v.shape[:-1],mode='right') \ - @ np.broadcast_to(v,sym_ops.shape+v.shape) - return ~(self if self.shape+v.shape[:-1] == () else self.broadcast_to(self.shape+v.shape[:-1],mode='right')) \ - @ np.broadcast_to(v,self.shape+v.shape) + shape = v.shape[:-1]+sym_ops.shape + blend += sym_ops.shape + v = sym_ops.broadcast_to(shape) \ + @ np.broadcast_to(v.reshape(util.shapeshifter(v.shape,shape+(3,))),shape+(3,)) + return ~(self.broadcast_to(blend)) \ + @ np.broadcast_to(v,blend+(3,)) def Schmid(self,*,N_slip=None,N_twin=None): diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 0c735c20f..b52481519 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -77,6 +77,16 @@ class TestOrientation: with pytest.raises(ValueError): Orientation(**kwargs) + @pytest.mark.parametrize('invalid_family',[None,'fcc','bcc','hello']) + def test_invalid_family_init(self,invalid_family): + with pytest.raises(KeyError): + Orientation(family=invalid_family) + + @pytest.mark.parametrize('invalid_lattice',[None,'fcc','bcc','hello']) + def test_invalid_family_init(self,invalid_lattice): + with pytest.raises(KeyError): + Orientation(lattice=invalid_lattice) + @pytest.mark.parametrize('kwargs',[ dict(lattice='aP',a=1.0,b=1.1,c=1.2,alpha=np.pi/4,beta=np.pi/3,gamma=np.pi/2), dict(lattice='mP',a=1.0,b=1.1,c=1.2, beta=np.pi/3 ), @@ -203,6 +213,15 @@ class TestOrientation: FZ = np.argmin(abs(eq.misorientation(i.broadcast_to(len(eq))).as_axis_angle(pair=True)[1])) assert o.reduced == eq[FZ] + @pytest.mark.parametrize('family',crystal_families) + def test_reduced_corner_cases(self,family): + # test whether there is always a sym-eq rotation that falls into the FZ + N = np.random.randint(10,40) + size = np.ones(3)*np.pi**(2./3.) + grid = grid_filters.coordinates0_node([N+1,N+1,N+1],size,-size*.5) + evenly_distributed = Orientation.from_cubochoric(x=grid[:-2,:-2,:-2],family=family) + assert evenly_distributed.shape == evenly_distributed.reduced.shape + @pytest.mark.parametrize('family',crystal_families) @pytest.mark.parametrize('N',[1,8,32]) def test_disorientation(self,family,N): @@ -221,81 +240,12 @@ class TestOrientation: .misorientation(p[n].equivalent[ops[n][1]]) .as_quaternion()) - @pytest.mark.parametrize('family',crystal_families) - @pytest.mark.parametrize('a,b',[ - ((2,3,2),(2,3,2)), - ((2,2),(4,4)), - ((3,1),(1,3)), - (None,None), - ]) - def test_disorientation_blending(self,family,a,b): - o = Orientation.from_random(family=family,shape=a) - p = Orientation.from_random(family=family,shape=b) - blend = util.shapeblender(o.shape,p.shape) - for loc in np.random.randint(0,blend,(10,len(blend))): - assert o[tuple(loc[:len(o.shape)])].disorientation(p[tuple(loc[-len(p.shape):])]) \ - .isclose(o.disorientation(p)[tuple(loc)]) - @pytest.mark.parametrize('family',crystal_families) def test_disorientation360(self,family): o_1 = Orientation(Rotation(),family=family) o_2 = Orientation.from_Euler_angles(family=family,phi=[360,0,0],degrees=True) assert np.allclose((o_1.disorientation(o_2)).as_matrix(),np.eye(3)) - @pytest.mark.parametrize('family',crystal_families) - @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) - def test_reduced_vectorization(self,family,shape): - o = Orientation.from_random(family=family,shape=shape) - for r, theO in zip(o.reduced.flatten(),o.flatten()): - assert r == theO.reduced - - @pytest.mark.parametrize('family',crystal_families) - def test_reduced_corner_cases(self,family): - # test whether there is always a sym-eq rotation that falls into the FZ - N = np.random.randint(10,40) - size = np.ones(3)*np.pi**(2./3.) - grid = grid_filters.coordinates0_node([N+1,N+1,N+1],size,-size*.5) - evenly_distributed = Orientation.from_cubochoric(x=grid[:-2,:-2,:-2],family=family) - assert evenly_distributed.shape == evenly_distributed.reduced.shape - - - @pytest.mark.parametrize('family',crystal_families) - @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) - @pytest.mark.parametrize('vector',np.array([[1,0,0],[1,2,3],[-1,1,-1]])) - @pytest.mark.parametrize('proper',[True,False]) - def test_to_SST_vectorization(self,family,shape,vector,proper): - o = Orientation.from_random(family=family,shape=shape) - for r, theO in zip(o.to_SST(vector=vector,proper=proper).reshape((-1,3)),o.flatten()): - assert np.allclose(r,theO.to_SST(vector=vector,proper=proper)) - - @pytest.mark.parametrize('family',crystal_families) - @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) - @pytest.mark.parametrize('vector',np.array([[1,0,0],[1,2,3],[-1,1,-1]])) - @pytest.mark.parametrize('proper',[True,False]) - @pytest.mark.parametrize('in_SST',[True,False]) - def test_IPF_color_vectorization(self,family,shape,vector,proper,in_SST): - o = Orientation.from_random(family=family,shape=shape) - for r, theO in zip(o.IPF_color(vector,in_SST=in_SST,proper=proper).reshape((-1,3)),o.flatten()): - assert np.allclose(r,theO.IPF_color(vector,in_SST=in_SST,proper=proper)) - - @pytest.mark.parametrize('family',crystal_families) - @pytest.mark.parametrize('a,b',[ - ((2,3,2),(2,3,2)), - ((2,2),(4,4)), - ((3,1),(1,3)), - (None,(3,)), - ]) - def test_to_SST_blending(self,family,a,b): - o = Orientation.from_random(family=family,shape=a) - v = np.random.random(b+(3,)) - blend = util.shapeblender(o.shape,b) - for loc in np.random.randint(0,blend,(10,len(blend))): - print(f'{a}/{b} @ {loc}') - print(o[tuple(loc[:len(o.shape)])].to_SST(v[tuple(loc[-len(b):])])) - print(o.to_SST(v)[tuple(loc)]) - assert np.allclose(o[tuple(loc[:len(o.shape)])].to_SST(v[tuple(loc[-len(b):])]), - o.to_SST(v)[tuple(loc)]) - @pytest.mark.parametrize('color',[{'label':'red', 'RGB':[1,0,0],'direction':[0,0,1]}, {'label':'green','RGB':[0,1,0],'direction':[0,1,1]}, {'label':'blue', 'RGB':[0,0,1],'direction':[1,1,1]}]) @@ -314,33 +264,6 @@ class TestOrientation: color = o.IPF_color(vector=direction,proper=proper) assert np.allclose(np.broadcast_to(color[0,...],color.shape),color) - @pytest.mark.parametrize('family',crystal_families) - def test_in_FZ_vectorization(self,set_of_rodrigues,family): - result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((-1,4,4)),family=family).in_FZ.reshape(-1) - for r,rho in zip(result,set_of_rodrigues[:len(result)]): - assert r == Orientation.from_Rodrigues_vector(rho=rho,family=family).in_FZ - - @pytest.mark.parametrize('family',crystal_families) - def test_in_disorientation_FZ_vectorization(self,set_of_rodrigues,family): - result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((-1,4,4)), - family=family).in_disorientation_FZ.reshape(-1) - for r,rho in zip(result,set_of_rodrigues[:len(result)]): - assert r == Orientation.from_Rodrigues_vector(rho=rho,family=family).in_disorientation_FZ - - @pytest.mark.parametrize('proper',[True,False]) - @pytest.mark.parametrize('family',crystal_families) - def test_in_SST_vectorization(self,family,proper): - vecs = np.random.rand(20,4,3) - result = Orientation(family=family).in_SST(vecs,proper).flatten() - for r,v in zip(result,vecs.reshape((-1,3))): - assert np.all(r == Orientation(family=family).in_SST(v,proper)) - - @pytest.mark.parametrize('invalid_family',[None,'fcc','bcc','hello']) - def test_invalid_lattice_init(self,invalid_family): - with pytest.raises(KeyError): - Orientation(family=invalid_family) - - @pytest.mark.parametrize('relation',[None,'Peter','Paul']) def test_unknown_relation(self,relation): with pytest.raises(KeyError): @@ -371,12 +294,6 @@ class TestOrientation: o = Orientation(family='cubic') # noqa with pytest.raises(ValueError): eval(f'o.{function}(np.ones(4))') - @pytest.mark.parametrize('model',['Bain','KS','GT','GT_prime','NW','Pitsch']) - @pytest.mark.parametrize('lattice',['cF','cI']) - def test_relationship_vectorize(self,set_of_quaternions,lattice,model): - r = Orientation(rotation=set_of_quaternions[:200].reshape((50,4,4)),lattice=lattice).related(model) - for i in range(200): - assert (r.reshape((-1,200))[:,i] == Orientation(set_of_quaternions[i],lattice=lattice).related(model)).all() @pytest.mark.parametrize('model',['Bain','KS','GT','GT_prime','NW','Pitsch']) @pytest.mark.parametrize('lattice',['cF','cI']) @@ -411,7 +328,6 @@ class TestOrientation: ) assert np.allclose(o.to_frame(uvw=np.eye(3)),basis), 'Lattice basis disagrees with initialization' - @pytest.mark.parametrize('lattice,a,b,c,alpha,beta,gamma', [ ('aP',0.5,2.0,3.0,0.8,0.5,1.2), @@ -421,7 +337,6 @@ class TestOrientation: ('hP',1.0,1.0,1.6,np.pi/2,np.pi/2,2*np.pi/3), ('cF',1.0,1.0,1.0,np.pi/2,np.pi/2,np.pi/2), ]) - @pytest.mark.parametrize('kw',['uvw','hkl']) @pytest.mark.parametrize('with_symmetry',[False,True]) @pytest.mark.parametrize('shape',[None,1,(12,24)]) @@ -436,7 +351,7 @@ class TestOrientation: a=a,b=b,c=c, alpha=alpha,beta=beta,gamma=gamma) assert o.to_pole(**{kw:vector,'with_symmetry':with_symmetry}).shape \ - == o.shape + (o.symmetry_operations.shape if with_symmetry else ()) + vector.shape + == o.shape + vector.shape[:-1] + (o.symmetry_operations.shape if with_symmetry else ()) + vector.shape[-1:] @pytest.mark.parametrize('lattice',['hP','cI','cF']) #tI not included yet def test_Schmid(self,update,ref_path,lattice): @@ -448,12 +363,145 @@ class TestOrientation: table = Table(P.reshape(-1,9),{'Schmid':(3,3,)}) table.save(reference) assert np.allclose(P,Table.load(reference).get('Schmid')) - + +### vectorization tests ### + @pytest.mark.parametrize('lattice',['hP','cI','cF']) # tI not included yet - def test_Schmid_vectorize(self,lattice): + def test_Schmid_vectorization(self,lattice): O = Orientation.from_random(shape=4,lattice=lattice) # noqa for mode in ['slip','twin']: Ps = O.Schmid(N_slip='*') if mode == 'slip' else O.Schmid(N_twin='*') for i in range(4): P = O[i].Schmid(N_slip='*') if mode == 'slip' else O[i].Schmid(N_twin='*') assert np.allclose(P,Ps[:,i]) + + @pytest.mark.parametrize('family',crystal_families) + @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) + def test_reduced_vectorization(self,family,shape): + o = Orientation.from_random(family=family,shape=shape) + for r, theO in zip(o.reduced.flatten(),o.flatten()): + assert r == theO.reduced + + + @pytest.mark.parametrize('family',crystal_families) + @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) + @pytest.mark.parametrize('vector',np.array([[1,0,0],[1,2,3],[-1,1,-1]])) + @pytest.mark.parametrize('proper',[True,False]) + def test_to_SST_vectorization(self,family,shape,vector,proper): + o = Orientation.from_random(family=family,shape=shape) + for r, theO in zip(o.to_SST(vector=vector,proper=proper).reshape((-1,3)),o.flatten()): + assert np.allclose(r,theO.to_SST(vector=vector,proper=proper)) + + @pytest.mark.parametrize('proper',[True,False]) + @pytest.mark.parametrize('family',crystal_families) + def test_in_SST_vectorization(self,family,proper): + vecs = np.random.rand(20,4,3) + result = Orientation(family=family).in_SST(vecs,proper).flatten() + for r,v in zip(result,vecs.reshape((-1,3))): + assert np.all(r == Orientation(family=family).in_SST(v,proper)) + + @pytest.mark.parametrize('family',crystal_families) + @pytest.mark.parametrize('shape',[(1),(2,3),(4,3,2)]) + @pytest.mark.parametrize('vector',np.array([[1,0,0],[1,2,3],[-1,1,-1]])) + @pytest.mark.parametrize('proper',[True,False]) + @pytest.mark.parametrize('in_SST',[True,False]) + def test_IPF_color_vectorization(self,family,shape,vector,proper,in_SST): + o = Orientation.from_random(family=family,shape=shape) + for r, theO in zip(o.IPF_color(vector,in_SST=in_SST,proper=proper).reshape((-1,3)),o.flatten()): + assert np.allclose(r,theO.IPF_color(vector,in_SST=in_SST,proper=proper)) + + @pytest.mark.parametrize('family',crystal_families) + def test_in_FZ_vectorization(self,set_of_rodrigues,family): + result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((-1,4,4)),family=family).in_FZ.reshape(-1) + for r,rho in zip(result,set_of_rodrigues[:len(result)]): + assert r == Orientation.from_Rodrigues_vector(rho=rho,family=family).in_FZ + + @pytest.mark.parametrize('family',crystal_families) + def test_in_disorientation_FZ_vectorization(self,set_of_rodrigues,family): + result = Orientation.from_Rodrigues_vector(rho=set_of_rodrigues.reshape((-1,4,4)), + family=family).in_disorientation_FZ.reshape(-1) + for r,rho in zip(result,set_of_rodrigues[:len(result)]): + assert r == Orientation.from_Rodrigues_vector(rho=rho,family=family).in_disorientation_FZ + + @pytest.mark.parametrize('model',['Bain','KS','GT','GT_prime','NW','Pitsch']) + @pytest.mark.parametrize('lattice',['cF','cI']) + def test_relationship_vectorization(self,set_of_quaternions,lattice,model): + r = Orientation(rotation=set_of_quaternions[:200].reshape((50,4,4)),lattice=lattice).related(model) + for i in range(200): + assert (r.reshape((-1,200))[:,i] == Orientation(set_of_quaternions[i],lattice=lattice).related(model)).all() + +### blending tests ### + + @pytest.mark.parametrize('family',crystal_families) + @pytest.mark.parametrize('left,right',[ + ((2,3,2),(2,3,2)), + ((2,2),(4,4)), + ((3,1),(1,3)), + (None,None), + ]) + def test_disorientation_blending(self,family,left,right): + o = Orientation.from_random(family=family,shape=left) + p = Orientation.from_random(family=family,shape=right) + blend = util.shapeblender(o.shape,p.shape) + for loc in np.random.randint(0,blend,(10,len(blend))): + # print(f'{a}/{b} @ {loc}') + # print(o[tuple(loc[:len(o.shape)])].disorientation(p[tuple(loc[-len(p.shape):])])) + # print(o.disorientation(p)[tuple(loc)]) + assert o[tuple(loc[:len(o.shape)])].disorientation(p[tuple(loc[-len(p.shape):])]) \ + .isclose(o.disorientation(p)[tuple(loc)]) + + @pytest.mark.parametrize('family',crystal_families) + @pytest.mark.parametrize('left,right',[ + ((2,3,2),(2,3,2)), + ((2,2),(4,4)), + ((3,1),(1,3)), + (None,(3,)), + ]) + def test_IPF_color_blending(self,family,left,right): + o = Orientation.from_random(family=family,shape=left) + v = np.random.random(right+(3,)) + blend = util.shapeblender(o.shape,v.shape[:-1]) + for loc in np.random.randint(0,blend,(10,len(blend))): + assert np.allclose(o[tuple(loc[:len(o.shape)])].IPF_color(v[tuple(loc[-len(v.shape[:-1]):])]), + o.IPF_color(v)[tuple(loc)]) + + @pytest.mark.parametrize('family',crystal_families) + @pytest.mark.parametrize('left,right',[ + ((2,3,2),(2,3,2)), + ((2,2),(4,4)), + ((3,1),(1,3)), + (None,(3,)), + ]) + def test_to_SST_blending(self,family,left,right): + o = Orientation.from_random(family=family,shape=left) + v = np.random.random(right+(3,)) + blend = util.shapeblender(o.shape,v.shape[:-1]) + for loc in np.random.randint(0,blend,(10,len(blend))): + assert np.allclose(o[tuple(loc[:len(o.shape)])].to_SST(v[tuple(loc[-len(v.shape[:-1]):])]), + o.to_SST(v)[tuple(loc)]) + + @pytest.mark.parametrize('lattice,a,b,c,alpha,beta,gamma', + [ + ('aP',0.5,2.0,3.0,0.8,0.5,1.2), + ('mP',1.0,2.0,3.0,np.pi/2,0.5,np.pi/2), + ('oI',0.5,1.5,3.0,np.pi/2,np.pi/2,np.pi/2), + ('tP',0.5,0.5,3.0,np.pi/2,np.pi/2,np.pi/2), + ('hP',1.0,1.0,1.6,np.pi/2,np.pi/2,2*np.pi/3), + ('cF',1.0,1.0,1.0,np.pi/2,np.pi/2,np.pi/2), + ]) + @pytest.mark.parametrize('left,right',[ + ((2,3,2),(2,3,2)), + ((2,2),(4,4)), + ((3,1),(1,3)), + (None,(3,)), + ]) + def test_to_pole_blending(self,lattice,a,b,c,alpha,beta,gamma,left,right): + o = Orientation.from_random(shape=left, + lattice=lattice, + a=a,b=b,c=c, + alpha=alpha,beta=beta,gamma=gamma) + v = np.random.random(right+(3,)) + blend = util.shapeblender(o.shape,v.shape[:-1]) + for loc in np.random.randint(0,blend,(10,len(blend))): + assert np.allclose(o[tuple(loc[:len(o.shape)])].to_pole(uvw=v[tuple(loc[-len(v.shape[:-1]):])]), + o.to_pole(uvw=v)[tuple(loc)]) From 5b63dc1e5e72a4a624c5997693ceaafcde298961 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 16 Aug 2021 19:23:46 +0200 Subject: [PATCH 03/12] [skip ci] updated version information after successful test of v3.0.0-alpha4-308-gb79fc5c09 --- python/damask/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/VERSION b/python/damask/VERSION index e35e43420..5ea374cfd 100644 --- a/python/damask/VERSION +++ b/python/damask/VERSION @@ -1 +1 @@ -v3.0.0-alpha4-298-g01d545861 +v3.0.0-alpha4-308-gb79fc5c09 From d2bd6e16ca49569355a5c532ea21ef646a5f9752 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 16 Aug 2021 13:24:34 -0400 Subject: [PATCH 04/12] capture special case early instead of failing --- python/damask/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/damask/util.py b/python/damask/util.py index d59b41b16..b34955659 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -375,6 +375,8 @@ def shapeshifter(fro,to,mode='left',keep_ones=False): """ + if not len(fro) and not len(to): return () + beg = dict(left ='(^.*\\b)', right='(^.*?\\b)') sep = dict(left ='(.*\\b)', From 9b695fd3fe7132d0ef9ea4d1d677693250e6ad7b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 16 Aug 2021 13:26:15 -0400 Subject: [PATCH 05/12] add_pole now has option "with_symmetry" --- python/damask/_result.py | 14 +++++++++----- python/tests/test_Result.py | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index a65ede773..47be41dab 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -983,20 +983,22 @@ class Result: @staticmethod - def _add_pole(q,uvw,hkl): + def _add_pole(q,uvw,hkl,with_symmetry): c = q['meta']['c/a'] if 'c/a' in q['meta'] else 1 - pole = Orientation(q['data'], lattice=q['meta']['lattice'], a=1, c=c).to_pole(uvw=uvw,hkl=hkl) + pole = Orientation(q['data'],lattice=q['meta']['lattice'],a=1,c=c).to_pole(uvw=uvw,hkl=hkl,with_symmetry=with_symmetry) return { 'data': pole, 'label': 'p^[{} {} {}]'.format(*uvw) if uvw else 'p^({} {} {})'.format(*hkl), 'meta' : { 'unit': '1', - 'description': f"lab frame vector along lattice {'direction' if uvw else 'plane'}", + 'description': 'lab frame vector along lattice ' \ + + ('direction' if uvw else 'plane') \ + + ('s' if with_symmetry else ''), 'creator': 'add_pole' } } - def add_pole(self,q='O',*,uvw=None,hkl=None): + def add_pole(self,q='O',*,uvw=None,hkl=None,with_symmetry=False): """ Add lab frame vector along lattice direction [uvw] or plane normal (hkl). @@ -1007,9 +1009,11 @@ class Result: Defaults to 'O'. uvw|hkl : numpy.ndarray of shape (...,3) Miller indices of crystallographic direction or plane normal. + with_symmetry : bool, optional + Calculate all N symmetrically equivalent vectors. """ - self._add_generic_pointwise(self._add_pole,{'q':q},{'uvw':uvw,'hkl':hkl}) + self._add_generic_pointwise(self._add_pole,{'q':q},{'uvw':uvw,'hkl':hkl,'with_symmetry':with_symmetry}) @staticmethod diff --git a/python/tests/test_Result.py b/python/tests/test_Result.py index 7126b4ab0..b597a67b7 100644 --- a/python/tests/test_Result.py +++ b/python/tests/test_Result.py @@ -219,7 +219,8 @@ class TestResult: in_file = default.place('S') assert np.allclose(in_memory,in_file) - @pytest.mark.parametrize('options',[{'uvw':[1,0,0]},{'hkl':[0,1,1]}]) + @pytest.mark.parametrize('options',[{'uvw':[1,0,0],'with_symmetry':False}, + {'hkl':[0,1,1],'with_symmetry':True}]) def test_add_pole(self,default,options): default.add_pole(**options) rot = default.place('O') From 5ea5416f37ff431baa8d7f468c8337681f5c9f3b Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Mon, 16 Aug 2021 13:40:10 -0400 Subject: [PATCH 06/12] more robust RuntimeError test; corrected name of double-defined test --- python/tests/test_Orientation.py | 2 +- python/tests/test_util.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index b52481519..686ed66c2 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -83,7 +83,7 @@ class TestOrientation: Orientation(family=invalid_family) @pytest.mark.parametrize('invalid_lattice',[None,'fcc','bcc','hello']) - def test_invalid_family_init(self,invalid_lattice): + def test_invalid_lattice_init(self,invalid_lattice): with pytest.raises(KeyError): Orientation(lattice=invalid_lattice) diff --git a/python/tests/test_util.py b/python/tests/test_util.py index 9af609ad0..13731eda2 100644 --- a/python/tests/test_util.py +++ b/python/tests/test_util.py @@ -19,9 +19,9 @@ class TestUtil: out,err = util.execute('sh -c "echo $test_for_execute"',env={'test_for_execute':'test'}) assert out=='test\n' and err=='' - def test_execute_invalid(self): + def test_execute_runtime_error(self): with pytest.raises(RuntimeError): - util.execute('/bin/false') + util.execute('false') @pytest.mark.parametrize('input,output', [ From a1fd45bdedaca4176ab0c19211c500cb04ecb70c Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 17 Aug 2021 17:11:02 +0200 Subject: [PATCH 07/12] offset should have been taken into account (like earlier) new changes should not break old functionality --- PRIVATE | 2 +- src/YAML_parse.f90 | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/PRIVATE b/PRIVATE index 4ce625b4a..3abca9c1d 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 4ce625b4ac0da9d490620f8cf1694d0a057cfa47 +Subproject commit 3abca9c1db05b76bff72b38b24897b881fd23077 diff --git a/src/YAML_parse.f90 b/src/YAML_parse.f90 index 5ee38691c..608fed1ee 100644 --- a/src/YAML_parse.f90 +++ b/src/YAML_parse.f90 @@ -360,18 +360,19 @@ end subroutine remove_line_break !-------------------------------------------------------------------------------------------------- !> @brief return the scalar list item without line break !-------------------------------------------------------------------------------------------------- -subroutine list_item_inline(blck,s_blck,inline) !ToDo: SR: merge with remove_line_break eventually +subroutine list_item_inline(blck,s_blck,inline,offset) - character(len=*), intent(in) :: blck !< YAML in mixed style - integer, intent(inout) :: s_blck - character(len=:), allocatable, intent(out) :: inline + character(len=*), intent(in) :: blck !< YAML in mixed style + integer, intent(inout) :: s_blck + character(len=:), allocatable, intent(out) :: inline + integer, intent(inout) :: offset character(len=:), allocatable :: line integer :: indent,indent_next + indent = indentDepth(blck(s_blck:),offset) line = IO_rmComment(blck(s_blck:s_blck + index(blck(s_blck:),IO_EOL) - 2)) - indent = indentDepth(blck(s_blck:)) - inline = line(indent+3:) + inline = line(indent-offset+3:) s_blck = s_blck + index(blck(s_blck:),IO_EOL) indent_next = indentDepth(blck(s_blck:)) @@ -563,9 +564,9 @@ recursive subroutine lst(blck,flow,s_blck,s_flow,offset) else ! list item in the same line line = line(indentDepth(line)+3:) if(isScalar(line)) then - call list_item_inline(blck,s_blck,inline) - call line_toFlow(flow,s_flow,inline) + call list_item_inline(blck,s_blck,inline,offset) offset = 0 + call line_toFlow(flow,s_flow,inline) elseif(isFlow(line)) then s_blck = s_blck + index(blck(s_blck:),'-') if(isFlowList(line)) then From 66953a7c04a624b417b8b24fc93cf73ba359c3e5 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 17 Aug 2021 18:56:24 +0200 Subject: [PATCH 08/12] test repo updated --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 3abca9c1d..6037ed541 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 3abca9c1db05b76bff72b38b24897b881fd23077 +Subproject commit 6037ed541710fc84699ee2ca1d36a69d7fa20f0f From 64ba6da5facfc4113c9c9495ea02fd5d45bbe43a Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 18 Aug 2021 11:02:01 +0200 Subject: [PATCH 09/12] [skip ci] updated version information after successful test of v3.0.0-alpha4-315-gc4cdb046b --- python/damask/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/VERSION b/python/damask/VERSION index 5ea374cfd..db59d9670 100644 --- a/python/damask/VERSION +++ b/python/damask/VERSION @@ -1 +1 @@ -v3.0.0-alpha4-308-gb79fc5c09 +v3.0.0-alpha4-315-gc4cdb046b From 7d506b5d99bf7d4efb3e44d0b6f475e7366cd148 Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 18 Aug 2021 15:59:45 +0200 Subject: [PATCH 10/12] [skip ci] updated version information after successful test of v3.0.0-alpha4-320-g13159caf4 --- python/damask/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/VERSION b/python/damask/VERSION index db59d9670..48ca92461 100644 --- a/python/damask/VERSION +++ b/python/damask/VERSION @@ -1 +1 @@ -v3.0.0-alpha4-315-gc4cdb046b +v3.0.0-alpha4-320-g13159caf4 From 9061297e6eb0876d9acea5442f52bcab70094a8d Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 19 Aug 2021 19:57:52 +0200 Subject: [PATCH 11/12] typo --- src/phase_mechanical_elastic.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/phase_mechanical_elastic.f90 b/src/phase_mechanical_elastic.f90 index 326c23c7a..f253a0f5d 100644 --- a/src/phase_mechanical_elastic.f90 +++ b/src/phase_mechanical_elastic.f90 @@ -146,7 +146,7 @@ module function elastic_nu(ph) result(nu) integer, intent(in) :: ph - nu = param(ph)%mu + nu = param(ph)%nu end function elastic_nu From 03622c5d9daf3e232083ea714908765c301e06f9 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 20 Aug 2021 19:33:05 +0200 Subject: [PATCH 12/12] [skip ci] updated version information after successful test of v3.0.0-alpha4-323-gcf8e9c262 --- python/damask/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/VERSION b/python/damask/VERSION index 48ca92461..4f889fdb3 100644 --- a/python/damask/VERSION +++ b/python/damask/VERSION @@ -1 +1 @@ -v3.0.0-alpha4-320-g13159caf4 +v3.0.0-alpha4-323-gcf8e9c262