* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <math.h>
-#include "gromacs/math/utilities.h"
-#include "typedefs.h"
-#include "types/commrec.h"
-#include "vec.h"
-#include "coulomb.h"
-#include "gromacs/utility/smalloc.h"
-#include "physics.h"
-#include "txtdump.h"
-#include "gromacs/fileio/futil.h"
-#include "names.h"
-#include "macros.h"
-
-real calc_ewaldcoeff_q(real rc, real dtol)
-{
- real x = 5, low, high;
- int n, i = 0;
-
-
- do
- {
- i++;
- x *= 2;
- }
- while (gmx_erfc(x*rc) > dtol);
-
- n = i+60; /* search tolerance is 2^-60 */
- low = 0;
- high = x;
- for (i = 0; i < n; i++)
- {
- x = (low+high)/2;
- if (gmx_erfc(x*rc) > dtol)
- {
- low = x;
- }
- else
- {
- high = x;
- }
- }
- return x;
-}
+#include "gmxpre.h"
-static real ewald_function_lj(real x, real rc)
-{
- real xrc, xrc2, xrc4, factor;
- xrc = x*rc;
- xrc2 = xrc*xrc;
- xrc4 = xrc2*xrc2;
-#ifdef GMX_DOUBLE
- factor = exp(-xrc2)*(1 + xrc2 + xrc4/2.0);
-#else
- factor = expf(-xrc2)*(1 + xrc2 + xrc4/2.0);
-#endif
+#include "long-range-correction.h"
- return factor;
-}
-
-real calc_ewaldcoeff_lj(real rc, real dtol)
-{
- real x = 5, low, high;
- int n, i = 0;
-
- do
- {
- i++;
- x *= 2.0;
- }
- while (ewald_function_lj(x, rc) > dtol);
+#include <math.h>
- n = i + 60; /* search tolerance is 2^-60 */
- low = 0;
- high = x;
- for (i = 0; i < n; ++i)
- {
- x = (low + high) / 2.0;
- if (ewald_function_lj(x, rc) > dtol)
- {
- low = x;
- }
- else
- {
- high = x;
- }
- }
- return x;
-}
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/legacyheaders/types/forcerec.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/utilities.h"
+#include "gromacs/math/vec.h"
+ /* There's nothing special to do here if just masses are perturbed,
+ * but if either charge or type is perturbed then the implementation
+ * requires that B states are defined for both charge and type, and
+ * does not optimize for the cases where only one changes.
+ *
+ * The parameter vectors for B states are left undefined in atoms2md()
+ * when either FEP is inactive, or when there are no mass/charge/type
+ * perturbations. The parameter vectors for LJ-PME are likewise
+ * undefined when LJ-PME is not active. This works because
+ * bHaveChargeOrTypePerturbed handles the control flow. */
void ewald_LRcorrection(int start, int end,
t_commrec *cr, int thread, t_forcerec *fr,
real *chargeA, real *chargeB,