Ejemplo n.º 1
0
    def test_post_distdiff(self):
        feff_dict_input = FEFFDictSet.from_directory(
            os.path.join(PymatgenTest.TEST_FILES_DIR, "feff_dist_test"))
        self.assertTrue(feff_dict_input.tags == Tags.from_file(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "feff_dist_test/feff.inp")))
        self.assertTrue(
            str(feff_dict_input.header()) == str(
                Header.from_file(
                    os.path.join(PymatgenTest.TEST_FILES_DIR,
                                 "feff_dist_test/HEADER"))))
        feff_dict_input.write_input("feff_dist_regen")
        origin_tags = Tags.from_file(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "feff_dist_test/PARAMETERS"))
        output_tags = Tags.from_file(
            os.path.join(".", "feff_dist_regen/PARAMETERS"))
        origin_mole = Atoms.cluster_from_file(
            os.path.join(PymatgenTest.TEST_FILES_DIR,
                         "feff_dist_test/feff.inp"))
        output_mole = Atoms.cluster_from_file(
            os.path.join(".", "feff_dist_regen/feff.inp"))
        original_mole_dist = np.array(
            origin_mole.distance_matrix[0, :]).astype(np.float64)
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(
            np.float64)
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join(".", "feff_dist_regen"))
Ejemplo n.º 2
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     d = header.as_dict()
     header2 = Header.from_dict(d)
     self.assertEqual(str(header), str(header2),
                      "Header failed to and from dict test")
Ejemplo n.º 3
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     d = header.as_dict()
     header2 = Header.from_dict(d)
     self.assertEqual(str(header), str(header2),
                      "Header failed to and from dict test")
Ejemplo n.º 4
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(PymatgenTest.TEST_FILES_DIR, "HEADER")
     header = Header.from_file(file_name)
     d = header.as_dict()
     header2 = Header.from_dict(d)
     self.assertEqual(str(header), str(header2),
                      "Header failed to and from dict test")
Ejemplo n.º 5
0
    def test_postfeffset(self):
        self.mp_xanes.write_input(os.path.join(".", "xanes_3"))
        feff_dict_input = FEFFDictSet.from_directory(os.path.join(".", "xanes_3"))
        self.assertTrue(
            feff_dict_input.tags
            == Tags.from_file(os.path.join(".", "xanes_3/feff.inp"))
        )
        self.assertTrue(
            str(feff_dict_input.header())
            == str(Header.from_file(os.path.join(".", "xanes_3/HEADER")))
        )
        feff_dict_input.write_input("xanes_3_regen")
        origin_tags = Tags.from_file(os.path.join(".", "xanes_3/PARAMETERS"))
        output_tags = Tags.from_file(os.path.join(".", "xanes_3_regen/PARAMETERS"))
        origin_mole = Atoms.cluster_from_file(os.path.join(".", "xanes_3/feff.inp"))
        output_mole = Atoms.cluster_from_file(
            os.path.join(".", "xanes_3_regen/feff.inp")
        )
        original_mole_dist = np.array(origin_mole.distance_matrix[0, :]).astype(
            np.float64
        )
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(
            np.float64
        )
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join(".", "xanes_3"))
        shutil.rmtree(os.path.join(".", "xanes_3_regen"))

        reci_mp_xanes = MPXANESSet(
            self.absorbing_atom, self.structure, user_tag_settings={"RECIPROCAL": ""}
        )
        reci_mp_xanes.write_input("xanes_reci")
        feff_reci_input = FEFFDictSet.from_directory(os.path.join(".", "xanes_reci"))
        self.assertTrue("RECIPROCAL" in feff_reci_input.tags)

        feff_reci_input.write_input("Dup_reci")
        self.assertTrue(os.path.exists(os.path.join(".", "Dup_reci", "HEADER")))
        self.assertTrue(os.path.exists(os.path.join(".", "Dup_reci", "feff.inp")))
        self.assertTrue(os.path.exists(os.path.join(".", "Dup_reci", "PARAMETERS")))
        self.assertFalse(os.path.exists(os.path.join(".", "Dup_reci", "ATOMS")))
        self.assertFalse(os.path.exists(os.path.join(".", "Dup_reci", "POTENTIALS")))

        tags_original = Tags.from_file(os.path.join(".", "xanes_reci/feff.inp"))
        tags_output = Tags.from_file(os.path.join(".", "Dup_reci/feff.inp"))
        self.assertTrue(tags_original == tags_output)

        stru_orig = Structure.from_file(os.path.join(".", "xanes_reci/Co2O2.cif"))
        stru_reci = Structure.from_file(os.path.join(".", "Dup_reci/Co2O2.cif"))
        self.assertTrue(stru_orig.__eq__(stru_reci))

        shutil.rmtree(os.path.join(".", "Dup_reci"))
        shutil.rmtree(os.path.join(".", "xanes_reci"))
Ejemplo n.º 6
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     pot = Potential(struct, 'O')
     d=pot.as_dict()
     pot2 = Potential.from_dict(d)
     self.assertEqual(str(pot), str(pot2),
                      "Potential to and from dict does not match")
Ejemplo n.º 7
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     atoms = Atoms(struct, 'O', radius=10.)
     d = atoms.as_dict()
     atoms2 = Atoms.from_dict(d)
     self.assertEqual(str(atoms), str(atoms2),
                      "Atoms failed to and from dict test")
Ejemplo n.º 8
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     pot = Potential(struct, 'O')
     d=pot.as_dict()
     pot2 = Potential.from_dict(d)
     self.assertEqual(str(pot), str(pot2),
                      "Potential to and from dict does not match")
