コード例 #1
0
ファイル: neb_tasks.py プロジェクト: montoyjh/MatMethods
    def _verify_inputs(self):
        """Validation of input files under user NEB directory."""
        user_incar = Incar.from_file(os.path.join(self.user_dir, "INCAR"))
        ref_incar = Incar.from_file(os.path.join(self.ref_dir_input, "INCAR"))

        # Check INCAR
        params_to_check = self.get("params_to_check", [])
        defaults = {"ICHAIN": 0, "LCLIMB": True}
        for p in params_to_check:
            if user_incar.get(p, defaults.get(p)) != ref_incar.get(p, defaults.get(p)):
                raise ValueError("INCAR value of {} is inconsistent!".format(p))

        # Check KPOINTS
        user_kpoints = Kpoints.from_file(os.path.join(self.user_dir, "KPOINTS"))
        ref_kpoints = Kpoints.from_file(os.path.join(self.ref_dir_input, "KPOINTS"))
        if user_kpoints.style != ref_kpoints.style or user_kpoints.num_kpts != ref_kpoints.num_kpts:
            raise ValueError("KPOINT files are inconsistent! "
                             "Paths are:\n{}\n{} with kpts = {} {}".format(
                self.user_dir, self.ref_dir_input, user_kpoints, ref_kpoints))

        # Check POTCAR
        user_potcar = Potcar.from_file(os.path.join(self.user_dir, "POTCAR"))
        ref_potcar = Potcar.from_file(os.path.join(self.ref_dir_input, "POTCAR"))
        if user_potcar.symbols != ref_potcar.symbols:
            raise ValueError("POTCAR files are inconsistent! "
                             "Paths are:\n{}\n{}".format(self.user_dir, self.ref_dir_input))

        # Check POSCARs
        for u, r in zip(self.user_sdir, self.ref_sdir_input):
            user_poscar = Poscar.from_file(os.path.join(u, "POSCAR"))
            ref_poscar = Poscar.from_file(os.path.join(r, "POSCAR"))
            if user_poscar.natoms != ref_poscar.natoms or \
                            user_poscar.site_symbols != ref_poscar.site_symbols:
                raise ValueError("POSCAR files are inconsistent! Paths are:\n{}\n{}".format(u, r))
コード例 #2
0
ファイル: neb_tasks.py プロジェクト: FilipchukB/P1
    def _verify_inputs(self):
        """Validation of input files under user NEB directory."""
        user_incar = Incar.from_file(os.path.join(self.user_dir, "INCAR"))
        ref_incar = Incar.from_file(os.path.join(self.ref_dir_input, "INCAR"))

        # Check INCAR
        params_to_check = self.get("params_to_check", [])
        defaults = {"ICHAIN": 0, "LCLIMB": True}
        for p in params_to_check:
            if user_incar.get(p, defaults.get(p)) != ref_incar.get(p, defaults.get(p)):
                raise ValueError("INCAR value of {} is inconsistent!".format(p))

        # Check KPOINTS
        user_kpoints = Kpoints.from_file(os.path.join(self.user_dir, "KPOINTS"))
        ref_kpoints = Kpoints.from_file(os.path.join(self.ref_dir_input, "KPOINTS"))
        if user_kpoints.style != ref_kpoints.style or user_kpoints.num_kpts != ref_kpoints.num_kpts:
            raise ValueError("KPOINT files are inconsistent! "
                             "Paths are:\n{}\n{} with kpts = {} {}".format(
                self.user_dir, self.ref_dir_input, user_kpoints, ref_kpoints))

        # Check POTCAR
        user_potcar = Potcar.from_file(os.path.join(self.user_dir, "POTCAR"))
        ref_potcar = Potcar.from_file(os.path.join(self.ref_dir_input, "POTCAR"))
        if user_potcar.symbols != ref_potcar.symbols:
            raise ValueError("POTCAR files are inconsistent! "
                             "Paths are:\n{}\n{}".format(self.user_dir, self.ref_dir_input))

        # Check POSCARs
        for u, r in zip(self.user_sdir, self.ref_sdir_input):
            user_poscar = Poscar.from_file(os.path.join(u, "POSCAR"))
            ref_poscar = Poscar.from_file(os.path.join(r, "POSCAR"))
            if user_poscar.natoms != ref_poscar.natoms or \
                            user_poscar.site_symbols != ref_poscar.site_symbols:
                raise ValueError("POSCAR files are inconsistent! Paths are:\n{}\n{}".format(u, r))
