当前位置: 首页>>代码示例>>Python>>正文


Python Vasp.magmom方法代码示例

本文整理汇总了Python中pylada.vasp.Vasp.magmom方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.magmom方法的具体用法?Python Vasp.magmom怎么用?Python Vasp.magmom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylada.vasp.Vasp的用法示例。


在下文中一共展示了Vasp.magmom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_magmom

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import magmom [as 别名]
def test_magmom():
  from pickle import loads, dumps
  from pylada.crystal.cppwrappers import Structure
  from pylada.vasp import Vasp

  u = 0.25
  x, y = u, 0.25-u
  structure = Structure([[0,0.5,0.5],[0.5,0,0.5],[0.5,0.5,0]]) \
                       .add_atom(5.000000e-01, 5.000000e-01, 5.000000e-01, "Mg") \
                       .add_atom(5.000000e-01, 2.500000e-01, 2.500000e-01, "Mg") \
                       .add_atom(2.500000e-01, 5.000000e-01, 2.500000e-01, "Mg") \
                       .add_atom(2.500000e-01, 2.500000e-01, 5.000000e-01, "Mg") \
                       .add_atom(8.750000e-01, 8.750000e-01, 8.750000e-01, "Al") \
                       .add_atom(1.250000e-01, 1.250000e-01, 1.250000e-01, "Al") \
                       .add_atom(     x,     x,     x, "O") \
                       .add_atom(     x,     y,     y, "O") \
                       .add_atom(     y,     x,     y, "O") \
                       .add_atom(     y,     y,     x, "O") \
                       .add_atom(    -x,    -x,    -x, "O") \
                       .add_atom(    -x,    -y,    -y, "O") \
                       .add_atom(    -y,    -x,    -y, "O") \
                       .add_atom(    -y,    -y,    -x, "O") 
  
  for atom in structure:
    if atom.type == 'Mg': atom.magmom = -1e0

  vasp = Vasp()
  vasp.magmom = None
  assert vasp.magmom is None
  assert vasp._input['magmom'].keyword == 'MAGMOM'
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure) is None

  # ispin == 1
  vasp.magmom = True
  vasp.ispin = 1
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure) is None
  # ispins == 2, magmom == False
  vasp.ispin = 2
  vasp.magmom = None
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure) is None
  vasp.magmom = False
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure) is None
  # now for real print
  vasp.magmom = True
  assert 'MAGMOM' in vasp._input['magmom'].output_map(vasp=vasp, structure=structure)
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure)['MAGMOM'] == '4*-1.00 2*0.00 8*0.00'
  # now print a string directly.
  vasp.magmom = 'hello'
  assert vasp.magmom == 'hello'
  assert 'MAGMOM' in vasp._input['magmom'].output_map(vasp=vasp, structure=structure)
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure)['MAGMOM'] == 'hello'

  # check repr
  assert repr(vasp._input['magmom']) == "Magmom(value='hello')"
  # check pickling
  assert repr(loads(dumps(vasp._input['magmom']))) == "Magmom(value='hello')"

  # more tests.
  for atom, mag in zip(structure, [1, -1, 1, 1]):
    if atom.type == 'Mg': atom.magmom = mag
  for atom, mag in zip(structure, [0.5, 0.5]):
    if atom.type == 'Al': atom.magmom = mag

  vasp.magmom = True
  assert 'MAGMOM' in vasp._input['magmom'].output_map(vasp=vasp, structure=structure)
  assert vasp._input['magmom'].output_map(vasp=vasp, structure=structure)['MAGMOM'] == '1.00 -1.00 2*1.00 2*0.00 8*0.00'
开发者ID:mdavezac,项目名称:LaDa,代码行数:68,代码来源:magmom.py


注:本文中的pylada.vasp.Vasp.magmom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。