本文整理汇总了Python中pymatgen.io.vaspio.vasp_input.Incar.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Incar.keys方法的具体用法?Python Incar.keys怎么用?Python Incar.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.io.vaspio.vasp_input.Incar
的用法示例。
在下文中一共展示了Incar.keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_incar
# 需要导入模块: from pymatgen.io.vaspio.vasp_input import Incar [as 别名]
# 或者: from pymatgen.io.vaspio.vasp_input.Incar import keys [as 别名]
def get_incar(self, structure):
incar = Incar()
if self.sort_structure:
structure = structure.get_sorted_structure()
comp = structure.composition
elements = sorted([el for el in comp.elements if comp[el] > 0],
key=lambda e: e.X)
most_electroneg = elements[-1].symbol
poscar = Poscar(structure)
for key, setting in self.incar_settings.items():
if key == "MAGMOM":
mag = []
for site in structure:
if hasattr(site, 'magmom'):
mag.append(site.magmom)
elif hasattr(site.specie, 'spin'):
mag.append(site.specie.spin)
elif str(site.specie) in setting:
mag.append(setting.get(str(site.specie)))
else:
mag.append(setting.get(site.specie.symbol, 0.6))
incar[key] = mag
elif key in ('LDAUU', 'LDAUJ', 'LDAUL'):
if most_electroneg in setting.keys():
incar[key] = [setting[most_electroneg].get(sym, 0)
for sym in poscar.site_symbols]
else:
incar[key] = [0] * len(poscar.site_symbols)
elif key == "EDIFF":
if self.ediff_per_atom:
incar[key] = float(setting) * structure.num_sites
else:
incar[key] = float(setting)
else:
incar[key] = setting
has_u = ("LDAUU" in incar and sum(incar['LDAUU']) > 0)
if has_u:
# modify LMAXMIX if LSDA+U and you have d or f electrons
# note that if the user explicitly sets LMAXMIX in settings it will
# override this logic.
if 'LMAXMIX' not in self.incar_settings.keys():
# contains f-electrons
if any([el.Z > 56 for el in structure.composition]):
incar['LMAXMIX'] = 6
# contains d-electrons
elif any([el.Z > 20 for el in structure.composition]):
incar['LMAXMIX'] = 4
else:
for key in incar.keys():
if key.startswith('LDAU'):
del incar[key]
if self.set_nupdown:
nupdown = sum([mag if abs(mag) > 0.6 else 0
for mag in incar['MAGMOM']])
incar['NUPDOWN'] = nupdown
return incar