コード例 #3
0
    def __init__(self,
                 symbols=None,
                 functional="PBE",
                 pp_file=None,
                 pp_lists=None):
        if pp_lists and pp_file is None:
            for pp in pp_lists:
                assert isinstance(pp, PotcarSingle)
            self.potcars = pp_lists
        elif pp_file and pp_list is None:
            self.potcars = Potcar.from_file(pp_file)
        elif pp_file and pp_list:
            self.potcars = Potcar.from_file(pp_file)
        else:
            try:
                self.potcars = Potcar(symbols=symbols, functional=functional)
            except:
                warnings.warn("""Inproperly configure of POTCAR !""")
                self.potcars = None

        if self.potcars is not None:
            self.symbols = [pp.symbol for pp in self.potcars]
            self.functional = list(set([pp.functional
                                        for pp in self.potcars]))[0]
            self.hashs = [pp.get_potcar_hash() for pp in self.potcars]
        else:
            self.symbols = symbols
            self.functional = functional
            self.hashs = ''
        self.elements = self._get_elements()
コード例 #4
0
ファイル: run_calc.py プロジェクト: saurabh02/MatMethods
    def _verify_inputs(self):
        user_incar = Incar.from_file(os.path.join(os.getcwd(), "INCAR"))
        ref_incar = Incar.from_file(os.path.join(self["ref_dir"], "inputs", "INCAR"))

        # perform some BASIC tests

        # check INCAR
        params_to_check = self.get("params_to_check", [])
        defaults = {"ISPIN": 1, "ISMEAR": 1, "SIGMA": 0.2}
        for p in params_to_check:
            if user_incar.get(p, defaults.get(p)) != ref_incar.get(p, defaults.get(p)):
                raise ValueError("INCAR value of {} is inconsistent!".format(p))

        # check KPOINTS
        user_kpoints = Kpoints.from_file(os.path.join(os.getcwd(), "KPOINTS"))
        ref_kpoints = Kpoints.from_file(os.path.join(self["ref_dir"], "inputs", "KPOINTS"))
        if user_kpoints.style != ref_kpoints.style or user_kpoints.num_kpts != ref_kpoints.num_kpts:
            raise ValueError("KPOINT files are inconsistent! Paths are:\n{}\n{}".format(
                os.getcwd(), os.path.join(self["ref_dir"], "inputs")))

        # check POSCAR
        user_poscar = Poscar.from_file(os.path.join(os.getcwd(), "POSCAR"))
        ref_poscar = Poscar.from_file(os.path.join(self["ref_dir"], "inputs", "POSCAR"))
        if user_poscar.natoms != ref_poscar.natoms or user_poscar.site_symbols != ref_poscar.site_symbols:
            raise ValueError("POSCAR files are inconsistent! Paths are:\n{}\n{}".format(
                os.getcwd(), os.path.join(self["ref_dir"], "inputs")))

        # check POTCAR
        user_potcar = Potcar.from_file(os.path.join(os.getcwd(), "POTCAR"))
        ref_potcar = Potcar.from_file(os.path.join(self["ref_dir"], "inputs", "POTCAR"))
        if user_potcar.symbols != ref_potcar.symbols:
            raise ValueError("POTCAR files are inconsistent! Paths are:\n{}\n{}".format(
                os.getcwd(), os.path.join(self["ref_dir"], "inputs")))
        logger.info("RunVaspFake: verified inputs successfully")
コード例 #5
0
def gen_potcar(dirname, filename):
    if filename == "POTCAR.spec":
        fullpath = os.path.join(dirname, filename)
        f = open(fullpath, "r")
        elements = f.readlines()
        f.close()
        symbols = [el.strip() for el in elements if el.strip() != ""]
        potcar = Potcar(symbols)
        potcar.write_file(os.path.join(dirname, "POTCAR"))
コード例 #6
0
ファイル: pmg_potcar.py プロジェクト: rakesharya21/NanoGen
def generate_potcar(args):
    if args.recursive:
        proc_dir(args.spec, gen_potcar)
    elif args.symbols:
        try:
            p = Potcar(args.symbols, functional=args.functional)
            p.write_file("POTCAR")
        except Exception as ex:
            print("An error has occurred: {}".format(str(ex)))

    else:
        print("No valid options selected.")
