Ejemplo n.º 1
0
 def _norm_coeff(self, n1, l1, n2, l2):
     """ Also extracted from Apendix D.1 of the thesis, 
     factor (1 / 2*pi^3) extracted."""
             
     aux =  fact(n1) + gamma_half_int(2*(n1 + l1) + 3)
     aux += fact(n2) + gamma_half_int(2*(n2 + l2) + 3)
     
     return np.exp(0.5 * aux)   
Ejemplo n.º 2
0
 def __sum_aux_denominator(self, n1, l1, n2, l2, p, k):
     
     denominator = sum(
         [fact(k), fact(n1 - k), fact(p - k), fact(n2 + k - p),
         gamma_half_int(2*(k + l1) + 3),  
         gamma_half_int(2*(p - k + l2) + 3)]  ## double factorial (n - 1)
     )
     return np.exp(denominator)
Ejemplo n.º 3
0
    def _phiWF(self, n, l, r):

        aux = 0.0 * r
        for p in range(0, n + 1):
            den = fact(p) + fact(n - p) + gamma_half_int(2 * (p + l) + 3)
            aux += ((-1)**p) * (r**(2 * p + l)) / np.exp(den)
        N = np.exp(0.5 * (fact(n) + gamma_half_int(2 *
                                                   (n + l) + 3) + np.log(2)))
        return aux * N
Ejemplo n.º 4
0
def _sho_series_coeff(sp_state, k):
    """ return logarithmic value. (insert the -1^k phase from outside) """
    n, l = sp_state.n, sp_state.l
    # Suhonen_
    #aux = ((fact(n) + gamma_half_int(2*(n + l) + 3)) 
    #       - (fact(k) + fact(n-k) + gamma_half_int(2*(k + l) + 3)))
    
    # Moshinsky_ or Llarena_
    aux = fact(k) + fact(n - k) + gamma_half_int(2*(k + l) + 3)
    
    return  _norm_sho(n, l) - aux #gamma_half_int(2*(n + l) + 3)
Ejemplo n.º 5
0
 def _aCoeff_nlk(self, n, l, k):
     """
     Access to the memorization object of the coefficient for the radial
     Coefficient for the radial function evaluation in series.
     
     Returns without the 1/sqrt(b^3) normalization factor,  
     """
     key_ = '({},{},{})'.format(n, l, k)
     
     if key_ not in self._a_coeff_nkl_memo:
         
         aux = 0.5*(fact(n) - gamma_half_int(2*(n+l+1))) # + 3*np.log(self.b_param)
         aux += gamma_half_int(2*(n+l+1)) - (fact(n) + fact(n-k) 
                                             + gamma_half_int(2*(k+l+1)))
         
         self._a_coeff_nkl_memo[key_] = (-1)**k * np.exp(aux)
     
     return self._a_coeff_nkl_memo.get(key_)
Ejemplo n.º 6
0
def _Legendre_coeffs(multipole_ord, i):
    """ 
    Return the c_[lambda][i] and the phase for the expansion of the gaussian
    in Legendre polynomials:
    
    v_lambda = exp(-(r1^2 + r2^2)/mu^2) 
        * sum_[i=0: floor(lambda/2)] {
            C_[lambda, i] * (exp(+2*r1*r2/mu^2) * sum1_[j] 
                             + (-)^phase exp(-2*r1*r2/mu^2) * sum2_[j])
                             }
    return C_[lambda, i] (LOGARITHMIC value), phase
    """
    aux_c  = fact(2*(multipole_ord - i)) - (fact(i) + fact(multipole_ord - i))
    aux_c -= (multipole_ord + 1)*np.log(2)
    #aux_c = np.exp(aux_c)
    #aux_c *= ((2*multipole_ord + 1) / (2**(multipole_ord + 1)))
    
    phase = multipole_ord - 2*i + 1
    return aux_c, phase
Ejemplo n.º 7
0
def _norm_sho(n, l):
    """ return logarithmic value (increase precission for very large n values) """
    #n, l = sp_state.n, sp_state.l
    # Suhonen_
    #aux = fact(n) - gamma_half_int(2*(n + l) + 3)
    #return np.sqrt(2 * np.exp(aux) / ((np.pi**0.5) * b_length**3))
    
    # Moshinsky_ or Llarena_
    aux = fact(n) + gamma_half_int(2*(n + l) + 3)
    #return 0.5 * (np.log(2 / (b_length**3)) + aux)
    return 0.5 * (np.log(2) + aux)
 def test_basefactorials(self):
     
     examples = [i for i in range(100)]
     
     tmp_fail = "[{}]! = [{}]. Got [{}]"
     
     checks = map(lambda x: (x, np.math.factorial(x), np.exp(fact(x))), examples)
     checks = filter(lambda f: abs(f[1] - f[2])/f[1] > self.TOLERANCE, checks)
     failures = [tmp_fail.format(*f) for f in checks]
             
     self.assertTrue(len(failures)==0, "\n"+"\n".join(failures))
Ejemplo n.º 9
0
def _testNormalizationSingleRadialFunction(n, l, b_length=1):
    
    sp_state = QN_1body_radial(n, l)
    
    N_coeff2 = fact(n) + gamma_half_int(2*(n+l)+3)# / np.sqrt(np.pi)
    #N_coeff_mine = _norm_sho(sp_state, b_length)
    
    sum_ = 0.
    sum_mine = 0.
    for k1 in range(n +1):
        aux1 = -(fact(k1) + fact(n-k1) + gamma_half_int(2*(k1+l)+3))
        aux1_mine = _sho_series_coeff(sp_state, k1)
        for k2 in range(n +1):
            aux2 = -(fact(k2) + fact(n-k2) + gamma_half_int(2*(k2+l)+3))
            aux2_mine = _sho_series_coeff(sp_state, k2)
            
            aux = np.exp(N_coeff2 + aux1 + aux2 + gamma_half_int(2*(k1+k2+l) + 3))
            aux_mine = np.exp(aux1_mine + aux2_mine + gamma_half_int(2*(k1+k2+l) + 3))
            
            sum_ += aux * ((-1)**(k1 + k2))
            sum_mine += 0.5 * aux_mine * ((-1)**(k1 + k2))
            
    
    return sum_, sum_mine
