def test_generate_reciprocal_vectors_squared(self): # test cubic case a = 6. lattvectors = [[a if i == j else 0. for j in range(3)] for i in range(3)] brecip = [1.0966227112321507 for i in range(6)] self.assertAlmostEqual( list(generate_reciprocal_vectors_squared(lattvectors[0], lattvectors[1], lattvectors[2], 1.3)), brecip) # test orthorhombic case lattconsts = [a, a / 2., 3. * a] lattvectors = [[lattconsts[i] if i == j else 0. for j in range(3)] for i in range(3)] brval = 0.4873878716587337 brecip = [brval, brval / 4., brval / 4., brval] self.assertAlmostEqual( list(generate_reciprocal_vectors_squared(lattvectors[0], lattvectors[1], lattvectors[2], 1.)), brecip) # test triclinic case lattvectors = [[1.5, 0.2, 0.3], [0.3, 1.2, .2], [0.5, 0.4, 1.3]] brval = 24.28330561545568 brecip = [brval, brval] self.assertAlmostEqual( list(generate_reciprocal_vectors_squared(lattvectors[0], lattvectors[1], lattvectors[2], 30.)), brecip)
def test_generate_reciprocal_vectors_squared(self): # test cubic case a = 6. lattvectors = [[a if i == j else 0. for j in range(3)] for i in range(3)] brecip = [1.0966227112321507 for i in range(6)] self.assertAlmostEqual( list(generate_reciprocal_vectors_squared(lattvectors[0], lattvectors[1], lattvectors[2], 1.3)), brecip) # test orthorhombic case lattconsts = [a, a / 2., 3. * a] lattvectors = [[lattconsts[i] if i == j else 0. for j in range(3)] for i in range(3)] brval = 0.4873878716587337 brecip = [brval, brval / 4., brval / 4., brval] self.assertAlmostEqual( list(generate_reciprocal_vectors_squared(lattvectors[0], lattvectors[1], lattvectors[2], 1.)), brecip) # test triclinic case lattvectors = [[1.5, 0.2, 0.3], [0.3, 1.2, .2], [0.5, 0.4, 1.3]] brval = 24.28330561545568 brecip = [brval, brval] self.assertAlmostEqual( list(generate_reciprocal_vectors_squared(lattvectors[0], lattvectors[1], lattvectors[2], 30.)), brecip)
def e_per(encut): eper = 0 for g2 in generate_reciprocal_vectors_squared(a1, a2, a3, encut): eper += (self.q_model.rho_rec(g2) ** 2) / g2 eper *= (q ** 2) * 2 * round(np.pi, 6) / vol eper += (q ** 2) * 4 * round(np.pi, 6) * self.q_model.rho_rec_limit0 / vol return eper
def e_per(encut): eper = 0 for g2 in generate_reciprocal_vectors_squared(a1, a2, a3, encut): eper += (self.q_model.rho_rec(g2)**2) / g2 eper *= (q**2) * 2 * round(np.pi, 6) / vol eper += (q**2) * 4 * round(np.pi, 6) \ * self.q_model.rho_rec_limit0 / vol return eper