コード例 #7
0
ファイル: run_calc.py プロジェクト: srshivani/atomate
    def _verify_inputs(self):
        user_incar = Incar.from_file(os.path.join(os.getcwd(), "INCAR"))

        # Carry out some BASIC tests.

        # Check INCAR
        if self.get("check_incar", True):
            ref_incar = Incar.from_file(
                os.path.join(self["ref_dir"], "inputs", "INCAR"))
            params_to_check = self.get("params_to_check", [])
            defaults = {"ISPIN": 1, "ISMEAR": 1, "SIGMA": 0.2}
            for p in params_to_check:
                if user_incar.get(p, defaults.get(p)) != ref_incar.get(
                        p, defaults.get(p)):
                    raise ValueError(
                        "INCAR value of {} is inconsistent!".format(p))

        # Check KPOINTS
        if self.get("check_kpoints", True):
            user_kpoints = Kpoints.from_file(
                os.path.join(os.getcwd(), "KPOINTS"))
            ref_kpoints = Kpoints.from_file(
                os.path.join(self["ref_dir"], "inputs", "KPOINTS"))
            if user_kpoints.style != ref_kpoints.style or \
                            user_kpoints.num_kpts != ref_kpoints.num_kpts:
                raise ValueError(
                    "KPOINT files are inconsistent! Paths are:\n{}\n{} with kpoints {} and {}"
                    .format(os.getcwd(), os.path.join(self["ref_dir"],
                                                      "inputs"), user_kpoints,
                            ref_kpoints))

        # Check POSCAR
        if self.get("check_poscar", True):
            user_poscar = Poscar.from_file(os.path.join(os.getcwd(), "POSCAR"))
            ref_poscar = Poscar.from_file(
                os.path.join(self["ref_dir"], "inputs", "POSCAR"))
            if user_poscar.natoms != ref_poscar.natoms or user_poscar.site_symbols != \
                    ref_poscar.site_symbols:
                raise ValueError(
                    "POSCAR files are inconsistent! Paths are:\n{}\n{}".format(
                        os.getcwd(), os.path.join(self["ref_dir"], "inputs")))

        # Check POTCAR
        if self.get("check_potcar", True):
            user_potcar = Potcar.from_file(os.path.join(os.getcwd(), "POTCAR"))
            ref_potcar = Potcar.from_file(
                os.path.join(self["ref_dir"], "inputs", "POTCAR"))
            if user_potcar.symbols != ref_potcar.symbols:
                raise ValueError(
                    "POTCAR files are inconsistent! Paths are:\n{}\n{}".format(
                        os.getcwd(), os.path.join(self["ref_dir"], "inputs")))

        logger.info("RunVaspFake: verified inputs successfully")
コード例 #8
0
ファイル: test_write_vasp.py プロジェクト: jwz360/atomate
    def test_modify_potcar(self):
        Potcar(["Si"]).write_file("POTCAR")
        potcar = Potcar.from_file("POTCAR")
        self.assertFalse("alt" in potcar[0].header)

        # modify/test
        ft = ModifyPotcar(potcar_symbols={"Si": "O"})
        ft = load_object(ft.to_dict())  # simulate database insertion
        ft.run_task({})

        new_potcar = Potcar.from_file("POTCAR")
        self.assertEqual(len(new_potcar), 1)
        self.assertEqual(new_potcar[0].symbol, "O")
コード例 #9
0
    def test_modify_potcar(self):
        Potcar(["Si"]).write_file("POTCAR")
        potcar = Potcar.from_file("POTCAR")
        self.assertFalse("alt" in potcar[0].header)

        # modify/test
        ft = ModifyPotcar(potcar_symbols={"Si": "O"})
        ft = load_object(ft.to_dict())  # simulate database insertion
        ft.run_task({})

        new_potcar = Potcar.from_file("POTCAR")
        self.assertEqual(len(new_potcar), 1)
        self.assertEqual(new_potcar[0].symbol, 'O')
コード例 #10
0
def gen_potcar(dirname, filename):
    """
    Generate POTCAR from POTCAR.spec in directories.

    Args:
        dirname (str): Directory name.
        filename (str): Filename in directory.
    """
    if filename == "POTCAR.spec":
        fullpath = os.path.join(dirname, filename)
        with open(fullpath, "r") as f:
            elements = f.readlines()
        symbols = [el.strip() for el in elements if el.strip() != ""]
        potcar = Potcar(symbols)
        potcar.write_file(os.path.join(dirname, "POTCAR"))
