示例#1
0
 def test_generate_points(self):
     # Tests that 3d points are properly generated
     c = TEMCalculator()
     actual = c.generate_points(-1, 1)
     expected = np.array([
         [-1, -1, -1],
         [-1, -1, 0],
         [-1, -1, 1],
         [0, -1, -1],
         [0, -1, 0],
         [0, -1, 1],
         [1, -1, -1],
         [1, -1, 0],
         [1, -1, 1],
         [-1, 0, -1],
         [-1, 0, 0],
         [-1, 0, 1],
         [0, 0, -1],
         [0, 0, 0],
         [0, 0, 1],
         [1, 0, -1],
         [1, 0, 0],
         [1, 0, 1],
         [-1, 1, -1],
         [-1, 1, 0],
         [-1, 1, 1],
         [0, 1, -1],
         [0, 1, 0],
         [0, 1, 1],
         [1, 1, -1],
         [1, 1, 0],
         [1, 1, 1],
     ])
     self.assertArrayEqual(expected, actual)
示例#2
0
 def test_get_first_point(self):
     c = TEMCalculator()
     latt = Lattice.cubic(4.209)
     points = c.generate_points(-2, 2)
     cubic = Structure(latt, ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]])
     first_pt = c.get_first_point(cubic, points)
     self.assertTrue(4.209 in first_pt.values())
示例#3
0
 def test_TEM_dots(self):
     # All dependencies in TEM_dots method are tested. Only make sure each object created is
     # the class desired.
     c = TEMCalculator()
     points = c.generate_points(-2, 2)
     structure = self.get_structure("Si")
     dots = c.tem_dots(structure, points)
     self.assertTrue(all([isinstance(x, tuple) for x in dots]))
示例#4
0
 def test_get_positions(self):
     c = TEMCalculator()
     points = c.generate_points(-2, 2)
     structure = self.get_structure("Si")
     positions = c.get_positions(structure, points)
     self.assertArrayEqual([0, 0], positions[(0, 0, 0)])
     # Test silicon diffraction data spot rough positions:
     # see https://www.doitpoms.ac.uk/tlplib/diffraction-patterns/printall.php
     self.assertArrayAlmostEqual([1, 0], positions[(-1, 0, 0)], 0)