def make_hex_lattice_input(path, atomic_sep, kpointdivs, comment, forbid_symmetry=True): pb = hexagonal_unitcell('C', atomic_sep, layersep=25.) incar = Incar() incar['SYSTEM'] = comment incar['ALGO'] = 'Fast' incar['NSW'] = 1000 incar['IBRION'] = 2 incar['EDIFF'] = 1E-8 if forbid_symmetry: incar['ISYM'] = 0 kpoints = Kpoints.gamma_automatic(kpointdivs, [0, 0, 0]) metadata = {'atomic_sep': atomic_sep, 'kpointdivs': kpointdivs} ws = VaspInput( poscar=pb.poscar(comment=comment), potcar=pb.potcar(functional='PBE'), incar=incar, kpoints=kpoints, # additional files metadata=json.dumps(metadata), ) ws.write_input(path)
def make_hex_lattice_input(path, atomic_sep, kpointdivs, comment, forbid_symmetry=True): pb = hexagonal_unitcell('C', atomic_sep, layersep=25.) incar = Incar() incar['SYSTEM'] = comment incar['ALGO'] = 'Fast' incar['NSW'] = 1000 incar['IBRION'] = 2 incar['EDIFF'] = 1E-8 if forbid_symmetry: incar['ISYM'] = 0 kpoints = Kpoints.gamma_automatic(kpointdivs, [0,0,0]) metadata = {'atomic_sep': atomic_sep, 'kpointdivs': kpointdivs} ws = VaspInput( poscar = pb.poscar(comment=comment), potcar = pb.potcar(functional='PBE'), incar = incar, kpoints = kpoints, # additional files metadata = json.dumps(metadata), ) ws.write_input(path)
def make_vasp_input(path, *, kpointdivs, comment, forbid_symmetry, functional, perturb_dist, **kwargs): assert hasattr(kpointdivs, '__iter__') assert isinstance(comment, str) assert isinstance(forbid_symmetry, bool) assert isinstance(perturb_dist, float) pb = carbon_chain_poxcar(**kwargs) incar = Incar() incar['SYSTEM'] = comment incar['ALGO'] = 'Fast' incar['NSW'] = 1000 incar['NPAR'] = 4 incar['IBRION'] = 2 incar['EDIFF'] = 1E-8 incar['EDIFFG'] = -0.001 if forbid_symmetry: incar['ISYM'] = 0 kpoints = Kpoints.gamma_automatic(kpointdivs, [0,0,0]) metadata = { 'kpointdivs':kpointdivs, 'functional':functional, 'perturb_dist':perturb_dist, 'forbid_symmetry':forbid_symmetry, } # FIXME FIXME FIXME # Here, we insert all structure parameters into the metadata. The purpose is because # oftentimes those parameters are the ones we're most interested in (such as scale). # # However, this is all kinds of bad: # * Not all structure arguments are necessarily desirable to have in the metadata. # * What if we want a structure argument to be of a non JSON-encodable type? # * It creates a dependency between names of function arguments in code, and the output file. # In other words, madness. metadata = dict_union(metadata, kwargs) ws = VaspInput( poscar = pb.poscar( perturb_dist=perturb_dist, comment=comment, ), potcar = pb.potcar( functional=functional, ), incar = incar, kpoints = kpoints, # additional files metadata = json.dumps(metadata), ) ws.write_input(path)
def make_vasp_input(path, *, kpointdivs, comment, forbid_symmetry, functional, perturb_dist, **kwargs): assert hasattr(kpointdivs, '__iter__') assert isinstance(comment, str) assert isinstance(forbid_symmetry, bool) assert isinstance(perturb_dist, float) pb = carbon_chain_poxcar(**kwargs) incar = Incar() incar['SYSTEM'] = comment incar['ALGO'] = 'Fast' incar['NSW'] = 1000 incar['NPAR'] = 4 incar['IBRION'] = 2 incar['EDIFF'] = 1E-8 incar['EDIFFG'] = -0.001 if forbid_symmetry: incar['ISYM'] = 0 kpoints = Kpoints.gamma_automatic(kpointdivs, [0, 0, 0]) metadata = { 'kpointdivs': kpointdivs, 'functional': functional, 'perturb_dist': perturb_dist, 'forbid_symmetry': forbid_symmetry, } # FIXME FIXME FIXME # Here, we insert all structure parameters into the metadata. The purpose is because # oftentimes those parameters are the ones we're most interested in (such as scale). # # However, this is all kinds of bad: # * Not all structure arguments are necessarily desirable to have in the metadata. # * What if we want a structure argument to be of a non JSON-encodable type? # * It creates a dependency between names of function arguments in code, and the output file. # In other words, madness. metadata = dict_union(metadata, kwargs) ws = VaspInput( poscar=pb.poscar( perturb_dist=perturb_dist, comment=comment, ), potcar=pb.potcar(functional=functional, ), incar=incar, kpoints=kpoints, # additional files metadata=json.dumps(metadata), ) ws.write_input(path)
def test_static_constructors(self): kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0]) self.assertEqual(kpoints.style, "Gamma") self.assertEqual(kpoints.kpts, [[3, 3, 3]]) kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0]) self.assertEqual(kpoints.style, "Monkhorst") self.assertEqual(kpoints.kpts, [[2, 2, 2]]) kpoints = Kpoints.automatic(100) self.assertEqual(kpoints.style, "Automatic") self.assertEqual(kpoints.kpts, [[100]]) filepath = os.path.join(test_dir, 'POSCAR') poscar = Poscar.from_file(filepath) kpoints = Kpoints.automatic_density(poscar.struct, 500) self.assertEqual(kpoints.kpts, [[2, 4, 4]])
def _vasp_kpoints_setup(self): """Parse mast_kpoints string, which should take the format: number, number, number designation examples: "3x3x3 M", "1x1x1 G". If no designation is given, Monkhorst-Pack is assumed. """ name = self.keywords['name'] tryname = os.path.join(name, "KPOINTS") if os.path.isfile(tryname): #KPOINTS already exists. Do not overwrite. my_kpoints = Kpoints.from_file(tryname) return my_kpoints if not (self.metafile.read_data('kpoints')==None): kpoints = self.metafile.read_data('kpoints').split() kmesh = (int(kpoints[0].split('x')[0]),int(kpoints[0].split('x')[1]),int(kpoints[0].split('x')[2])) try: desig = kpoints[1].upper() except IndexError: desig = 'M' try: kshift = (float(kpoints[2]),float(kpoints[3]),float(kpoints[4])) except IndexError: kshift = (0.0,0.0,0.0) else: if 'mast_kpoints' in self.keywords['program_keys'].keys(): kpoints = self.keywords['program_keys']['mast_kpoints'] else: raise MASTError(self.__class__.__name__,"k-point instructions need to be set either in ingredients keyword mast_kpoints or scaling section in structure ingredient: No k-point settings for the ingredient %s"% name) if len(kpoints) == 3: desig = "M" elif 'line' in str(kpoints[1]): desig = 'L' else: desig = kpoints[3].upper() if not desig == 'L': kmesh = (int(kpoints[0]),int(kpoints[1]),int(kpoints[2])) kshift = (0,0,0) if desig == "M": my_kpoints = Kpoints.monkhorst_automatic(kpts=kmesh,shift=kshift) elif desig == "G": my_kpoints = Kpoints.gamma_automatic(kpts=kmesh,shift=kshift) elif desig == 'L': my_kpoints='Line Mode\n'+'\n'.join(' '.join(kpoints).split(','))+'\n' fp=open(name+'/KPOINTS','w') fp.write(my_kpoints) else: raise MASTError(self.__class__.__name__,"kpoint designation " + desig + " not recognized.") dirutil.lock_directory(name) if not desig=='L': my_kpoints.write_file(name + "/KPOINTS") dirutil.unlock_directory(name) return my_kpoints