Esempio n. 1
0
    def getthetaterms(self, dp1, dp1dot):
        r"""Return array of integrated values for specified theta function and dphi function.
        
        Parameters
        ----------
        dp1 : array_like
             Array of values for dphi1
        
        dp1dot : array_like
                Array of values for dphi1dot
                                      
        Returns
        -------
        theta_terms : tuple
                     Tuple of len(k)xlen(q) shaped arrays of integration results in form
        
        Notes
        -----
        The returned expression is of the form
        
        .. math::
        
            \bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,
            
             \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,
             
             \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,
             
             \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)
                     
        """

        sinth = np.sin(self.theta)
        cossinth = np.cos(self.theta) * np.sin(self.theta)
        theta_terms = np.empty([4, self.k.shape[0], self.k.shape[0]],
                               dtype=dp1.dtype)
        lenq = len(self.k)

        for n in np.atleast_1d(self.kix_wanted):
            #Calculate interpolated values of dphi and dphidot
            dphi_res = srccython.interpdps(dp1, dp1dot, self.kmin, self.deltak,
                                           n, self.theta, lenq)

            #Integrate theta dependence of interpolated values
            # dphi terms
            theta_terms[0, n] = romb(sinth * dphi_res[0], dx=self.dtheta)
            theta_terms[1, n] = romb(cossinth * dphi_res[0], dx=self.dtheta)
            # dphidot terms
            theta_terms[2, n] = romb(sinth * dphi_res[1], dx=self.dtheta)
            theta_terms[3, n] = romb(cossinth * dphi_res[1], dx=self.dtheta)
        return theta_terms
Esempio n. 2
0
 def getthetaterms(self, dp1, dp1dot):
     r"""Return array of integrated values for specified theta function and dphi function.
     
     Parameters
     ----------
     dp1 : array_like
          Array of values for dphi1
     
     dp1dot : array_like
             Array of values for dphi1dot
                                   
     Returns
     -------
     theta_terms : tuple
                  Tuple of len(k)xlen(q) shaped arrays of integration results in form
     
     Notes
     -----
     The returned expression is of the form
     
     .. math::
     
         \bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,
         
          \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,
          
          \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,
          
          \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)
                  
     """
     
     sinth = np.sin(self.theta)
     cossinth = np.cos(self.theta)*np.sin(self.theta)
     theta_terms = np.empty([4, self.k.shape[0], self.k.shape[0]], dtype=dp1.dtype)
     lenq = len(self.k)
     
     for n in np.atleast_1d(self.kix_wanted):
         #Calculate interpolated values of dphi and dphidot
         dphi_res = srccython.interpdps(dp1, dp1dot, self.kmin, self.deltak, n, self.theta, lenq)
         
         #Integrate theta dependence of interpolated values
         # dphi terms
         theta_terms[0,n] = romb(sinth*dphi_res[0], dx=self.dtheta)
         theta_terms[1,n] = romb(cossinth*dphi_res[0], dx=self.dtheta)
         # dphidot terms
         theta_terms[2,n] = romb(sinth*dphi_res[1], dx=self.dtheta)
         theta_terms[3,n] = romb(cossinth*dphi_res[1], dx=self.dtheta)
     return theta_terms
Esempio n. 3
0
 def J_C(self, preterms, dp1, dp1dot, Cterms):
     """Solution for J_C which is the integral for C in terms of constants C5."""
             
     q = self.k
     C5k = Cterms[4][..., np.newaxis]
     cterm = (C5k*q**2) * dp1dot * preterms[2]
     J_C = romb(cterm, self.deltak)
     return J_C
Esempio n. 4
0
    def J_C(self, preterms, dp1, dp1dot, Cterms):
        """Solution for J_C which is the integral for C in terms of constants C5."""

        q = self.k
        C5k = Cterms[4][..., np.newaxis]
        cterm = (C5k * q**2) * dp1dot * preterms[2]
        J_C = romb(cterm, self.deltak)
        return J_C
Esempio n. 5
0
 def J_D(self, preterms, dp1, dp1dot, Cterms):
     """Solution for J_D which is the integral for D in terms of constants C6 and C7."""
             
     q = self.k
     C6k = Cterms[5][..., np.newaxis]
     C7k = Cterms[6][..., np.newaxis]
     dterm = (C6k*q + C7k*q**3) * dp1dot * preterms[3]
     J_D = romb(dterm, self.deltak)
     return J_D
