ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/nonbonded/SlaterIntegrals.hpp
(Generate patch)

Comparing branches/development/src/nonbonded/SlaterIntegrals.hpp (file contents):
Revision 1718 by gezelter, Thu May 24 01:29:59 2012 UTC vs.
Revision 1874 by gezelter, Wed May 15 15:09:35 2013 UTC

# Line 61 | Line 61
61  
62   #include "config.h"
63   #include <cmath>
64 + #include <cstdlib>
65 + #include <iostream>
66   #include "math/Factorials.hpp"
67 + #include "utils/NumericConstant.hpp"
68  
69   #ifndef NONBONDED_SLATERINTEGRALS_HPP
70   #define NONBONDED_SLATERINTEGRALS_HPP
# Line 82 | Line 85 | template <typename T> inline T mod(T x, T m)
85   *   \frac{\alpha^\nu}{\nu!}
86   * \f]
87   * @param n - principal quantum number
88 < * @param alpha - Slater exponent
88 > * @param a - Slater exponent
89   * @return the value of Rosen's A integral
90   * @note N. Rosen, Phys. Rev., 38 (1931), 255
91   */
# Line 93 | Line 96 | inline RealType RosenA(int n, RealType a)
96      {
97        RealType Term = 1.;
98        RosenA_ = Term;
99 <      for (unsigned nu=1; nu<=n; nu++)
99 >      for (int nu=1; nu<=n; nu++)
100          {
101            Term *= a / nu;
102            RosenA_ += Term;
# Line 122 | Line 125 | inline RealType RosenB(int n, RealType alpha)
125   {
126    RealType TheSum, Term;
127    RealType RosenB_, PSinhRosenA, PCoshRosenA, PHyperRosenA;
128 <  int nu;
126 <  bool IsPositive;
128 >
129    if (alpha != 0.)
130      {
131        Term = 1.;
132 <      TheSum = 1.;
131 <      IsPositive = true;
132 >      bool IsPositive = true;
133                  
134        // These two expressions are (up to constant factors) equivalent
135        // to computing the hyperbolic sine and cosine of a respectively
# Line 172 | Line 173 | inline RealType RosenD(int m, int n, int p)
173   * @note N. Rosen, Phys. Rev., 38 (1931), 255
174   */
175   inline RealType RosenD(int m, int n, int p)
175 // [?ERROR?] can't return int
176   {
177  printf("RosenD\n");
178  exit(0);
177    if (m+n+p > maxFact)
178      {
179        printf("Error, arguments exceed maximum factorial computed %d > %d\n", m+n+p, maxFact);
# Line 206 | Line 204 | inline RealType sSTOCoulInt(RealType a, RealType b, in
204   */
205   inline RealType sSTOCoulInt(RealType a, RealType b, int m, int n, RealType R)
206   {
209  int nu, p;
207    RealType x, K2;
208    RealType Factor1, Factor2, Term, OneElectronTerm;
209    RealType eps, epsi;
# Line 220 | Line 217 | inline RealType sSTOCoulInt(RealType a, RealType b, in
217          
218    // First compute the two-electron component
219    RealType sSTOCoulInt_ = 0.;
220 <  if (x == 0.) // Pathological case
220 >  if (std::fabs(x) < OpenMD::NumericConstant::epsilon) // Pathological case
221      {
222 <      if ((a==b) && (m==n))
223 <        {
224 <          for (int nu=0; nu<=2*n-1; nu++)
225 <            {
226 <              K2 = 0.;
227 <              for (unsigned p=0; p<=2*n+m; p++) K2 += 1. / fact[p];
228 <              sSTOCoulInt_ += K2 * fact[2*n+m] / fact[m];
229 <            }
230 <          sSTOCoulInt_ = 2 * a / (n * fact[2*n]) * sSTOCoulInt_;
231 <        }
232 <      else
233 <        {
234 <          // Not implemented
235 <          printf("ERROR, sSTOCoulInt cannot compute from arguments\n");
236 <          printf("a = %lf b = %lf m = %d n = %d R = %lf\n",a, b, m, n, R);
237 <          exit(0);
238 <        }
222 >
223 >      // This solution for the one-center coulomb integrals comes from
224 >      // Yoshiyuki Hase, Computers & Chemistry 9(4), pp. 285-287 (1985).
225 >      
226 >      RealType Term1 = fact[2*m - 1] / pow(2*a, 2*m);
227 >      RealType Term2 = 0.;
228 >      for (int nu = 1; nu <= 2*n; nu++) {
229 >        Term2 += nu * pow(2*b, 2*n - nu) * fact[2*(m+n)-nu-1] / (fact[2*n-nu]*2*n * pow(2*(a+b), 2*(m+n)-nu));
230 >      }
231 >      sSTOCoulInt_ = pow(2*a, 2*m+1) * (Term1 - Term2) / fact[2*m];
232 >
233 >      // Original QTPIE code for the one-center case is below.  Doesn't
234 >      // appear to generate the correct one-center results.
235 >      //
236 >      // if ((a==b) && (m==n))
237 >      //   {
238 >      //     for (int nu=0; nu<=2*n-1; nu++)
239 >      //       {
240 >      //         K2 = 0.;
241 >      //         for (unsigned p=0; p<=2*n+m; p++) K2 += 1. / fact[p];
242 >      //         sSTOCoulInt_ += K2 * fact[2*n+m] / fact[m];
243 >      //       }
244 >      //     sSTOCoulInt_ = 2 * a / (n * fact[2*n]) * sSTOCoulInt_;
245 >      //   }
246 >      // else
247 >      //   {
248 >      //     // Not implemented
249 >      //     printf("ERROR, sSTOCoulInt cannot compute from arguments\n");
250 >      //     printf("a = %lf b = %lf m = %d n = %d R = %lf\n",a, b, m, n, R);
251 >      //     exit(0);
252 >      //   }
253 >
254      }
255    else
256      {
# Line 497 | Line 509 | inline RealType sSTOOvIntGrad(RealType a, RealType b,
509  
510   /**
511   * @brief Calculates a Slater-type orbital exponent based on the hardness parameters
512 < * @param Hardness: chemical hardness in atomic units
512 > * @param hardness: chemical hardness in atomic units
513   * @param        n: principal quantum number
514   * @note Modified for use with OpenMD by Gezelter and Michalka.
515   */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines