def test_change_encut(self): incar1 = vasp.Incar() incar1.encut = 123 incar1.write('INCAR.encuttest') incar2 = vasp.Incar(2) incar2.read('INCAR.encuttest') assert incar2.encut == incar1.encut
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 read_incar(self,incar='None'): if incar is None: if os.path.exists(os.path.join(self.task_directory,'INCAR')): self.incar = vasp.Incar() self.incar.read(os.path.join(self.task_directory,'INCAR')) else: self.incar = vasp.Incar() elif isinstance(incar,str): self.incar = vasp.Incar() self.incar.read(incar) elif isinstance(incar,dict): # check to see if the incar already exists, and read it in if os.path.exists(os.path.join(self.task_directory,'INCAR')): self.incar = vasp.Incar() self.incar.read(os.path.join(self.task_directory,'INCAR')) # otherwise, we're just going to use the default configuarion else: self.incar = vasp.Incar() # now update based upon what is dictionary for k,v in incar.items(): setattr(self.incar,k,v) else: raise VaspSimulationError
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"))
a = 3.508 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
def test_write(self): incar = vasp.Incar() incar.write('INCAR.std')
def test_init(self): incar = vasp.Incar()
def test_write_w_ibrion_2(self): incar = vasp.Incar() incar.ibrion = 2 incar.isif = 3 incar.write('INCAR.ibrion2')
def test_read(self): incar = vasp.Incar() incar.read('INCAR.std')
def test_read(self): incar = vasp.Incar() incar.read('INCAR.std') def test_write_w_ibrion_2(self): incar = vasp.Incar() incar.ibrion = 2 incar.isif = 3 incar.write('INCAR.ibrion2') def test_change_encut(self): incar1 = vasp.Incar() incar1.encut = 123 incar1.write('INCAR.encuttest') incar2 = vasp.Incar(2) incar2.read('INCAR.encuttest') assert incar2.encut == incar1.encut if __name__ == "__main__": filename = 'INCAR.std' incar = vasp.Incar() incar.write(filename) filename = 'INCAR.ibrion2' incar = vasp.Incar() incar.ibrion = 2 incar.write(filename)
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)