コード例 #11
0
ファイル: test_write_vasp.py プロジェクト: aykol/MatMethods
    def setUpClass(cls):
        if not os.environ.get("VASP_PSP_DIR"):
            os.environ["VASP_PSP_DIR"] = os.path.join(module_dir,
                                                      "reference_files")
            print(
                'Note: This system is not set up to run VASP jobs. '
                'Please set your VASP_PSP_DIR environment variable.')

        cls.struct_si = PymatgenTest.get_structure("Si")

        cls.ref_incar = Incar.from_file(
            os.path.join(module_dir, "reference_files", "setup_test", "INCAR"))
        cls.ref_poscar = Poscar.from_file(
            os.path.join(module_dir, "reference_files", "setup_test",
                         "POSCAR"))
        cls.ref_potcar = Potcar.from_file(
            os.path.join(module_dir, "reference_files", "setup_test",
                         "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(
            os.path.join(module_dir, "reference_files", "setup_test",
                         "KPOINTS"))
        cls.ref_incar_preserve = Incar.from_file(os.path.join(module_dir,
                                                              "reference_files",
                                                              "preserve_incar",
                                                              "INCAR"))
コード例 #12
0
def get_wavefunction(potcar="POTCAR",
                     wavecar="WAVECAR",
                     vasprun="vasprun.xml",
                     directory=None):
    from pawpyseed.core import pawpyc
    from pawpyseed.core.wavefunction import CoreRegion, Wavefunction

    if directory:
        wf = Wavefunction.from_directory(path=directory)
    else:
        if isinstance(vasprun, str):
            vasprun = Vasprun(vasprun)

        if isinstance(potcar, str):
            potcar = Potcar.from_file(potcar)

        ngx = vasprun.parameters["NGX"]
        ngy = vasprun.parameters["NGY"]
        ngz = vasprun.parameters["NGZ"]
        dim = np.array([ngx, ngy, ngz])
        symprec = vasprun.parameters["SYMPREC"]
        structure = vasprun.final_structure

        pwf = pawpyc.PWFPointer(wavecar, vasprun)
        core_region = CoreRegion(potcar)

        wf = Wavefunction(structure, pwf, core_region, dim, symprec, False)

    wf = wf.desymmetrized_copy(time_reversal_symmetry=False, symprec=1e-4)
    return wf
コード例 #13
0
    def test_gga(self) -> None:
        xc_task_potcar = XcTaskPotcar.from_options(xc=Xc.pbe,
                                                   symbol_list=["Mg", "O"])

        expected = Potcar(["Mg", "O"], functional="PBE_54").as_dict()
        self.assertEqual(expected, xc_task_potcar.potcar.as_dict())
        self.assertEqual(400.0, xc_task_potcar.max_enmax)
コード例 #14
0
    def testDPPotcar(self):

        refd = {
            '@module': 'dpgen.database.vasp',
            '@class': 'DPPotcar',
            'symbols': ['Al'],
            'elements': ['Al'],
            'hashs': '',
            'functional': 'PBE'
        }
        try:
            Potcar(['Al'])
            #ps  TITEL  = PAW_PBE Al 04Jan2001
            refd.update({'hashs': ['9aafba2c552fad8414179cae2e888e67']})
        except:
            pass

        for f in self.init_path + self.iter_path:
            fpp = os.path.join(f, 'POTCAR')
            pp = DPPotcar.from_file(fpp)
            self.assertEqual(pp.elements, refd['elements'])
            self.assertEqual(pp.symbols, refd['symbols'])
            self.assertEqual(pp.hashs, refd['hashs'])
            self.assertEqual(pp.functional, refd['functional'])
            self.assertEqual(pp.as_dict(), refd)
コード例 #15
0
ファイル: test_write_vasp.py プロジェクト: jwz360/atomate
    def setUpClass(cls):
        cls.struct_si = PymatgenTest.get_structure("Si")

        cls.ref_incar = Incar.from_file(p_setup_test / "INCAR")
        cls.ref_poscar = Poscar.from_file(p_setup_test / "POSCAR")
        cls.ref_potcar = Potcar.from_file(p_setup_test / "POTCAR")
        cls.ref_kpoints = Kpoints.from_file(p_setup_test / "KPOINTS")
        cls.ref_incar_preserve = Incar.from_file(p_preserve_incar / "INCAR")
コード例 #16
0
    def test_override(self) -> None:
        xc_task_potcar = \
            XcTaskPotcar.from_options(xc=Xc.pbe,
                                      symbol_list=["Mg", "O"],
                                      override_potcar_set={"O": "O_h"})

        expected = Potcar(["Mg", "O_h"], functional="PBE_54").as_dict()
        self.assertEqual(expected, xc_task_potcar.potcar.as_dict())
コード例 #17
0
def default_dict():
    return {"composition": Composition("HO2"),
            "symbol_list": ["H", "O"],
            "num_kpts": 5,
            "num_kpt_multiplication_factor": 1,
            "potcar": Potcar(["H", "O"]),
            "xc": Xc.pbe,
            "task": Task.structure_opt}
コード例 #18
0
    def test_mp_relax_set(self) -> None:
        xc_task_potcar = \
            XcTaskPotcar.from_options(xc=Xc.pbe,
                                      symbol_list=["Mg", "O"],
                                      potcar_set_name="mp_relax_set")

        expected = Potcar(["Mg_pv", "O"], functional="PBE_54").as_dict()
        self.assertEqual(expected, xc_task_potcar.potcar.as_dict())
コード例 #19
0
ファイル: test_setup.py プロジェクト: montoyjh/MatMethods
 def _verify_files(self):
     self.assertEqual(Incar.from_file(os.path.join(module_dir, "INCAR")), self.ref_incar)
     self.assertEqual(str(Poscar.from_file(os.path.join(module_dir, "POSCAR"))),
                      str(self.ref_poscar))
     self.assertEqual(Potcar.from_file(os.path.join(module_dir, "POTCAR")).symbols,
                      self.ref_potcar.symbols)
     self.assertEqual(str(Kpoints.from_file(os.path.join(module_dir, "KPOINTS"))),
                      str(self.ref_kpoints))
コード例 #20
0
 def setUp(self) -> None:
     self.default_kwargs = {
         "potcar": Potcar(["Mg", "O"]),
         "composition": Composition({
             "Mg": 1,
             "O": 2
         }),
         "charge": 1
     }
コード例 #21
0
ファイル: pmg_potcar.py プロジェクト: zooks97/pymatgen
def generate_potcar(args):
    """
    Generate POTCAR.

    Args:
        args (dict): Args from argparse.
    """
    if args.recursive:
        proc_dir(args.recursive, gen_potcar)
    elif args.symbols:
        try:
            p = Potcar(args.symbols, functional=args.functional)
            p.write_file("POTCAR")
        except Exception as ex:
            print("An error has occurred: {}".format(str(ex)))

    else:
        print("No valid options selected.")
コード例 #22
0
 def _verify_files(self, skip_kpoints=False, preserve_incar=False):
     if not preserve_incar:
         self.assertEqual(Incar.from_file(os.path.join(module_dir, "INCAR")), self.ref_incar)
         self.assertEqual(str(Poscar.from_file(os.path.join(module_dir, "POSCAR"))), str(self.ref_poscar))
         self.assertEqual((Potcar.from_file(os.path.join(module_dir, "POTCAR"))).symbols, self.ref_potcar.symbols)
         if not skip_kpoints:
             self.assertEqual(str(Kpoints.from_file(os.path.join(module_dir, "KPOINTS"))), str(self.ref_kpoints))
     else:
         self.assertEqual(Incar.from_file(os.path.join(module_dir, "INCAR")), self.ref_incar_preserve)
コード例 #23
0
def test_nbands():
    composition = Composition("KH2")
    potcar = Potcar(symbols=["Mn", "O"])
    nelect_mn_pv = 7
    nelect_o = 6
    unoccupied_band_mn = 9
    unoccupied_band_o = 4
    expected = (ceil((nelect_mn_pv + nelect_o * 2) / 2) + unoccupied_band_mn +
                unoccupied_band_o * 2)
    assert num_bands(composition, potcar) == expected
コード例 #24
0
def test_ldau_option(default_dict):
    generator = IncarSettingsGenerator(composition=Composition("Zn"),
                                       symbol_list=["Zn"],
                                       potcar=Potcar(["Zn"]),
                                       num_kpts=5,
                                       num_kpt_multiplication_factor=1,
                                       xc=Xc.pbe,
                                       task=Task.structure_opt,
                                       ldau=False)
    assert "LDAU" not in generator.incar_settings
コード例 #25
0
 def from_file(cls, filename):
     try:
         potcars = Potcar.from_file(filename)
         return cls(pp_lists=potcars)
     except:
         with open(filename, 'r') as f:
             content = f.readlines()
         functional = content[0].strip().split(':')[-1].strip()
         symbols = content[1].strip().split()
         return cls(symbols=symbols, functional=functional)
コード例 #26
0
def get_num_electrons_from_potcar(potcar, nions, charge=0):
    """
    Returns the number of electrons from POTCAR, number of ions, and charge
    state.
    """
    p = Potcar.from_file(potcar)
    # check only the number of ions written in potcar and nions.
    if not len(p) == len(nions):
        raise ValueError("Size of elements in POTCAR file is different")

    return sum([v.nelectrons * nions[i] for i, v in enumerate(p)]) - charge
コード例 #27
0
ファイル: test_setup.py プロジェクト: zhenming-xu/atomate
 def _verify_files(self):
     self.assertEqual(Incar.from_file(os.path.join(module_dir, "INCAR")),
                      self.ref_incar)
     self.assertEqual(
         str(Poscar.from_file(os.path.join(module_dir, "POSCAR"))),
         str(self.ref_poscar))
     self.assertEqual(
         Potcar.from_file(os.path.join(module_dir, "POTCAR")).symbols,
         self.ref_potcar.symbols)
     self.assertEqual(
         str(Kpoints.from_file(os.path.join(module_dir, "KPOINTS"))),
         str(self.ref_kpoints))
コード例 #28
0
 def _verify_files(self, skip_kpoints=False, preserve_incar=False):
     if not preserve_incar:
         self.assertEqual(Incar.from_file("INCAR"), self.ref_incar)
         self.assertEqual(str(Poscar.from_file("POSCAR")), str(self.ref_poscar))
         self.assertEqual(Potcar.from_file("POTCAR").symbols,
                          self.ref_potcar.symbols)
         if not skip_kpoints:
             self.assertEqual(str(Kpoints.from_file("KPOINTS")),
                              str(self.ref_kpoints))
     else:
         self.assertEqual(Incar.from_file("INCAR"),
                          self.ref_incar_preserve)
コード例 #29
0
    def run_task(self, fw_spec):
        potcar_symbols = env_chk(self.get("potcar_symbols"), fw_spec)
        functional = self.get("functional", None)
        potcar_name = self.get("input_filename", "POTCAR")
        potcar = Potcar.from_file(potcar_name)

        # Replace PotcarSingles corresponding to elements
        # contained in potcar_symbols
        for n, psingle in enumerate(potcar):
            if psingle.element in potcar_symbols:
                potcar[n] = PotcarSingle.from_symbol_and_functional(
                    potcar_symbols[psingle.element], functional)

        potcar.write_file(self.get("output_filename", "POTCAR"))
コード例 #30
0
def getCharges():
    ''' Extract Bader charges from Bader analysis output '''

    POTCAR = Potcar.from_file(loc + '/POTCAR')
    z = ferro.zval_dict_from_potcar(POTCAR)
    bader = open(loc + '/ACF.dat')
    c = []
    s = [line.split() for line in bader if re.match('[0-9]+', line.split()[0])]
    for i in unit.symbol_set:
        for j in unit.indices_from_symbol(i):
            c.append(z[i] - float(s[j][4]))
    bader.close()

    return c
コード例 #31
0
ファイル: write_inputs.py プロジェクト: montoyjh/MatMethods
    def run_task(self, fw_spec):
        potcar_symbols = env_chk(self.get("potcar_symbols"), fw_spec)
        functional = self.get("functional", None)
        potcar_name = self.get("input_filename", "POTCAR")
        potcar = Potcar.from_file(potcar_name)

        # Replace PotcarSingles corresponding to elements
        # contained in potcar_symbols
        for n, psingle in enumerate(potcar):
            if psingle.element in potcar_symbols:
                potcar[n] = PotcarSingle.from_symbol_and_functional(
                    potcar_symbols[psingle.element], functional)

        potcar.write_file(self.get("output_filename", "POTCAR"))
コード例 #32
0
    def setUpClass(cls):
        if not SETTINGS.get("VASP_PSP_DIR"):
            SETTINGS["VASP_PSP_DIR"] = os.path.join(module_dir, "reference_files")
            print(
                "This system is not set up to run VASP jobs. "
                "Please set VASP_PSP_DIR variable in your ~/.pmgrc.yaml file."
            )

        cls.struct_si = PymatgenTest.get_structure("Si")

        cls.ref_incar = Incar.from_file(os.path.join(module_dir, "reference_files", "setup_test", "INCAR"))
        cls.ref_poscar = Poscar.from_file(os.path.join(module_dir, "reference_files", "setup_test", "POSCAR"))
        cls.ref_potcar = Potcar.from_file(os.path.join(module_dir, "reference_files", "setup_test", "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(os.path.join(module_dir, "reference_files", "setup_test", "KPOINTS"))
        cls.ref_incar_preserve = Incar.from_file(os.path.join(module_dir, "reference_files", "preserve_incar", "INCAR"))
コード例 #33
0
ファイル: test_setup.py プロジェクト: montoyjh/MatMethods
    def setUpClass(cls):
        coords = [[0, 0, 0], [0.75, 0.5, 0.75]]
        lattice = Lattice([[3.8401979337, 0.00, 0.00],
                           [1.9200989668, 3.3257101909, 0.00],
                           [0.00, -2.2171384943, 3.1355090603]])
        cls.struct_si = IStructure(lattice, ["Si"] * 2, coords)

        cls.ref_incar = Incar.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test", "INCAR"))
        cls.ref_poscar = Poscar.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test", "POSCAR"))
        cls.ref_potcar = Potcar.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test", "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test", "KPOINTS"))
コード例 #34
0
 def setUp(self) -> None:
     mgo = self.get_structure_by_name("MgO64atoms")
     potcar = Potcar(["Mg", "O"], functional="PBE_54")
     self.defect = TaskIncarSettings.from_options(
         task=Task.defect,
         structure=mgo,
         potcar=potcar,
         num_kpoints=10,
         max_enmax=400.0,
         is_magnetization=False,
         band_gap=5.0,
         vbm_cbm=[2.0, 7.0],
         npar_kpar=False,
         encut=None,
         structure_opt_encut_factor=1.3)
コード例 #35
0
 def setUp(self) -> None:
     mgo = self.get_structure_by_name("MgO")
     self.default_kwargs = {
         "task": Task.structure_opt,
         "structure": mgo,
         "potcar": Potcar(["Mg", "O"]),
         "num_kpoints": 8,
         "max_enmax": 400.0,
         "is_magnetization": False,
         "vbm_cbm": [3.0, 8.0],
         "npar_kpar": True,
         "num_nodes": 1,
         "encut": None,
         "structure_opt_encut_factor": 1.3,
         "dos_step_size": 0.01
     }
コード例 #36
0
    def setUpClass(cls):
        cls.struct_si = PymatgenTest.get_structure("Si")

        cls.ref_incar = Incar.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test", "INCAR"))
        cls.ref_poscar = Poscar.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test",
                         "POSCAR"))
        cls.ref_potcar = Potcar.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test",
                         "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test",
                         "KPOINTS"))
        cls.ref_incar_preserve = Incar.from_file(os.path.join(module_dir,
                                                              "..", "..", "test_files",
                                                              "preserve_incar", "INCAR"))
