static double v_ewald_lr(double beta,double r) { if (r == 0) { return beta*2/sqrt(M_PI); } else { return gmx_erfd(beta*r)/r; } }
/*! \brief Compute y=(a0+a1)/2-(a0-a1)/2*erf((x-a2)/a3^2) */ static double lmc_erffit (double x, const double *a) { double erfarg; double myerf; if (a[3] != 0) { erfarg = (x-a[2])/(a[3]*a[3]); myerf = gmx_erfd(erfarg); } else { /* If a[3] == 0, a[3]^2 = 0 and the erfarg becomes +/- infinity */ if (x < a[2]) { myerf = -1; } else { myerf = 1; } } return 0.5*((a[0]+a[1]) - (a[0]-a[1])*myerf); }