def calcWignerMatrices(self, rot):
     a,b,y = rot
     sinb2 = sin(b/2)
     cosb2 = cos(b/2)
     cosb = cos(b)
     sinb = sin(b)
     Jmax = self.Jmax
     Js, m1s, m2s = self.Js, self.m1s, self.m2s
     Ds = np.zeros((Jmax+1, 2*Jmax+1, 2*Jmax+1), np.complex128)
     grad = np.zeros((3, Jmax+1, 2*Jmax+1, 2*Jmax+1), np.complex128)
     mu = abs(m1s-m2s)
     nu = abs(m1s+m2s)
     s = Js - (mu + nu)/2
     xi = np.ones_like(s)
     xi[m2s<m1s] = (-1)**(m1s-m2s)[m2s<m1s]
     factor = sqrt(factorial(s)*factorial(s+mu+nu)/
                       factorial(s+mu)/factorial(s+nu)) * xi
     jac = eval_jacobi(s, mu, nu, cosb)
     d = (factor * jac * sinb2 ** mu * cosb2 ** nu)
     ##
     gradjac = eval_grad_jacobi(s, mu, nu, cosb) * - sinb
     gradd = (factor * gradjac * sinb2 ** mu * cosb2 ** nu +
                  factor * jac * sinb2 ** (mu-1) * cosb2 ** (nu+1) * mu/2 - 
                  factor * jac * sinb2 ** (mu+1) * cosb2 ** (nu-1) * nu/2)
     ##
     Ds[Js, m1s, m2s] = exp(-1j*m1s*a) * d * exp(-1j*m2s*y)
     grad[0,Js, m1s, m2s] = -1j*m1s * Ds[Js, m1s, m2s]
     grad[1,Js, m1s, m2s] = exp(-1j*m1s*a) * gradd * exp(-1j*m2s*y)
     grad[2,Js, m1s, m2s] = -1j*m2s * Ds[Js, m1s, m2s]
     return Ds, grad
    def _rnm(self, radialDegree, azimuthalFrequency, rhoArray):
        n = radialDegree
        m = azimuthalFrequency
        rho = rhoArray
        if (n - m) % 2 != 0:
            raise Exception("n-m must be even. Got %d-%d" % (n, m))
        if abs(m) > n:
            raise Exception("The following must be true |m|<=n. Got %d, %d" %
                            (n, m))
        mask = np.where(rho <= 1, False, True)

        if (n == 0 and m == 0):
            return np.ma.masked_array(data=np.ones(rho.shape), mask=mask)
        rho = np.where(rho < 0, 0, rho)
        Rnm = np.zeros(rho.shape)
        S = (n - abs(m)) // 2
        for s in range(0, S + 1):
            CR = pow(-1, s) * factorial(n - s) / \
                (factorial(s) * factorial(-s + (n + abs(m)) / 2) *
                 factorial(-s + (n - abs(m)) / 2))
            p = CR * pow(rho, n - 2 * s)
            Rnm = Rnm + p
        return np.ma.masked_array(data=Rnm, mask=mask)
Esempio n. 3
0
 def calcWignerMatrices(self):
     bw = self.bw
     bws = self.bws
     beta = self.b
     sinb2 = sin(beta / 2)
     cosb2 = cos(beta / 2)
     cosb = cos(beta)
     Js, m1s, m2s = self.Js, self.m1s, self.m2s
     Dfull = np.zeros((bw, 2 * bw - 1, 2 * bw - 1, 2 * bw))
     mu = abs(m1s - m2s)
     nu = abs(m1s + m2s)
     s = Js - (mu + nu) / 2
     xi = np.ones_like(s)
     xi[m2s < m1s] = (-1)**(m1s - m2s)[m2s < m1s]
     factor = sqrt(
         factorial(s) * factorial(s + mu + nu) / factorial(s + mu) /
         factorial(s + nu)) * xi
     jac = eval_jacobi(s[:, None], mu[:, None], nu[:, None], cosb[None, :])
     Dfull[Js[:, None], m1s[:, None], m2s[:, None],
           bws[None, :]] = (((2. * Js[:, None] + 1.) / 2.)**0.5 *
                            factor[:, None] * jac *
                            sinb2[None, :]**mu[:, None] *
                            cosb2[None, :]**nu[:, None])
     return Dfull
Esempio n. 4
0
def norm_harmonicBasis(n, l, r0):
    """
    returns the normalisaton constant of the harmonic basis function
    """
    return (2 * factorial(n) * r0**(-2 * l - 3) / gamma(1.5 + n + l))**0.5