コード例 #1
0
 def test_potcar_file_hash_warning(self):
     filename = (
         self.TEST_FILES_DIR
         / "modified_potcars_header"
         / "POT_GGA_PAW_PBE"
         / "POTCAR.Fe_pv"
     )
     with pytest.warns(UnknownPotcarWarning, match="following"):
         PotcarSingle.from_file(filename)
コード例 #2
0
 def test_potcar_hash_warning(self):
     filename = (
         self.TEST_FILES_DIR
         / "modified_potcars_data"
         / "POT_GGA_PAW_PBE"
         / "POTCAR.Fe_pv"
     )
     with pytest.warns(UnknownPotcarWarning, match="integrity"):
         PotcarSingle.from_file(filename)
コード例 #3
0
    def get_Potcar(self):
        ''' Reads the file titled POTCAR from the present working directory '''
        ''' Generates and returns pymatgen.io.vasp.inputs.PotcarSingle object from POTCAR '''

        potcar = PotcarSingle.from_file(self.path + '/POTCAR')

        return potcar
コード例 #4
0
 def test_from_functional_and_symbols(self):
     test_potcar_dir = os.path.abspath(
         os.path.join(os.path.dirname(__file__),
                      "..", "..", "..", "..", "test_files"))
     SETTINGS["VASP_PSP_DIR"] = test_potcar_dir
     p = PotcarSingle.from_symbol_and_functional("Li_sv", "PBE")
     self.assertEqual(p.enmax, 271.649)
コード例 #5
0
ファイル: test_inputs.py プロジェクト: matk86/pymatgen
 def test_from_functional_and_symbols(self):
     test_potcar_dir = os.path.abspath(
         os.path.join(os.path.dirname(__file__),
                      "..", "..", "..", "..", "test_files"))
     SETTINGS["PMG_VASP_PSP_DIR"] = test_potcar_dir
     p = PotcarSingle.from_symbol_and_functional("Li_sv", "PBE")
     self.assertEqual(p.enmax, 271.649)
コード例 #6
0
ファイル: test_inputs.py プロジェクト: CompRhys/pymatgen
    def test_identify_potcar(self):
        filename = PymatgenTest.TEST_FILES_DIR / "POT_GGA_PAW_PBE_54" / "POTCAR.Fe.gz"

        with pytest.warns(None):
            psingle = PotcarSingle.from_file(filename)
        assert "PBE_54" in psingle.identify_potcar()[0]
        assert "Fe" in psingle.identify_potcar()[1]
コード例 #7
0
    def isotope (self,before="POMASS =    1.000", change="POMASS =    3.000"):
        from pymatgen.io.vasp.outputs import Poscar
        from pymatgen.io.vasp.inputs import PotcarSingle
        from pymatgen.io.vasp.outputs import Potcar
        from pymatgen.io.vasp.sets import MPNMRSet
        import shutil
        import os
        os.chdir(self.dire)
        print (os.getcwd())
        poscar= Poscar.from_file("POSCAR")
        # structure = poscar.structure
        print (poscar)
        potcar= Potcar.from_file("POTCAR")
        potc=str(potcar)

        cc= potc.replace(before,change)

        vv=PotcarSingle(cc,)
        vv.write_file("POTCAR_1")

        print (vv)
コード例 #8
0
    def test_functional_types(self):
        self.assertEqual(self.psingle.functional, "PBE")

        self.assertEqual(self.psingle.functional_class, "GGA")

        self.assertEqual(self.psingle.potential_type, "PAW")

        psingle = PotcarSingle.from_file(PymatgenTest.TEST_FILES_DIR / "POT_LDA_PAW" / "POTCAR.Fe.gz")

        self.assertEqual(psingle.functional, "Perdew-Zunger81")

        self.assertEqual(psingle.functional_class, "LDA")

        self.assertEqual(psingle.potential_type, "PAW")
コード例 #9
0
ファイル: test_inputs.py プロジェクト: zhuruijie16/pymatgen
    def test_functional_types(self):
        self.assertEqual(self.psingle.functional, 'PBE')

        self.assertEqual(self.psingle.functional_class, 'GGA')

        self.assertEqual(self.psingle.potential_type, 'PAW')

        psingle = PotcarSingle.from_file(self.TEST_FILES_DIR/ "POT_LDA_PAW"/ "POTCAR.Fe.gz")

        self.assertEqual(psingle.functional, 'Perdew-Zunger81')

        self.assertEqual(psingle.functional_class, 'LDA')

        self.assertEqual(psingle.potential_type, 'PAW')
