Example #1
0
 def test_analysis(self):
     n = 6
     for l in range(n):
         for m in range(-l, l+1):
             y = sph_harm(abs(m), l, self.phi, self.theta)
             y = {-1: 2**.5*y.real, 0: y.real, 1: 2**.5*y.imag}[np.sign(m)]
             self.e.data = [(y*self.r**l)[:, :, :, None]]
             self.e.generate(n)
             for k in range(n):
                 p = self.e.potential(self.xt, k).T
                 a = utils.cartesian_to_spherical_harmonics(p)
                 a = a.T.reshape(self.x[0].shape + (a.shape[0],))
                 ac = a[self.nn, self.nn, self.nn]
                 if k == l:
                     nptest.assert_allclose(ac, np.identity(2*l+1)[l-m],
                             rtol=1e-12, atol=1e-12)
                 elif not (l > k and (l-k)%2 == 0): # FIXME
                     nptest.assert_allclose(ac, 0, atol=1e-12)
 def test_spherical_harmonics(self):
     ns = range(6)
     v = [self.e.potential(self.x, i).T for i in ns]
     for i, vi in enumerate(v):
         s = utils.cartesian_to_spherical_harmonics(vi)
         self.assertEqual(s.shape, vi.shape)
Example #3
0
 def test_spherical_harmonics(self):
     ns = range(6)
     v = [self.e.potential(self.x, i).T for i in ns]
     for i, vi in enumerate(v):
         s = utils.cartesian_to_spherical_harmonics(vi)
         self.assertEqual(s.shape, vi.shape)