本文整理汇总了Python中ase.lattice.cubic.FaceCenteredCubic.get_potential_energies方法的典型用法代码示例。如果您正苦于以下问题:Python FaceCenteredCubic.get_potential_energies方法的具体用法?Python FaceCenteredCubic.get_potential_energies怎么用?Python FaceCenteredCubic.get_potential_energies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ase.lattice.cubic.FaceCenteredCubic
的用法示例。
在下文中一共展示了FaceCenteredCubic.get_potential_energies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FaceCenteredCubic
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_potential_energies [as 别名]
"""Check that energy is correct even after wrapping through periodic boundary conditions.
"""
from ase.lattice.cubic import FaceCenteredCubic
from asap3 import *
from asap3.testtools import *
import random
ref_atoms = FaceCenteredCubic(size=(7,7,7), symbol="Cu", pbc=(True, False, True))
ref_atoms.set_calculator(EMT())
ref_energy = ref_atoms.get_potential_energy()
ref_energies = ref_atoms.get_potential_energies()
ref_forces = ref_atoms.get_forces()
passes = 5
for ps in range(passes):
print "Pass", ps, "of", passes
atoms = ref_atoms.copy()
atoms.set_calculator(EMT())
nat = random.randint(0, len(atoms))
assert nat < len(atoms)
pos0 = atoms[nat].position
cell = atoms.get_cell()
for d in range(1,4):
for dx in (-d, 0, d):
#for dy in (-d, 0, d):
for dy in (0,):
for dz in (-d, 0 ,d):
deltar = dx * cell[0] + dy * cell[1] + dz * cell[2]
示例2: range
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_potential_energies [as 别名]
for ntest in range(nrun):
print
print "Running pass", ntest+1, "of", nrun
print
if pbcrnd:
pbc = tuple(random.randint(0,2,3))
print "Periodic boundaries:", pbc
if nrun > 1:
time.sleep(1)
atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]], size=(10,10,10),
symbol=element, pbc=pbc)
atoms = MonteCarloAtoms(atoms)
print "Number of atoms:", len(atoms)
atoms.set_calculator(MonteCarloEMT())
atoms.get_potential_energies() # Force creation of neighbor list.
atoms2 = atoms.copy()
atoms2.set_calculator(EMT())
print
print "Testing perturbations of single atoms"
pick1 = argsort(random.random((len(magnarr),)))
for magn in take(magnarr, pick1):
pick2 = argsort(random.random((len(numarr),)))
for number in take(numarr, pick2):
# Pick number random atoms.
if number < 0:
# Find N neighboring atoms and perturb them
number = -number
nblist = atoms.get_calculator().get_neighborlist()
示例3: len
# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_potential_energies [as 别名]
# symbol="Cu")
natoms = len(atoms_kim)
atoms_kim.set_pbc(pbc)
r = atoms_kim.get_positions()
r.flat[:] += 0.1 * np.sin(np.arange(3*natoms))
atoms_kim.set_positions(r)
atoms_emt = atoms_kim.copy()
kim = OpenKIMcalculator(openkimmodel, allowed=nbltype)
emt = EMT()
emt.set_subtractE0(False)
atoms_kim.set_calculator(kim)
atoms_emt.set_calculator(emt)
ek = atoms_kim.get_potential_energy()
ee = atoms_emt.get_potential_energy()
ReportTest(txt+"Total energy", ek, ee, 1e-8)
ek = atoms_kim.get_potential_energies()
ee = atoms_emt.get_potential_energies()
for i in range(0, natoms, step):
ReportTest(txt+"Energy of atom %i" % (i,), ek[i], ee[i], 1e-8)
fk = atoms_kim.get_forces()
fe = atoms_emt.get_forces()
n = 0
for i in range(0, natoms, step):
n = (n + 1) % 3
ReportTest(txt+"Force(%i) of atom %i" % (n, i), fk[i, n], fe[i, n], 1e-8)
sk = atoms_kim.get_stress()
se = atoms_emt.get_stress()
for i in range(6):
ReportTest(txt+"Stress(%i)" % (i,), sk[i], se[i], 1e-8)
sk = atoms_kim.get_stresses()
se = atoms_emt.get_stresses()