Ejemplo n.º 9
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(test_dir, 'HEADER')
     header = Header.from_file(file_name)
     struct = header.struct
     atoms = Atoms(struct, 'O', radius=10.)
     d = atoms.as_dict()
     atoms2 = Atoms.from_dict(d)
     self.assertEqual(str(atoms), str(atoms2),
                      "Atoms failed to and from dict test")
Ejemplo n.º 10
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(PymatgenTest.TEST_FILES_DIR, "HEADER")
     header = Header.from_file(file_name)
     struct = header.struct
     pot = Potential(struct, "O")
     d = pot.as_dict()
     pot2 = Potential.from_dict(d)
     self.assertEqual(str(pot), str(pot2),
                      "Potential to and from dict does not match")
Ejemplo n.º 11
0
 def test_as_dict_and_from_dict(self):
     file_name = os.path.join(PymatgenTest.TEST_FILES_DIR, "HEADER")
     header = Header.from_file(file_name)
     struct = header.struct
     atoms = Atoms(struct, "O", radius=10.0)
     d = atoms.as_dict()
     atoms2 = Atoms.from_dict(d)
     self.assertEqual(str(atoms), str(atoms2),
                      "Atoms failed to and from dict test")
Ejemplo n.º 12
0
    def test_postfeffset(self):
        self.mp_xanes.write_input(os.path.join('.', 'xanes_3'))
        feff_dict_input = FEFFDictSet.from_directory(os.path.join('.', 'xanes_3'))
        self.assertTrue(feff_dict_input.tags == Tags.from_file(os.path.join('.', 'xanes_3/feff.inp')))
        self.assertTrue(str(feff_dict_input.header()) == str(Header.from_file(os.path.join('.', 'xanes_3/HEADER'))))
        feff_dict_input.write_input('xanes_3_regen')
        origin_tags = Tags.from_file(os.path.join('.', 'xanes_3/PARAMETERS'))
        output_tags = Tags.from_file(os.path.join('.', 'xanes_3_regen/PARAMETERS'))
        origin_mole = Atoms.cluster_from_file(os.path.join('.', 'xanes_3/feff.inp'))
        output_mole = Atoms.cluster_from_file(os.path.join('.', 'xanes_3_regen/feff.inp'))
        original_mole_dist = np.array(origin_mole.distance_matrix[0, :]).astype(np.float64)
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(np.float64)
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join('.', 'xanes_3'))
        shutil.rmtree(os.path.join('.', 'xanes_3_regen'))

        reci_mp_xanes = MPXANESSet(self.absorbing_atom, self.structure,
                                   user_tag_settings={"RECIPROCAL": ""})
        reci_mp_xanes.write_input('xanes_reci')
        feff_reci_input = FEFFDictSet.from_directory(os.path.join('.', 'xanes_reci'))
        self.assertTrue("RECIPROCAL" in feff_reci_input.tags)

        feff_reci_input.write_input('Dup_reci')
        self.assertTrue(os.path.exists(os.path.join('.', 'Dup_reci', 'HEADER')))
        self.assertTrue(os.path.exists(os.path.join('.', 'Dup_reci', 'feff.inp')))
        self.assertTrue(os.path.exists(os.path.join('.', 'Dup_reci', 'PARAMETERS')))
        self.assertFalse(os.path.exists(os.path.join('.', 'Dup_reci', 'ATOMS')))
        self.assertFalse(os.path.exists(os.path.join('.', 'Dup_reci', 'POTENTIALS')))

        tags_original = Tags.from_file(os.path.join('.', 'xanes_reci/feff.inp'))
        tags_output = Tags.from_file(os.path.join('.', 'Dup_reci/feff.inp'))
        self.assertTrue(tags_original == tags_output)

        stru_orig = Structure.from_file(os.path.join('.', 'xanes_reci/Co2O2.cif'))
        stru_reci = Structure.from_file(os.path.join('.', 'Dup_reci/Co2O2.cif'))
        self.assertTrue(stru_orig.__eq__(stru_reci))

        shutil.rmtree(os.path.join('.', 'Dup_reci'))
        shutil.rmtree(os.path.join('.', 'xanes_reci'))
Ejemplo n.º 13
0
    def test_post_distdiff(self):
        feff_dict_input = FEFFDictSet.from_directory(os.path.join(test_dir, 'feff_dist_test'))
        self.assertTrue(feff_dict_input.tags == Tags.from_file(os.path.join(test_dir, 'feff_dist_test/feff.inp')))
        self.assertTrue(
            str(feff_dict_input.header()) == str(Header.from_file(os.path.join(test_dir, 'feff_dist_test/HEADER'))))
        feff_dict_input.write_input('feff_dist_regen')
        origin_tags = Tags.from_file(os.path.join(test_dir, 'feff_dist_test/PARAMETERS'))
        output_tags = Tags.from_file(os.path.join('.', 'feff_dist_regen/PARAMETERS'))
        origin_mole = Atoms.cluster_from_file(os.path.join(test_dir, 'feff_dist_test/feff.inp'))
        output_mole = Atoms.cluster_from_file(os.path.join('.', 'feff_dist_regen/feff.inp'))
        original_mole_dist = np.array(origin_mole.distance_matrix[0, :]).astype(np.float64)
        output_mole_dist = np.array(output_mole.distance_matrix[0, :]).astype(np.float64)
        original_mole_shell = [x.species_string for x in origin_mole]
        output_mole_shell = [x.species_string for x in output_mole]

        self.assertTrue(np.allclose(original_mole_dist, output_mole_dist))
        self.assertTrue(origin_tags == output_tags)
        self.assertTrue(original_mole_shell == output_mole_shell)

        shutil.rmtree(os.path.join('.', 'feff_dist_regen'))