Esempio n. 6
0
 def J_B(self, preterms, dp1, dp1dot, Cterms):
     """Solution for J_B which is the integral for B in terms of constants C3 and C4."""
             
     q = self.k
     C3k = Cterms[2][..., np.newaxis]
     C4k = Cterms[3][..., np.newaxis]
     bterm = (C3k*q**3 + C4k*q**5) * dp1 * preterms[1]
     J_B = romb(bterm, self.deltak)
     return J_B
Esempio n. 7
0
 def J_A(self, preterms, dp1, dp1dot, Cterms):
     """Solution for J_A which is the integral for A in terms of constants C1 and C2."""
             
     q = self.k
     C1k = Cterms[0][..., np.newaxis]
     C2k = Cterms[1][..., np.newaxis]
     aterm = (C1k*q**2 + C2k*q**4) * dp1 * preterms[0]
     J_A = romb(aterm, self.deltak)
     return J_A
Esempio n. 8
0
    def J_D(self, preterms, dp1, dp1dot, Cterms):
        """Solution for J_D which is the integral for D in terms of constants C6 and C7."""

        q = self.k
        C6k = Cterms[5][..., np.newaxis]
        C7k = Cterms[6][..., np.newaxis]
        dterm = (C6k * q + C7k * q**3) * dp1dot * preterms[3]
        J_D = romb(dterm, self.deltak)
        return J_D
Esempio n. 9
0
    def J_B(self, preterms, dp1, dp1dot, Cterms):
        """Solution for J_B which is the integral for B in terms of constants C3 and C4."""

        q = self.k
        C3k = Cterms[2][..., np.newaxis]
        C4k = Cterms[3][..., np.newaxis]
        bterm = (C3k * q**3 + C4k * q**5) * dp1 * preterms[1]
        J_B = romb(bterm, self.deltak)
        return J_B
Esempio n. 10
0
    def J_A(self, preterms, dp1, dp1dot, Cterms):
        """Solution for J_A which is the integral for A in terms of constants C1 and C2."""

        q = self.k
        C1k = Cterms[0][..., np.newaxis]
        C2k = Cterms[1][..., np.newaxis]
        aterm = (C1k * q**2 + C2k * q**4) * dp1 * preterms[0]
        J_A = romb(aterm, self.deltak)
        return J_A
Esempio n. 11
0
 def J_func(self, preterms, dp1, dp1dot, Cterms, Jkey):
     """Generic solution for J_func integral."""
     q = self.k
     #Set up variables from list of Jterms and constants
     #Constant term
     Cterm = Cterms[Jkey][..., np.newaxis]
     #Index of q
     n = self.J_params[Jkey]["n"]
     #Get text of dphiterm and set variable
     dphitermtext = self.J_params[Jkey]["dphiterm"]
     if dphitermtext == "dp1":
         dphiterm = dp1
     elif dphitermtext == "dp1dot":
         dphiterm = dp1dot
     #Get preterm index
     pretermix = self.J_params[Jkey]["pretermix"]
     preterm = preterms[pretermix]
     
     integrand = (Cterm*q**n) * dphiterm * preterm
     J_integral = romb(integrand, self.deltak)
     return J_integral
Esempio n. 12
0
    def J_func(self, preterms, dp1, dp1dot, Cterms, Jkey):
        """Generic solution for J_func integral."""
        q = self.k
        #Set up variables from list of Jterms and constants
        #Constant term
        Cterm = Cterms[Jkey][..., np.newaxis]
        #Index of q
        n = self.J_params[Jkey]["n"]
        #Get text of dphiterm and set variable
        dphitermtext = self.J_params[Jkey]["dphiterm"]
        if dphitermtext == "dp1":
            dphiterm = dp1
        elif dphitermtext == "dp1dot":
            dphiterm = dp1dot
        #Get preterm index
        pretermix = self.J_params[Jkey]["pretermix"]
        preterm = preterms[pretermix]

        integrand = (Cterm * q**n) * dphiterm * preterm
        J_integral = romb(integrand, self.deltak)
        return J_integral
