def test_multipole_derivative(self): Rab = 2.0 * np.random.random(3) + 1 for k in range(6): ll = 1 # derivative n_comps_symm = multipole_components(k) M = np.random.random(n_comps_symm) # unfold the tensor M_full = symmetry.unfold_tensor(M, k) sym_indices = symmetry.get_symm_indices(k) np.testing.assert_allclose(M, M_full.take(sym_indices)) res = multipole_derivative(k, ll, Rab, M, 0.0) ref_field = polfields.field(Rab, k, M_full, ll) np.testing.assert_allclose(ref_field, res, atol=1e-14) if k <= 2: damp = 2.0 a_i = 4.0 a_j = 10.0 a = 1 / (a_i * a_j)**(1 / 6) * damp res = multipole_derivative(k, ll, Rab, M, a) ref_field = polfields.thole_exp_field(Rab, k, M_full, ll, a) np.testing.assert_allclose(ref_field, res, atol=1e-14)
def test_multipole_components(self): for k in range(6): comps = (k + 1) * (k + 2) / 2 assert comps == multipole_components(k)