コード例 #37
0
    def setUpClass(cls):
        if not SETTINGS.get("VASP_PSP_DIR"):
            raise unittest.SkipTest(
                "This system is not set up to run VASP jobs. "
                "Please set VASP_PSP_DIR variable in your ~/.pmgrc.yaml file."
            )

        coords = [[0, 0, 0], [0.75, 0.5, 0.75]]
        lattice = Lattice(
            [[3.8401979337, 0.00, 0.00], [1.9200989668, 3.3257101909, 0.00], [0.00, -2.2171384943, 3.1355090603]]
        )
        cls.struct_si = IStructure(lattice, ["Si"] * 2, coords)

        cls.ref_incar = Incar.from_file(os.path.join(module_dir, "reference_files", "setup_test", "INCAR"))
        cls.ref_poscar = Poscar.from_file(os.path.join(module_dir, "reference_files", "setup_test", "POSCAR"))
        cls.ref_potcar = Potcar.from_file(os.path.join(module_dir, "reference_files", "setup_test", "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(os.path.join(module_dir, "reference_files", "setup_test", "KPOINTS"))
コード例 #38
0
    def setUpClass(cls):
        cls.struct_si = PymatgenTest.get_structure("Si")

        cls.ref_incar = Incar.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test", "INCAR"))
        cls.ref_poscar = Poscar.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test",
                         "POSCAR"))
        cls.ref_potcar = Potcar.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test",
                         "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(
            os.path.join(module_dir, "..", "..", "test_files", "setup_test",
                         "KPOINTS"))
        cls.ref_incar_preserve = Incar.from_file(os.path.join(module_dir,
                                                              "..", "..", "test_files",
                                                              "preserve_incar", "INCAR"))
