Tinker9 70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
damp.h
1#pragma once
2#include "math/const.h"
3#include "math/libfunc.h"
4#include "seq/seq.h"
5
6namespace tinker {
7// ufield, PCG
9inline void dmpthole2_a(real r, real pgamma, real pdi, real pdk,
10 real& restrict scale3, real& restrict scale5)
11{
12 real damp = pdi * pdk;
13 real ratio = r * REAL_RECIP(damp);
14 damp = (damp == 0 ? ((real)-1.0e16) : -pgamma * ratio * ratio * ratio);
15 real expdamp = REAL_EXP(damp);
16 scale3 = 1 - expdamp;
17 scale5 = 1 - expdamp * (1 - damp);
18}
19
21inline void damp_thole2(real r, real pdi, real pti, real pdk, real ptk,
22 real& restrict scale3, real& restrict scale5)
23{
24 real pgamma = REAL_MIN(pti, ptk);
25 dmpthole2_a(r, pgamma, pdi, pdk, scale3, scale5);
26}
27
28// dfield
30inline void dmpthole3_a(real r, real pgamma, real pdi, real pdk,
31 real& restrict scale3, real& restrict scale5, real& restrict scale7)
32{
33 real damp = pdi * pdk;
34 real ratio = r * REAL_RECIP(damp);
35 damp = (damp == 0 ? ((real)-1.0e16) : -pgamma * ratio * ratio * ratio);
36 real expdamp = REAL_EXP(damp);
37 scale3 = 1 - expdamp;
38 scale5 = 1 - expdamp * (1 - damp);
39 scale7 = 1 - expdamp * (1 - damp + (real)0.6 * damp * damp);
40}
41
43inline void damp_thole3(real r, real pdi, real pti, real pdk, real ptk,
44 real& restrict scale3, real& restrict scale5, real& restrict scale7)
45{
46 real pgamma = REAL_MIN(pti, ptk);
47 dmpthole3_a(r, pgamma, pdi, pdk, scale3, scale5, scale7);
48}
49
51inline void dmpthole3g_a(real r, real rr2, real xr, real yr, real zr,
52 real pgamma, real pdi, real pdk, real& restrict scale31,
53 real& restrict scale51, real& restrict scale71, real& restrict rc31,
54 real& restrict rc32, real& restrict rc33, real& restrict rc51,
55 real& restrict rc52, real& restrict rc53, real& restrict rc71,
56 real& restrict rc72, real& restrict rc73)
57{
58 real damp = pdi * pdk;
59 real ratio = r * REAL_RECIP(damp);
60 damp = (damp == 0 ? ((real)1.0e16) : pgamma * ratio * ratio * ratio);
61 scale31 = REAL_EXP(-damp);
62 scale51 = scale31 * (1 + damp);
63 scale71 = scale31 * (1 + damp + (real)0.6 * damp * damp);
64 real temp3 = 3 * damp * scale31 * rr2;
65 real temp5 = damp;
66 real temp7 = (real)-0.2 + (real)0.6 * damp;
67 rc31 = xr * temp3;
68 rc32 = yr * temp3;
69 rc33 = zr * temp3;
70 rc51 = rc31 * temp5;
71 rc52 = rc32 * temp5;
72 rc53 = rc33 * temp5;
73 rc71 = rc51 * temp7;
74 rc72 = rc52 * temp7;
75 rc73 = rc53 * temp7;
76}
77
79inline void damp_thole3g(real r, real rr2, real xr, real yr, real zr, real pdi,
80 real pti, real pdk, real ptk, real& restrict scale31, real& restrict scale51,
81 real& restrict scale71, real& restrict rc31, real& restrict rc32,
82 real& restrict rc33, real& restrict rc51, real& restrict rc52,
83 real& restrict rc53, real& restrict rc71, real& restrict rc72,
84 real& restrict rc73)
85{
86 real pgamma = REAL_MIN(pti, ptk);
87 dmpthole3g_a(r, rr2, xr, yr, zr, pgamma, pdi, pdk, scale31, scale51, scale71,
88 rc31, rc32, rc33, rc51, rc52, rc53, rc71, rc72, rc73);
89}
90
92inline void dmpthole4_a(real r, real pgamma, real pdi, real pdk,
93 real& restrict ex3, real& restrict ex5, real& restrict ex7,
94 real& restrict ex9)
95{
96 real damp = pdi * pdk;
97 real ratio = r * REAL_RECIP(damp);
98 damp = (damp == 0 ? ((real)1.0e16) : pgamma * ratio * ratio * ratio);
99 ex3 = REAL_EXP(-damp);
100 ex5 = ex3 * (1 + damp);
101 ex7 = ex3 * (1 + damp + (real)0.6 * damp * damp);
102 constexpr real coef1 = ((real)18) / ((real)35);
103 constexpr real coef2 = ((real)9) / ((real)35);
104 ex9 = ex3 * (1 + damp * (1 + damp * (coef1 + coef2 * damp)));
105}
106
108inline void damp_thole4(real r, real pdi, real pti, real pdk, real ptk,
109 real& restrict ex3, real& restrict ex5, real& restrict ex7,
110 real& restrict ex9)
111{
112 real pgamma = REAL_MIN(pti, ptk);
113 dmpthole4_a(r, pgamma, pdi, pdk, ex3, ex5, ex7, ex9);
114}
115
116#pragma acc routine seq
117template <int order>
119inline void damp_ewald(real* restrict bn, real r, real rinv, real rr2,
120 real aewald)
121{
122 real ralpha = aewald * r;
123 bn[0] = REAL_ERFC(ralpha) * rinv;
124 real alsq2 = 2 * aewald * aewald;
125 real alsq2n = REAL_RECIP(sqrtpi * aewald);
126 real exp2a = REAL_EXP(-ralpha * ralpha);
127 #pragma unroll
128 for (int j = 1; j < order; ++j) {
129 alsq2n *= alsq2;
130 bn[j] = ((j + j - 1) * bn[j - 1] + alsq2n * exp2a) * rr2;
131 }
132}
133}
#define SEQ_ROUTINE
Definition: acc/seqdef.h:7
#define SEQ_CUDA
Definition: acc/seqdef.h:12
#define restrict
Definition: macro.h:51
constexpr real sqrtpi
Definition: const.h:11
float real
Definition: precision.h:80
Definition: testrt.h:9
__device__ void damp_ewald(real *__restrict__ bn, real r, real rinv, real rr2, real aewald)
Definition: damp.h:119
__device__ void damp_thole3(real r, real pdi, real pti, real pdk, real ptk, real &__restrict__ scale3, real &__restrict__ scale5, real &__restrict__ scale7)
Definition: damp.h:43
__device__ void dmpthole3_a(real r, real pgamma, real pdi, real pdk, real &__restrict__ scale3, real &__restrict__ scale5, real &__restrict__ scale7)
Definition: damp.h:30
__device__ void dmpthole2_a(real r, real pgamma, real pdi, real pdk, real &__restrict__ scale3, real &__restrict__ scale5)
Definition: damp.h:9
__device__ void dmpthole3g_a(real r, real rr2, real xr, real yr, real zr, real pgamma, real pdi, real pdk, real &__restrict__ scale31, real &__restrict__ scale51, real &__restrict__ scale71, real &__restrict__ rc31, real &__restrict__ rc32, real &__restrict__ rc33, real &__restrict__ rc51, real &__restrict__ rc52, real &__restrict__ rc53, real &__restrict__ rc71, real &__restrict__ rc72, real &__restrict__ rc73)
Definition: damp.h:51
__device__ void damp_thole3g(real r, real rr2, real xr, real yr, real zr, real pdi, real pti, real pdk, real ptk, real &__restrict__ scale31, real &__restrict__ scale51, real &__restrict__ scale71, real &__restrict__ rc31, real &__restrict__ rc32, real &__restrict__ rc33, real &__restrict__ rc51, real &__restrict__ rc52, real &__restrict__ rc53, real &__restrict__ rc71, real &__restrict__ rc72, real &__restrict__ rc73)
Definition: damp.h:79
__device__ void dmpthole4_a(real r, real pgamma, real pdi, real pdk, real &__restrict__ ex3, real &__restrict__ ex5, real &__restrict__ ex7, real &__restrict__ ex9)
Definition: damp.h:92
__device__ void damp_thole4(real r, real pdi, real pti, real pdk, real ptk, real &__restrict__ ex3, real &__restrict__ ex5, real &__restrict__ ex7, real &__restrict__ ex9)
Definition: damp.h:108
__device__ void damp_thole2(real r, real pdi, real pti, real pdk, real ptk, real &__restrict__ scale3, real &__restrict__ scale5)
Definition: damp.h:21