Exemple #1
0
 def test_distance(self):
     index = 456
     site = Mock(spec=Site)
     label = 'foo'
     other_atom = Atom(index=index, site=site, label=label)
     self.atom.site.distance = Mock(return_value=2.3)
     self.assertEqual(self.atom.distance(other_atom), 2.3)
    def __init__(self,
                 structure: Structure,
                 recipes: List[PolyhedraRecipe]) -> None:
        """
        A Configuration object describes a single atomic geometry.

        Args:
            structure (pymatgen.Structure): A pymatgen Structure object for this configuration.
            recipes (list(PolyhedraRecipe): A list of PolyhedraRecipe objects used to construct
                polyhedra for this configuration.

        Attributes:
            atoms (list(Atom)): A list of atoms that make up this configuration.
            polyhedra (list(CoordinationPolyhedron)): A list of polyhedra, generated using
                the PolyhedraRecipe definitions passed in as the `recipes` list.
            central_atoms (list(Atom)): A list of atoms that define the centres of the 
                coordination polyhedra.
            coordination_atoms (list(Atom)): A list of atoms that define the vertices of 
                the coordination polyhedra.
         """
        self.atoms = [Atom(index=i,
                           site=site,
                           label=site.species_string)
                      for i, site in enumerate(structure.sites)]
        self.polyhedra: List[CoordinationPolyhedron] = []
        for recipe in recipes:
            self.polyhedra.extend(recipe.find_polyhedra(self.atoms, structure))
        self.central_atoms = sorted(list(set(
            [p.central_atom for p in self.polyhedra])),
            key=lambda x: x.index)
        self.coordination_atoms = sorted(list(set(flatten(
            [p.vertices for p in self.polyhedra]))),
            key=lambda x: x.index)
Exemple #3
0
 def test___eq___when_false(self):
     index = 456
     site = Mock(spec=Site)
     label = 'foo'
     site.frac_coords = np.array([1.0, 2.0, 3.0])
     site.coords = np.array([10.0, 11.0, 12.0])
     site.lattice = Mock(spec=Lattice)
     other_atom = Atom(index=index, site=site, label=label)
     self.assertNotEqual(self.atom, other_atom)
Exemple #4
0
 def test___lt__(self):
     index = 456
     site = MagicMock(spec=Site)
     label = 'bar'
     self.frac_coords = np.array([2.0, 3.0, 4.0])
     site.coords = np.array([20.0, 21.0, 22.0])
     site.lattice = Mock(spec=Lattice)
     other_atom = Atom(index=index, site=site, label=label)
     self.assertTrue(self.atom < other_atom)
Exemple #5
0
 def setUp(self):
     index = 123
     site = Mock(spec=Site)
     label = 'foo'
     site.frac_coords = np.array([1.0, 2.0, 3.0])
     site.coords = np.array([10.0, 11.0, 12.0])
     site.lattice = Mock(spec=Lattice)
     self.site = site
     self.atom = Atom(index=index, site=site, label=label)
 def test_atom_is_initialised_without_label( self ):
     index = 123
     site = Mock( spec=Site )
     atom = Atom( index=index, site=site )
     self.assertEqual( atom.index, index )
     self.assertEqual( atom.site, site )
     self.assertEqual( atom.label, None )
     self.assertEqual( atom.in_polyhedra, [] )
     self.assertEqual( atom.neighbours, None )
Exemple #7
0
 def test_atom_is_initialised_without_label(self):
     index = 123
     site = Mock(spec=Site)
     site.species_string = 'bar'
     atom = Atom(index=index, site=site)
     self.assertEqual(atom.index, index)
     self.assertEqual(atom.site, site)
     self.assertEqual(atom.label, 'bar')
     self.assertEqual(atom.in_polyhedra, [])
     self.assertEqual(atom.neighbours, {})
Exemple #8
0
 def test_atom_is_initialised(self):
     index = 123
     site = Mock(spec=Site)
     label = 'foo'
     atom = Atom(index=index, site=site, label=label)
     self.assertEqual(atom.index, index)
     self.assertEqual(atom.site, site)
     self.assertEqual(atom.label, label)
     self.assertEqual(atom.in_polyhedra, [])
     self.assertEqual(atom.neighbours, {})