Esempio n. 13
0
    def getthetaterms(self, dp1, dp1dot):
        r"""Return array of integrated values for specified theta function and dphi function.
        This modified version only returns the result for one k value.
        
        Parameters
        ----------
        dp1 : array_like
             Array of values for dphi1
        
        dp1dot : array_like
                Array of values for dphi1dot
                                      
        Returns
        -------
        theta_terms : tuple
                     Tuple of len(k)xlen(q) shaped arrays of integration results in form

        Notes
        -----
        The returned expression is of the form
        
        .. math::
        
            \bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,
            
             \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,
             
             \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,
             
             \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)
                     
        """
        
        # Sinusoidal theta terms
        sinth = np.sin(self.theta)
        cossinth = np.cos(self.theta)*sinth
        cos2sinth = np.cos(self.theta)*cossinth
        sin3th = sinth*sinth*sinth
        
        theta_terms = np.empty([7, self.k.shape[0], self.k.shape[0]], dtype=dp1.dtype)
        lenq = len(self.k)
        for n in np.atleast_1d(self.kix_wanted): 
            #klq = klessq(onek, q, theta)
            dphi_res = srccython.interpdps(dp1, dp1dot, self.kmin, self.deltak, n, self.theta, lenq)
            
            theta_terms[0,n] = romb(sinth*dphi_res[0], dx=self.dtheta)
            theta_terms[1,n] = romb(cossinth*dphi_res[0], dx=self.dtheta)
            theta_terms[2,n] = romb(sinth*dphi_res[1], dx=self.dtheta)
            theta_terms[3,n] = romb(cossinth*dphi_res[1], dx=self.dtheta)
            
            #New terms for full solution
            # E term integration
            theta_terms[4,n] = romb(cos2sinth*dphi_res[0], dx=self.dtheta)
            #Get klessq for F and G terms
            klq2 = klessqksq(self.k[n], self.k, self.theta)
            sinklq = sin3th/klq2
            #Get rid of NaNs in places where dphi_res=0 or equivalently klq2<self.kmin**2
            sinklq[klq2<self.kmin**2] = 0
            # F term integration
            theta_terms[5,n] = romb(sinklq *dphi_res[0], dx=self.dtheta)
            # G term integration
            theta_terms[6,n] = romb(sinklq *dphi_res[1], dx=self.dtheta)
            
        return theta_terms
Esempio n. 14
0
    def getthetaterms(self, dp1, dp1dot):
        r"""Return array of integrated values for specified theta function and dphi function.
        This modified version only returns the result for one k value.
        
        Parameters
        ----------
        dp1 : array_like
             Array of values for dphi1
        
        dp1dot : array_like
                Array of values for dphi1dot
                                      
        Returns
        -------
        theta_terms : tuple
                     Tuple of len(k)xlen(q) shaped arrays of integration results in form

        Notes
        -----
        The returned expression is of the form
        
        .. math::
        
            \bigg(\int(\sin(\theta) \delta\varphi_1(k-q) d\theta,
            
             \int(\cos(\theta)\sin(\theta) \delta\varphi_1(k-q) d\theta,
             
             \int(\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta,
             
             \int(\cos(\theta)\sin(\theta) \delta\varphi^\dagger_1(k-q) d\theta)\bigg)
                     
        """

        # Sinusoidal theta terms
        sinth = np.sin(self.theta)
        cossinth = np.cos(self.theta) * sinth
        cos2sinth = np.cos(self.theta) * cossinth
        sin3th = sinth * sinth * sinth

        theta_terms = np.empty([7, self.k.shape[0], self.k.shape[0]],
                               dtype=dp1.dtype)
        lenq = len(self.k)
        for n in np.atleast_1d(self.kix_wanted):
            #klq = klessq(onek, q, theta)
            dphi_res = srccython.interpdps(dp1, dp1dot, self.kmin, self.deltak,
                                           n, self.theta, lenq)

            theta_terms[0, n] = romb(sinth * dphi_res[0], dx=self.dtheta)
            theta_terms[1, n] = romb(cossinth * dphi_res[0], dx=self.dtheta)
            theta_terms[2, n] = romb(sinth * dphi_res[1], dx=self.dtheta)
            theta_terms[3, n] = romb(cossinth * dphi_res[1], dx=self.dtheta)

            #New terms for full solution
            # E term integration
            theta_terms[4, n] = romb(cos2sinth * dphi_res[0], dx=self.dtheta)
            #Get klessq for F and G terms
            klq2 = klessqksq(self.k[n], self.k, self.theta)
            sinklq = sin3th / klq2
            #Get rid of NaNs in places where dphi_res=0 or equivalently klq2<self.kmin**2
            sinklq[klq2 < self.kmin**2] = 0
            # F term integration
            theta_terms[5, n] = romb(sinklq * dphi_res[0], dx=self.dtheta)
            # G term integration
            theta_terms[6, n] = romb(sinklq * dphi_res[1], dx=self.dtheta)

        return theta_terms