Ejemplo n.º 10
0
def _coeff_r2_integral(multipole_ord, i, j, mu2r1_const):
    """ Return (not logarithm value)"""
    aux  = mu2r1_const**(j + 1)   #(mu_param**2 / (2*r1))**(j+1)
    aux /= np.exp(fact(multipole_ord - (2*i) - j))
    return aux
    def _B_coefficient_evaluation(self):
        """ SHO normalization coefficients for WF, not b_length dependent """

        # parity condition
        if (((self._l + self._l_q) % 2) != 0):
            return 0

        const = 0.5 * (
            (fact(self._n) + fact(self._n_q) + fact(2 *
                                                    (self._n + self._l) + 1) +
             fact(2 * (self._n_q + self._l_q) + 1)) -
            (fact(self._n + self._l) + fact(self._n_q + self._l_q)))

        const += fact(2 * self._p + 1) - fact(self._p)

        const = (-1)**(self._p - (self._l + self._l_q) // 2) * np.exp(const)
        const /= (2**(self._n + self._n_q))

        aux_sum = 0.
        max_ = min(self._n, self._p - (self._l + self._l_q) // 2)
        min_ = max(0, self._p - (self._l + self._l_q) // 2 - self._n_q)

        for k in range(min_, max_ + 1):
            const_k = ((fact(self._l + k) + fact(self._p - k -
                                                 (self._l - self._l_q) // 2)) -
                       (fact(k) + fact(self._n - k) + fact(2 *
                                                           (self._l + k) + 1) +
                        fact(self._p - (self._l + self._l_q) // 2 - k) +
                        fact(self._n_q - self._p + k +
                             (self._l + self._l_q) // 2) +
                        fact(2 * (self._p - k) + self._l_q - self._l + 1)))
            aux_sum += np.exp(const_k)

        return const * aux_sum
Ejemplo n.º 12
0
def talmiIntegral(p, potential, b_param, mu_param, n_power=0, **kwargs):
    """
    :p          index order
    :potential  form of the potential, from Poten
    :b_param    SHO length parameter
    :mu_param   force proportional coefficient (by interaction definition)
    :n_power    auxiliary parameter for power dependent potentials
    """
    
    if potential == PotentialForms.Gaussian:
        return (b_param**3) / (1 + 2*(b_param/mu_param)**2)**(p+1.5)
    
    elif potential == PotentialForms.Coulomb:
        return (b_param**2) * np.exp(fact(p) - gamma_half_int(2*p + 3)) / (2**.5)
    
    elif potential == PotentialForms.Gaussian_power:
        aux = gamma_half_int(2*p + 3 - n_power) - gamma_half_int(2*p + 3)
        aux = (b_param**3) * np.exp(aux)
        
        x = (2**0.5) * b_param / mu_param
        return aux / ((x**n_power) * ((1 + x**2)**(p + 1.5 - (n_power/2))))
    
    elif potential == PotentialForms.Power:
        if n_power == 0:
            return b_param**3
        aux =  gamma_half_int(2*p + 3 + n_power) - gamma_half_int(2*p + 3)
        aux += n_power * ((np.log(2)/2) - np.log(mu_param))
        return np.exp(aux + ((n_power + 3)*np.log(b_param)))
    
    elif potential == PotentialForms.Yukawa:
        sum_ = 0.
        cte_k = b_param / ((2**0.5) * mu_param)
        cte_k_log = np.log(cte_k)
        
        for k in range(0, 2*p + 1 +1):
            aux  = fact(2*p + 1) - fact(k) - fact(2*p + 1 - k)            
            aux += (2*p + 1 - k) * cte_k_log
            aux += gamma_half_int(k + 1) ## normalization of gammaincc_
            aux  = np.exp(aux)
            
            sum_ += (-1)**(2*p + 1 - k) * aux * gammaincc((k + 1)/2, cte_k**2)
            
        #sum_ *= mu_param * (b_param**2) / np.exp(0.5 * ((b_param/mu_param)**2)) 
        sum_ *= mu_param * (b_param**2) / np.exp(cte_k**2) 
        sum_ /= np.exp(gamma_half_int(2*p + 3)) * (2**0.5)
        
        return sum_
    
    elif potential == PotentialForms.Exponential:
        sum_ = 0.
        cte_k = b_param / ((2**0.5) * mu_param)
        cte_k_log = np.log(cte_k)
        
        for k in range(2*p + 2 +1):
            aux  = fact(2*p + 2) - fact(k) - fact(2*p + 2 - k)            
            aux += (2*p + 2 - k) * cte_k
            aux += gamma_half_int(k + 1) ## normalization of gammaincc_
            aux  = np.exp(aux)
            
            sum_ += (-1)**(2*p + 2 - k) * aux * gammaincc((k + 1)/2, cte_k**2)
            
        sum_ *= (b_param**3) / np.exp(0.5 * ((b_param/mu_param)**2)) 
        sum_ /= np.exp(gamma_half_int(2*p + 3))
        
        return sum_
    
    else:
        raise IntegralException("Talmi integral [{}] is not defined, valid potentials: {}"
                        .format(potential, PotentialForms.members()))