def test_forces_linear(self): a = triangular_lattice_slab(1.0, 1, 1) calc = IdealBrittleSolid(rc=1.2, beta=0.0, linear=True) calc.set_reference_crystal(a) a.set_calculator(calc) a.rattle(0.01) f = a.get_forces() fn = calc.calculate_numerical_forces(a) self.assertArrayAlmostEqual(f, fn, tol=self.tol)
def test_forces_and_virial(self): a = triangular_lattice_slab(1.0, 2, 2) calc = IdealBrittleSolid(rc=1.2, beta=0.0) a.set_calculator(calc) a.rattle(0.1) f = a.get_forces() fn = calc.calculate_numerical_forces(a) self.assertArrayAlmostEqual(f, fn, tol=self.tol) self.assertArrayAlmostEqual(a.get_stress(), calc.calculate_numerical_stress(a), tol=self.tol)
cell=[10., 10., 10.], pbc=True) for x in x_dimer] calc.set_reference_crystal(dimers[0]) e_dimer = [] f_dimer = [] f_num = [] for d in dimers: d.set_calculator(calc) e_dimer.append(d.get_potential_energy()) f_dimer.append(d.get_forces()) f_num.append(calc.calculate_numerical_forces(d)) e_dimer = np.array(e_dimer) f_dimer = np.array(f_dimer) f_num = np.array(f_num) assert abs(f_dimer - f_num).max() < 0.1 crystal = triangular_lattice_slab(params.a, 3*params.N, params.N) calc.set_reference_crystal(crystal) crystal.set_calculator(calc) e0 = crystal.get_potential_energy() l = crystal.cell[0,0] h = crystal.cell[1,1] print 'l=', l, 'h=', h # compute surface (Griffith) energy b = crystal.copy() b.set_calculator(calc) shift = calc.parameters['rc']*2 y = crystal.positions[:, 1] b.positions[y > h/2, 1] += shift b.cell[1, 1] += shift
def test_neighbour_list_triangular(self): a = triangular_lattice_slab(1.0, 2, 2) i, j, D, S = neighbour_list('ijDS', a, 1.2) D2 = a.positions[j] - a.positions[i] + S.dot(a.cell) self.assertArrayAlmostEqual(D, D2)
def test_new_style_interface(self): calc = IdealBrittleSolid() atoms = triangular_lattice_slab(1.0, 5, 5) self.rattle_calc(atoms, calc)