Пример #1
0
    def setup(self):
        """ Setup initial relaxation run

            Uses the following files from the most local .../settings/calctype.name directory:
                INCAR: VASP input settings
                KPOINTS: VASP kpoints settings
                POSCAR: reference for KPOINTS if KPOINTS mode is not A/AUTO/Automatic
                SPECIES: info for each species such as which POTCAR files to use, MAGMOM, GGA+U, etc.

            Uses the following files from the .../config directory:
                POS: structure of the configuration to be relaxed

        """
        # Find required input files in CASM project directory tree
        vaspfiles=casm.vaspwrapper.vasp_input_file_names(self.casm_directories, self.configname, self.clex)
        incarfile,prim_kpointsfile,prim_poscarfile,super_poscarfile,speciesfile=vaspfiles
        
        # Find optional input files
        extra_input_files = []
        for s in self.settings["extra_input_files"]:
            extra_input_files.append(self.casm_directories.settings_path_crawl(s, self.configname, self.clex))
            if extra_input_files[-1] is None:
                raise vasp.VaspError("Relax.setup failed. Extra input file " + s + " not found in CASM project.")
        if self.settings["initial"]:
            extra_input_files += [ self.casm_directories.settings_path_crawl(self.settings["initial"], self.configname, self.clex) ]
            if extra_input_files[-1] is None:
                raise vasp.VaspError("Relax.setup failed. No initial INCAR file " + self.settings["initial"] + " found in CASM project.")
        if self.settings["final"]:
            extra_input_files += [ self.casm_directories.settings_path_crawl(self.settings["final"], self.configname, self.clex) ]
            if extra_input_files[-1] is None:
                raise vasp.VaspError("Relax.setup failed. No final INCAR file " + self.settings["final"] + " found in CASM project.")
        sys.stdout.flush()

        vasp.io.write_vasp_input(self.calcdir, incarfile, prim_kpointsfile, prim_poscarfile, super_poscarfile, speciesfile, self.sort, extra_input_files,self.settings["strict_kpoints"])
Пример #2
0
    def setup(self):
        """ Setup initial relaxation run

            Uses the following files from the most local .../settings/calctype.name directory:
                INCAR: VASP input settings
                KPOINTS: VASP kpoints settings
                POSCAR: reference for KPOINTS if KPOINTS mode is not A/AUTO/Automatic
                SPECIES: info for each species such as which POTCAR files to use, MAGMOM, GGA+U, etc.

            Uses the following files from the .../config directory:
                POS: structure of the configuration to be relaxed

        """
        incarfile = casm.settings_path("INCAR",
                                       self.casm_settings["curr_calctype"],
                                       self.configdir)
        prim_kpointsfile = casm.settings_path(
            "KPOINTS", self.casm_settings["curr_calctype"], self.configdir)
        prim_poscarfile = casm.settings_path(
            "POSCAR", self.casm_settings["curr_calctype"], self.configdir)
        super_poscarfile = os.path.join(self.configdir, "POS")
        speciesfile = casm.settings_path("SPECIES",
                                         self.casm_settings["curr_calctype"],
                                         self.configdir)

        if incarfile == None or not os.path.isfile(incarfile):
            raise vasp.VaspError("Relax.setup failed. No incar file: '" +
                                 incarfile + "'")
        if prim_kpointsfile == None or not os.path.isfile(prim_kpointsfile):
            raise vasp.VaspError("Relax.setup failed. No kpoints file: '" +
                                 prim_kpointsfile + "'")
        if prim_poscarfile == None or not os.path.isfile(prim_poscarfile):
            #            raise vasp.VaspError("Relax.setup failed. No prim poscar file: '" + prim_poscarfile + "'")
            warnings.warn(
                "No prim poscar file: '" + prim_poscarfile +
                "', I hope your KPOINTS mode is A/AUTO/Automatic \
            or this will fail!!!", vasp.VaspWarning)
            prim_poscarfile = None
        if super_poscarfile == None or not os.path.isfile(super_poscarfile):
            raise vasp.VaspError("Relax.setup failed. No pos file: '" +
                                 super_poscarfile + "'")
        if speciesfile == None or not os.path.isfile(speciesfile):
            raise vasp.VaspError("Relax.setup failed. No species file: '" +
                                 speciesfile + "'")
        sys.stdout.flush()

        vasp.io.write_vasp_input(self.calcdir, incarfile, prim_kpointsfile,
                                 prim_poscarfile, super_poscarfile,
                                 speciesfile, self.sort)
Пример #3
0
    def __init__(self, configdir=None, auto = True, sort = True):
        """
        Construct a VASP relaxation job object.

        Args:
            configdir: path to configuration
            auto: True if using pbs module's JobDB to manage pbs jobs

        """
        if configdir == None:
            configdir = os.getcwd()

        print "Reading CASM settings"
        self.casm_settings = casm.casm_settings(configdir)
        if self.casm_settings == None:
            raise vaspwrapper.VaspWrapperError("Not in a CASM project. The file '.casm' directory was not found.")

        print "Constructing a CASM VASPWrapper Relax object"
        sys.stdout.flush()

        print "  Setting up directories"
        sys.stdout.flush()

        # store path to .../config, if not existing raise
        self.configdir = os.path.abspath(configdir)
        if not os.path.isdir(self.configdir):
            raise vasp.VaspError("Error in casm.vasp.relax: Did not find directory: " + self.configdir)
            sys.stdout.flush()

        # store path to .../config/calctype.name, and create if not existing
        self.calcdir = os.path.join(self.configdir, self.casm_settings["curr_calctype"])
        try:
            os.mkdir(self.calcdir)
        except:
            pass

        # read the settings json file
        print "  Reading relax.json settings file"
        sys.stdout.flush()
        setfile = casm.settings_path("relax.json",self.casm_settings["curr_calctype"],self.configdir)
        if setfile == None:
            raise vaspwrapper.VaspWrapperError("Could not find .../settings/" + self.casm_settings["curr_calctype"] + "/relax.json file.")
            sys.stdout.flush()
        self.settings = vaspwrapper.read_settings(setfile)

        # add required keys to settings if not present
        if not "ncore" in self.settings:
            self.settings["ncore"] = None
        if not "npar" in self.settings:
            self.settings["npar"] = None
        if not "kpar" in self.settings:
            self.settings["kpar"] = None
        if not "vasp_cmd" in self.settings:
            self.settings["vasp_cmd"] = None
        if not "ncpus" in self.settings:
            self.settings["ncpus"] = None
        if not "run_limit" in self.settings:
            self.settings["run_limit"] = None



        self.auto = auto
        self.sort = sort
        print "VASP Relax object constructed\n"
        sys.stdout.flush()