def __init__(self,task_name,task_directory,restart=True): Task.__init__(self,task_name,task_directory,restart) self.poscar = vasp.Poscar() self.incar = vasp.Incar() self.potcar = vasp.Potcar() self.kpoints = vasp.Kpoints() self.contcar = vasp.Contcar()
def vasp_structural_minimization(structure, task_name): assert isinstance(structure, pypospack.crystal.SimulationCell) assert isinstance(task_name, str) vasp_simulation = vasp.VaspSimulation() vasp_simulation.simulation_directory = task_dir vasp_simulation.poscar = vasp.Poscar(structure) vasp_simulation.incar = vasp.Incar() vasp_simulation.potcar = vasp.Potcar() vasp_simulation.kpoints = vasp.Kpoints()
def create_simulation(self): # initialize input files self.vs = vasp.VaspSimulation() self.vs.poscar = vasp.Poscar(obj_structure) self.vs.incar = vasp.Incar() self.vs.potcar = vasp.Potcar() self.vs.kpoints = vasp.Kpoints() self.vs.xc = self.xc self.vs.simulation_directory = self.sim_dir self.vs.symbols = self.vs.poscar.symbols # configure potcar file self.vs.potcar.symbols = self.vs.symbols self.vs.potcar.xc = self.vs.xc fn_potcar = os.path.join(self.vs.simulation_directory, 'POTCAR') self.vs.potcar.write(fn_potcar) self.vs.potcar.read(fn_potcar) self.vs.encut = max(self.vs.potcar.encut_max) self.vs.natoms = self.vs.poscar.n_atoms # configure incar file magmom_0 = 1.0 self.vs.incar.ismear = 1 self.vs.incar.sigma = 0.20 self.vs.incar.ispin = 2 self.vs.incar.magmom = "{}*{}".format(self.vs.natoms, magmom_0) self.vs.incar.ibrion = 2 self.vs.incar.isif = 3 self.vs.incar.potim = 0.5 self.vs.incar.ediffg = -0.001 self.vs.poscar.write(os.path.join(\ self.vs.simulation_directory,"POSCAR")) self.vs.incar.write(os.path.join(\ self.vs.simulation_directory,"INCAR")) self.vs.kpoints.write(os.path.join(\ self.vs.simulation_directory,"KPOINTS"))
task_name = 'minimize_init' job_name = "{}_{}_min1".format(symbol, sg) email = "*****@*****.**" qos = "phillpot" ntasks = 16 time = "1:00:00" init_directory = os.getcwd() task_dir = os.path.join(os.getcwd(), task_name) vasp_simulation = vasp.VaspSimulation() vasp_simulation.simulation_directory = task_dir vasp_simulation.poscar = vasp.Poscar(\ ase.build.bulk(symbol,sg,a,cubic=True)) vasp_simulation.incar = vasp.Incar() vasp_simulation.potcar = vasp.Potcar() vasp_simulation.kpoints = vasp.Kpoints() # create directory # create vasp simulation directory and files # delete the directory and the contents if it exists if os.path.exists(vasp_simulation.simulation_directory): shutil.rmtree(vasp_simulation.simulation_directory) os.mkdir(vasp_simulation.simulation_directory) # configure potcar file print('confguring potcar file...') vasp_simulation.xc = 'GGA' vasp_simulation.symbols = vasp_simulation.poscar.symbols vasp_simulation.potcar.symbols = vasp_simulation.symbols vasp_simulation.potcar.xc = vasp_simulation.xc
import pypospack.io.vasp as vasp if __name__ == '__main__': symbols = ['Mg', 'O'] filename = 'POTCAR' # let's try to read potcar = vasp.Potcar(symbols=symbols) potcar.write('POTCAR') # now let's try to write potcar = vasp.Potcar(symbols=symbols) potcar.write('POTCAR') potcar.read('POTCAR') print('symbols', potcar.symbols) print('encut_min', potcar.encut_min) print('encut_max', potcar.encut_max) print('lexch', potcar.xc) print('models', potcar.models)
def __init__(self, structure='POSCAR', xc='GGA', encut_min=None, encut_max=None, encut_step=25, incar_dict=None, slurm_dict=None, full_auto=True): # check argument 'structure' if isinstance(structure, crystal.SimulationCell): self.structure_filename = 'POSCAR' self.poscar = vasp.Poscar(structure) self.poscar.write(structure_filename) elif isinstance(structure, str): self.structure_filename = structure self.poscar = vasp.Poscar() self.poscar.read(structure) else: msg_err = "structure must either be an instance of " msg_err += "pypospack.crystal.SimulationCell or a string" raise ValueError(msg_err) self.xc = xc # determine energy cutoff if any([encut_min is None, encut_max is None]): # create a potcar containing the information contained in the # potcar files potcar = vasp.Potcar() potcar.symbols = self.poscar.symbols potcar.xc = xc # this is kind of clunky because I have to write the potcar file # before i read it. # TODO: what I should actually do is read the POTCARS for each # individual symbol and collect the information I need potcar.write('POTCAR.tmp') potcar.read('POTCAR.tmp') os.remove('POTCAR.tmp') # set encut min if any([isinstance(encut_min, float), isinstance(encut_min, int)]): self.encut_min = encut_min else: self.encut_min = max(potcar.encut_min) # set encut max if any([isinstance(encut_max, float), isinstance(encut_max, int)]): self.encut_max = encut_max else: self.encut_max = 1.5 * max(potcar.encut_max) else: self.encut_min = encut_min self.encut_max = encut_max self.encut_step = encut_step # set incut_dict if isinstance(incar_dict, dict): self.incar_dict = copy.deepcopy(incar_dict) # set slurm_dict if isinstance(slurm_dict, dict): self.slurm_dict = copy.deepcopy(slurm_dict) # additional attributes which aren't parameters self.tasks = {} self.task_results = {} if full_auto is True: self.do_full_auto()
def minimize_init(): if __name__ == "__main__": ase_symbol = 'Ni' ase_sg = 'bcc' ase_a = 3.508 ase_shape = 'cubic' system_name = '{}_{}_{}'.format(ase_symbol,ase_sg,ase_a,ase_shape) init_dir = os.path.join(os.getcwd(),system_name) if os.path.exists(init_dir): # simulation has already been started else: os.mkdir(init_dir) minimize_init_task_name = 'minimize_init' minimize_init_slurm_job_name = "{}_{}_min_0".format(symbol,sg) minimize_init_slurm_email = "*****@*****.**" minimize_init_slurm_qos="phillpot" minimize_init_slurm_ntasks=16 minimize_init_slurm_time="1:00:00" task_dir = os.path.join(os.getcwd(),task_name) vasp_simulation = vasp.VaspSimulation() vasp_simulation.simulation_directory = task_dir vasp_simulation.poscar = vasp.Poscar(\ ase.build.bulk(symbol,sg,a,cubic=True)) vasp_simulation.incar = vasp.Incar() vasp_simulation.potcar = vasp.Potcar() vasp_simulation.kpoints = vasp.Kpoints() # create directory # create vasp simulation directory and files # delete the directory and the contents if it exists if os.path.exists(vasp_simulation.simulation_directory): shutil.rmtree(vasp_simulation.simulation_directory) os.mkdir(vasp_simulation.simulation_directory) # configure potcar file print('confguring potcar file...') vasp_simulation.xc = 'GGA' vasp_simulation.symbols = vasp_simulation.poscar.symbols vasp_simulation.potcar.symbols = vasp_simulation.symbols vasp_simulation.potcar.xc = vasp_simulation.xc # get information from potcar vasp_simulation.potcar.write( os.path.join(vasp_simulation.simulation_directory,"POTCAR")) vasp_simulation.potcar.read( os.path.join(vasp_simulation.simulation_directory,"POTCAR")) # stuff to put into tests # use the largest enmax of all a # print('symbols:{}'.format(','.join(vasp_simulation.potcar.symbols))) # print('recommended encut range: {}-{}'.format( # min(vasp_simulation.potcar.encut_min) # max(vasp_simulation.potcar.encut_max) # vasp_simulation.encut_min, # vasp_simulation.encut_max)) # print('n_atoms:{}'.format(vasp_simulation.poscar.n_atoms)) # print('n_atomic_basis:{}'.format(len(vasp_simulation.poscar.atomic_basis))) # print('n_interstitials:{}'.format(len(vasp_simulation.poscar.interstitials))) # configure incar file vasp_simulation.encut = max(vasp_simulation.potcar.encut_max) vasp_simulation.natoms = vasp_simulation.poscar.n_atoms vasp_simulation.incar.encut = vasp_simulation.encut magmom_init = 1.0 vasp_simulation.incar.ismear = 1 # methfessel paxton order 1 vasp_simulation.incar.sigma = 0.20 # smearing parameter vasp_simulation.incar.ispin = 2 # spin-polarized calculations vasp_simulation.incar.magmom = "{}*{}".format( vasp_simulation.poscar.n_atoms,magmom_init) vasp_simulation.incar.ibrion = 2 # conjugate gradient method vasp_simulation.incar.isif = 3 # relax everything vasp_simulation.incar.potim = 0.5 # dampening parameter vasp_simulation.incar.ediffg = -0.001 # ev/Ang vasp_simulation.poscar.write( os.path.join(vasp_simulation.simulation_directory,"POSCAR")) vasp_simulation.incar.write( os.path.join(vasp_simulation.simulation_directory,"INCAR")) vasp_simulation.kpoints.write( os.path.join(vasp_simulation.simulation_directory,"KPOINTS")) slurm.write_vasp_batch_script( filename=os.path.join(vasp_simulation.simulation_directory,"runjob_hpg.slurm"), job_name=job_name, email=email, qos=qos, ntasks=ntasks, time=time) # submit job init_dir = os.getcwd() os.chdir(vasp_simulation.simulation_directory) print('running in {}'.format(os.getcwd())) os.system('sbatch runjob_hpg.slurm') os.chdir(init_dir)
def __init__(self,directory=None,structure='POSCAR',xc='GGA', encut_min=None,encut_max=None,encut_step=25, incar_dict=None,kpoints_dict=None,slurm_dict=None,full_auto=True): self.orig_directory = os.getcwd() self.filename_results = 'converg.encut.results' self.manifest_filename = 'pypospack.manifest.yaml' # --- PROCESS ARGUMENTS --- # process the dictionary attribute if directory is not None: if os.path.isabs(directory): self.directory = directory else: self.directory = os.path.join( self.orig_directory, directory) if not os.path.exists(self.directory): os.makedirs(self.directory) # change the location of the result output file self.filename_results = os.path.join( self.directory, self.filename_results) self.manifest_filename = os.path.join( self.directory, self.manifest_filename) # check argument 'structure' if isinstance(structure,crystal.SimulationCell): self.structure_filename = 'POSCAR' self.poscar = vasp.Poscar(structure) self.poscar.write(structure_filename) elif isinstance(structure,str): if os.path.isabs(structure): self.structure_filename = structure else: # convert to absolute path self.structure_filename = os.path.join( self.orig_directory, structure) self.structure_filename = os.path.normpath( self.structure_filename) # read the poscar file self.poscar = vasp.Poscar() self.poscar.read(self.structure_filename) else: msg_err = "structure must either be an instance of " msg_err += "pypospack.crystal.SimulationCell or a string" raise ValueError(msg_err) # self exchange correlation functional self.xc = xc # determine energy cutoff if any([encut_min is None, encut_max is None]): # create a potcar containing the information contained in the # potcar files potcar = vasp.Potcar() potcar.symbols = self.poscar.symbols potcar.xc = xc # this is kind of clunky because I have to write the potcar file # before i read it. # TODO: what I should actually do is read the POTCARS for each # individual symbol and collect the information I need potcar.write('POTCAR.tmp') potcar.read('POTCAR.tmp') os.remove('POTCAR.tmp') # set encut min if any([isinstance(encut_min,float), isinstance(encut_min,int)]): self.encut_min = encut_min else: self.encut_min = max(potcar.encut_min) # set encut max if any([isinstance(encut_max,float), isinstance(encut_max,int)]): self.encut_max = encut_max else: self.encut_max = 1.5 * max (potcar.encut_max) else: self.encut_min = encut_min self.encut_max = encut_max self.encut_min = (self.encut_min//encut_step)*encut_step self.encut_max = ((self.encut_max//encut_step)+1)*encut_step self.encut_step = encut_step # set incut_dict if isinstance(incar_dict, dict): self.incar_dict = copy.deepcopy(incar_dict) # set kpoints_dict self.kpoints_dict = None if isinstance(kpoints_dict, dict): self.kpoints_dict = copy.deepcopy(kpoints_dict) # set slurm_dict if isinstance(slurm_dict, dict): self.slurm_dict = copy.deepcopy(slurm_dict) # additional attributes which aren't parameters self.tasks = {} self.task_results = {} if full_auto is True: self.do_full_auto()
import pypospack.io.vasp as vasp # an array of symbols symbols = ['Mg', 'O'] xc = 'GGA' potcar = vasp.Potcar(symbols=symbols, xc='GGA') potcar.write('POTCAR') symbols = ['Ni'] xc = 'GGA' potcar = vasp.Potcar(symbols=symbols, xc=xc) potcar.write('POTCAR')