コード例 #39
0
def test_hse_structure_opt(default_dict):
    default_dict.update({
        "xc": Xc.hse,
        "composition": Composition("UO2"),
        "symbol_list": ["U", "O"],
        "potcar": Potcar(["U", "O"]),
        "exchange_ratio": 0.5,
        "set_hubbard_u": True
    })

    generator = IncarSettingsGenerator(**default_dict)
    # for k, v in generator.incar_settings.items():
    #     print(f'\"{k}\": {v}, ')
    expected = {
        "ALGO": "Damped",
        "PREC": "Normal",
        "LREAL": False,
        "EDIFF": 1e-07,
        "ENCUT": 520.0,
        "LASPH": True,
        "NELM": 100,
        "ISIF": 3,
        "IBRION": 2,
        "EDIFFG": -0.005,
        "NSW": 50,
        "ISMEAR": 0,
        "SIGMA": 0.1,
        "LWAVE": True,
        "LCHARG": False,
        "LORBIT": 10,
        "LHFCALC": True,
        "PRECFOCK": "Fast",
        "TIME": 0.4,
        "AEXX": 0.5,
        "HFSCREEN": 0.208,
        "LDAU": True,
        "LDAUTYPE": 2,
        "LMAXMIX": 6,
        "LDAUPRINT": 1,
        "LDAUU": [5, 0],
        "LDAUL": [3, -1],
        "KPAR": 1,
    }
    assert generator.incar_settings == expected
