コード例 #1
0
ファイル: test_Zeolite.py プロジェクト: kul-group/MAZE-sim
    def test_register_with_parent(self):
        with self.subTest(msg='test simple case, no additions'):
            parent = PerfectZeolite.make('BEA')
            child = Zeolite.make('BEA')
            child = child.retag_self()
            child.register_with_parent(parent)
            self.assertEqual(parent.index_mapper, child.index_mapper)
            self.assertEqual(parent, child.parent_zeotype)
            self.assertIn(child.name, child.index_mapper.names)

        with self.subTest(msg='test additions'):
            parent = PerfectZeolite.make('BEA')
            additions_dict = copy.deepcopy(parent.additions)
            child = Zeolite.make('BEA')
            child = child.add_atoms(
                Atoms("H2", positions=[[0, 0, 0], [1, 1, 1]]),
                'H2').delete_atoms([1, 2, 3, 4])
            ads_map = child.build_additions_map()
            child.additions = additions_dict
            child = child.retag_self()
            child.register_with_parent(parent, ads_map)
            self.assertEqual(parent.index_mapper, child.index_mapper)
            self.assertEqual(parent, child.parent_zeotype)
            self.assertIn(child.name, child.index_mapper.names)
            name_list = []
            for key in ads_map:
                name_list.extend(list(ads_map[key]))
            for name in name_list:
                self.assertIn(name, child.index_mapper.names)
コード例 #2
0
    def test_build_iz_from_z(self):
        tmp_goo = PerfectZeolite.make('GOO')
        z = PerfectZeolite.build_from_cif_with_labels('data/GOO.cif')
        iz = Zeolite(z)
        # tests inheritance
        self.assertIsInstance(iz, Zeolite)
        self.assertIsInstance(iz, PerfectZeolite)
        self.assertIsInstance(iz, Atoms)
        # tests empty list attributes
        # tests corretly defined parameters
        self.assertEqual(iz._site_to_atom_indices, None)
        self.assertEqual(iz._atom_indices_to_site, None)
        #self.assertEqual(iz.name)
        self.assertEqual(iz.parent_zeotype, z)
        #tests atoms are there and behave the same
        self.assertCountEqual(iz.get_tags(), z.get_tags())
        self.assertCountEqual(iz.get_chemical_symbols(),
                              z.get_chemical_symbols())
        self.assertEqual(id(iz.parent_zeotype), id(z.parent_zeotype))
        self.assertEqual(id(iz.index_mapper), id(z.index_mapper))
        self.assertEqual(id(iz.parent_zeotype), id(z.parent_zeotype))
        self.assertNotEqual(iz.index_mapper, None)

        self.assertEqual(iz.parent_zeotype, z)
        self.assertEqual(iz.index_mapper, z.index_mapper)
        self.assertEqual(iz.index_mapper, z.index_mapper)
コード例 #3
0
 def test_init_with_zeolite_obj(self):
     tmp_goo = PerfectZeolite.make('GOO')
     z = PerfectZeolite.build_from_cif_with_labels('data/GOO.cif')
     my_zeotype = PerfectZeolite(z)
     print(os.getcwd())
     # tests inheritance
     self.assertIsInstance(my_zeotype, PerfectZeolite)
     self.assertIsInstance(my_zeotype, Atoms)
     # tests empty list attributes
     # tests corretly defined parameters
     self.assertEqual(my_zeotype._site_to_atom_indices,
                      z._site_to_atom_indices)
     self.assertEqual(my_zeotype._atom_indices_to_site,
                      z._atom_indices_to_site)
     self.assertEqual(my_zeotype.name, z.name)
     self.assertEqual(my_zeotype.parent_zeotype, my_zeotype)
     #tests atoms are there and behave the same
     self.assertCountEqual(my_zeotype.get_tags(), z.get_tags())
     self.assertCountEqual(my_zeotype.get_chemical_symbols(),
                           z.get_chemical_symbols())
     self.assertNotEqual(id(my_zeotype.parent_zeotype),
                         id(z.parent_zeotype))
     self.assertNotEqual(id(my_zeotype.index_mapper), id(z.index_mapper))
     self.assertNotEqual(id(my_zeotype.index_mapper), id(z.parent_zeotype))
     self.assertNotEqual(my_zeotype.index_mapper, None)
コード例 #4
0
    def test_make(self):
        z = PerfectZeolite.make('CHA')

        cha_site_dict = {
            'O1':
            [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
            'O2': [
                18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
                34, 35
            ],
            'O3': [
                36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
                52, 53
            ],
            'O4': [
                54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
                70, 71
            ],
            'T1': [
                72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
                88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
                103, 104, 105, 106, 107
            ]
        }

        self.assertIsInstance(z, PerfectZeolite)
        self.assertIs(z, z.parent_zeotype)
        self.assertDictEqual(cha_site_dict, z._site_to_atom_indices)
コード例 #5
0
 def test_get_hetero_atoms(self):
     z = PerfectZeolite.make('CHA')
     with self.subTest(msg='testing default arguments'):
         z[3].symbol = 'Hf'
         z[5].symbol = 'Sn'
         self.assertCountEqual([3, 5], z.get_hetero_atoms())
     with self.subTest(msg='Custom hetero atoms list'):
         # first get a list of O atoms
         O_list = []
         for atom in z:
             if atom.symbol == 'O':
                 O_list.append(atom.index)
         self.assertCountEqual(O_list, z.get_hetero_atoms(['O']))
コード例 #6
0
 def test_init_with_atoms_obj(self):
     tmp_goo = PerfectZeolite.make('GOO')
     my_atoms = read('data/GOO.cif')
     my_zeotype = PerfectZeolite(my_atoms)
     # tests inheritance
     self.assertIsInstance(my_zeotype, PerfectZeolite)
     self.assertIsInstance(my_zeotype, Atoms)
     # tests empty list attributes
     # tests corretly defined parameters
     self.assertEqual(my_zeotype._site_to_atom_indices, None)
     self.assertEqual(my_zeotype._atom_indices_to_site, None)
     self.assertEqual('parent', my_zeotype.name)
     self.assertEqual(my_zeotype.parent_zeotype, my_zeotype)
     #tests atoms are there and behave the same
     self.assertCountEqual(my_zeotype.get_tags(), my_atoms.get_tags())
     self.assertCountEqual(my_zeotype.get_chemical_symbols(),
                           my_atoms.get_chemical_symbols())
コード例 #7
0
    def test_get_atom_types(self):
        z = PerfectZeolite.make('CHA')
        get_atom_types_dict = {
            'framework-O': [
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
                18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
                34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
                50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
                66, 67, 68, 69, 70, 71
            ],
            'framework-Si': [
                72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
                88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
                103, 104, 105, 106, 107
            ]
        }

        with self.subTest(msg='test get atom types'):
            self.assertDictEqual(z.get_atom_types(), get_atom_types_dict)