JDFTx  1.2.0
Fex_H2O_FittedCorrelations_internal.h
1 /*-------------------------------------------------------------------
2 Copyright 2011 Ravishankar Sundararaman
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx. If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #ifndef JDFTX_FLUID_FEX_H2O_FITTEDCORRELATIONS_INTERNAL_H
21 #define JDFTX_FLUID_FEX_H2O_FITTEDCORRELATIONS_INTERNAL_H
22 
23 #include <core/scalar.h>
24 
26 {
27  //Coefficients from Table II of [FittedCorrelations]:
28  static const double f0 = 3.83929979127276e-18;
29  static const double f1 = -1.01124264551199e-10;
30  static const double f2 = 8.87857550440045e-04;
31  static const double f3 = -2.59856289573731e+03;
32  static const double f4 = 9.17183837107696e+05;
33  static const double f5 = -1.27079357385654e+08;
34  static const double f6 = 6.58720860464796e+09;
35  static const double pObar = -19.0/20;
36  static const double pHbar = +12.0/20;
37  static const double pMean = +27.0/20;
38 
39  __hostanddev__ double fex(double N)
40  { return N<0. ? 0. : f0 + N*(f1 + N*(f2 + N*(f3 + N*(f4 + N*(f5 + N*f6)))));
41  }
42  __hostanddev__ double fexDot(double N)
43  { return N<0. ? 0. : f1 + N*(2*f2 + N*(3*f3 + N*(4*f4 + N*(5*f5 + N*(6*f6)))));
44  }
45 }
46 //Compute the gaussian weighted density energy and gradients
47 __hostanddev__
48 double Fex_H2O_FittedCorrelations_calc(int i, const double* NObar, const double* NHbar, double* Phi_NObar, double* Phi_NHbar)
49 { using namespace Fex_H2O_FittedCorrelations_internal;
50  double Nmean = (1.0/3)*(NObar[i] + NHbar[i]);
51  double fDotMean = fexDot(Nmean);
52  Phi_NObar[i] = ((1.0/3)*pMean*fDotMean + pObar*fexDot(NObar[i]));
53  Phi_NHbar[i] = ((1.0/3)*pMean*fDotMean + pHbar*fexDot(NHbar[i]*0.5)*0.5);
54  return pMean*fex(Nmean) + pObar*fex(NObar[i]) + pHbar*fex(NHbar[i]*0.5);
55 }
56 
57 #endif // JDFTX_FLUID_FEX_H2O_FITTEDCORRELATIONS_INTERNAL_H
Definition: Fex_H2O_FittedCorrelations_internal.h:25