def __init__(self, configdir = None, convtype = None, auto = True, sort = True): """ Construct a VASP convergence job object. Args: configdir: path to configuration convtype: type of convergence (e.g. 'kpoints' or 'encut') 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/project_settings.json' was not found.") print "Constructing a CASM VASPWrapper Converge 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 converge.json settings file" sys.stdout.flush() setfile = casm.settings_path("converge.json",self.casm_settings["curr_calctype"],self.configdir) if setfile == None: raise vaspwrapper.VaspWrapperError("Could not find .../settings/" + self.casm_settings["curr_calctype"] + "/converge.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 "encut" in self.settings: self.settings["encut"] = None if not "kpoints" in self.settings: self.settings["kpoints"] = None if not "nrg_convergence" in self.settings: self.settings["nrg_convergence"] = None if not "run_limit" in self.settings: self.settings["run_limit"] = None self.auto = auto self.sort = sort print "VASP Converge object constructed\n" sys.stdout.flush()
def __init__(self, configdir=None, auto=True, sort=True): """ Construct a VASP relaxation job object. Arguments ---------- configdir: str, optional, default=None Path to configuration directory. If None, uses the current working directory auto: boolean, optional, default=True, Use True to use the pbs module's JobDB to manage pbs jobs sort: boolean, optional, default=True, Use True to sort atoms in POSCAR by type """ print "Construct a casm.vaspwrapper.Relax instance:" if configdir is None: configdir = os.getcwd() print " Input directory:", configdir # get the configname from the configdir path _res = os.path.split(configdir) self.configname = os.path.split(_res[0])[1] + "/" + _res[1] print " Configuration:", self.configname print " Reading CASM settings" self.casm_directories = casm.project.DirectoryStructure(configdir) self.casm_settings = casm.project.ProjectSettings(configdir) if self.casm_settings is None: raise vaspwrapper.VaspWrapperError( "Not in a CASM project. The file '.casm' directory was not found." ) if os.path.abspath(configdir) != self.configdir: print "" print "input configdir:", configdir print "determined configname:", self.configname print "expected configdir given configname:", self.configdir raise vaspwrapper.VaspWrapperError( "Mismatch between configname and configdir") # fixed to default_clex for now self.clex = self.casm_settings.default_clex # store path to .../config/calctype.name, and create if not existing self.calcdir = self.casm_directories.calctype_dir( self.configname, self.clex) try: os.mkdir(self.calcdir) except: pass print " Calculations directory:", self.calcdir # read the settings json file print " Reading relax.json settings file" sys.stdout.flush() setfile = self.casm_directories.settings_path_crawl( "relax.json", self.configname, self.clex) if setfile is None: raise vaspwrapper.VaspWrapperError( "Could not find \"relax.json\" in an appropriate \"settings\" directory" ) sys.stdout.flush() else: print " Read settings from:", setfile self.settings = vaspwrapper.read_settings(setfile) # set default 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 if not "prerun" in self.settings: self.settings["prerun"] = None if not "postrun" in self.settings: self.settings["postrun"] = None self.auto = auto self.sort = sort print " DONE\n" sys.stdout.flush()
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()
def __init__(self, configdir=None, auto=True, sort=True): """ Construct a VASP relaxation job object. Arguments ---------- configdir: str, optional, default=None Path to configuration directory. If None, uses the current working directory auto: boolean, optional, default=True, Use True to use the pbs module's JobDB to manage pbs jobs sort: boolean, optional, default=True, Use True to sort atoms in POSCAR by type """ print "Construct a casm.vaspwrapper.Relax instance:" if configdir is None: configdir = os.getcwd() print " Input directory:", configdir # get the configname from the configdir path _res = os.path.split(configdir) self.configname = os.path.split(_res[0])[1] + "/" + _res[1] print " Configuration:", self.configname print " Reading CASM settings" self.casm_directories=casm.project.DirectoryStructure(configdir) self.casm_settings = casm.project.ProjectSettings(configdir) if self.casm_settings is None: raise vaspwrapper.VaspWrapperError("Not in a CASM project. The file '.casm' directory was not found.") if os.path.abspath(configdir) != self.configdir: print "" print "input configdir:", configdir print "determined configname:", self.configname print "expected configdir given configname:", self.configdir raise vaspwrapper.VaspWrapperError("Mismatch between configname and configdir") # fixed to default_clex for now self.clex = self.casm_settings.default_clex # store path to .../config/calctype.name, and create if not existing self.calcdir = self.casm_directories.calctype_dir(self.configname, self.clex) try: os.mkdir(self.calcdir) except: pass print " Calculations directory:", self.calcdir # read the settings json file print " Reading relax.json settings file" sys.stdout.flush() setfile = self.casm_directories.settings_path_crawl("relax.json", self.configname, self.clex) if setfile is None: raise vaspwrapper.VaspWrapperError("Could not find \"relax.json\" in an appropriate \"settings\" directory") sys.stdout.flush() else: print " Read settings from:", setfile self.settings = vaspwrapper.read_settings(setfile) # set default 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 if not "prerun" in self.settings: self.settings["prerun"] = None if not "postrun" in self.settings: self.settings["postrun"] = None self.auto = auto self.sort = sort print " DONE\n" sys.stdout.flush()