コード例 #10
0
ファイル: test_inputs.py プロジェクト: gpetretto/pymatgen
    def test_functional_types(self):
        self.assertEqual(self.psingle.functional, "PBE")

        self.assertEqual(self.psingle.functional_class, "GGA")

        self.assertEqual(self.psingle.potential_type, "PAW")

        psingle = PotcarSingle.from_file(os.path.join(test_dir, "POT_LDA_PAW", "POTCAR.Fe.gz"))

        self.assertEqual(psingle.functional, "Perdew-Zunger81")

        self.assertEqual(psingle.functional_class, "LDA")

        self.assertEqual(psingle.potential_type, "PAW")
コード例 #11
0
ファイル: test_inputs.py プロジェクト: zclpf/pymatgen
    def test_functional_types(self):
        self.assertEqual(self.psingle.functional, 'PBE')

        self.assertEqual(self.psingle.functional_class, 'GGA')

        self.assertEqual(self.psingle.potential_type, 'PAW')

        psingle = PotcarSingle.from_file(os.path.join(test_dir, "POT_LDA_PAW",
                                                      "POTCAR.Fe.gz"))

        self.assertEqual(psingle.functional, 'Perdew-Zunger81')

        self.assertEqual(psingle.functional_class, 'LDA')

        self.assertEqual(psingle.potential_type, 'PAW')
コード例 #12
0
    def potcar_from_linklist(cls, poscar_data, linklist):
        """
        Assemble pymatgen Potcar object from a list of VaspPotcarData instances

        Reads pseudo-potential from the passed list connecting each element
        with it's potential and creates the complete Potcar file according
        to the element ordering fodun in the passed poscar data object.

        :param poscar_data: input structure for VASP calculations
        :type poscar: :class:`aiida_cusp.data.inputs.VaspPoscarData`
        :param linklist: dictionary mapping element names to VaspPotcarData
            instances
        :type linklist: `dict`
        :returns: pymatgen Potcar data instance with containing the
            concatenated pseudo-potential information for all elements defined
            in the linklist
        :rtype: :class:`~pymatgen.io.vasp.inputs.Potcar`
        """
        # initialize empty Potcar object
        complete_potcar = Potcar()
        # file empty potcar with potential in order of elements found in the
        # passed structure data
        site_symbols = poscar_data.get_poscar().site_symbols
        for site_symbol in site_symbols:
            try:
                potential_pointer = linklist[site_symbol]
            except KeyError:
                raise VaspPotcarDataError(
                    "Found no potential in passed "
                    "potential-element map for "
                    "site symbol '{}'".format(site_symbol))
            potential_file = potential_pointer.load_potential_file_node()
            potential_contents = potential_file.get_content()
            potcar_single = PotcarSingle(potential_contents)
            complete_potcar.append(potcar_single)
        return complete_potcar
コード例 #13
0
ファイル: test_inputs.py プロジェクト: zclpf/pymatgen
 def setUp(self):
     self.psingle = PotcarSingle.from_file(
         os.path.join(test_dir, "POT_GGA_PAW_PBE", "POTCAR.Mn_pv.gz"))
