本文整理汇总了Python中pymatgen.io.vaspio.vasp_input.Kpoints.automatic_density方法的典型用法代码示例。如果您正苦于以下问题:Python Kpoints.automatic_density方法的具体用法?Python Kpoints.automatic_density怎么用?Python Kpoints.automatic_density使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vaspio.vasp_input.Kpoints
的用法示例。
在下文中一共展示了Kpoints.automatic_density方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_static_constructors
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
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.structure, 500)
self.assertEqual(kpoints.kpts, [[2, 4, 4]])
self.assertEqual(kpoints.style, "Monkhorst")
kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
self.assertEqual(kpoints.style, "Gamma")
kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
self.assertEqual(kpoints.kpts, [[6, 11, 13]])
self.assertEqual(kpoints.style, "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, "Gamma")
示例2: get_kpoints
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
def get_kpoints(self, structure):
"""
Get a KPOINTS file for NonSCF calculation. In "Line" mode, kpoints are
generated along high symmetry lines. In "Uniform" mode, kpoints are
Gamma-centered mesh grid. Kpoints are written explicitly in both cases.
Args:
structure (Structure/IStructure): structure to get Kpoints
"""
if self.mode == "Line":
kpath = HighSymmKpath(structure)
cart_k_points, k_points_labels = kpath.get_kpoints()
frac_k_points = [kpath._prim_rec.get_fractional_coords(k)
for k in cart_k_points]
return Kpoints(comment="Non SCF run along symmetry lines",
style="Reciprocal", num_kpts=len(frac_k_points),
kpts=frac_k_points, labels=k_points_labels,
kpts_weights=[1] * len(cart_k_points))
else:
num_kpoints = self.kpoints_settings["kpoints_density"] * \
structure.lattice.reciprocal_lattice.volume
kpoints = Kpoints.automatic_density(
structure, num_kpoints * structure.num_sites)
mesh = kpoints.kpts[0]
ir_kpts = SymmetryFinder(structure, symprec=self.sym_prec) \
.get_ir_reciprocal_mesh(mesh)
kpts = []
weights = []
for k in ir_kpts:
kpts.append(k[0])
weights.append(int(k[1]))
return Kpoints(comment="Non SCF run on uniform grid",
style="Reciprocal", num_kpts=len(ir_kpts),
kpts=kpts, kpts_weights=weights)
示例3: get_kpoints
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
def get_kpoints(self, structure):
"""
Writes out a KPOINTS file using the fully automated grid method. Uses
Gamma centered meshes for hexagonal cells and Monk grids otherwise.
Algorithm:
Uses a simple approach scaling the number of divisions along each
reciprocal lattice vector proportional to its length.
"""
dens = int(self.kpoints_settings['grid_density'])
return Kpoints.automatic_density(structure, dens)
示例4: test_static_constructors
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
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.structure, 500)
self.assertEqual(kpoints.kpts, [[2, 3, 4]])
示例5: vac_antisite_def_struct_gen
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
def vac_antisite_def_struct_gen(mpid, mapi_key, cellmax):
if not mpid:
print ("============\nERROR: Provide an mpid\n============")
return
if not mapi_key:
with MPRester() as mp:
struct = mp.get_structure_by_material_id(mpid)
else:
with MPRester(mapi_key) as mp:
struct = mp.get_structure_by_material_id(mpid)
prim_struct_sites = len(struct.sites)
struct = SpacegroupAnalyzer(struct).get_conventional_standard_structure()
conv_struct_sites = len(struct.sites)
conv_prim_rat = int(conv_struct_sites/prim_struct_sites)
sc_scale = get_sc_scale(struct,cellmax)
mpvis = MPGGAVaspInputSet()
# Begin defaults: All default settings.
blk_vasp_incar_param = {'IBRION':-1,'EDIFF':1e-4,'EDIFFG':0.001,'NSW':0,}
def_vasp_incar_param = {'ISIF':2,'NELM':99,'IBRION':2,'EDIFF':1e-6,
'EDIFFG':0.001,'NSW':40,}
kpoint_den = 6000
# End defaults
ptcr_flag = True
try:
potcar = mpvis.get_potcar(struct)
except:
print ("VASP POTCAR folder not detected.\n" \
"Only INCAR, POSCAR, KPOINTS are generated.\n" \
"If you have VASP installed on this system, \n" \
"refer to pymatgen documentation for configuring the settings.")
ptcr_flag = False
vac = Vacancy(struct, {}, {})
scs = vac.make_supercells_with_defects(sc_scale)
site_no = scs[0].num_sites
if site_no > cellmax:
max_sc_dim = max(sc_scale)
i = sc_scale.index(max_sc_dim)
sc_scale[i] -= 1
scs = vac.make_supercells_with_defects(sc_scale)
for i in range(len(scs)):
sc = scs[i]
poscar = mpvis.get_poscar(sc)
kpoints = Kpoints.automatic_density(sc,kpoint_den)
incar = mpvis.get_incar(sc)
if ptcr_flag:
potcar = mpvis.get_potcar(sc)
interdir = mpid
if not i:
fin_dir = os.path.join(interdir,'bulk')
try:
os.makedirs(fin_dir)
except:
pass
incar.update(blk_vasp_incar_param)
incar.write_file(os.path.join(fin_dir,'INCAR'))
poscar.write_file(os.path.join(fin_dir,'POSCAR'))
if ptcr_flag:
potcar.write_file(os.path.join(fin_dir,'POTCAR'))
kpoints.write_file(os.path.join(fin_dir,'KPOINTS'))
else:
blk_str_sites = set(scs[0].sites)
vac_str_sites = set(sc.sites)
vac_sites = blk_str_sites - vac_str_sites
vac_site = list(vac_sites)[0]
site_mult = int(vac.get_defectsite_multiplicity(i-1)/conv_prim_rat)
vac_site_specie = vac_site.specie
vac_symbol = vac_site.specie.symbol
vac_dir ='vacancy_{}_mult-{}_sitespecie-{}'.format(str(i),
site_mult, vac_symbol)
fin_dir = os.path.join(interdir,vac_dir)
try:
os.makedirs(fin_dir)
except:
pass
incar.update(def_vasp_incar_param)
poscar.write_file(os.path.join(fin_dir,'POSCAR'))
incar.write_file(os.path.join(fin_dir,'INCAR'))
if ptcr_flag:
potcar.write_file(os.path.join(fin_dir,'POTCAR'))
kpoints.write_file(os.path.join(fin_dir,'KPOINTS'))
# Antisite generation at all vacancy sites
struct_species = scs[0].types_of_specie
for specie in set(struct_species)-set([vac_site_specie]):
subspecie_symbol = specie.symbol
anti_struct = sc.copy()
anti_struct.append(specie, vac_site.frac_coords)
poscar = mpvis.get_poscar(anti_struct)
incar = mpvis.get_incar(anti_struct)
incar.update(def_vasp_incar_param)
#.........这里部分代码省略.........
示例6: get_VASP_inputs
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
def get_VASP_inputs(structure, workdir, job_name, nproc=64, kppa=500, extra_incar_dict = None):
if os.path.exists(workdir):
print 'WORKDIR ALREADY EXISTS. DELETE TO LAUNCH NEW JOB'
return -1
poscar = Poscar(structure)
list_potcar_singles, potcar= get_POTCAR(poscar)
kpoints = Kpoints.automatic_density(structure, kppa=kppa)
# Default values
incar_dict = dict( SYSTEM = structure.formula, # Name of job
LREAL = 'Auto', # Should projections be done in real space? Let VASP decide
ENCUT = 520., # 520. eV, just like Ceder
IBRION = 2, # Controls ionic relataxion: 1-> DISS, 2 -> CG, 3-> MD
EDIFF = 1E-7, # criterion to stop SCF loop, in eV
EDIFFG = -1E-3, # criterion to stop ionic relaxations. Negative means FORCES < |EDIFFG|
PREC = 'HIGH', # level of precision
AMIX = 0.2,
AMIX_MAG= 0.8,
BMIX = 0.001,
BMIX_MAG= 0.001,
NSW = 150, # Maximum number of ionic steps
ISMEAR = 0, # smearing scheme. Use 0 for insulators, as suggested by VASPWIKI
ISPIN = 2, # spin polarized
NPAR = 8, # VASPWIKI recommends sqrt(ncore)
LSCALU = False, # Don't use scalapack. Probably a can of worms.
ALGO = 'NORMAL', # what ionic relaxation scheme to use?
LORBIT = 11, # 11 prints out the DOS
ISIF = 3, # Controls the computation of stress tensor. 3 computes everything
NSIM = 4, # how many bands to treat in parallel? Default is 4, probably fine.
SIGMA = 0.025, # smearing in eV
LMAXMIX = 4, # Description: LMAXMIX controls up to which l-quantum number the one-center PAW charge densities are passed through the charge density mixer. MaterialsProject uses 4.
LCHARG = False, # Write charge densities?
LWAVE = False, # write out the wavefunctions?
LPLANE = True, # Plane distribution of FFT coefficients. Reduces communications in FFT.
NELM = 100, # maximum number of SCF cycles.
NELMDL = -10, # since initial orbitals may be random, fixes hamiltonian for |NELM| SCF cycles to give wf a chance to simmer down.
ISTART = 0, # begin from scratch!
ISYM = 2) # use symmetry
if extra_incar_dict != None:
incar_dict.update( extra_incar_dict )
incar = Incar.from_dict(incar_dict )
incar.write_file(workdir+'INCAR')
poscar.write_file(workdir+'POSCAR', vasp4_compatible = True)
kpoints.write_file(workdir+'KPOINTS')
potcar.write_file(workdir+'POTCAR')
potcar.sort()
hack_potcar_file(workdir,list_potcar_singles)
with open(workdir+'job.sh','w') as f:
f.write(submit_template.format(job_name,nproc))
with open(workdir+'clean.sh','w') as f:
f.write(clean_template)
return 0
示例7: substitute_def_struct_gen
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Kpoints [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Kpoints import automatic_density [as 别名]
def substitute_def_struct_gen(mpid, solute, mapi_key, cellmax):
print (mpid, solute, mapi_key, cellmax)
if not mpid:
print ("============\nERROR: Provide an mpid\n============")
return
if not solute:
print ("============\nERROR: Provide solute atom\n============")
return
if not mapi_key:
with MPRester() as mp:
struct = mp.get_structure_by_material_id(mpid)
else:
with MPRester(mapi_key) as mp:
struct = mp.get_structure_by_material_id(mpid)
print (struct.formula)
mpvis = MPGGAVaspInputSet()
# Begin defaults: All default settings.
blk_vasp_incar_param = {'IBRION':-1,'EDIFF':1e-4,'EDIFFG':0.001,'NSW':0,}
def_vasp_incar_param = {'ISIF':2,'NELM':99,'IBRION':2,'EDIFF':1e-6,
'EDIFFG':0.001,'NSW':40,}
kpoint_den = 6000
# End defaults
# Check if POTCAR file can be geneated
ptcr_flag = True
try:
potcar = mpvis.get_potcar(struct)
except:
print ("VASP POTCAR folder not detected.\n" \
"Only INCAR, POSCAR, KPOINTS are generated.\n" \
"If you have VASP installed on this system, \n" \
"refer to pymatgen documentation for configuring the settings.")
ptcr_flag = False
print (ptcr_flag)
vac = Vacancy(struct, {}, {})
sc_scale = get_sc_scale(struct,cellmax)
scs = vac.make_supercells_with_defects(sc_scale)
site_no = scs[0].num_sites
if site_no > cellmax:
max_sc_dim = max(sc_scale)
i = sc_scale.index(max_sc_dim)
sc_scale[i] -= 1
scs = vac.make_supercells_with_defects(sc_scale)
print len(scs)
interdir = mpid
blk_str_sites = set(scs[0].sites)
for i in range(1,len(scs)):
sc = scs[i]
vac_str_sites = set(sc.sites)
vac_sites = blk_str_sites - vac_str_sites
vac_site = list(vac_sites)[0]
site_mult = vac.get_defectsite_multiplicity(i-1)
vac_site_specie = vac_site.specie
vac_specie = vac_site.specie.symbol
# Solute substitution defect generation at all vacancy sites
struct_species = scs[0].types_of_specie
solute_struct = sc.copy()
solute_struct.append(solute, vac_site.frac_coords)
incar = mpvis.get_incar(solute_struct)
incar.update(def_vasp_incar_param)
poscar = mpvis.get_poscar(solute_struct)
kpoints = Kpoints.automatic_density(solute_struct,kpoint_den)
if ptcr_flag:
potcar = mpvis.get_potcar(solute_struct)
sub_def_dir ='solute_{}_mult-{}_sitespecie-{}_subspecie-{}'.format(
str(i), site_mult, vac_specie, solute)
fin_dir = os.path.join(interdir,sub_def_dir)
try:
os.makedirs(fin_dir)
except:
pass
poscar.write_file(os.path.join(fin_dir,'POSCAR'))
incar.write_file(os.path.join(fin_dir,'INCAR'))
kpoints.write_file(os.path.join(fin_dir,'KPOINTS'))
if ptcr_flag:
potcar.write_file(os.path.join(fin_dir,'POTCAR'))