From b11a14999bbcc2def839adfdbf5819d63c4dea37 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Thu, 30 Sep 2021 11:01:42 -0400 Subject: [PATCH] simplified lattice point data; added test --- python/damask/_crystal.py | 10 +++------- python/tests/test_Crystal.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/python/damask/_crystal.py b/python/damask/_crystal.py index 5cfdad848..f36b28b4c 100644 --- a/python/damask/_crystal.py +++ b/python/damask/_crystal.py @@ -290,31 +290,27 @@ class Crystal(): """Return lattice points.""" _lattice_points = { 'P': [ - [0,0,0], ], 'S': [ - [0,0,0], [0.5,0.5,0], ], 'I': [ - [0,0,0], [0.5,0.5,0.5], ], 'F': [ - [0,0,0], [0.0,0.5,0.5], [0.5,0.0,0.5], [0.5,0.5,0.0], ], 'hP': [ - [0,0,0], [2./3.,1./3.,0.5], ], } if self.lattice is None: raise KeyError('no lattice type specified') - return np.array(_lattice_points.get(self.lattice if self.lattice == 'hP' else \ - self.lattice[-1],None),dtype=float) + return np.array([[0,0,0]] + + _lattice_points.get(self.lattice if self.lattice == 'hP' else \ + self.lattice[-1],None),dtype=float) def to_lattice(self,*,direction=None,plane=None): """ diff --git a/python/tests/test_Crystal.py b/python/tests/test_Crystal.py index 8b5217f63..90fbdce74 100644 --- a/python/tests/test_Crystal.py +++ b/python/tests/test_Crystal.py @@ -65,4 +65,17 @@ class TestCrystal: alpha=alpha,beta=beta,gamma=gamma) assert np.allclose(vector, c.to_frame(**{keyFrame:c.to_lattice(**{keyLattice:vector})})) - + + @pytest.mark.parametrize('lattice,a,b,c,alpha,beta,gamma,points', + [ + ('aP',0.5,2.0,3.0,0.8,0.5,1.2,[[0,0,0]]), + ('mS',1.0,2.0,3.0,np.pi/2,0.5,np.pi/2,[[0,0,0],[0.5,0.5,0.0]]), + ('oI',0.5,1.5,3.0,np.pi/2,np.pi/2,np.pi/2,[[0,0,0],[0.5,0.5,0.5]]), + ('hP',1.0,1.0,1.6,np.pi/2,np.pi/2,2*np.pi/3,[[0,0,0],[2./3.,1./3.,0.5]]), + ('cF',1.0,1.0,1.0,np.pi/2,np.pi/2,np.pi/2,[[0,0,0],[0.0,0.5,0.5],[0.5,0.0,0.5],[0.5,0.5,0.0]]), + ]) + def test_lattice_points(self,lattice,a,b,c,alpha,beta,gamma,points): + c = Crystal(lattice=lattice, + a=a,b=b,c=c, + alpha=alpha,beta=beta,gamma=gamma) + assert np.allclose(points,c.lattice_points)