コード例 #40
0
ファイル: test_setup.py プロジェクト: zhenming-xu/atomate
    def setUpClass(cls):
        coords = [[0, 0, 0], [0.75, 0.5, 0.75]]
        lattice = Lattice([[3.8401979337, 0.00, 0.00],
                           [1.9200989668, 3.3257101909, 0.00],
                           [0.00, -2.2171384943, 3.1355090603]])
        cls.struct_si = IStructure(lattice, ["Si"] * 2, coords)

        cls.ref_incar = Incar.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test",
                         "INCAR"))
        cls.ref_poscar = Poscar.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test",
                         "POSCAR"))
        cls.ref_potcar = Potcar.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test",
                         "POTCAR"))
        cls.ref_kpoints = Kpoints.from_file(
            os.path.join(module_dir, "..", "test_files", "setup_test",
                         "KPOINTS"))
コード例 #41
0
def test_get_defect_charge_state(tmpdir):
    tmpdir.chdir()
    structure = Structure(Lattice.cubic(10), ["H", "He"],
                          [[0.0] * 3, [0.5] * 3])
    fake_potcar_str = """ PAW_PBE H 15Jun2001                    
   1.00000000000000     
 parameters from PSCTR are:
   VRHFIN =H: ultrasoft test
   LEXCH  = PE
   TITEL  = PAW_PBE H 15Jun2001
   POMASS =    1.000; ZVAL   =    1.000    mass and valenz
   ENMAX  =  250.000; ENMIN  =  200.000 eV

   END of PSCTR-controll parameters
 End of Dataset
      PAW_PBE He_pv 15Jun2001                    
   1.00000000000000     
 parameters from PSCTR are:
   VRHFIN =He: ultrasoft test
   LEXCH  = PE
   TITEL  = PAW_PBE He_pv 15Jun2001
   POMASS =    1.000; ZVAL   =    1.000    mass and valenz
   ENMAX  =  250.000; ENMIN  =  200.000 eV

   END of PSCTR-controll parameters
 End of Dataset
 """
    Path("POTCAR").write_text(fake_potcar_str)
    potcar = Potcar.from_file("POTCAR")
    incar = Incar.from_string("NELECT = 1")
    assert get_defect_charge_state(Poscar(structure), potcar, incar) == 2 - 1

    structure = Structure(Lattice.cubic(10), ["H", "He", "H", "H"],
                          [[0.0] * 3, [0.2] * 3, [0.4] * 3, [0.6] * 3])
    with pytest.raises(ValueError):
        get_defect_charge_state(Poscar(structure), potcar, incar)

    incar = Incar.from_string("")
    assert get_defect_charge_state(Poscar(structure), potcar, incar) == 0
