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


Python FaceCenteredCubic.get_forces方法代码示例

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


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

示例1: len

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_forces [as 别名]
from asap3 import *
from asap3.Timing import report_timing
from ase.lattice.cubic import FaceCenteredCubic
import time

nsteps = 10

start = time.time()
if len(sys.argv) >= 2 and sys.argv[1] == '-t':
    AsapThreads()   
if len(sys.argv) >= 2 and sys.argv[1] == '-T':
    AsapThreads(6)   

atoms = FaceCenteredCubic(size=(100,100,50), symbol='Cu')
atoms.set_calculator(EMT())
print "Number of atoms:", len(atoms)

d = 0.1
pos = atoms.arrays['positions']  # Nasty!

for i in range(nsteps):
    pos[50][0] += d
    d = -d
    f = atoms.get_forces()
    
report_timing()

print "Wall time elapsed:", time.time() - start


开发者ID:auag92,项目名称:n2dm,代码行数:30,代码来源:ThreadForceTiming.py

示例2: range

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_forces [as 别名]
            for j in range(3):
                if i != j and np.abs(uc[i,j]) > 1e-15:
                    diagonal = False  
        if not (self.allow_mi_opbc and atoms.get_pbc().all() and diagonal):
            # Minimum Image Orthogonal Periodic Boundary Conditions
            # are not allowed
            remove.extend(["MI_OPBC_H", "MI_OPBC_F"])
        if  atoms.get_pbc().any():
            # Cluster method is not allowed
            remove.append("CLUSTER")
        for rem in remove:
            if rem in allowed:
                allowed.remove(rem)
        if self.verbose:
            print "Allowed PBC:", allowed
        return allowed
    
if __name__ == '__main__':
    from ase.lattice.cubic import FaceCenteredCubic
    atoms = FaceCenteredCubic(size=(10,10,10), symbol='Cu')
    print "Creating calculator"
    pot = OpenKIMcalculator('EMT_Asap_Standard_AlAgAuCuNiPdPt__MO_118428466217_000')
    print "Setting atoms"
    atoms.set_calculator(pot)
    print "Calculating energy"
    print atoms.get_potential_energy()
    print atoms.get_forces()[10:]
    print atoms.get_stress()
    
    
    
开发者ID:auag92,项目名称:n2dm,代码行数:30,代码来源:OpenKIMcalculator.py

示例3: FaceCenteredCubic

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_forces [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]
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:PBCwrap.py

示例4: FaceCenteredCubic

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_forces [as 别名]
from asap3 import *
from ase.lattice.cubic import FaceCenteredCubic
from asap3.testtools import ReportTest

atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,0],[0,0,1]],
                          size=(6,6,6), symbol="Cu")
atoms.set_calculator(EMT())
f1 = atoms.get_forces()
atoms.set_calculator(EMT())
f2 = atoms.get_forces()
maxdev = abs(f2 - f1).max()
print maxdev
ReportTest("Max error 1:", maxdev, 0.0, 1e-6)

atoms2 = Atoms(atoms)
if atoms2.get_calculator() is None:
    # Slightly old ase
    atoms2.set_calculator(atoms.get_calculator())
f2 = atoms2.get_forces()
maxdev = abs(f2 - f1).max()
print maxdev
ReportTest("Max error 2:", maxdev, 0.0, 1e-6)

f2 = atoms.get_forces()
maxdev = abs(f2 - f1).max()
print maxdev
ReportTest("Max error 1:", maxdev, 0.0, 1e-6)

开发者ID:auag92,项目名称:n2dm,代码行数:29,代码来源:ChangeCalculator.py

示例5: OpenKIMcalculator

# 需要导入模块: from ase.lattice.cubic import FaceCenteredCubic [as 别名]
# 或者: from ase.lattice.cubic.FaceCenteredCubic import get_forces [as 别名]
 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()
 for i in range(0, natoms, step):
     n = (n + 1) % 6
     # Volume per atom is not defined the same way: greater tolerance needed
     ReportTest(txt+"Stress(%i) of atom %i" % (n, i), sk[i, n], se[i, n], 1e-3)
开发者ID:auag92,项目名称:n2dm,代码行数:33,代码来源:OpenKIM_EMT.py


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