本文整理汇总了Python中pymatgen.io.vasp.inputs.Kpoints.automatic_density方法的典型用法代码示例。如果您正苦于以下问题:Python Kpoints.automatic_density方法的具体用法?Python Kpoints.automatic_density怎么用?Python Kpoints.automatic_density使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vasp.inputs.Kpoints
的用法示例。
在下文中一共展示了Kpoints.automatic_density方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_static_constructors
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
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])
示例2: test_static_constructors
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
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)
示例3: relax
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
def relax(dim=2, submit=True, force_overwrite=False):
"""
Writes input files and (optionally) submits a self-consistent
relaxation. Should be run before pretty much anything else, in
order to get the right energy and structure of the material.
Args:
dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
submit (bool): Whether or not to submit the job.
force_overwrite (bool): Whether or not to overwrite files
if an already converged vasprun.xml exists in the
directory.
"""
if force_overwrite or not utl.is_converged(os.getcwd()):
directory = os.getcwd().split('/')[-1]
# vdw_kernel.bindat file required for VDW calculations.
if VDW_KERNEL:
os.system('cp {} .'.format(VDW_KERNEL))
# KPOINTS
Kpoints.automatic_density(Structure.from_file('POSCAR'),
1000).write_file('KPOINTS')
# INCAR
INCAR_DICT.update(
{'MAGMOM': utl.get_magmom_string(Structure.from_file('POSCAR'))}
)
Incar.from_dict(INCAR_DICT).write_file('INCAR')
# POTCAR
utl.write_potcar()
# Special tasks only performed for 2D materials.
if dim == 2:
# Ensure 20A interlayer vacuum
utl.ensure_vacuum(Structure.from_file('POSCAR'), 20)
# Remove all z k-points.
kpts_lines = open('KPOINTS').readlines()
with open('KPOINTS', 'w') as kpts:
for line in kpts_lines[:3]:
kpts.write(line)
kpts.write(kpts_lines[3].split()[0] + ' '
+ kpts_lines[3].split()[1] + ' 1')
# Submission script
if dim == 2:
binary = VASP_TWOD_BIN
elif dim == 3:
binary = VASP_STD_BIN
if QUEUE_SYSTEM == 'pbs':
utl.write_pbs_runjob(directory, 1, 16, '800mb', '6:00:00', binary)
submission_command = 'qsub runjob'
elif QUEUE_SYSTEM == 'slurm':
utl.write_slurm_runjob(directory, 16, '800mb', '6:00:00', binary)
submission_command = 'sbatch runjob'
if submit:
os.system(submission_command)
示例4: run_hse_prep_calculation
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
def run_hse_prep_calculation(dim=2, submit=True):
"""
Submits a quick static calculation to calculate the IBZKPT
file using a smaller number of k-points (200/atom instead of
1000/atom). The other outputs from this calculation are
essentially useless.
Args:
dim (int): 2 for relaxing a 2D material, 3 for a 3D material.
submit (bool): Whether or not to submit the job.
"""
if not os.path.isdir('hse_prep'):
os.mkdir('hse_prep')
os.chdir('hse_prep')
os.system('cp ../CONTCAR ./POSCAR')
if os.path.isfile('../POTCAR'):
os.system('cp POTCAR .')
relax(dim=2, submit=False)
incar_dict = Incar.from_file('INCAR').as_dict()
incar_dict.update({'NSW': 0, 'NELM': 1, 'LWAVE': False, 'LCHARG': False,
'LAECHG': False})
Incar.from_dict(incar_dict).write_file('INCAR')
Kpoints.automatic_density(
Structure.from_file('POSCAR'), 200
).write_file('KPOINTS')
if dim == 2:
kpts_lines = open('KPOINTS').readlines()
with open('KPOINTS', 'w') as kpts:
for line in kpts_lines[:3]:
kpts.write(line)
kpts.write(kpts_lines[3].split()[0] + ' '
+ kpts_lines[3].split()[1] + ' 1')
if QUEUE == 'pbs':
write_pbs_runjob('{}_prep'.format(
os.getcwd().split('/')[-2]), 1, 16, '800mb', '6:00:00', VASP)
submission_command = 'qsub runjob'
elif QUEUE == 'slurm':
write_slurm_runjob('{}_prep'.format(
os.getcwd().split('/')[-2]), 16, '800mb', '6:00:00', VASP)
submission_command = 'sbatch runjob'
if submit:
os.system(submission_command)
os.chdir('../')
示例5: test_automatic_kpoint
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
def test_automatic_kpoint(self):
# s = PymatgenTest.get_structure("Li2O")
p = Poscar.from_string("""Al1
1.0
2.473329 0.000000 1.427977
0.824443 2.331877 1.427977
0.000000 0.000000 2.855955
Al
1
direct
0.000000 0.000000 0.000000 Al""")
kpoints = Kpoints.automatic_density(p.structure, 1000)
self.assertArrayAlmostEqual(kpoints.kpts[0], [10, 10, 10])
示例6: update_spec_force_convergence
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
def update_spec_force_convergence(spec, user_vasp_settings=None):
fw_spec = spec
update_set = {"ENCUT": 700, "EDIFF": 0.000001, "ALGO":"N", "NPAR":2}
if user_vasp_settings and user_vasp_settings.get("incar"):
update_set.update(user_vasp_settings["incar"])
fw_spec['vasp']['incar'].update(update_set)
old_struct=Poscar.from_dict(fw_spec["vasp"]["poscar"]).structure
if user_vasp_settings and user_vasp_settings.get("kpoints"):
kpoints_density = user_vasp_settings["kpoints"]["kpoints_density"]
else:
kpoints_density = 7000
k=Kpoints.automatic_density(old_struct, kpoints_density)
fw_spec['vasp']['kpoints'] = k.as_dict()
return fw_spec
示例7: set_kpoints
# 需要导入模块: from pymatgen.io.vasp.inputs import Kpoints [as 别名]
# 或者: from pymatgen.io.vasp.inputs.Kpoints import automatic_density [as 别名]
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)