if ReportTest.GetNumberOfErrors() > 10: print "*** Too many errors - giving up! ***" break print_version(1) element = "Cu" latconst = ase.data.reference_states[ase.data.atomic_numbers[element]]['a'] atoms = FaceCenteredCubic(directions=[[1,0,0],[0,1,1],[0,0,1]], size=(9,7,5), symbol=element, debug=0) atoms.set_calculator(EMT(minimum_image=True)) epot = atoms.get_potential_energy() nblist = atoms.get_calculator().get_neighborlist() count = {} for lst in nblist: n = len(lst) try: count[n] += 1 except KeyError: count[n] = 1 # print "Histogram:" numbers = count.keys() numbers.sort() sum = 0 for i in numbers: #print i, count[i] sum += i*count[i]
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)