simplified lattice point data; added test

This commit is contained in:
Philip Eisenlohr 2021-09-30 11:01:42 -04:00
parent d293fb8af9
commit b11a14999b
2 changed files with 17 additions and 8 deletions

View File

@ -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):
"""

View File

@ -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)