def test_static_constructors(self): kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) self.assertEqual(kpoints.kpts, [[3, 3, 3]]) kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) self.assertEqual(kpoints.kpts, [[2, 2, 2]]) kpoints = Kpoints.automatic(100) self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic) self.assertEqual(kpoints.kpts, [[100]]) filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) kpoints = Kpoints.automatic_density(poscar.structure, 500) self.assertEqual(kpoints.kpts, [[1, 3, 3]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.automatic_density(poscar.structure, 500, True) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000) self.assertEqual(kpoints.kpts, [[6, 10, 13]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) s = poscar.structure s.make_supercell(3) kpoints = Kpoints.automatic_density(s, 500) self.assertEqual(kpoints.kpts, [[1, 1, 1]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.from_string("""k-point mesh 0 G 10 10 10 0.5 0.5 0.5 """) self.assertArrayAlmostEqual(kpoints.kpts_shift, [0.5, 0.5, 0.5])
def test_static_constructors(self): kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) self.assertEqual(kpoints.kpts, [[3, 3, 3]]) kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) self.assertEqual(kpoints.kpts, [[2, 2, 2]]) kpoints = Kpoints.automatic(100) self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic) self.assertEqual(kpoints.kpts, [[100]]) filepath = self.TEST_FILES_DIR / 'POSCAR' poscar = Poscar.from_file(filepath) kpoints = Kpoints.automatic_density(poscar.structure, 500) self.assertEqual(kpoints.kpts, [[1, 3, 3]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.automatic_density(poscar.structure, 500, True) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000) self.assertEqual(kpoints.kpts, [[6, 10, 13]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) s = poscar.structure s.make_supercell(3) kpoints = Kpoints.automatic_density(s, 500) self.assertEqual(kpoints.kpts, [[1, 1, 1]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.from_string("""k-point mesh 0 G 10 10 10 0.5 0.5 0.5 """) self.assertArrayAlmostEqual(kpoints.kpts_shift, [0.5, 0.5, 0.5])
def test_static_constructors(self): kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) self.assertEqual(kpoints.kpts, [[3, 3, 3]]) kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) self.assertEqual(kpoints.kpts, [[2, 2, 2]]) kpoints = Kpoints.automatic(100) self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic) self.assertEqual(kpoints.kpts, [[100]]) filepath = os.path.join(test_dir, "POSCAR") poscar = Poscar.from_file(filepath) kpoints = Kpoints.automatic_density(poscar.structure, 500) self.assertEqual(kpoints.kpts, [[2, 4, 4]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = Kpoints.automatic_density(poscar.structure, 500, True) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000) self.assertEqual(kpoints.kpts, [[6, 11, 13]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) s = poscar.structure s.make_supercell(3) kpoints = Kpoints.automatic_density(s, 500) self.assertEqual(kpoints.kpts, [[1, 1, 1]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
def test_static_constructors(self): kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) self.assertEqual(kpoints.kpts, [[3, 3, 3]]) kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) self.assertEqual(kpoints.kpts, [[2, 2, 2]]) kpoints = Kpoints.automatic(100) self.assertEqual(kpoints.style, Kpoints.supported_modes.Automatic) self.assertEqual(kpoints.kpts, [[100]]) filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) kpoints = Kpoints.automatic_density(poscar.structure, 500) self.assertEqual(kpoints.kpts, [[2, 4, 4]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Monkhorst) kpoints = Kpoints.automatic_density(poscar.structure, 500, True) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000) self.assertEqual(kpoints.kpts, [[6, 11, 13]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma) s = poscar.structure s.make_supercell(3) kpoints = Kpoints.automatic_density(s, 500) self.assertEqual(kpoints.kpts, [[1, 1, 1]]) self.assertEqual(kpoints.style, Kpoints.supported_modes.Gamma)
def set_kpoints(self, kpoint): """ set the kpoint """ if self.Grid_type == 'M': self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint) elif self.Grid_type == 'A': self.kpoints = Kpoints.automatic(subdivisions=kpoint) elif self.Grid_type == 'G': self.kpoints = Kpoints.gamma_automatic(kpts=kpoint) elif self.Grid_type == '3DD': self.kpoints = Kpoints.automatic_density_by_vol(structure= \ self.poscar.structure, kppvol=kpoint) elif self.Grid_type == 'band': self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, \ ibz=HighSymmKpath(self.poscar.structure))
def set_kpoints(self, kpoint): """ set the kpoint """ if self.Grid_type == 'M': self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint) elif self.Grid_type == 'A': self.kpoints = Kpoints.automatic(subdivisions=kpoint) elif self.Grid_type == 'G': self.kpoints = Kpoints.gamma_automatic(kpts=kpoint) elif self.Grid_type == '3DD': self.kpoints = Kpoints.automatic_density_by_vol(structure= \ self.poscar.structure, kppvol=kpoint) elif self.Grid_type == 'band': self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, \ ibz=HighSymmKpath( self.poscar.structure))
def auto_int(cls): """ Initialize automatic kpoint grid following the VASP automatic mode Example:: Automatic Mesh 0 Auto 40 """ # inform user that some set parameters will be ignored if cls.kpoint_params['shift'] is not None: warnings.warn("Automatic kpoint mode: Ignoring defined shift") if cls.kpoint_params['sympath'] is not None: warnings.warn("Automatic kpoint mode: Ignoring defined high " "symmetry path object") kpoints = cls.kpoint_params['kpoints'] return Kpoints.automatic(kpoints)
def set_kpoints(self, kpoint): """ set the kpoint """ if self.Grid_type == 'M': self.kpoints = Kpoints.monkhorst_automatic(kpts = kpoint) elif self.Grid_type == 'A': self.kpoints = Kpoints.automatic(subdivisions = kpoint) elif self.Grid_type == 'G': self.kpoints = Kpoints.gamma_automatic(kpts = kpoint) elif self.Grid_type == '3DD': self.kpoints = Kpoints.automatic_density_by_vol(structure=\ self.poscar.structure, kppvol=kpoint) elif self.Grid_type == 'band': self.kpoints = Kpoints.automatic_linemode(divisions=kpoint,\ ibz=HighSymmKpath(self.poscar.structure)) name = self.kpoint_to_name(kpoint, self.Grid_type) job_dir = self.job_dir +os.sep+ self.key_to_name('KPOINTS') \ + os.sep + name return job_dir
def set_kpoints(self, kpoint): """ set the kpoint """ if self.Grid_type == 'M': self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint) elif self.Grid_type == 'A': self.kpoints = Kpoints.automatic(subdivisions=kpoint) elif self.Grid_type == 'G': self.kpoints = Kpoints.gamma_automatic(kpts=kpoint) elif self.Grid_type == '3DD': self.kpoints = Kpoints.automatic_density_by_vol(structure= \ self.poscar.structure, kppvol=kpoint) elif self.Grid_type == 'band': self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, \ ibz=HighSymmKpath(self.poscar.structure)) name = self.kpoint_to_name(kpoint, self.Grid_type) job_dir = self.job_dir + os.sep + self.key_to_name('KPOINTS') \ + os.sep + name return job_dir
incar_dict = { 'SYSTEM': 'test', 'ENCUT': 500, 'ISIF': 2, 'IBRION': 2, 'ISMEAR': 1, 'EDIFF': 1e-06, 'NPAR': 8, 'SIGMA': 0.1, 'NSW' : 100, 'PREC': 'Accurate' } incar = Incar.from_dict(incar_dict) poscar = Poscar(iface) potcar = Potcar(poscar.site_symbols) kpoints = Kpoints.automatic(20) #set job list. if empty a single job will be run encut_list = [] #range(400,800,100) turn_knobs = OrderedDict( [ ('ENCUT', encut_list) ]) #job directory job_dir = 'vasp_job' # run settings qadapter = None job_cmd = None nprocs = 16 nnodes = 1 walltime = '24:00:00' mem = 1000
incar_dict = { 'SYSTEM': 'test', 'ENCUT': 500, 'ISIF': 2, 'IBRION': 2, 'ISMEAR': 1, 'EDIFF': 1e-06, 'NPAR': 8, 'SIGMA': 0.1, 'NSW': 100, 'PREC': 'Accurate' } incar = Incar.from_dict(incar_dict) poscar = Poscar(iface) potcar = Potcar(poscar.site_symbols) kpoints = Kpoints.automatic(20) #set job list. if empty a single job will be run encut_list = [] #range(400,800,100) turn_knobs = OrderedDict([('ENCUT', encut_list)]) #job directory job_dir = 'vasp_job' # run settings qadapter = None job_cmd = None nprocs = 16 nnodes = 1 walltime = '24:00:00' mem = 1000 incar['NPAR'] = int(sqrt(nprocs)) job_bin = '/home/km468/Software/VASP/vasp.5.3.5/vasp' qadapter, job_cmd = get_run_cmmnd(nnodes=nnodes,
def test_init_from_kpoint_object(): # get kpoints object pmg_kpoints = Kpoints.automatic(100) wrapper_kpoints = KpointWrapper(kpoints=pmg_kpoints) assert str(pmg_kpoints) == str(wrapper_kpoints)
def set_kpoints(self, kpoint=None, poscar=None, ibzkpth=None): """ set the kpoint """ # useful to check if a poscar is supplied from setup_poscar_jobs (most often the case) # or this is a single poscar use case if not poscar: poscar = self.poscar # splitting into two if elif branches means fewer if statements to check on # a run # Most general method of setting the k-points for # different grid types # NOTE: requires that at least one k-points value be passed # as a turn - knobs list value # this is not true for values that may be caculated out of # a database # use this part only if this is a non-database run for example # for k-points calibration if not self.database: if self.Grid_type == 'M': self.kpoints = Kpoints.monkhorst_automatic(kpts=kpoint) elif self.Grid_type == 'A': self.kpoints = Kpoints.automatic(subdivisions=kpoint) elif self.Grid_type == 'G': self.kpoints = Kpoints.gamma_automatic(kpts=kpoint) elif self.Grid_type == '3D_vol': self.kpoints = Kpoints.automatic_density_by_vol(structure=poscar.structure, kppvol=kpoint) elif self.Grid_type == 'bulk_bands_pbe': self.kpoints = Kpoints.automatic_linemode(divisions=kpoint, ibz=HighSymmKpath( poscar.structure)) elif self.Grid_type == 'D': self.kpoints = Kpoints.automatic_density(structure=poscar.structure,kppa=kpoint) elif self.Grid_type == 'Finer_G_Mesh': # kpoint is the scaling factor and self.kpoints is the old kpoint mesh self.logger.info('Setting Finer G Mesh for {0} by scale {1}'.format(kpoint, self.finer_kpoint)) self.kpoints = Kpoints.gamma_automatic(kpts = \ [i * self.finer_kpoint for i in kpoint]) self.logger.info('Finished scaling operation of k-mesh') # applicable for database runs # future constructs or settinsg can be activated via a yaml file # database yaml file or better still the input deck from its speification # decides what combination of input calibrate constructor settings to use # one of them being the grid_type tag elif self.database == 'twod': # set of kpoints settings according to the 2D database profile # the actual settings of k-points density # will in future come from any database input file set if self.Grid_type == 'hse_bands_2D_prep': kpoint_dict = Kpoints.automatic_gamma_density(poscar.structure, 200).as_dict() kpoint_dict['kpoints'][0][2] = 1 # remove z kpoints self.kpoints = Kpoints.from_dict(kpoint_dict) elif self.Grid_type == 'hse_bands_2D': # can at most return the path to the correct kpoints file # needs kpoints to be written out in instrument in a different way # not using the Kpoints object self.kpoints = get_2D_hse_kpoints(poscar.structure, ibzkpth) elif self.Grid_type == 'bands_2D': kpoint_dict = Kpoints.automatic_linemode(divisions=20, ibz=HighSymmKpath(poscar.structure)).as_dict() self.kpoints = Kpoints.from_dict(kpoint_dict) elif self.Grid_type == 'relax_2D': # general relaxation settings for 2D kpoint_dict = Kpoints.automatic_gamma_density(poscar.structure, 1000).as_dict() kpoint_dict['kpoints'][0][2] = 1 self.kpoints = Kpoints.from_dict(kpoint_dict) elif self.Grid_type == 'relax_3D': # general relaxation settings for 3D kpoint_dict = Kpoints.automatic_gamma_density( poscar.structure, 1000) self.kpoints = Kpoints.from_dict(kpoint_dict)