Esempio 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)   
Esempio 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)
Esempio 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
Esempio n. 4
0
    def test_sumDiagonalB_coeffs(self):
        """ If we integrate any sho function norm it must return 1 
        integral(|phi_(n,l)|^2) = c^2 sum B(nl,nl,p) Gamma(p + l + 3/2)/2
        
        integral(r^2 * exp(-r/b^2) * r^(2(p + l))) = Gamma(p+l+3/2) / 2
        """
        N_max = 8
        Integrals_ = _RadialTwoBodyDecoupled()
        print("\n==== TEST NORM SHO FUNCTION DECOUPLED B COEFFS  ====\n")
        for N in range(N_max + 1):
            print("N =", N)
            for n in range(N // 2 + 1):
                l = N - 2 * n

                aux = 0.0
                for p in range(2 * n + 1):
                    B0 = Integrals_._B_coeff(n, l, n, l, p)
                    integ = np.exp(gamma_half_int(2 * (p + l) + 3)) / 2
                    aux += B0 * integ

                print("\t* integral(|phi(n,l)=(", n, l, ")|^2) =", aux)
                self.assertAlmostEqual(
                    1,
                    aux,
                    delta=1e-9,
                    msg="\nnorm of the function in terms of B decoupled "
                    "is not 1.0 for (n,l)={}".format((n, l)))
Esempio 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_)
Esempio n. 6
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)
Esempio 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)
Esempio n. 8
0
 def _baseIntegral(self, K):
     """
     Access to the memorization object of the base integral
     integral for Gogny:  (r/b_param)^K * V(r)* exp(-2*(r/b)^2)
     """
     # TODO: Extend for different self.PARAMS_FORCE 
     
     if K not in self._baseIntegrals_memo:
         b = self.b_param
         integral_ = (0.5/(b**3)) * np.exp(gamma_half_int(2*K+3))\
                     * talmiIntegral(K, PotentialForms.Gaussian, b, b)
         self._baseIntegral_memo[K] = integral_
     
     return self._baseIntegral_memo.get(K)
Esempio 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
Esempio n. 10
0
 def _r_dependentIntegral(self, No2):
     """ Integral r^2*No2 exp(-r^2), b lengths extracted (b**6)
     :No2 stands for N over 2, being N = 2*(p+p') + sum{l} (+2 opt.)"""
     
     # l1 + l2 + l1_q + l2_q is even
     return np.exp(gamma_half_int(2*No2 + 1) - ((No2 + 1.5)*np.log(2)))
Esempio n. 11
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()))