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"))
if __name__ == "__main__": symbol = 'Ni' sg = 'sc' 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
if os.path.exists(dir_conv_kpoints): shutil.rmtree(dir_conv_kpoints) os.mkdir(dir_conv_kpoints) # do kpoint mesh for k in range(5, 12): # vasp_simulation = vasp.VaspSimulation() # vasp_simulation.simulation_directory = os.path.join( # dir_conv_kpoints, # '{}x{}x{}'.format(k,k,k)) # slurm_job_name = "{}_{}_{}".format( # symbol,sg,"{}x{}x{}".format(k,k,k)) sim_dir = os.path.join(dir_conv_kpoints, '{}x{}x{}'.format(k, k, k)) slurm_job_name = '{}_{}_{}'.format(symbol, sg, '{}x{}x{}'.format(k, k, k)) vasp_simulation = vasp.VaspSimulation(sim_dir=sim_dir) # if os.path.exists(vasp_simulation.simulation_directory): # shutil.rmtree(vasp_simulation.simulation_directory) # os.mkdir(vasp_simulation.simulation_directory) if os.path.exists(sim_dir): shutil.rmtree(sim_dir) os.mkdir(sim_dir) # write poscar vasp_simulation.poscar = vasp.Poscar(vasp.read_poscar_file(\ filename = os.path.join(dir_min_0,'CONTCAR'))) # vasp_simulation.poscar.write( # os.path.join(vasp_simulation.simulation_directory,"POSCAR")) vasp_simulation.poscar.write(os.path.join(sim_dir, "POSCAR")) # write potcar vasp_simulation.xc = xc vasp_simulation.symbols = vasp_simulation.poscar.symbols
def create_simulation(self): # initialize input files self.vs = vasp.VaspSimulation()
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)