本文整理汇总了Python中pylada.vasp.Vasp.ediffg方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.ediffg方法的具体用法?Python Vasp.ediffg怎么用?Python Vasp.ediffg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylada.vasp.Vasp
的用法示例。
在下文中一共展示了Vasp.ediffg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ediffg
# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import ediffg [as 别名]
def test_ediffg():
from pickle import loads, dumps
from pylada.vasp import Vasp
from pylada.crystal import Structure
a = 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")
N = float(len(structure))
o = a._input['ediffg']
d = {'Ediffg': o.__class__}
assert a.ediffg is None
assert a.ediffg_per_atom is None
assert o.output_map() is None
assert eval(repr(o), d).output_map() is None
assert eval(repr(o), d).keyword == 'ediffg'
assert loads(dumps(o)).output_map() is None
a.ediffg_per_atom = 1e-5
a.ediffg = 2e-4
assert abs(a.ediffg - 2e-4) < 1e-8
assert a.ediffg_per_atom is None
assert abs(float(o.output_map(structure=structure)['ediffg']) - a.ediffg) < a.ediffg * 1e-2
assert abs(float(eval(repr(o), d).output_map(structure=structure)['ediffg']) - a.ediffg) < a.ediffg * 1e-2
assert abs(float(loads(dumps(o)).output_map(structure=structure)['ediffg']) - a.ediffg) < a.ediffg * 1e-2
a.ediffg_per_atom = 1e-5
a.ediffg = -2e-4
assert abs(a.ediffg + 2e-4) < 1e-8
assert a.ediffg_per_atom is None
assert abs(float(o.output_map(structure=structure)['ediffg']) - a.ediffg) < -a.ediffg * 1e-2
assert abs(float(eval(repr(o), d).output_map(structure=structure)['ediffg']) - a.ediffg) < -a.ediffg * 1e-2
assert abs(float(loads(dumps(o)).output_map(structure=structure)['ediffg']) - a.ediffg) < -a.ediffg * 1e-2
a.ediffg = 2e-4
a.ediffg_per_atom = 2e-4
o = a._input['ediffg_per_atom']
d = {'EdiffgPerAtom': o.__class__}
assert a.ediffg is None
assert abs(a.ediffg_per_atom - 2e-4) < 1e-8
assert abs(float(o.output_map(structure=structure)['ediffg']) - 2e-4*N) < 2e-4 * 1e-2
assert abs(float(eval(repr(o), d).output_map(structure=structure)['ediffg']) - 2e-4*N) < 2e-4 * 1e-2
assert abs(float(loads(dumps(o)).output_map(structure=structure)['ediffg']) - 2e-4*N) < 2e-4 * 1e-2
a.ediffg = 2e-4
a.ediffg_per_atom = -2e-4
assert a.ediffg is None
assert abs(a.ediffg_per_atom + 2e-4) < 1e-8
assert abs(float(o.output_map(structure=structure)['ediffg']) + 2e-4) < 2e-4 * 1e-2
assert abs(float(eval(repr(o), d).output_map(structure=structure)['ediffg']) + 2e-4) < 2e-4 * 1e-2
assert abs(float(loads(dumps(o)).output_map(structure=structure)['ediffg']) + 2e-4) < 2e-4 * 1e-2
a.ediffg_per_atom = None
assert a.ediffg is None
assert a.ediffg_per_atom is None
assert o.output_map() is None
assert eval(repr(o), d).output_map() is None
assert eval(repr(o), d).keyword == 'ediffg'
assert loads(dumps(o)).output_map() is None
a.ediffg = 1e-4
a.ediffg_per_atom = None
assert abs(a.ediffg-1e-4) < 1e-8
assert a.ediffg_per_atom is None
a.ediffg_per_atom = 1e-4
a.ediffg = None
assert abs(a.ediffg_per_atom-1e-4) < 1e-8
assert a.ediffg is None