コード例 #14
0
ファイル: config_dfttk.py プロジェクト: kcbhamu/dfttk
def test_config_pymatgen():
    path_mp_config = os.path.join(os.environ["HOME"], ".pmgrc.yaml")
    if os.path.exists(path_mp_config):
        mp_config = loadfn(path_mp_config)

        print("##########Start to test the PMG_MAPI_KEY paramter##########")
        help_cmd = "-mapi YOUR_MP_API_KEY"
        param = "PMG_MAPI_KEY"
        if param in mp_config:
            try:
                with MPRester(mp_config[param]) as mpr:
                    mpr.get_structure_by_material_id("mp-66")
                Tips().set_properly(MAPI_KEY=mp_config[param])
            except Exception as e:
                Tips().set_improper(param, help_cmd)
        else:
            Tips().set_not_exist(param, help_cmd)

        print(
            "\n##########Start to test the PMG_DEFAULT_FUNCTIONAL paramter##########"
        )
        help_cmd = "-df DEFAULT_FUNCTIONAL"
        param = "PMG_DEFAULT_FUNCTIONAL"
        flag_functional = False
        FUNCTIONAL_CHOICES = Potcar.FUNCTIONAL_CHOICES
        if param in mp_config:
            DF = mp_config[param]
            if DF in FUNCTIONAL_CHOICES:
                Tips().set_properly(PMG_DEFAULT_FUNCTIONAL=DF)
                flag_functional = True
            else:
                Tips().set_improper(param, help_cmd)
        else:
            Tips().set_not_exist(param, help_cmd)

        print(
            "\n##########Start to test the PMG_VASP_PSP_DIR paramter##########"
        )
        help_cmd = "-psp VASP_PSP_DIR"
        param = "PMG_VASP_PSP_DIR"
        flag_psp = False
        FUNCTIONAL_DIR = list(PotcarSingle.functional_dir.values())
        functional_name = {
            v: k
            for k, v in PotcarSingle.functional_dir.items()
        }
        if param in mp_config:
            psp_dir = mp_config[param]
            if os.path.isdir(psp_dir):
                flag_psp = False
                functional_available = []
                sub_dirs = os.listdir(psp_dir)
                for item in sub_dirs:
                    if item in FUNCTIONAL_DIR:
                        functional = functional_name[item]
                        try:
                            p = PotcarSingle.from_symbol_and_functional(
                                "Fe", functional)
                            functional_available.append(functional)
                            flag_psp = True
                        except Exception as e:
                            print("There are some problems of " + functional +
                                  " in " + os.path.join(psp_dir, item))
                if flag_psp:
                    Tips().functional_info(param)
                    print("\t The supported functional is/are: " +
                          ", ".join(functional_available))
                    flag_psp = True
                else:
                    print("There is no available functional in " + psp_dir)
                    Tips().set_improper(param, help_cmd)
            else:
                print("The path " + psp_dir + " not exists.")
                Tips().set_improper(param, help_cmd)
        else:
            Tips().set_not_exist(param, help_cmd)
    else:
        Tips().set_not_exist("~/.pmgrc.yaml", "-mp")
    if flag_psp and flag_functional:
        if not (mp_config["PMG_DEFAULT_FUNCTIONAL"] in functional_available):
            warnings.warn(
                "The default functional '{}' is not supported in current available \
                functionals: {}.".format(
                    mp_config["PMG_DEFAULT_FUNCTIONAL"],
                    "\n" + ", ".join(functional_available)))
コード例 #15
0
ファイル: test_inputs.py プロジェクト: zetayue/pymatgen
 def test_default_functional(self):
     p = PotcarSingle.from_symbol_and_functional("Fe")
     self.assertEqual(p.functional_class, 'GGA')
     SETTINGS["PMG_DEFAULT_FUNCTIONAL"] = "LDA"
     p = PotcarSingle.from_symbol_and_functional("Fe")
     self.assertEqual(p.functional_class, 'LDA')
コード例 #16
0
ファイル: test_inputs.py プロジェクト: matk86/pymatgen
 def test_default_functional(self):
     p = PotcarSingle.from_symbol_and_functional("Fe")
     self.assertEqual(p.functional_class, 'GGA')
     SETTINGS["PMG_DEFAULT_FUNCTIONAL"] = "LDA"
     p = PotcarSingle.from_symbol_and_functional("Fe")
     self.assertEqual(p.functional_class, 'LDA')
コード例 #17
0
 def setUp(self):
     #with zopen(os.path.join(test_dir, "POT_GGA_PAW_PBE",
     #                        "POTCAR.Mn_pv.gz"), 'rb') as f:
     self.psingle = PotcarSingle.from_file(os.path.join(test_dir, "POT_GGA_PAW_PBE",
                             "POTCAR.Mn_pv.gz"))
コード例 #18
0
 def setUp(self):
     self.psingle = PotcarSingle.from_file(
         self.TEST_FILES_DIR / "POT_GGA_PAW_PBE" / "POTCAR.Mn_pv.gz")
コード例 #19
0
ファイル: test_inputs.py プロジェクト: adengz/pymatgen
 def setUp(self):
     self.psingle = PotcarSingle.from_file(
         self.TEST_FILES_DIR / "POT_GGA_PAW_PBE" / "POTCAR.Mn_pv.gz")