コード例 #42
0
ファイル: creator.py プロジェクト: xhqu1981/pymatgen-db
    def process_killed_run(self, dir_name):
        """
        Process a killed vasp run.
        """
        fullpath = os.path.abspath(dir_name)
        logger.info("Processing Killed run " + fullpath)
        d = {"dir_name": fullpath, "state": "killed", "oszicar": {}}

        for f in os.listdir(dir_name):
            filename = os.path.join(dir_name, f)
            if fnmatch(f, "INCAR*"):
                try:
                    incar = Incar.from_file(filename)
                    d["incar"] = incar.as_dict()
                    d["is_hubbard"] = incar.get("LDAU", False)
                    if d["is_hubbard"]:
                        us = np.array(incar.get("LDAUU", []))
                        js = np.array(incar.get("LDAUJ", []))
                        if sum(us - js) == 0:
                            d["is_hubbard"] = False
                            d["hubbards"] = {}
                    else:
                        d["hubbards"] = {}
                    if d["is_hubbard"]:
                        d["run_type"] = "GGA+U"
                    elif incar.get("LHFCALC", False):
                        d["run_type"] = "HF"
                    else:
                        d["run_type"] = "GGA"
                except Exception as ex:
                    print(str(ex))
                    logger.error("Unable to parse INCAR for killed run {}."
                                 .format(dir_name))
            elif fnmatch(f, "KPOINTS*"):
                try:
                    kpoints = Kpoints.from_file(filename)
                    d["kpoints"] = kpoints.as_dict()
                except:
                    logger.error("Unable to parse KPOINTS for killed run {}."
                                 .format(dir_name))
            elif fnmatch(f, "POSCAR*"):
                try:
                    s = Poscar.from_file(filename).structure
                    comp = s.composition
                    el_amt = s.composition.get_el_amt_dict()
                    d.update({"unit_cell_formula": comp.as_dict(),
                              "reduced_cell_formula": comp.to_reduced_dict,
                              "elements": list(el_amt.keys()),
                              "nelements": len(el_amt),
                              "pretty_formula": comp.reduced_formula,
                              "anonymous_formula": comp.anonymized_formula,
                              "nsites": comp.num_atoms,
                              "chemsys": "-".join(sorted(el_amt.keys()))})
                    d["poscar"] = s.as_dict()
                except:
                    logger.error("Unable to parse POSCAR for killed run {}."
                                 .format(dir_name))
            elif fnmatch(f, "POTCAR*"):
                try:
                    potcar = Potcar.from_file(filename)
                    d["pseudo_potential"] = {
                        "functional": potcar.functional.lower(),
                        "pot_type": "paw",
                        "labels": potcar.symbols}
                except:
                    logger.error("Unable to parse POTCAR for killed run in {}."
                                 .format(dir_name))
            elif fnmatch(f, "OSZICAR"):
                try:
                    d["oszicar"]["root"] = \
                        Oszicar(os.path.join(dir_name, f)).as_dict()
                except:
                    logger.error("Unable to parse OSZICAR for killed run in {}."
                                 .format(dir_name))
            elif re.match("relax\d", f):
                if os.path.exists(os.path.join(dir_name, f, "OSZICAR")):
                    try:
                        d["oszicar"][f] = Oszicar(
                            os.path.join(dir_name, f, "OSZICAR")).as_dict()
                    except:
                        logger.error("Unable to parse OSZICAR for killed "
                                     "run in {}.".format(dir_name))
        return d