コード例 #1
0
def _dmat_to_real(l, d, reorder_p=False):
    ''' Transform the input D-matrix to make it compatible with the real
    spherical harmonic functions.
    '''
    # The input D matrix works for pure spherical harmonics. The real
    # representation should be U^\dagger * D * U, where U is the unitary
    # matrix that transform the complex harmonics to the real harmonics.
    u = sph.sph_pure2real(l, reorder_p)
    return reduce(numpy.dot, (u.conj().T, d, u)).real
コード例 #2
0
def angular_moment_matrix(l):
    '''Matrix of angular moment operator l*1j on the real spherical harmonic
    basis'''
    lz = numpy.diag(numpy.arange(-l, l + 1, dtype=numpy.complex128))
    lx = numpy.zeros_like(lz)
    ly = numpy.zeros_like(lz)
    for mi in range(-l, l + 1):
        mj = mi + 1
        if mj <= l:
            lx[l + mi, l + mj] = .5 * ((l + mj) * (l - mj + 1))**.5
            ly[l + mi, l + mj] = .5j * ((l + mj) * (l - mj + 1))**.5

        mj = mi - 1
        if mj >= -l:
            lx[l + mi, l + mj] = .5 * ((l - mj) * (l + mj + 1))**.5
            ly[l + mi, l + mj] = -.5j * ((l - mj) * (l + mj + 1))**.5

    u = sph.sph_pure2real(l)
    lx = u.conj().T.dot(lx).dot(u)
    ly = u.conj().T.dot(ly).dot(u)
    lz = u.conj().T.dot(lz).dot(u)
    return numpy.array((lx, ly, lz))